Charas-Project

Game Creation => Requests => RPG Maker Programming => Topic started by: TheBlobbyKnight on June 11, 2007, 08:56:51 AM

Title: Restoring % of MP after battle ...
Post by: TheBlobbyKnight on June 11, 2007, 08:56:51 AM
Restoring a percentage of MP when a battle is won; Is it possible, and if so, how? I figure there has to be some way of triggering a common event when a battle is won, but the only thing that comes to mind is a bunch of nested IF conditions with enemy hp for each monster group, which would be amazingly inefficient and take forever to do ... Is there any other way of doing this?
Title:
Post by: Phayre on June 11, 2007, 02:55:21 PM
I'm not sure if this is possible, or exactly how to do it, but you could seta switch to turn on on a battle end, then on each screen have a common event where it auto starts, restores the MP, then turns the switch off.
Title:
Post by: TheBlobbyKnight on June 13, 2007, 05:32:49 AM
In case anyone's interested, I did manage to solve this ... Without even touching battle events, in just one common event. It's pretty simple, but I hadn't noticed the game kept track of the # of battles and victories ...

It needs five variables: Temp, Battles A, Battles B, Wins A, Wins B. The part in italics should be repeated for each party member. The whole thing goes under a parallel process common event (with no trigger switch).

- Set Battle B to number of battles (it's under Other)
- Set Wins B to number of victories (also under Other)
- Branch: If Battle B > Battle A
    - Branch: If Wins B > Wins A
        - Branch: if [char] is in party
            - Branch: if [char] HP >= 1
                - Set Temp to [char]'s max MP
                - Set Temp divide by ten
                - Change [char]'s MP + Temp
            :End
        :End

     :End
     - Set Battle A to number of battles
     - Set Wins A to number of victories
:End

The characters will recover 10% of MP after each battle won (but not when they're dead). You could use another variable and the modulus function to change the rounding too, if that mattered.