03-03-2008, 05:21 AM
HP Absorbption Skills
by RPG Advocate
saved from Phylomortis.Com
by RPG Advocate
saved from Phylomortis.Com
Introduction
This script restores yet another feature that was present in RPG Maker 2000 and 2003, but is missing in RPG Maker XP, HP absorption skills. To use this script, add the script to your script editor. To set up a skill that absorbs HP, make a damage skill, then link it to a common event (like the sample code in the script).
Demo
>Click<
Script
HP Absorbption Skills
Code:
# HP Absorbption Skills
# by RPG Advocate
# Sample code used for an 'absorb' common event:
#
# absorb = $game_temp.damage_hook * -1
# $scene.active_battler.damage = absorb
# $scene.active_battler.damage_pop=true
# $scene.active_battler.hp -= absorb
#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
# This class handles temporary data that is not included with save data.
# Refer to "$game_temp" for the instance of this class.
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :damage_hook # damage hook
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias has_initialize initialize
def initialize
# Original call
has_initialize
# Initialize damage hook
@damage_hook = 0
end
end
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
# This class deals with battlers. It's used as a superclass for the Game_Actor
# and Game_Enemy classes.
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Apply Skill Effects
# user : the one using skills (battler)
# skill : skill
#--------------------------------------------------------------------------
alias has_skill_effect skill_effect
def skill_effect(user, skill, dilute = 1)
# Original call
effective = has_skill_effect(user, skill)
# Set hook to damage
if self.damage.is_a?(Numeric)
$game_temp.damage_hook += self.damage
end
# End Method
return effective
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :active_battler
#--------------------------------------------------------------------------
# * Frame Update (main phase step 1 : action preparation)
#--------------------------------------------------------------------------
alias has_up4s1 update_phase4_step1
def update_phase4_step1
# Reset damage hook
$game_temp.damage_hook = 0
# Original call
has_up4s1
end
end