Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed
Absolute Defense
Version: 1.0 Author: Kread-EX
Introduction
You never know what you can find when plugging an old hard drive you don't use since 5 years. And what did I find ? Oooh... this script. This takes us back to the dawn of RMXP - a time when only DynaEmu's was the only existing English version ! In other words, this is one of my very first scripts. Well, let's go back on topic:
Absolute Defense is a technique used in the game Breath of Fire V (Ps2). It allows to nullify damage inflicted by the user under a set value. Technically, you must spam your best attacks in order to wound the big tank who use this.
# INTRODUCTION # Absolute Defense is a technique used in the game Breath of Fire V (Ps2). # It allows to nullify damage inflicted by the user under a set value. # Technically, you must spam your best attacks in order to wound the big tank who use this.
# IMPORTANT NOTE # Absolute Defense protect only from HP damage. Not from eventual SP damage or status ailments.
# HOW TO USE # Just copy this and paste above Main. # Then follow the configuration steps.
# COMPATIBILITY # Very low compatibility with any script which modify Game_Battler, Sprite_Battler or Scene_Battle (this was one of my very first script, be indulgent). # I suggest to NOT make 2 enemies in the same group using Absolute Degense # Actors can't use this because this would unbalance the game. # Work with the DBS and turn-based CBS. You shouldn't use this with ATB or RTAB. Maybe CTB, but I'm not sure. # Will clash with custom damage displays.
#============================================================================== # Configuration part #============================================================================== module KreadCFG
# Ids of enemies using Absolute Defense ENEMIES_IDS = [1,5]
# Value of the Absolute Defense. The order MUST match the order inside the ENEMIES_ID ABSOLUTE_VALUES = [80,650]
# Number of turns before the Absolute Defense is recharged. Then again, the order must match ENEMIES_ID REFRESH_RATE = [1,3]
# ID of the animation used when the defense is active (leave to 0 for no animation) FULL_ANIM_ID = 0
# ID of the animation used when the defense breaks (leave to 0 for no animation) BREAK_ANIM_ID = 0
end
#============================================================================== # Game_Enemy #============================================================================== class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # Public instance variables #-------------------------------------------------------------------------- attr_accessor :absolute_defense_break attr_accessor :absolute_defense_value attr_accessor :absolute_defense_refresh_rate #-------------------------------------------------------------------------- # Object initialization #-------------------------------------------------------------------------- alias orig_enemy_init initialize def initialize(troop_id, member_index) orig_enemy_init(troop_id, member_index) unless KreadCFG::ENEMIES_IDS.include?(self.id) @absolute_defense_break = false @absolute_defense_value = 0 @absolute_defense_refresh_rate = 0 return end #Les variables d'instances prennent les valeurs des constantes. index = KreadCFG::ENEMIES_IDS.index(self.id) @absolute_defense_break = false @absolute_defense_value = KreadCFG::ABSOLUTE_VALUES[index] @absolute_defense_refresh_rate = KreadCFG::REFRESH_RATE[index] end end
#============================================================================== # Game_Battler #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # Apply normal attack effect #-------------------------------------------------------------------------- alias krx_absdef_attack_effect attack_effect def attack_effect(attacker) if self.class == Game_Actor or self.absolute_defense_value == 0 return krx_absdef_attack_effect(attacker) end last_hp = self.hp result = krx_absdef_attack_effect(attacker) if self.damage.is_a?(Numeric) and self.damage >= self.absolute_defense_value and self.damage > 0 last_damage = self.damage self.damage = [self.damage - self.absolute_defense_value, 0].max self.absolute_defense_break = true self.absolute_defense_value = [self.absolute_defense_value - last_damage, 0].max self.hp = last_hp - self.damage elsif self.damage.is_a?(Numeric) and self.damage > 0 self.absolute_defense_value -= self.damage self.hp = last_hp self.damage = '-' + self.absolute_defense_value.to_s end return result end #-------------------------------------------------------------------------- # Apply skill effect #-------------------------------------------------------------------------- alias krx_absdef_skill_effect skill_effect def skill_effect(user,skill) if self.class == Game_Actor or self.absolute_defense_value == 0 return krx_absdef_skill_effect(user,skill) end last_hp = self.hp result = krx_absdef_skill_effect(user,skill) if self.damage.class == Numeric and self.damage >= self.absolute_defense_value and self.damage > 0 last_damage = self.damage self.damage = [self.damage - self.absolute_defense_value, 0].max self.absolute_defense_break = true self.absolute_defense_value = [self.absolute_defense_value - last_damage, 0].max self.hp = last_hp - self.damage elsif self.damage.class == Numeric and self.damage > 0 self.absolute_defense_value -= self.damage self.damage = '-' + self.absolute_defense_value.to_s end return result end #-------------------------------------------------------------------------- # Apply item effect #-------------------------------------------------------------------------- alias krx_absdef_item_effect item_effect def item_effect(user,item) if self.class == Game_Actor or self.absolute_defense_value == 0 return krx_absdef_item_effect(user,item) end last_hp = self.hp result = krx_absdef_item_effect(user,item) if self.damage.class == Numeric and self.damage >= self.absolute_defense_value and self.damage > 0 last_damage = self.damage self.damage = [self.damage - self.absolute_defense_value, 0].max self.absolute_defense_break = true self.absolute_defense_value = [self.absolute_defense_value - last_damage, 0].max self.hp = last_hp - self.damage elsif self.damage.class == Numeric and self.damage > 0 self.absolute_defense_value -= self.damage self.damage = '-' + self.absolute_defense_value.to_s end return result end end
#============================================================================== # Scene_Battle #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # Alias the phase 1 #-------------------------------------------------------------------------- alias krx_absdef_start_phase1 start_phase1 def start_phase1 @ad_count = {} $game_troop.enemies.each do |enemy| @ad_count[enemy.index] = enemy.absolute_defense_refresh_rate end krx_absdef_start_phase1 end #-------------------------------------------------------------------------- # Alias the step 6 of phase 4 #-------------------------------------------------------------------------- alias krx_absdef_update_step6 update_phase4_step6 def update_phase4_step6 if @active_battler.is_a?(Game_Enemy) and @active_battler.movable? @ad_count[@active_battler.index] -= 1 if @ad_count[@active_battler.index] == 0 @ad_count[@active_battler.index] = @active_battler.absolute_defense_refresh_rate r_index = KreadCFG::ENEMIES_IDS.index(@active_battler.id) @active_battler.absolute_defense_value = KreadCFG::ABSOLUTE_VALUES[r_index] end end krx_absdef_update_step6 end end
Compatibility
Very low compatibility with any script which modify Game_Battler, Sprite_Battler or Scene_Battle (this was one of my very first script, be indulgent). I suggest to NOT make 2 enemies in the same group using Absolute Degense Actors can't use this because this would unbalance the game. Work with the DBS and turn-based CBS. You shouldn't use this with ATB or RTAB. Maybe CTB, but I'm not sure. Will clash with custom damage displays.
Installation
Just copy this and paste above Main. Then follow the configuration steps.
Terms and Conditions
Use this as you see fit, as long as you credit me. Even for a commercial project, I do not care. Redistribute the script however you like, but please keep the script header.
Additional info
If you want to use this with a CBS other than ATB or RTAB, you can ask and I will adapt it. Same goes with custom damage displays.
__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.