#=============================================================================== # # Yanfly Engine Zealous - Class Stat: DUR # Last Date Updated: 2010.02.02 # Level: Normal, Hard # # Sometimes it's just downright unfair to stun an enemy completely with just # one attack and reaping the benefits of the stun. This script introduces a new # stat called the Stun Counter, universal to both actors and enemies alike. As # actors and enemies are hit with elemental weaknesses, certain abilities, or # take critical hits, their stun counter rises. Once the stun counter is full, # the battler will be stunned. This counter is the Durability stat. # #=============================================================================== # Updates # ----------------------------------------------------------------------------- # o 2010.02.02 - Element Status Affinity compatibility. # o 2010.01.27 - Enemy Levels compatibility. # o 2009.12.31 - Item Growth Fix. # o 2009.12.30 - Bugfix update regarding double stun messages. # o 2009.12.22 - Compatibility with Custom Status Properties state stacking. # o 2009.12.17 - Fixed actor initialization process. # o 2009.12.16 - Bugfix regarding when stun is added. # o 2009.12.04 - Started Script and Finished. #=============================================================================== # Instructions # ----------------------------------------------------------------------------- # To install this script, open up your script editor and copy/paste this script # to an open slot below ▼ Materials but above ▼ Main. Remember to save. # # ----------------------------------------------------------------------------- # Skill and Item Tags - Insert the following tags into Skill or Item noteboxes. # ----------------------------------------------------------------------------- # # This will plant n stun counters on the target if it is + or remove n stun if # it is -. This amount can be amplified by the tag. # # ----------------------------------------------------------------------------- # Item Tags - Insert the following tags into usable Item noteboxes. # ----------------------------------------------------------------------------- # # This will determine whether or not the item will raise or lower DUR when used # on an actor. This is a permanent increase or decrease to the DUR stat. # # ----------------------------------------------------------------------------- # Equip Tags - Insert the following tags into Weapon and Armour noteboxes. # ----------------------------------------------------------------------------- # # # This will give weapons and armours bonus increases to the DUR stat. + and - # will signify an increase or decrease as a set amount. Adding % after n will # signify an increase or decrease as a percentile amount. # # ----------------------------------------------------------------------------- # Enemy Tags - Insert the following tags into Enemy noteboxes. # ----------------------------------------------------------------------------- # # This will determine what the enemy's max DUR stat is. If nothing is entered, # the particular enemy will use the DEFAULT_ENEMY_DUR to calculate its max DUR # instead of this. # # ----------------------------------------------------------------------------- # State Tags - Insert the following tags into State noteboxes. # ----------------------------------------------------------------------------- # # This will cause the user afflicted with the status effect to receive n% stun # when stun is applied. Set n to 50 if you want only half the stun rate. # # # This will cause the state to give an increase or decrease to the battler's # DUR stat as long as the state remains. + and - will result in a directly set # increase or decrease in the DUR stat while the % will result in a percentile # alteration of the DUR stat. Stackable. # # ----------------------------------------------------------------------------- # Script Commands - These are used with the Event Editor's Script command. # ----------------------------------------------------------------------------- # $game_actors[1].dur += 50 # This will add actor 1's stun stat to 50. # #=============================================================================== # Compatibility # ----------------------------------------------------------------------------- # - Works With: YEZ Battle Engine Zealous # ----------------------------------------------------------------------------- # Note: This script may not work with former Yanfly Engine ReDux scripts. # Use Yanfly Engine Zealous scripts to work with this if available. #=============================================================================== $imported = {} if $imported == nil $imported["ClassStatDUR"] = true module YEZ module STAT #=========================================================================== # Basic Setup # ------------------------------------------------------------------------- # Adjust the following settings in the module to govern how you want Stun # and DUR to work. #=========================================================================== # This is what the DUR stat will be called in your game. The stun percent # will appear in the status windows. VOCAB_DUR = "DUR" VOCAB_STUN = "Stun %d%%" VOCAB_STUNNED = "Stunned" # This will be the state used for the stunned effect. It will be applied # once the battler's stun counter is full. Add more to this array if you # wish for there to be more effects when stunned. ADD_STUN_STATES = [2] # This will be primary state that will mark the battler as stunned. When # a battler is stunned, the stun counter cannot rise higher until this # state is gone. However, stun counter can drop lower while stunned. MAIN_STUN_STATE = 2 # The following defines the maximum base DUR for each class. CLASS_BASE_DUR ={ # Do not remove class 0. # ClassID => Base DUR 0 => 100, # Unlisted 1 => 100, # Knight 2 => 120, # Warrior 3 => 50, # Priest 4 => 50, # Magician 5 => 100, # Paladin 6 => 100, # Dark Knight 7 => 80, # Grappler 8 => 80, # Thief } # Do not remove this. # Once an actor is stunned, the stun counter may reset back to 0 or to a # percentage depending on the class. Leave classes out of this if you want # them to have a full reset or modify class 0 to a higher amount so all # unlisted classes will have a remaining stun. AFTER_STUN_RESET ={ # ClassID => Stun Remain 0 => 0, # Unlisted 3 => 50, # Priest 4 => 50, # Magician 7 => 25, # Grappler 8 => 25, # Thief } # Do not remove this. # This will determine the maximum base DUR for enemies with a # tag in their notebox. DEFAULT_ENEMY_DUR = 100 # This is the default after stun reset percentage for enemies without a # tag. Set to 0 to remove fully reset stun counter. DEFAULT_ENEMY_AFTER_STUN = 0 # The Durability Indicator is represented by a group of icons based off of # the percentage of the stun counter over maximum durability. DUR_INDICATOR ={ # Do not remove 0 and 100 # Percent => Icon ID 0 => 213, 10 => 212, 25 => 209, 33 => 210, 50 => 211, 75 => 208, 100 => 116, } # Do not remove this. # This will determine what percent of the stun counter will remain after # battle for actors. Set it to 0 to fully reset the stun counter. BATTLE_OVER_STUN = 50 # If actors have any remaining stun, they will lose stun per step taken by # the player on the map. This is a set value, and not a percentage. STUN_LOSS_PER_STEP = 5 # The following hash will determine how much to raise the stun counter # inflicted upon the target. To make a calculation invalid, just change # the value to nil and it won't have any effect. STUN_CALC ={ # Condition => Value Change :critical_hit => 10, # Change upon receiving a critical hit. :element_s => 35, # Being hit with weakness of over 200% :element_a => 25, # Being hit with weakness of over 150% :element_b => 15, # Being hit with weakness of over 100% } # Do not remove this. # To display the durability indicator, set this value to true. It will the # durability indicator next to the states. To change which side the stun # indicator appears, use 1 for left and 2 for right side. If using the # Battle Engine Zealous script, this will appear below states. SHOW_DUR_INDICATOR = true DUR_INDICATOR_SIDE = 1 # If this is set to true, the stun indicators will be placed to the left # of the enemy's name when selecting them in the actions list. DISPLAY_ENEMY_DUR = true end # STAT end # YEZ #=============================================================================== # Editting anything past this point may potentially result in causing computer # damage, incontinence, explosion of user's head, coma, death, and/or halitosis. # Therefore, edit at your own risk. #=============================================================================== module YEZ module REGEXP module BASEITEM DUR_SET = /<(?:DUR|dur)[ ]*([\+\-]\d+)>/i DUR_PER = /<(?:DUR|dur)[ ]*([\+\-]\d+)([%%])>/i DUR_GROWTH = /<(?:DUR_GROWTH|dur growth)[ ]*([\+\-]\d+)>/i STUN_EFFECT = /<(?:STUN_EFFECT|stun effect|stun)[ ]*([\+\-]\d+)>/i end # BASEITEM module ENEMY BASE_DUR = /<(?:MAX_DUR|max dur|dur)[ ]*(\d+)>/i end # ENEMY module STATE STUNNED_RATE = /<(?:STUNNED_RATE|stunned rate)[ ]*(\d+)([%%])>/i DUR_SET = /<(?:DUR|dur)[ ]*([\+\-]\d+)>/i DUR_PER = /<(?:DUR|dur)[ ]*(\d+)([%%])>/i end # STATE end # REGEXP end # YEZ module Vocab def self.dur return YEZ::STAT::VOCAB_DUR end end # Vocab #=============================================================================== # RPG::BaseItem #=============================================================================== class RPG::BaseItem #-------------------------------------------------------------------------- # common cache: yez_cache_baseitem_csdur #-------------------------------------------------------------------------- def yez_cache_baseitem_csdur @equip_dur_set = 0; @equip_dur_per = 0; @dur_growth = 0; @stun_effect = 0 self.note.split(/[\r\n]+/).each { |line| case line when YEZ::REGEXP::BASEITEM::DUR_SET @equip_dur_set = $1.to_i when YEZ::REGEXP::BASEITEM::DUR_PER @equip_dur_per += $1.to_i when YEZ::REGEXP::BASEITEM::DUR_GROWTH @dur_growth = $1.to_i when YEZ::REGEXP::BASEITEM::STUN_EFFECT @stun_effect = $1.to_i end } # end self.note.split end # yez_cache_baseitem_csdur #-------------------------------------------------------------------------- # new method: equip_dur_set #-------------------------------------------------------------------------- def equip_dur_set yez_cache_baseitem_csdur if @equip_dur_set == nil return @equip_dur_set end #-------------------------------------------------------------------------- # new method: equip_dur_per #-------------------------------------------------------------------------- def equip_dur_per yez_cache_baseitem_csdur if @equip_dur_per == nil return @equip_dur_per end #-------------------------------------------------------------------------- # new method: dur_growth #-------------------------------------------------------------------------- def dur_growth yez_cache_baseitem_csdur if @dur_growth == nil return @dur_growth end #-------------------------------------------------------------------------- # new method: stun_effect #-------------------------------------------------------------------------- def stun_effect yez_cache_baseitem_csdur if @stun_effect == nil return @stun_effect end end # RPG::BaseItem #=============================================================================== # RPG::Enemy #=============================================================================== class RPG::Enemy #-------------------------------------------------------------------------- # common cache: yez_cache_enemy_csdur #-------------------------------------------------------------------------- def yez_cache_enemy_csdur @base_dur = YEZ::STAT::DEFAULT_ENEMY_DUR self.note.split(/[\r\n]+/).each { |line| case line when YEZ::REGEXP::ENEMY::BASE_DUR @base_dur = $1.to_i end } # end self.note.split end # yez_cache_enemy_csdur #-------------------------------------------------------------------------- # new method: equip_res_set #-------------------------------------------------------------------------- def base_dur yez_cache_enemy_csdur if @base_dur == nil return @base_dur end end # RPG::Enemy #=============================================================================== # RPG::State #=============================================================================== class RPG::State #-------------------------------------------------------------------------- # common cache: yez_cache_state_csdur #-------------------------------------------------------------------------- def yez_cache_state_csdur @stunned_rate = 100; @dur_set = 0; @dur_per = 100 self.note.split(/[\r\n]+/).each { |line| case line when YEZ::REGEXP::STATE::STUNNED_RATE @stunned_rate = $1.to_i when YEZ::REGEXP::STATE::DUR_SET @dur_set = $1.to_i when YEZ::REGEXP::STATE::DUR_PER @dur_per = $1.to_i end } # end self.note.split end # yez_cache_state_csdur #-------------------------------------------------------------------------- # new method: stunned_rate #-------------------------------------------------------------------------- def stunned_rate yez_cache_state_csdur if @stunned_rate == nil return @stunned_rate end #-------------------------------------------------------------------------- # new method: dur_set #-------------------------------------------------------------------------- def dur_set yez_cache_state_csdur if @dur_set == nil return @dur_set end #-------------------------------------------------------------------------- # new method: dur_per #-------------------------------------------------------------------------- def dur_per yez_cache_state_csdur if @dur_per == nil return @dur_per end end # RPG::State #=============================================================================== # Game_Battler #=============================================================================== class Game_Battler #-------------------------------------------------------------------------- # public instance variables #-------------------------------------------------------------------------- attr_accessor :dur #-------------------------------------------------------------------------- # alias method: clear_extra_values #-------------------------------------------------------------------------- alias clear_extra_values_csdur clear_extra_values unless $@ def clear_extra_values clear_extra_values_csdur @dur = 0 @dur_plus = 0 end #-------------------------------------------------------------------------- # new method: stun #-------------------------------------------------------------------------- def stun; return dur; end #-------------------------------------------------------------------------- # new method: dur #-------------------------------------------------------------------------- def dur @dur = 0 if @dur == nil return @dur end #-------------------------------------------------------------------------- # new method: stunned? #-------------------------------------------------------------------------- def stunned? return state?(YEZ::STAT::MAIN_STUN_STATE) end #-------------------------------------------------------------------------- # new method: gain_stun #-------------------------------------------------------------------------- def gain_stun(value) return if value == nil or value == 0 if value < 0 lose_stun(value) return end @dur = 0 if @dur == nil return if value > 0 and stunned? @dur = [@dur, 0].max for state in states do value *= state.stunned_rate / 100.0 end @dur += Integer(value) apply_stun if @dur >= max_dur end #-------------------------------------------------------------------------- # new method: clear_stun #-------------------------------------------------------------------------- def clear_stun @dur = 0 end #-------------------------------------------------------------------------- # new method: lose_stun #-------------------------------------------------------------------------- def lose_stun(value) @dur = 0 if @dur == nil @dur -= value @dur = [@dur, 0].max end #-------------------------------------------------------------------------- # new method: apply_stun #-------------------------------------------------------------------------- def apply_stun #----- Add Stun States for i in YEZ::STAT::ADD_STUN_STATES break if dead? next if state_resist?(i) if state?(i) @remained_states.push(i) next end add_state(i) @added_states.push(i) unless @added_states.include?(i) end #----- After Stun Reset if actor? if YEZ::STAT::AFTER_STUN_RESET.include?(@class_id) @dur = self.max_dur * YEZ::STAT::AFTER_STUN_RESET[@class_id] / 100 else @dur = self.max_dur * YEZ::STAT::AFTER_STUN_RESET[0] / 100 end else @dur = self.max_dur * YEZ::STAT::DEFAULT_ENEMY_AFTER_STUN / 100 end end #-------------------------------------------------------------------------- # alias method: skill_effect #-------------------------------------------------------------------------- alias skill_effect_csdur skill_effect unless $@ def skill_effect(user, skill) skill_effect_csdur(user, skill) if !@skipped and !@missed and !@evaded gain_stun(skill.stun_effect) end end #-------------------------------------------------------------------------- # alias method: item_effect #-------------------------------------------------------------------------- alias item_effect_csdur item_effect unless $@ def item_effect(user, item) item_effect_csdur(user, item) if !@skipped and !@missed and !@evaded gain_stun(item.stun_effect) end end #-------------------------------------------------------------------------- # alias method: execute_damage #-------------------------------------------------------------------------- alias execute_damage_csdur execute_damage unless $@ def execute_damage(user) execute_damage_csdur(user) if @critical and @hp_damage > 0 gain_stun(YEZ::STAT::STUN_CALC[:critical_hit]) end end #-------------------------------------------------------------------------- # alias method: item_test #-------------------------------------------------------------------------- alias item_test_csdur item_test unless $@ def item_test(user, item) return true if item.dur_growth != 0 return item_test_csdur(user, item) end #-------------------------------------------------------------------------- # alias method: item_growth_effect #-------------------------------------------------------------------------- alias item_growth_effect_csdur item_growth_effect unless $@ def item_growth_effect(user, item) if item.dur_growth != 0 and actor? @dur_plus = 0 if @dur_plus == nil @dur_plus += item.dur_growth end item_growth_effect_csdur(user, item) end #-------------------------------------------------------------------------- # alias method: elements_max_rate #-------------------------------------------------------------------------- unless $imported["ElementalStatusAffinity"] alias elements_max_rate_csdur elements_max_rate unless $@ def elements_max_rate(element_set) n = elements_max_rate_csdur(element_set) elements_gain_stun(n) return n end end # $imported["ElementalStatusAffinity"] #-------------------------------------------------------------------------- # new method: elements_gain_stun #-------------------------------------------------------------------------- def elements_gain_stun(n) return unless $scene.is_a?(Scene_Battle) and $scene.battle_phase if n > 200 gain_stun(YEZ::STAT::STUN_CALC[:element_s]) elsif n > 150 gain_stun(YEZ::STAT::STUN_CALC[:element_a]) elsif n > 100 gain_stun(YEZ::STAT::STUN_CALC[:element_b]) end end #-------------------------------------------------------------------------- # new method: max_dur #-------------------------------------------------------------------------- def max_dur @dur_plus = 0 if @dur_plus == nil n = base_dur n = [@dur_plus + n, 1].max for state in states if $imported["CustomStatusPropertiesZeal"] percent = 100 for i in 1..stack(state); percent += state.dur_per - 100; end else percent = state.dur_per end n = n * percent / 100.0 end for state in states; if $imported["CustomStatusPropertiesZeal"] for i in 1..stack(state); n += state.dur_set; end else n += state.dur_set end end return Integer(n) end #-------------------------------------------------------------------------- # new method: max_dur= #-------------------------------------------------------------------------- def max_dur=(new_max_dur) @dur_plus = 0 if @dur_plus == nil @dur_plus = new_max_dur - max_dur end end # Game_Battler #=============================================================================== # Game_Actor #=============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # new method: base_dur #-------------------------------------------------------------------------- def base_dur if YEZ::STAT::CLASS_BASE_DUR.include?(@class_id) n = YEZ::STAT::CLASS_BASE_DUR[@class_id] else n = YEZ::STAT::CLASS_BASE_DUR[0] end percent = 100 for item in equips.compact percent += item.equip_dur_per end n *= percent / 100.0 for item in equips.compact n += item.equip_dur_set end return n end end # Game_Actor #=============================================================================== # Game_Enemy #=============================================================================== class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # new method: base_dur #-------------------------------------------------------------------------- def base_dur @base_stats = {} if @base_stats == nil return @base_stats[:dur] if @base_stats[:dur] != nil @base_stats[:dur] = enemy.base_dur if @base_stats[:dur] == nil return @base_stats[:dur] end end # Game_Enemy #=============================================================================== # Game_Player #=============================================================================== class Game_Player < Game_Character #-------------------------------------------------------------------------- # alias method: increase_steps #-------------------------------------------------------------------------- alias increase_steps_csdur increase_steps unless $@ def increase_steps increase_steps_csdur return if @move_route_forcing for member in $game_party.members member.lose_stun(YEZ::STAT::STUN_LOSS_PER_STEP) end end end # Game_Player #=============================================================================== # Scene_Battle #=============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # public instance variables #-------------------------------------------------------------------------- attr_accessor :battle_phase #-------------------------------------------------------------------------- # alias method: start #-------------------------------------------------------------------------- alias start_battle_csdur start unless $@ def start start_battle_csdur @battle_phase = false end #-------------------------------------------------------------------------- # alias method: battle_end #-------------------------------------------------------------------------- alias battle_end_csdur battle_end unless $@ def battle_end(result) battle_end_csdur(result) @battle_phase = false for member in $game_party.members member.lose_stun(member.dur * YEZ::STAT::BATTLE_OVER_STUN / 100) end end #-------------------------------------------------------------------------- # alias method: start_main #-------------------------------------------------------------------------- alias start_main_csdur start_main unless $@ def start_main @battle_phase = true start_main_csdur end end # Scene_Battle #=============================================================================== # Window_Base #=============================================================================== class Window_Base < Window #-------------------------------------------------------------------------- # alias method: draw_actor_parameter #-------------------------------------------------------------------------- alias draw_actor_parameter_csdur draw_actor_parameter unless $@ def draw_actor_parameter(actor, x, y, type) if type == 201 self.contents.font.color = system_color self.contents.draw_text(x, y, 120, WLH, Vocab::dur) self.contents.font.color = normal_color self.contents.draw_text(x + 120, y, 36, WLH, actor.max_dur, 2) else draw_actor_parameter_csdur(actor, x, y, type) end end #-------------------------------------------------------------------------- # new method: draw_actor_stun #-------------------------------------------------------------------------- def draw_actor_stun(actor, x, y, width = 120) draw_stun_indicator(x, y, actor) percent = actor.dur * 100 / actor.max_dur text = sprintf(YEZ::STAT::VOCAB_STUN, percent) text = YEZ::STAT::VOCAB_STUNNED if actor.stunned? self.contents.draw_text(x + 24, y, width - 24, WLH, text) end #-------------------------------------------------------------------------- # new method: draw_stun_indicator #-------------------------------------------------------------------------- def draw_stun_indicator(x, y, actor) percent = actor.dur * 100 / actor.max_dur if actor.stunned? draw_icon(YEZ::STAT::DUR_INDICATOR[100], x, y, true) return end icon = YEZ::STAT::DUR_INDICATOR[0]; n = 0 enabled = false for key in YEZ::STAT::DUR_INDICATOR next if key[0] == 0 next if n > key[0] next if percent < key[0] n = key[0] icon = YEZ::STAT::DUR_INDICATOR[key[0]] enabled = true end draw_icon(icon, x, y, enabled) end end # Window_Base #=============================================================================== # Window_BattleStatus #=============================================================================== class Window_BattleStatus < Window_Selectable #-------------------------------------------------------------------------- # new method: draw_actor_state #-------------------------------------------------------------------------- if YEZ::STAT::SHOW_DUR_INDICATOR and !$imported["BattleEngineZealous"] def draw_actor_state(actor, x, y, width = 96) if YEZ::STAT::DUR_INDICATOR_SIDE == 1 draw_stun_indicator(x - 24, y, actor) else draw_stun_indicator(width + 24, y, actor) end super end end end # Window_BattleStatus #=============================================================================== # Window_TargetEnemy #=============================================================================== class Window_TargetEnemy < Window_Command #-------------------------------------------------------------------------- # new method: draw_item #-------------------------------------------------------------------------- if YEZ::STAT::DISPLAY_ENEMY_DUR def draw_item(index, enabled = true) rect = item_rect(index) self.draw_stun_indicator(rect.x + 4, rect.y, $game_troop.existing_members[index]) rect.x += 28 rect.width -= 32 self.contents.clear_rect(rect) self.contents.font.color = normal_color self.contents.font.color.alpha = enabled ? 255 : 128 self.contents.draw_text(rect, @commands[index]) end end end # Window_TargetEnemy #=============================================================================== # Window_Status #=============================================================================== class Window_Status < Window_Base #-------------------------------------------------------------------------- # alias method: draw_parameters #-------------------------------------------------------------------------- alias draw_parameters_csdur draw_parameters unless $@ def draw_parameters(x, y) draw_parameters_csdur(x, y) @param_rows = 3 if @param_rows == nil @param_rows += 1 draw_actor_parameter(@actor, x, y + WLH * @param_rows, 201) end end # Window_Status #=============================================================================== # # END OF FILE # #===============================================================================