#=============================================================================== # # Yanfly Engine Zealous - Elemental Status Affinity # Last Date Updated: 2010.02.02 # Level: Normal, Hard # # Elements and status effects in RPG Maker had set rates that couldn't be # altered no matter what the means. With this script, they can be altered by # means of items, weapons, armours, and status effects. In addition to that, # special elemental and status properties can be applied to the said objects # in manners where attacks can gain elemental and status traits. Enemies can # innately possess these traits as well. This script provides the affinity rate # efficiency for your players to control on the battlefield. # #=============================================================================== # Updates # ----------------------------------------------------------------------------- # o 2010.02.02 - Finished Script. # o 2010.02.01 - Started Script. #=============================================================================== # 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. # # ----------------------------------------------------------------------------- # Item Tags - Insert the following tags into usable Item noteboxes. # ----------------------------------------------------------------------------- # or # or # This raises the individual element and status weakness and resistance rates # for the actor by y amount for element/state x. Note that +y% makes the actor # take more elemental damage and more likely to fall under the status effect # while -y% makes the actor more immune. # # ----------------------------------------------------------------------------- # Equip and Status Tags - Insert the following tags into either notebox. # ----------------------------------------------------------------------------- # or # This will set the element or state's rank for X to Y rank. X has to be the # integer ID of the element/state while Y has to be a letter: S,A,B,C,D,E,F. # Use multiple of these tags to include multiple effects. You can also replace # x with "ALL" to affect all elements or states. For both states and equips. # # or # or # This will raise or lower the element/state x's rank by y. Note that when a # rank is lowered, the target becomes more vulnerable to it. Increasing the rank # will make the target more immune towards it. Stackable. For both states and # equips. # # or # or # This will reverse the element rates of the target. S rank will swap to F rank, # A rank will swap to E rank, and so on. This is calculated after all of the # other rank effects have taken place, but before the rates will take effect. # For states only. # # or # or # This will set the element/state rate of x to y% of what it used to be. This # is a value is calculated before the extra percentages are added. Stackable. # For both states and equips. # # or # or # Note that this is rate and not rank. Rate is different as this is a numeric # value associated with the actual affinity rather than the rank value. So with # this, you can cause the afflicted battler to be +5% weaker or -5% more immune # towards an element or state. Stackable. For both states and equips. # # or # or # This will apply the element or state to the actor's physical attacks. This # will add on top of the default weapon attack set. For both states and equips. # If placed inside of an enemy's notebox, that enemy will have the attack # element or state applying trait. # #=============================================================================== # Compatibility # ----------------------------------------------------------------------------- # - Works With: YEZ Battle Engine Zealous, YEZ Class Statu: DUR # YEZ Custom Status Properties # ----------------------------------------------------------------------------- # 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["ElementalStatusAffinity"] = true module YEZ module AFFINITY #=========================================================================== # Affinity Settings # -------------------------------------------------------------------------- # The following adjusts the affinity tables and settings used for your game. # Whatever is filled in here will affect the game universally. #=========================================================================== # For those who would like different elements to have different rates based # on their ranks, change the settings here. This way, you can prevent some # elements from being absorbed or whatnot. ELEMENT ={ # Do not remove element ID 0. # ID => [RankS, RankA, RankB, RankC, RankD, RankE, RankF], 0 => [ 300, 200, 150, 100, 50, 0, -100], # Common 1 => [ 300, 200, 150, 100, 50, 25, 0], # Hand 2 => [ 300, 200, 150, 100, 50, 25, 0], # Sword 3 => [ 300, 200, 150, 100, 50, 25, 0], # Axe 4 => [ 300, 200, 150, 100, 50, 25, 0], # Hammer 5 => [ 300, 200, 150, 100, 50, 25, 0], # Dagger 6 => [ 300, 200, 150, 100, 50, 25, 0], # Spear 7 => [ 300, 200, 150, 100, 50, 25, 0], # Scythe 8 => [ 300, 200, 150, 100, 50, 25, 0], # Bow 9 => [ 300, 200, 150, 100, 50, 25, 0], # Gun } # Do not remove this. # This determines the way element rates are calculated when more than one # element is present on an attack. # Type Method # 0 Highest of the rates (default) # 1 Lowest of the rates # 2 Average of the rates without absorb, then apply absorb # 3 Average of the rates with absorb # 4 Priority to absorb, immune, find maximum for the rest. # 5 Priority to absorb, immune, find average for the rest. ELEMENT_RATE_CALCULATION = 4 # This determines the maximum and minimum rates adjustable for element # rates so that damage doesn't suddenly shoot through the roof from just # element state stacking. MAX_ELEMENT_RATE = 400 MIN_ELEMENT_RATE = -400 # For those who would like different success rates for each status effect # based on ranks, you may change their settings here. STATE ={ # Do not remove status ID 0. # ID => [RankS, RankA, RankB, RankC, RankD, RankE, RankF], 0 => [ 120, 100, 80, 60, 40, 20, 0], # Common 3 => [ 130, 100, 90, 70, 50, 30, 0], # Bleed 4 => [ 130, 100, 90, 70, 50, 30, 0], # Blind 5 => [ 130, 100, 90, 70, 50, 30, 0], # Broken 6 => [ 130, 100, 90, 70, 50, 30, 0], # Burning 7 => [ 130, 100, 90, 70, 50, 30, 0], # Cripple 8 => [ 130, 100, 90, 70, 50, 30, 0], # Dazed 9 => [ 130, 100, 90, 70, 50, 30, 0], # Poison 10 => [ 130, 100, 90, 70, 50, 30, 0], # Sleep 11 => [ 130, 100, 90, 70, 50, 30, 0], # Weaken } # Do not remove this. end # AFFINITY 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 ELE_GROWTH = /^<(?:ELEMENT_RATE|element rate)[ ](\d+):[ ]*([\+\-]\d+)([%%])>/i STATE_GROWTH = /^<(?:STATE_RATE|state rate)[ ](\d+):[ ]*([\+\-]\d+)([%%])>/i end # BASEITEM module STATE SET_ELEMENT_RANK = /^<(?:ELEMENT_RANK|element rank)[ ](.*):(.*)>/i SET_STATE_RANK = /^<(?:STATE_RANK|state rank)[ ](.*):(.*)>/i ADD_ELEMENT_RANK = /^<(?:ELEMENT_RANK|element rank)[ ](.*):[ ]*([\+\-]\d+)>/i ADD_STATE_RANK = /^<(?:STATE_RANK|state rank)[ ](.*):[ ]*([\+\-]\d+)>/i REV_ELEMENT_RANK = /^<(?:ELEMENT_REVERSE|element reverse):[ ]*(\d+(?:\s*,\s*\d+)*)>/i REV_STATE_RANK = /^<(?:STATE_REVERSE|state reverse):[ ]*(\d+(?:\s*,\s*\d+)*)>/i SET_ELEMENT_RATE = /^<(?:ELEMENT_RATE|element rate)[ ](.*):[ ]*([\+\-]\d+)([%%])>/i SET_STATE_RATE = /^<(?:STATE_RATE|state rate)[ ](.*):[ ]*([\+\-]\d+)([%%])>/i PER_ELEMENT_RATE = /^<(?:ELEMENT_RATE|element rate)[ ](.*):[ ]*(\d+)([%%])>/i PER_STATE_RATE = /^<(?:STATE_RATE|state rate)[ ](.*):[ ]*(\d+)([%%])>/i ATTACK_ELEMENT = /^<(?:ATTACK_ELEMENT|attack element):[ ]*(\d+(?:\s*,\s*\d+)*)>/i ATTACK_STATE = /^<(?:ATTACK_STATE|attack state):[ ]*(\d+(?:\s*,\s*\d+)*)>/i end # STATE end # REGEXP end # YEZ #=============================================================================== # RPG::BaseItem #=============================================================================== class RPG::BaseItem #-------------------------------------------------------------------------- # common cache: yez_cache_baseitem_esa #-------------------------------------------------------------------------- def yez_cache_baseitem_esa @element_growth = {}; @state_growth = {} @element_rank = {}; @state_rank = {} @attack_element = []; @attack_state = [] @element_rank_add = {}; @state_rank_add = {} @element_rank_rev = []; @state_rank_rev = [] @element_rate_set = {}; @state_rate_set = {} @element_rate_per = {}; @state_rate_per = {} self.note.split(/[\r\n]+/).each { |line| case line #--- when YEZ::REGEXP::BASEITEM::ELE_GROWTH @element_growth[$1.to_i] = $2.to_i when YEZ::REGEXP::BASEITEM::STATE_GROWTH @state_growth[$1.to_i] = $2.to_i #--- when YEZ::REGEXP::STATE::SET_ELEMENT_RATE if $1.to_i != 0 @element_rate_set[$1.to_i] = $2.to_i elsif $1.upcase == "ALL" for i in 1..($data_system.elements.size - 1) @element_rate_set[i] = $2.to_i end end #--- when YEZ::REGEXP::STATE::PER_ELEMENT_RATE if $1.to_i != 0 @element_rate_per[$1.to_i] = $2.to_i elsif $1.upcase == "ALL" for i in 1..($data_system.elements.size - 1) @element_rate_per[i] = $2.to_i end end #--- when YEZ::REGEXP::STATE::ADD_ELEMENT_RANK if $1.to_i != 0 @element_rank_add[$1.to_i] = $2.to_i elsif $1.upcase == "ALL" for i in 1..($data_system.elements.size - 1) @element_rank_add[i] = $2.to_i end end #--- when YEZ::REGEXP::STATE::SET_ELEMENT_RANK case $2.upcase when "S", "Z"; value = 0 when "A"; value = 1 when "B"; value = 2 when "C"; value = 3 when "D"; value = 4 when "E"; value = 5 when "F"; value = 6 else; next end if $1.to_i != 0 @element_rank[$1.to_i] = value elsif $1.upcase == "ALL" for i in 1..($data_system.elements.size - 1) @element_rank[i] = value end end #--- when YEZ::REGEXP::STATE::SET_STATE_RATE if $1.to_i != 0 @state_rate_set[$1.to_i] = $2.to_i elsif $1.upcase == "ALL" for i in 1..($data_states.size - 1) @state_rate_set[i] = $2.to_i end end #--- when YEZ::REGEXP::STATE::PER_STATE_RATE if $1.to_i != 0 @state_rate_per[$1.to_i] = $2.to_i elsif $1.upcase == "ALL" for i in 1..($data_states.size - 1) @state_rate_per[i] = $2.to_i end end #--- when YEZ::REGEXP::STATE::ADD_STATE_RANK if $1.to_i != 0 @state_rank_add[$1.to_i] = $2.to_i elsif $1.upcase == "ALL" for i in 1..($data_states.size - 1) @state_rank_add[i] = $2.to_i end end #--- when YEZ::REGEXP::STATE::SET_STATE_RANK case $2.upcase when "S", "Z"; value = 0 when "A"; value = 1 when "B"; value = 2 when "C"; value = 3 when "D"; value = 4 when "E"; value = 5 when "F"; value = 6 else; next end if $1.to_i != 0 @state_rank[$1.to_i] = value elsif $1.upcase == "ALL" for i in 1..($data_states.size - 1) @state_rank[i] = value end end #--- when YEZ::REGEXP::STATE::ATTACK_ELEMENT $1.scan(/\d+/).each { |num| @attack_element.push(num.to_i) if num.to_i > 0 } #--- when YEZ::REGEXP::STATE::ATTACK_STATE $1.scan(/\d+/).each { |num| @attack_state.push(num.to_i) if num.to_i > 0 } #--- end } # end self.note.split end # yez_cache_state_esa #-------------------------------------------------------------------------- # new method: element_growth #-------------------------------------------------------------------------- def element_growth yez_cache_baseitem_esa if @element_growth == nil return @element_growth end #-------------------------------------------------------------------------- # new method: state_growth #-------------------------------------------------------------------------- def state_growth yez_cache_baseitem_esa if @state_growth == nil return @state_growth end #-------------------------------------------------------------------------- # new method: element_rank #-------------------------------------------------------------------------- def element_rank yez_cache_baseitem_esa if @element_rank == nil return @element_rank end #-------------------------------------------------------------------------- # new method: element_rank_add #-------------------------------------------------------------------------- def element_rank_add yez_cache_baseitem_esa if @element_rank_add == nil return @element_rank_add end #-------------------------------------------------------------------------- # new method: element_rate_set #-------------------------------------------------------------------------- def element_rate_set yez_cache_baseitem_esa if @element_rate_set == nil return @element_rate_set end #-------------------------------------------------------------------------- # new method: element_rate_per #-------------------------------------------------------------------------- def element_rate_per yez_cache_baseitem_esa if @element_rate_per == nil return @element_rate_per end #-------------------------------------------------------------------------- # new method: state_rank #-------------------------------------------------------------------------- def state_rank yez_cache_baseitem_esa if @state_rank == nil return @state_rank end #-------------------------------------------------------------------------- # new method: state_rank_add #-------------------------------------------------------------------------- def state_rank_add yez_cache_baseitem_esa if @state_rank_add == nil return @state_rank_add end #-------------------------------------------------------------------------- # new method: state_rate_set #-------------------------------------------------------------------------- def state_rate_set yez_cache_baseitem_esa if @state_rate_set == nil return @state_rate_set end #-------------------------------------------------------------------------- # new method: state_rate_per #-------------------------------------------------------------------------- def state_rate_per yez_cache_baseitem_esa if @state_rate_per == nil return @state_rate_per end #-------------------------------------------------------------------------- # new method: attack_element #-------------------------------------------------------------------------- def attack_element yez_cache_baseitem_esa if @attack_element == nil return @attack_element end #-------------------------------------------------------------------------- # new method: attack_state #-------------------------------------------------------------------------- def attack_state yez_cache_baseitem_esa if @attack_state == nil return @attack_state end end # RPG::BaseItem #=============================================================================== # RPG::State #=============================================================================== class RPG::State #-------------------------------------------------------------------------- # common cache: yez_cache_state_esa #-------------------------------------------------------------------------- def yez_cache_state_esa @element_rank = {}; @state_rank = {} @attack_element = []; @attack_state = [] @element_rank_add = {}; @state_rank_add = {} @element_rank_rev = []; @state_rank_rev = [] @element_rate_set = {}; @state_rate_set = {} @element_rate_per = {}; @state_rate_per = {} self.note.split(/[\r\n]+/).each { |line| case line #--- when YEZ::REGEXP::STATE::SET_ELEMENT_RATE if $1.to_i != 0 @element_rate_set[$1.to_i] = $2.to_i elsif $1.upcase == "ALL" for i in 1..($data_system.elements.size - 1) @element_rate_set[i] = $2.to_i end end #--- when YEZ::REGEXP::STATE::PER_ELEMENT_RATE if $1.to_i != 0 @element_rate_per[$1.to_i] = $2.to_i elsif $1.upcase == "ALL" for i in 1..($data_system.elements.size - 1) @element_rate_per[i] = $2.to_i end end #--- when YEZ::REGEXP::STATE::ADD_ELEMENT_RANK if $1.to_i != 0 @element_rank_add[$1.to_i] = $2.to_i elsif $1.upcase == "ALL" for i in 1..($data_system.elements.size - 1) @element_rank_add[i] = $2.to_i end end #--- when YEZ::REGEXP::STATE::REV_ELEMENT_RANK $1.scan(/\d+/).each { |num| @element_rank_rev.push(num.to_i) if num.to_i > 0 } #--- when YEZ::REGEXP::STATE::SET_ELEMENT_RANK case $2.upcase when "S", "Z"; value = 0 when "A"; value = 1 when "B"; value = 2 when "C"; value = 3 when "D"; value = 4 when "E"; value = 5 when "F"; value = 6 else; next end if $1.to_i != 0 @element_rank[$1.to_i] = value elsif $1.upcase == "ALL" for i in 1..($data_system.elements.size - 1) @element_rank[i] = value end end #--- when YEZ::REGEXP::STATE::SET_STATE_RATE if $1.to_i != 0 @state_rate_set[$1.to_i] = $2.to_i elsif $1.upcase == "ALL" for i in 1..($data_states.size - 1) @state_rate_set[i] = $2.to_i end end #--- when YEZ::REGEXP::STATE::PER_STATE_RATE if $1.to_i != 0 @state_rate_per[$1.to_i] = $2.to_i elsif $1.upcase == "ALL" for i in 1..($data_states.size - 1) @state_rate_per[i] = $2.to_i end end #--- when YEZ::REGEXP::STATE::ADD_STATE_RANK if $1.to_i != 0 @state_rank_add[$1.to_i] = $2.to_i elsif $1.upcase == "ALL" for i in 1..($data_states.size - 1) @state_rank_add[i] = $2.to_i end end #--- when YEZ::REGEXP::STATE::REV_STATE_RANK $1.scan(/\d+/).each { |num| @state_rank_rev.push(num.to_i) if num.to_i > 0 } #--- when YEZ::REGEXP::STATE::SET_STATE_RANK case $2.upcase when "S", "Z"; value = 0 when "A"; value = 1 when "B"; value = 2 when "C"; value = 3 when "D"; value = 4 when "E"; value = 5 when "F"; value = 6 else; next end if $1.to_i != 0 @state_rank[$1.to_i] = value elsif $1.upcase == "ALL" for i in 1..($data_states.size - 1) @state_rank[i] = value end end #--- when YEZ::REGEXP::STATE::ATTACK_ELEMENT $1.scan(/\d+/).each { |num| @attack_element.push(num.to_i) if num.to_i > 0 } #--- when YEZ::REGEXP::STATE::ATTACK_STATE $1.scan(/\d+/).each { |num| @attack_state.push(num.to_i) if num.to_i > 0 } #--- end } # end self.note.split end # yez_cache_state_esa #-------------------------------------------------------------------------- # new method: element_rank #-------------------------------------------------------------------------- def element_rank yez_cache_state_esa if @element_rank == nil return @element_rank end #-------------------------------------------------------------------------- # new method: element_rank_add #-------------------------------------------------------------------------- def element_rank_add yez_cache_state_esa if @element_rank_add == nil return @element_rank_add end #-------------------------------------------------------------------------- # new method: element_rank_rev #-------------------------------------------------------------------------- def element_rank_rev yez_cache_state_esa if @element_rank_rev == nil return @element_rank_rev end #-------------------------------------------------------------------------- # new method: element_rate_set #-------------------------------------------------------------------------- def element_rate_set yez_cache_state_esa if @element_rate_set == nil return @element_rate_set end #-------------------------------------------------------------------------- # new method: element_rate_per #-------------------------------------------------------------------------- def element_rate_per yez_cache_state_esa if @element_rate_per == nil return @element_rate_per end #-------------------------------------------------------------------------- # new method: state_rank #-------------------------------------------------------------------------- def state_rank yez_cache_state_esa if @state_rank == nil return @state_rank end #-------------------------------------------------------------------------- # new method: state_rank_add #-------------------------------------------------------------------------- def state_rank_add yez_cache_state_esa if @state_rank_add == nil return @state_rank_add end #-------------------------------------------------------------------------- # new method: state_rank_rev #-------------------------------------------------------------------------- def state_rank_rev yez_cache_state_esa if @state_rank_rev == nil return @state_rank_rev end #-------------------------------------------------------------------------- # new method: state_rate_set #-------------------------------------------------------------------------- def state_rate_set yez_cache_state_esa if @state_rate_set == nil return @state_rate_set end #-------------------------------------------------------------------------- # new method: state_rate_per #-------------------------------------------------------------------------- def state_rate_per yez_cache_state_esa if @state_rate_per == nil return @state_rate_per end #-------------------------------------------------------------------------- # new method: attack_element #-------------------------------------------------------------------------- def attack_element yez_cache_state_esa if @attack_element == nil return @attack_element end #-------------------------------------------------------------------------- # new method: attack_state #-------------------------------------------------------------------------- def attack_state yez_cache_state_esa if @attack_state == nil return @attack_state end end # RPG::State #=============================================================================== # RPG::Enemy #=============================================================================== class RPG::Enemy #-------------------------------------------------------------------------- # common cache: yez_cache_enemy_esa #-------------------------------------------------------------------------- def yez_cache_enemy_esa @attack_element = []; @attack_state = [] self.note.split(/[\r\n]+/).each { |line| case line #--- when YEZ::REGEXP::STATE::ATTACK_ELEMENT $1.scan(/\d+/).each { |num| @attack_element.push(num.to_i) if num.to_i > 0 } #--- when YEZ::REGEXP::STATE::ATTACK_STATE $1.scan(/\d+/).each { |num| @attack_state.push(num.to_i) if num.to_i > 0 } #--- end } # end self.note.split end # yez_cache_enemy_esa #-------------------------------------------------------------------------- # new method: attack_element #-------------------------------------------------------------------------- def attack_element yez_cache_enemy_esa if @attack_element == nil return @attack_element end #-------------------------------------------------------------------------- # new method: attack_state #-------------------------------------------------------------------------- def attack_state yez_cache_enemy_esa if @attack_state == nil return @attack_state end end # RPG::Enemy #=============================================================================== # Game_Battler #=============================================================================== class Game_Battler #-------------------------------------------------------------------------- # overwrite method: elements_max_rate #-------------------------------------------------------------------------- def elements_max_rate(element_set) return 100 if element_set.empty? rate_list = [] for i in element_set rate_list.push(element_rate(i)) end #--- case YEZ::AFFINITY::ELEMENT_RATE_CALCULATION when 1 # Lowest of the rates n = rate_list.min when 2 # Average of the rates without absorb, then apply absorb n = 0; absorb = false for rate in rate_list absorb = true if rate < 0 n += rate.abs end n *= -1 if absorb n /= rate_list.size when 3 # Average of the rates with absorb n = 0 for rate in rate_list; n += rate end n /= rate_list.size when 4 # Priority to absorb, immune, find maximum for the rest. result = [] for rate in rate_list next if rate > 0 result.push(rate) end n = (result != []) ? result.min : rate_list.max when 5 # Priority to absorb, immune, find average for the rest. result = []; average = 0 for rate in rate_list result.push(rate) if rate <= 0 average += rate end n = (result != []) ? result.min : average / rate_list.size else # Default: Highest of the rates n = rate_list.max end #--- elements_weakness_popup(n) if $imported["BattleEngineZealous"] elements_gain_stun(n) if $imported["ClassStatDUR"] return n end #-------------------------------------------------------------------------- # new method: apply_element_rank #-------------------------------------------------------------------------- def apply_element_rank(element_id) if actor? rank = self.class.element_ranks[element_id] else rank = enemy.element_ranks[element_id] end result = [] #--- if actor? for equip in equips.compact next unless equip.element_rank.include?(element_id) result.push(equip.element_rank[element_id]) end end #--- for state in states next unless state.element_rank.include?(element_id) result.push(state.element_rank[element_id]) end rank = result.min if result != [] #--- if actor? for equip in equips.compact next unless equip.element_rank_add.include?(element_id) rank += equip.element_rank_add[element_id] end end #--- for state in states next unless state.element_rank_add.include?(element_id) multiplier = $imported["CustomStatusPropertiesZeal"] ? stack(state) : 1 rank += state.element_rank_add[element_id] * multiplier end #--- rank = [[rank, 0].max, 6].min for state in states next unless state.element_rank_rev.include?(element_id) case rank when 0; rank = 6 when 1; rank = 5 when 2; rank = 4 when 4; rank = 2 when 5; rank = 1 when 6; rank = 0 end break end #--- return rank end #-------------------------------------------------------------------------- # new method: element_rate_table #-------------------------------------------------------------------------- def element_rate_table(element_id, rank) if YEZ::AFFINITY::ELEMENT.include?(element_id) result = YEZ::AFFINITY::ELEMENT[element_id] else result = YEZ::AFFINITY::ELEMENT[0] end rate = result[rank] absorb = (rate < 0) #--- create_affinity_bonus @bonus_element_affinity[element_id] = 0 if @bonus_element_affinity[element_id] == nil rate += @bonus_element_affinity[element_id] #--- if actor? for equip in equips.compact next unless equip.element_rate_per.include?(element_id) percent = equip.element_rate_per[element_id] rate = rate * percent / 100 end end #--- for state in states next unless state.element_rate_per.include?(element_id) if $imported["CustomStatusPropertiesZeal"] percent = 100 percent += state.element_rate_per[element_id] - 100 * stack(state) else percent = state.element_rate_per[element_id] end percent = [percent, 0].max rate = rate * percent / 100 end #--- if actor? for equip in equips.compact next unless equip.element_rate_set.include?(element_id) rate += equip.element_rate_set[element_id] end end #--- for state in states next unless state.element_rate_set.include?(element_id) multiplier = $imported["CustomStatusPropertiesZeal"] ? stack(state) : 1 rate += state.element_rate_set[element_id] * multiplier end #--- rate = absorb ? [rate, 0].min : [rate, 0].max rate = [rate, YEZ::AFFINITY::MAX_ELEMENT_RATE].min rate = [rate, YEZ::AFFINITY::MIN_ELEMENT_RATE].max return rate end #-------------------------------------------------------------------------- # new method: apply_state_rank #-------------------------------------------------------------------------- def apply_state_rank(state_id) if actor? rank = self.class.state_ranks[state_id] else rank = enemy.state_ranks[state_id] end result = [] #--- if actor? for equip in equips.compact next unless equip.state_rank.include?(state_id) result.push(equip.state_rank[state_id]) end end #--- for state in states next unless state.state_rank.include?(state_id) result.push(state.state_rank[state_id]) end #--- rank = result.min if result != [] #--- if actor? for equip in equips.compact next unless equip.state_rank_add.include?(state_id) rank += equip.state_rank_add[state_id] end end #--- for state in states next unless state.state_rank_add.include?(state_id) multiplier = $imported["CustomStatusPropertiesZeal"] ? stack(state) : 1 rank += state.state_rank_add[state_id] * multiplier end #--- rank = [[rank, 0].max, 6].min for state in states next unless state.state_rank_rev.include?(state_id) case rank when 0; rank = 6 when 1; rank = 5 when 2; rank = 4 when 4; rank = 2 when 5; rank = 1 when 6; rank = 0 end break end return rank end #-------------------------------------------------------------------------- # new method: state_probability_table #-------------------------------------------------------------------------- def state_probability_table(state_id, rank) if YEZ::AFFINITY::STATE.include?(state_id) result = YEZ::AFFINITY::STATE[state_id] else result = YEZ::AFFINITY::STATE[0] end rate = result[rank] #--- create_affinity_bonus @bonus_state_affinity[state_id] = 0 if @bonus_state_affinity[state_id] == nil rate += @bonus_state_affinity[state_id] #--- if actor? for equip in equips.compact next unless equip.state_rate_per.include?(state_id) percent = equip.state_rate_per[state_id] rate = rate * percent / 100 end end #--- for state in states next unless state.state_rate_per.include?(state_id) if $imported["CustomStatusPropertiesZeal"] percent = 100 percent += state.state_rate_per[state_id] - 100 * stack(state) else percent = state.state_rate_per[state_id] end percent = [percent, 0].max rate = rate * percent / 100 end #--- if actor? for equip in equips.compact next unless equip.state_rate_set.include?(state_id) rate += equip.state_rate_set[state_id] end end #--- for state in states next unless state.state_rate_set.include?(state_id) multiplier = $imported["CustomStatusPropertiesZeal"] ? stack(state) : 1 rate += state.state_rate_set[state_id] * multiplier end #--- return [rate, 0].max end #-------------------------------------------------------------------------- # new method: create_affinity_bonus #-------------------------------------------------------------------------- def create_affinity_bonus @bonus_element_affinity = {} if @bonus_element_affinity == nil @bonus_state_affinity = {} if @bonus_state_affinity == nil end #-------------------------------------------------------------------------- # alias method: item_test #-------------------------------------------------------------------------- alias item_test_esa item_test unless $@ def item_test(user, item) return true if item.element_growth != {} return true if item.state_growth != {} return item_test_esa(user, item) end #-------------------------------------------------------------------------- # alias method: item_growth_effect #-------------------------------------------------------------------------- alias item_growth_effect_esa item_growth_effect unless $@ def item_growth_effect(user, item) create_affinity_bonus if item.element_growth != {} for key in item.element_growth ele_id = key[0]; value = key[1] @bonus_element_affinity[ele_id] = 0 if @bonus_element_affinity[ele_id] == nil @bonus_element_affinity[ele_id] += value end end if item.state_growth != {} for key in item.state_growth state_id = key[0]; value = key[1] @bonus_state_affinity[state_id] = 0 if @bonus_state_affinity[state_id] == nil @bonus_state_affinity[state_id] += value end end item_growth_effect_esa(user, item) end end # Game_Battler #=============================================================================== # Game_Actor #=============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # alias method: setup #-------------------------------------------------------------------------- alias setup_esa setup unless $@ def setup(actor_id) setup_esa(actor_id) @bonus_element_affinity = nil @bonus_state_affinity = nil create_affinity_bonus end #-------------------------------------------------------------------------- # overwrite method: element_rate #-------------------------------------------------------------------------- def element_rate(element_id) rank = apply_element_rank(element_id) result = element_rate_table(element_id, rank) for armor in armors.compact result /= 2 if armor.element_set.include?(element_id) end for state in states result /= 2 if state.element_set.include?(element_id) end return result end #-------------------------------------------------------------------------- # overiwrite method: state_probability #-------------------------------------------------------------------------- def state_probability(state_id) if $data_states[state_id].nonresistance result = 100 else rank = apply_state_rank(state_id) result = state_probability_table(state_id, rank) end return result end #-------------------------------------------------------------------------- # alias method: element_set #-------------------------------------------------------------------------- alias element_set_actor_esa element_set unless $@ def element_set result = element_set_actor_esa #--- for equip in equips.compact result += equip.attack_element end #--- for state in states result += state.attack_element end #--- return result.uniq end #-------------------------------------------------------------------------- # alias method: plus_state_set #-------------------------------------------------------------------------- alias plus_state_set_actor_esa plus_state_set unless $@ def plus_state_set result = plus_state_set_actor_esa #--- for equip in equips.compact result += equip.attack_state end #--- for state in states result += state.attack_state end #--- return result.uniq end end # Game_Actor #=============================================================================== # Game_Enemy #=============================================================================== class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # alias method: initialize #-------------------------------------------------------------------------- alias initialize_enemy_esa initialize unless $@ def initialize(index, enemy_id) initialize_enemy_esa(index, enemy_id) @bonus_element_affinity = nil @bonus_state_affinity = nil create_affinity_bonus end #-------------------------------------------------------------------------- # overwrite method: element_rate #-------------------------------------------------------------------------- def element_rate(element_id) rank = apply_element_rank(element_id) result = element_rate_table(element_id, rank) for state in states result /= 2 if state.element_set.include?(element_id) end return result end #-------------------------------------------------------------------------- # overwrite method: state_probability #-------------------------------------------------------------------------- def state_probability(state_id) if $data_states[state_id].nonresistance result = 100 else rank = apply_state_rank(state_id) result = state_probability_table(state_id, rank) end return result end #-------------------------------------------------------------------------- # new method: element_set #-------------------------------------------------------------------------- def element_set result = super result += enemy.attack_element for state in states result += state.attack_element end return result.uniq end #-------------------------------------------------------------------------- # new method: plus_state_set #-------------------------------------------------------------------------- def plus_state_set result = super result += enemy.attack_state for state in states result += state.attack_state end return result.uniq end end # Game_Enemy #=============================================================================== # # END OF FILE # #===============================================================================