Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> Restoring a bit more HP and SP while guarding for one character only [SOLVED], KGC GuardRecover Upgrade ***
TheDrifter
post Oct 1 2011, 06:21 PM
Post #1


Level 2
Group Icon

Group: Member
Posts: 25
Type: Mapper
RM Skill: Masterful




Hi, I'm currently using this script that allows the player to restore HP & MP while guarding.

KGC script
CODE
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
#_/ ◆ Recover on Guard - KGC_GuardRecover ◆ VX ◆
#_/ ◇  Last Update: 08/10/2008
#_/ ◆ Written by TOMY    
#_/ ◆ Translation by Mr. Anonymous                  
#_/ ◆ KGC Site:                                                  
#_/ ◆  [url="http://ytomy.sakura.ne.jp/"]http://ytomy.sakura.ne.jp/[/url]                                  
#_/ ◆ Translator's Blog:                                            
#_/ ◆  [url="http://mraprojects.wordpress.com"]http://mraprojects.wordpress.com[/url]    
#_/-----------------------------------------------------------------------------
#_/  This script allows you to add HP/MP Recovery percentiles to the battle
#_/   guard/defend command.
#_/  * Note from the translator: I had previously ported this script myself,
#_/     this official KGC port however, is a bit more cleanly coded.
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_

#==============================================================================
# ★ BEGIN Customization ★                                
#==============================================================================

module KGC
  module GuardRecover
    # ◆ HP Recovery Rate [In Percentile]
    HP_RATE_ACTOR = 5
    # ◆ MP Recovery Rate [In Percentile]
    MP_RATE_ACTOR = 5

    # ◆ Guarding Enemy HP Recovery Rate [In Percentile]
    HP_RATE_ENEMY = 0
    # ◆ Guarding Enemy MP Recovery Rate [In Percentile]
    MP_RATE_ENEMY = 0
  end
end

#==============================================================================
# ★ END Customization ★                                
#==============================================================================

$imported = {} if $imported == nil
$imported["GuardRecover"] = true

#==============================================================================
# ■ Game_Battler
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # ○ Defending Recovery Calculation
  #     hp_rate : HP Recovery Rate
  #     mp_rate : MP Recovery Rate
  #--------------------------------------------------------------------------
  def make_guard_recover_value(hp_rate, mp_rate)
    recover_hp = maxhp * hp_rate / 100
    if hp_rate > 0
      recover_hp = [1, recover_hp].max
    elsif hp_rate < 0
      recover_hp = [-1, recover_hp].min
    end

    recover_mp = maxmp * mp_rate / 100
    if mp_rate > 0
      recover_mp = [1, recover_mp].max
    elsif mp_rate < 0
      recover_mp = [-1, recover_mp].min
    end

    @hp_damage -= recover_hp
    @mp_damage -= recover_mp
  end
end

#==================================End Class===================================#
#==============================================================================
# ■ Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ○ Apply Recovery Effect
  #--------------------------------------------------------------------------
  def guard_recover_effect
    clear_action_results
    make_guard_recover_value(
      KGC::GuardRecover::HP_RATE_ACTOR,
      KGC::GuardRecover::MP_RATE_ACTOR)
    execute_damage(nil)
  end
end

#==================================End Class===================================#
#==============================================================================
# ■ Game_Enemy
#==============================================================================

class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ○ Apply Recovery Effect
  #--------------------------------------------------------------------------
  def guard_recover_effect
    clear_action_results
    make_guard_recover_value(
      KGC::GuardRecover::HP_RATE_ENEMY,
      KGC::GuardRecover::MP_RATE_ENEMY)
    execute_damage(nil)
  end
end

#==================================End Class===================================#
#==============================================================================
# ■ Scene_Battle
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ● Execute Battle Action: Guard
  #--------------------------------------------------------------------------
  alias execute_action_guard_KGC_GuardRecover execute_action_guard
  def execute_action_guard
    execute_action_guard_KGC_GuardRecover

    @active_battler.guard_recover_effect
    if @active_battler.hp_damage != 0
      display_damage(@active_battler)
    elsif @active_battler.mp_damage != 0
      display_mp_damage(@active_battler)
    end
  end
end


It works really nicely, the only thing I wish to change is the recovery rate for one of the characters, making it his specialty.
In my database, it's the character #001 (class #001) if it helps.
He should be able to regain 10% of his HP and 10% of his MP for guarding instead of 5% each.

Thanks a lot for your help!

This post has been edited by TheDrifter: Oct 15 2011, 11:44 AM
Go to the top of the page
 
+Quote Post
   



Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

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