Main Menu
  • Welcome to The RPG Maker Resource Kit.

[RESOLVED]Request for HP/MP Recovery after battle

Started by Ghero, September 19, 2008, 01:52:14 AM

0 Members and 1 Guest are viewing this topic.

Ghero

<HP/MP Recovery After Battle>
<9-18-2008>




Summary
Looking for a script that would recovery a certain % of HP/MP based on Spirit after battle. I want this to happen during the battle reward screen, or at least after enemies are dead, and before the Battle End. I want Spirit to add + .5% HP/MP per point.

Features Desired

  • HP/MP Recovery after battle
  • Recovery before battle end if possible, if not it's ok


Games its been in

  • Star Ocean




Did you search?
yes

Where did you search?

  • forums here
  • google

What did you search for?

  • hp/mp after battle

modern algebra

Okay, is this separate from your initial question in support, or is it connnected?

The following code will restore an actor to 1 HP if he was just dead, and if not, will restore 0.5% of his HP and MP. It has no graphical component. If you want something different, please ask.


class Scene_Battle
  #--------------------------------------------------------------------------
  # * End Battle
  #     result : Results (0: win, 1: escape, 2:lose)
  #--------------------------------------------------------------------------
  alias ghero_hp_recover_to1_on_bttl_end_8fbf battle_end
  def battle_end(result)
    ghero_hp_recover_to1_on_bttl_end_8fbf (result)
    return if result == 2
    $game_party.members.each { |actor|
       if actor.dead?
         actor.hp = 1
       else
         actor.hp += (0.5*actor.maxhp).to_i
         actor.mp += (0.5*actor.maxmp).to_i
       end
     }
  end
end

Ghero

#2
Awesome. It's such a small code but I can't figure it out xD I went from RPGMaker2000 to this xD heh Thanks a whole bunch man! I'll have other small things later I presume :p

P.S. If I want to change

actor.hp += (0.5*actor.maxhp).to_i
         actor.mp += (0.5*actor.maxmp).to_i

to rely on Spirit I would change the code to

actor.hp += ((0.5*actor.spi)%*actor.maxhp).to_i
         actor.mp += ((0.5*actor.spi)%*actor.maxmp).to_i

I think at least, would that % work in the formula?

Ghero

Figured out the actul script!

#--------------------------------------------------------
#             HP > 0 Script by Ghero
#          Made possible by modern algebra
#--------------------------------------------------------

class Scene_Battle
  #--------------------------------------------------------------------------
  # * End Battle
  #     result : Results (0: win, 1: escape, 2:lose)
  #--------------------------------------------------------------------------
  alias ghero_hp_recover_to1_on_bttl_end_8fbf battle_end
  def battle_end(result)
    ghero_hp_recover_to1_on_bttl_end_8fbf (result)
    return if result == 2
    $game_party.members.each { |actor|
       if actor.dead?
         actor.hp = 1
       else
         actor.hp += ((0.005*actor.spi)*actor.maxhp).to_i
         actor.mp += ((0.005*actor.spi)*actor.maxhp).to_i
       end
     }
  end
end

modern algebra

Good stuff.

I'm glad you have resolved your problem.

Also, yeah, one of the fun things about scripting is that small changes make a big difference. Producing scenes and graphical effects will usually require more than is shown there, but in terms of what actually happens, usually very little does a lot.