Recover on Guard - KGC_GuardRecover Extended
Written by TOMY - http://ytomy.sakura.ne.jp/
Translation by Mr. Anonymous - http://mraprojects.wordpress.com
Edited by Digioso - http://www.digioso.org


Introduction
This script allows you to add HP/MP Recovery percentiles to the battle guard/defend command.
So basically whenever your characters (or your enemies) guard he/she/it will recover some HP/MP.
The original script only had a global value for all characters. So all your characters did recover 5% of their HP. Now you can set the rates for each of your characters individually. Same goes for enemy HP/MP recovery values. And you can change these values during the game as well.

Features
- Player characters can recover HP/MP through guarding
- Enemies can recover HP/MP through guarding

Screenshot
http://www.digioso.org/cgi-bin/gallery.pl?...gc_guardrec.png

How to Use
How to use

Put the script into the "Materials" section and above "Main process".

The script has four configuration items: HP_RATE_ACTOR (for player character HP reg), MP_RATE_ACTOR (player MP reg), HP_RATE_ENEMY (enemy HP reg) and MP_RATE_ENEMY (enemy MP reg). It is recommended to change the standard values to whatever you need for your game. You probably don't want your 2nd hero to recover 100% of his/her HP during guarding. smile.gif
CODE
# Guarding HP recovery rate in percent
        # Syntax:
        # Actor_ID => percent,
        # eg actor 2 recovers 100% of his/her HP
        # Actors you don't specify recover the value behind default
        # If you're fine with just the default value and don't want any settings for anything else,
        # remove all other stuff AND the "," in the default row
        # Some goes for the MP below and the enemy HP/MP recovery

        # It is possible to change the recovery rates in the middle of the game
        # as well! So if one of your characters falls in the magical river of
        # magical recovery and you want him to recover 10% HP instead of 5%
        # create a script event and put this into it:
        # KGC::GuardRecover::HP_RATE_ACTOR[1] = 10
        # This changes the HP recovery rate for actor 1 (Ralph in this demo) to 10%
        # Works with MP (use KGC::GuardRecover::MP_RATE_ACTOR[actor_id] ) and
        # the recovery rates of enemies as well:
        # KGC::GuardRecover::HP_RATE_ENEMY[enemy_id] and KGC::GuardRecover::MP_RATE_ENEMY[enemy_id]

        HP_RATE_ACTOR = {
        "default" => 5,
        1 => 10,
        2 => 100,
        3 => 5
        } # Do not remove this line
        
        # Guarding MP recovery rate in percent
        MP_RATE_ACTOR = {
        "default" => 5,
        1 => 10,
        2 => 5,
        3 => 100
        } # Do not remove this line
        
        # ? Guarding Enemy HP Recovery Rate in percent
        HP_RATE_ENEMY = {
        "default" => 0,
        1 => 5
        } # Do not remove this line
        
        # ? Guarding Enemy MP Recovery Rate in percent
        MP_RATE_ENEMY = {
        "default" => 0,
        1 => 5
        } # Do not remove this line


Demo
The newest version of this script/demo can always be found here: http://www.digioso.org/KGC_GuardRec
Just run around until you see a fight. Use the "Guard" command in battle to see what the script is capable of. Talk to Ralph in the game to change the recovery values for him during the game.

Script
Script

The newest version of this demo/script can also be found here: http://www.digioso.org/KGC_GuardRec
CODE
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
#_/ ? Recover on Guard - KGC_GuardRecover Extended 1.1 ? 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]
#_/ ? Edited by Digioso on 14.10.2011 so that you can now specify the recovery
#_/ ? values for each actor/enemy seperately. If not specified a default value is used.
#_/ ? [url="http://www.digioso.org"]http://www.digioso.org[/url]
#_/ ? Updated documentation on 17.10.2011
#_/-----------------------------------------------------------------------------
#_/ 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
      
        # Guarding HP recovery rate in percent
        # Syntax:
        # Actor_ID => percent,
        # eg actor 2 recovers 100% of his/her HP
        # Actors you don't specify recover the value behind default
        # If you're fine with just the default value and don't want any
        # settings for anything else,
        # remove all other stuff AND the "," in the default row
        # Some goes for the MP below and the enemy HP/MP recovery
        
        # It is possible to change the recovery rates in the middle of the game
        # as well! So if one of your characters falls in the magical river of
        # magical recovery and you want him to recover 10% HP instead of 5%
        # create a script event and put this into it:
        # KGC::GuardRecover::HP_RATE_ACTOR[1] = 10
        # This changes the HP recovery rate for actor 1 (Ralph in this demo) to 10%
        # Works with MP (use KGC::GuardRecover::MP_RATE_ACTOR[actor_id] ) and
        # the recovery rates of enemies as well:
        # KGC::GuardRecover::HP_RATE_ENEMY[enemy_id] and KGC::GuardRecover::MP_RATE_ENEMY[enemy_id]
        
        HP_RATE_ACTOR = {
        "default" => 5,
        1 => 10,
        2 => 100,
        3 => 5
        } # Do not remove this line
        
        # Guarding MP recovery rate in percent
        MP_RATE_ACTOR = {
        "default" => 5,
        1 => 10,
        2 => 5,
        3 => 100
        } # Do not remove this line
        
        # ? Guarding Enemy HP Recovery Rate in percent
        HP_RATE_ENEMY = {
        "default" => 0,
        1 => 5
        } # Do not remove this line
        
        # ? Guarding Enemy MP Recovery Rate in percent
        MP_RATE_ENEMY = {
        "default" => 0,
        1 => 5
        } # Do not remove this line
    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
        if(KGC::GuardRecover::HP_RATE_ACTOR.has_key?(@actor_id))
          if(KGC::GuardRecover::MP_RATE_ACTOR.has_key?(@actor_id))
            make_guard_recover_value(
            KGC::GuardRecover::HP_RATE_ACTOR[@actor_id],
            KGC::GuardRecover::MP_RATE_ACTOR[@actor_id])
          else
            make_guard_recover_value(
            KGC::GuardRecover::HP_RATE_ACTOR[@actor_id],
            KGC::GuardRecover::MP_RATE_ACTOR["default"])
          end
        else
          if(KGC::GuardRecover::MP_RATE_ACTOR.has_key?(@actor_id))
            make_guard_recover_value(
            KGC::GuardRecover::HP_RATE_ACTOR["default"],
            KGC::GuardRecover::MP_RATE_ACTOR[@actor_id])
          else
            make_guard_recover_value(
            KGC::GuardRecover::HP_RATE_ACTOR["default"],
            KGC::GuardRecover::MP_RATE_ACTOR["default"])
          end
        end
        execute_damage(nil)
    end
end

#==================================End Class===================================#
#==============================================================================
# ¦ Game_Enemy
#==============================================================================

class Game_Enemy < Game_Battler
    #--------------------------------------------------------------------------
    # ? Apply Recovery Effect
    #--------------------------------------------------------------------------
    def guard_recover_effect
        clear_action_results
        if(KGC::GuardRecover::HP_RATE_ENEMY.has_key?(@enemy_id))
          if(KGC::GuardRecover::MP_RATE_ENEMY.has_key?(@enemy_id))
            make_guard_recover_value(
            KGC::GuardRecover::HP_RATE_ENEMY[@enemy_id],
            KGC::GuardRecover::MP_RATE_ENEMY[@enemy_id])
          else
            make_guard_recover_value(
            KGC::GuardRecover::HP_RATE_ENEMY[@enemy_id],
            KGC::GuardRecover::MP_RATE_ENEMY["default"])
          end
        else
          if(KGC::GuardRecover::MP_RATE_ENEMY.has_key?(@enemy_id))
            make_guard_recover_value(
            KGC::GuardRecover::HP_RATE_ENEMY["default"],
            KGC::GuardRecover::MP_RATE_ENEMY[@enemy_id])
          else
            make_guard_recover_value(
            KGC::GuardRecover::HP_RATE_ENEMY["default"],
            KGC::GuardRecover::MP_RATE_ENEMY["default"])
          end
        end
        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


FAQ
Q: The demo won't open, how to open it?
A: Download 7-zip and try again.

Terms and Conditions
I'm not the original author I'd say it's free to use in non-commercial games. Since I only modified the script myself I don't have anything against other people modifying it further. Just give credit to everybody mentioned below.

Credit and Thanks
Written by TOMY - http://ytomy.sakura.ne.jp/
Translation by Mr. Anonymous - http://mraprojects.wordpress.com
Edited by Digioso - http://www.digioso.org

Author's Notes
These changes were requested by TheDrifter here.
Well, he only wanted that his first actor recoverd 10% HP/MP while everyone else gets 5%. I took it a step further and made these customization options for all actors/enemies.