Cost proportional to HP and MP healed

(I don't know if this would require a plugin or something else, or if this belongs in this thread so I do apologize)

I was wondering if there's a way to make it so I could have an event or something heal my party but, as the title suggests, for a price that depends on how much HP and/or MP is healed. So the more HP/MP healed then the more it would cost to do.
Moved to: MV Support

You would be able to do this without a plugin. Something like this in an event command:

Code:
Control Variables: Total Cost = 0
If Actor 1 is in the party
  Control Variables: Total Cost += Actor 1's Max HP
  Control Variables: Total Cost -= Actor 1's HP
End
If Actor 2 is in the party
  Control Variables: Total Cost += Actor 2's Max HP
  Control Variables: Total Cost -= Actor 2's HP
End
... repeat for all possible actors

After the above, the variable will contain the total amount of HP that needs to be healed for all party members. If you want 1HP = 1 Gold, you can just use the variable. If you want something like 1HP = 5 Gold, multiply the variable by 5. If you want something like 10HP = 1 Gold, divide the variable by 10.

Replace Max HP and HP with Max MP and MP if you want to heal MP instead. If you want to heal both HP and MP, just add each actor's Max HP and Max MP to the variable, then subtract their current HP and MP, as in the example below.

Finally, if you only want to heal living party members and skip those who are dead, make the condition look like this instead:
Code:
If Actor 1 is in the party
  If Actor 1 is [Death] Inflicted
  Else
    Control Variables: Total Cost += Actor 1's Max HP
    Control Variables: Total Cost -= Actor 1's HP
    Control Variables: Total Cost += Actor 1's Max MP
    Control Variables: Total Cost -= Actor 1's MP
  End
End

Once you have the variable, just use that in the text message where you want to show the cost (it will have to be an event, not a shop window), in a conditional branch to ensure the player has at least that much gold, and in the change gold command to pay for it. And you can use the Recover HP / Recover MP commands for the whole party to make it happen.
It worked, thank you so much!

Original thread: https://forums.rpgmakerweb.com/threads/cost-proportional-to-hp-and-mp-healed.151367/