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.

Quick Question (re: Defending in script)

SPN

Member

Quick question for you guys :)

What lines of script do I add to where to have an actor recover 2 SP every time they Defend? I've been looking around in the scripts for the spots where it calculates the action and whatnot, but I wouldn't even know what to add if I found it to be honest.

Basically, if x character performs the defending action, x character's SP increases by a fixed number (not exceeding 100% of course).

The help is much, much appreciated, thanks in advance!
 
Here ya go...

Code:
class Scene_Battle

  alias spn_make_basic_action_result make_basic_action_result

  def make_basic_action_result

    # If guard

    if @active_battler.current_action.basic == 1

      # heal 2 SP

      @active_battler.sp += 2 

    end

    spn_make_basic_action_result

  end

end
 
Rather quick and dirty, but in Game_Battler 3 find
Code:
        if self.guarding?

          self.damage /= 2

        end
under def attack_effect(attacker) and change it to
Code:
        if self.guarding?

          self.damage == 0

        end

did you want that to work for skill effects as well? If so, the same 'If' statement is there, too, and the same thing should work.
 

SPN

Member

Thanks a lot for the help, Brew! I eventually found where to put the lines, but it was the syntax and all that that I was unfamiliar with. I just added that right after the physical attacking and defending if clauses (or whatever you scripters call them, haha) and it works great.

Again, thanks for the help :)
 

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