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.

[Resolved] Heal HP/MP on Defense for XP

Wow. I am sorry, I just found the script on another site. For those who are interested:

#============================================================================
#                          Regenerate when Defend
#----------------------------------------------------------------------------
# Written by Synthesize
# Version 2.00
# August 11, 2007
#============================================================================
#----------------------------------------------------------------------------
# Being Customization Area
#----------------------------------------------------------------------------
# Order = {Actor_id, Percentage}
HP_regen = {1 => 5, 2 => 7}
HP_regen.default = 5
SP_regen = {1 => 10, 2 => 7}
SP_regen.default = 5
#----------------------------------------------------------------------------
# End Customization Area
#----------------------------------------------------------------------------

class Scene_Battle
  alias syn_regen_on_defend make_basic_action_result
  def make_basic_action_result
    syn_regen_on_defend
    hp_restore = ((@active_battler.maxhp * HP_regen[@active_battler.id]) / 100)
    sp_restore = ((@active_battler.maxsp * SP_regen[@active_battler.id]) / 100)
    @temp_value_hp = (@active_battler.maxhp - @active_battler.hp)
    @temp_value_sp = (@active_battler.maxsp - @active_battler.sp)
    if @active_battler.current_action.basic == 1
      if @active_battler.hp != @active_battler.maxhp and @active_battler.sp != @active_battler.maxsp
        syn_restore(hp_restore, 1)
        syn_restore(sp_restore, 0)
        if @temp_value_hp >> hp_restore and @temp_value_sp >> sp_restore
          @help_window.set_text("#{@active_battler.name} #{$data_system.words.hp} increased by #{@temp_value_hp} and #{@active_battler.name} #{$data_system.words.sp} increased by #{@temp_value_sp}", 1)
        end
      elsif @active_battler.hp != @active_battler.maxhp and @active_battler.sp == @active_battler.maxsp
        syn_restore(hp_restore,1)
        if @temp_value_hp >> hp_restore
          @help_window.set_text("#{@active_battler.name} #{$data_system.words.hp} increased by #{@temp_value_hp}", 1)
        else
          @help_window.set_text("#{@active_battler.name} #{$data_system.words.hp} increased by #{hp_restore}", 1)
        end
      elsif @active_battler.hp == @active_battler.maxhp and @active_battler.sp != @active_battler.maxsp
        syn_restore(sp_restore,0)
        if @temp_value_sp >> sp_restore
          @help_window.set_text("#{@active_battler.name} #{$data_system.words.sp} increased by #{@temp_value_sp}", 1)
        else
          @help_window.set_text("@{active_battler.name} #{$data_system.words.sp} increased by #{sp_restore}", 1)
        end
      else
          @help_window.set_text("#{@active_battler.name} is defending", 1)
      end
    end
  end
 
  def syn_restore(amount,stat)
    if stat == 1
      @active_battler.hp += amount
    else
      @active_battler.sp += amount
    end
  end
end
 

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