Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Defend regenerates SP script

Alright, I've realized how much help you guys are so I'm back to ask for more help :P

I need a script that makes it so that when you use the defend option in battle it regenerates about 7% of your SP.

I'm absolutely terrible with scripts so I need one that's idiot proof.
Someone please help me.
Thank you in advance.
 
Simply paste the following below any script that edits Game_Battler or Scene_Battle but above main
Code:
#--------------------------------------------------------------------------

# * SP Recover on Defend

# A simple script that heals 7 percent of sp when the player defends

#--------------------------------------------------------------------------

 

class Game_Battler

  #--------------------------------------------------------------------------

  # * Application of Defend Effects

  #--------------------------------------------------------------------------

  def defend_effect

    recover_sp = maxsp / 100.0 * 7

    recover_sp = recover_sp.round

    self.sp += recover_sp

  end

end

 

class Scene_Battle

  alias old_result make_basic_action_result

  #--------------------------------------------------------------------------

  # * Make Basic Action Results

  #--------------------------------------------------------------------------

  def make_basic_action_result

    # If guard

    if @active_battler.current_action.basic == 1

      @active_battler.defend_effect

    end

    old_result

  end

end
If you want to change from 7% to another percent, you can just change where it says 7 on line 11.
 
Off the top of my head, one of two possibilities could cause that error:

A) You pasted the script above Scene_Battle
or
B) You're not using XP despite using the XP tag on this thread
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top