As the title says, I'd like my actors to receive gold after defeating any enemy based on how many party members there are. For example, if there are 3 party members, then receive 300 gold. If there are 2 party members, then receive 200 gold. So on and so forth. How would I go about implementing this?
Receive gold based on the amount of party members
RPG Maker MZ SupportYou can use Eventing like this:
Code:
Variable Op: Party Size = 0
If Hero 1 in Party:
Variable Op: Party Size + 1
End
If Hero 2 in Party:
Variable Op: Party Size + 1
End
...
Variable Op: Gold to get = Party Size
Variable Op: Gold to get * 100
Gain Gold by Variable: Gold to get
Or you can use Control Variables -> Game Data -> Party Members to get the current party size, e.g.
◆Control Variables:#0001 = Party Members
◆Control Variables:#0001 *= 100
◆Change Gold:+ {#0001}Since you've said "after defeating any enemy" am I right in thinking what you actually want is for the gold the enemy drops to be multiplied by the party size during the rewards phase of battle end, rather than awarding gold via an event?
Yes, that's exactly what I mean :] So for example, 100 * 3 party members would be 300 gold.
I'm reading your post the way Trihan did...you'd modify this function:
If you just want it the way you said, and no enemies are different, change it to:
the goldRate() part is so that if you use any items with the double gold reward trait, they'll still work.
Code:
Game_Troop.prototype.goldTotal = function() {
return this.deadMembers().reduce(function(r, enemy) {
return r + enemy.gold();
}, 0) * this.goldRate();
};
If you just want it the way you said, and no enemies are different, change it to:
Code:
Game_Troop.prototype.goldTotal = function() {
return this.deadMembers().length * $gameParty.members().length * 100 * this.goldRate();
};
the goldRate() part is so that if you use any items with the double gold reward trait, they'll still work.
Save this as a .js in your plugins folder:
@ATT_Turan I think 100 was just an example and what OP wants is the defined gold amount for the enemy to be multiplied rather than a flat 100 for each.
JavaScript:
Game_Troop.prototype.goldRate = function() {
return ($gameParty.hasGoldDouble() ? 2 : 1) * $gameParty.size();
};
@ATT_Turan I think 100 was just an example and what OP wants is the defined gold amount for the enemy to be multiplied rather than a flat 100 for each.
It worked! Thank you so much everyone :]
I didn't know that! 😀
Original thread: https://forums.rpgmakerweb.com/threads/receive-gold-based-on-the-amount-of-party-members.159319/