Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> Regenerate HP/SP while Defending
Ty
post Jul 31 2007, 12:51 PM
Post #1


Level 38
Group Icon

Group: +Gold Member
Posts: 1,007
Type: Scripter
RM Skill: Undisclosed




What is it?
A simple script that Aliases the make_action_result method of the Scene_Battle so that when you defend a certain percentage of HP and SP will be recovered. Made for a request

Screenshots:
Look at the script, you have yourself a screenshot with extra flavored text.

The Script
Place Above Main.

CODE
#============================================================================
#                          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



F.A.Q.
Q. How do I call the script?
A. You don't simply install it and let it do it's job.

Q. How do I make it so Current HP is calculated instead of Max HP?
A. If you want the percent of HP/SP to recover to be based on current HP/SP simply change all occurences of .maxhp and .maxsp to only .hp and .sp.

This post has been edited by Synthesize: Aug 11 2007, 01:56 PM


__________________________
My Script Demo link broken? Looking for old scripts? Go here:
http://synthesize.4shared.com
Go to the top of the page
 
+Quote Post
   
 
Start new topic
Replies
amerk
post Aug 9 2012, 10:37 AM
Post #2


Level 56
Group Icon

Group: Global Mod
Posts: 1,784
Type: None
RM Skill: Undisclosed
Rev Points: 15




Not sure what the post above was asking or saying, but in any case, seeing as this hasn't been touched in well over 3 years, I don't think it needs to be revived unless the OP needs it to be. Ty, please pm me if you'd like this re-opened.

Thanks!


__________________________
Go to the top of the page
 
+Quote Post
   



Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th May 2013 - 07:37 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker