Code:
#==============================================================================
# XRXS No38. Element Limitation and Correction
#------------------------------------------------------------------------------
# Written by Xiderowg (http://sboox.hp.infoseek.co.jp/xp/)
#------------------------------------------------------------------------------
# * FUNCTION
# Configures the element_correct method in Game_Battler3,
# which affects the method in which the elemental multiplier
# is calculated and applied to the battler's damage, as well
# as limiting the element list in the database so that
# 'special elements' - ones that shouldn't affect the skill's
# damage, don't.
#
#==============================================================================
module XRXS38
#=========================================================================
# Establish Elements
#-------------------------------------------------------------------------
# Number of initial elements, eg. fire, ice, wind, water, etc. in the
# database. This counts from the first (usually fire) to the number
# entered below. In this case, only elements 1-16 are calculated.
#=========================================================================
ELEMENTS_NUMBER_LIMIT = 16
#=========================================================================
# Determine element correct method.
#-------------------------------------------------------------------------
# The Sahagin used in the example is weak against vsAquatic (200% dmg)
# and absorbs Fire (-100% dmg).
#-------------------------------------------------------------------------
# 0: ?STRONGEST (RGSS Default)
# Only the strongest element applies.
# EX: Fire/vsAquatic vs. Sahagin => 200% dmg
# 1: MULTIPLICATION
# All elements are included in the calculation.
# EX: Fire/vsAquatic vs. Sahagin => -200% dmg
# 2: AVERAGE
# Average power of elements are used in the calculation.
# EX: Fire/vsAquatic vs. Sahagin => 50% dmg
# 3: WEAKEST
# Only the weakest element applies.
# EX: Fire/vsAquatic vs. Sahagin => -100% dmg
#=========================================================================
ELEMENT_CORRECT_METHOD = 2
end
#==============================================================================
# ** Game_Battler
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Calculation + Element correction methods
#--------------------------------------------------------------------------
alias xrxs38_elements_correct elements_correct
def elements_correct(element_set)
# Initially duplicates
elements = element_set.dup
# Checks element restriction and if it exceeds the limit
for element_id in element_set
if element_id >XRXS38:: ELEMENTS_NUMBER_LIMIT
elements.delete(element_id)
end
end
# If it is not an element, return 100
return 100 if elements.size == 0
#
case XRXS38::ELEMENT_CORRECT_METHOD
when 0 # Strongest
return xrxs38_elements_correct(elements)
when 1 # Multiplication
result = 100.0
minus_enable = false
for i in elements
n = self.element_rate(i)
minus_enable |= (n < 0)
result *= n / 100.0
end
result = -1 * result.abs if minus_enable
return result.to_i
when 2 # Average
rates = []
result = 0
for i in elements
rates.push(self.element_rate(i))
end
for rate in rates
result += rate
end
return result / rates.size
when 3 # Weakest
for i in elements
n = self.element_rate(i)
result = n if result.nil? or result > n
end
return result
end
end
end