Try this instead it's an older version of the script you tried. For help with it
http://www.rpgrevolution.com/forums/lofiversion/index.php/t44139.html#===============================================================================
#
# Yanfly Engine RD - Custom Element Affinity
# Last Date Updated: 2009.06.26
# Level: Normal, Hard, Lunatic
#
# Element rates were used universally for nearly everything. This goes for
# items, weapons, armours, and skills. However, the lack of control we have
# over them as far as RPG Maker VX is concerned leaves me rather disappointed.
# Keep in mind that this script is heavily geared towards element control and
# has tags split around for weapons, armours, states, and enemies.
#
#===============================================================================
# Updates:
# ----------------------------------------------------------------------------
# o 2009.04.27 - Bugfix for melee actors.
# o 2009.04.23 - Compatibility Update and bugfix.
# o 2009.04.19 - Started script and publicized.
#===============================================================================
# How to Use: Normal Mode
#===============================================================================
#
# Element control is split between multiple instances. First, we'll handle any
# elemental rank changes. These affect the battlers on the receiving end of
# an elemental attack, skill, or item.
#
# <element rank add x:y>, <element rank sub x:y>
# x is the ID of the element you wish to affect. y is the rank change.
# Insert these into weapons, equips, or states to increase or decrease an
# element rate. Note that adding an element rank means they become more
# resistant while lowering an element rate means they become weaker. Element
# rates will fluctuate amongst [Z,A,B,C,D,E,F] ranks.
#
# <element rank set x:y>
# x is the ID of the element you wish to affect. y is either [Z,A,B,C,D,E,F].
# This will set the element of battler to exactly that. There is a rule set of
# priorities. They'll be determined by the highest rank state, then weapons, and
# finally armours from top to bottom. With that said, you can place these into
# weapons, equips, and states.
#
# Elemental control for normal attacks can be applied via states, weapons, and
# equips for actors and states and enemy data for enemies.
#
# <element attack add x>
# x is the ID of the element you wish to infuse normal attacks with. If it's
# placed in a state, weapon, or equip, that battler's normal attacks will have
# that elemental attribute. If it's in an enemy notebox, that enemy will have
# normal attacks with that elemental attribute. This allows for enemies like
# elemental djinns to innately have an elemental attack or swordsmen to have a
# slashing element.
#
# <element attack sub x>
# x is the ID of the element you wish to prevent the battler from using in a
# normal attack. The removal tag will nullify any bonuses that would otherwise
# give an elemental trait to a normal attack. This can be placed inside a state,
# weapon, or equip. If placed in an enemy box, that enemy will never have such
# an elemental trait to its normal attack no matter what kind of status effect
# would provide for it. This is to prevent something like a fire slime suddenly
# using ice attacks.
#
#===============================================================================
# How to Use: Hard Mode
#===============================================================================
#
# Elemental control for skills can be adjusted with the following tags. Note
# that if you wish to use elemental control for skills, you REQUIRE Yanfly's
# Custom Damage Formula script.
#
# <element skill add x>
# x is the ID of the element you wish to infuse skills with. If it's placed in
# a state, weapon, or equip, the battler's skills will possess an additional
# element with them.
#
# <element skill sub x>
# x is the ID of the element you wish to prevent the battler from using in a
# skill. The removal tag will completely nullify any elemental traits that the
# skill would otherwise have. This can be placed inside a state, weapon, or
# equip to take effect.
#
# <element lock>
# Placing this inside of a skill's notebox to prevent that skill from having
# its elements alter through means of the two previously mentioned tags.
#
#===============================================================================
#
# Compatibility
# - Requires: Yanfly Engine, Custom Damage Formula
# - Overwrites: Game_Battler, element_rate, elements_max_rate
# - Overwrites: Game_Actor, element_rate, element_set
# - Overwrites: Game_Enemy, element_rate
#
#===============================================================================
$imported = {} if $imported == nil
$imported["CustomElementAffinity"] = true
module YE
module BATTLE
module ELEMENT
# This is what element an actor's unarmed attack is considered.
# Set to nil if you would like unarmed attacks to have no element.
UNARMED = 7
# This is the modifier for reduction rate if any states or armour possess
# protection against that element. By default, rates are 50%.
REDUCTION = 50
# This sets the default rates for your elements. These rates affect
# how damage inflates or deflates corresponding to a battler's elemental
# affinity. Negative values indicate damage converting to healing.
RATE_Z = 300
RATE_A = 200
RATE_B = 150
RATE_C = 100
RATE_D = 50
RATE_E = 0
RATE_F = -100
# This allows you to set custom elemental rates. This is mostly to prevent
# odd instances like enemies absorbing blunt attacks and whatnot. Any
# element ID that's not listed in here will use the default rates.
CUSTOM_RATES = {
# ID => [ Z, A, B, C, D, E, F]
1 => [300, 200, 150, 100, 50, 25, 0],
2 => [300, 200, 150, 100, 50, 25, 0],
3 => [300, 200, 150, 100, 50, 25, 0],
4 => [300, 200, 150, 100, 50, 25, 0],
5 => [300, 200, 150, 100, 50, 25, 0],
6 => [300, 200, 150, 100, 50, 25, 0],
} # Do not remove this.
end # ELEMENT
end # BATTLE
module HASH
ELEMENT_TYPE = { # Input the elements into any category you want here.
"Elements" => [ 1, 2, 3, 4, 5, 6, 7 ],
"Magical" => [],
}
end # HASH
end # YE
#===============================================================================
# How to Use: Lunatic Mode
#===============================================================================
#
# <custom element x>
# If placed in a skill, this calls on case ID x. The returned element_set array
# will reveal to the damage multiplier what kind of elements you're applying to
# the skill or skills. Similar to the other Lunatic portions of other Yanfly
# Engine ReDux scripts, there is a "common_element" definition which will run
# for every skill regardless of a custom element tag or not.
#
#===============================================================================
class Game_Battler
def run_custom_element(case_id, element_set, user, target)
case case_id
#---------------------------------------------------------------------------
# //////////////////////////////////////////////////////////////////////////
# This is where you begin adding in your own custom elements
#---------------------------------------------------------------------------
when 1
if target.hp > user.hp
element_set = [10]
else
element_set = [9]
end
when 2
#---------------------------------------------------------------------------
# This is the part you guys shouldn't touch afterwards.
# //////////////////////////////////////////////////////////////////////////
#---------------------------------------------------------------------------
end
return element_set
end
#-----------------------------------------------------------------------------
#-----This is the common element adjustment. Make any element changes here.
def common_element(element_set, user, target)
if user != nil
# This means there is someone performing the elemental adjustments.
end
return element_set
end
#-----------------------------------------------------------------------------
end # Game_Battler
#===============================================================================
# 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 YE
module REGEXP
module ELEMENT
# these adjust rank modification
RANK_ADD = /<(?:ELEMENT_RANK_ADD|element rank add)[ ]*(\d+)sad.gif\d+)>/i
RANK_SUB = /<(?:ELEMENT_RANK_SUB|element rank sub)[ ]*(\d+)sad.gif\d+)>/i
RANK_SET = /<(?:ELEMENT_RANK_SET|element rank set)[ ]*(\d+):\s*([ZABCDEF])?>/i
# these adjust normal attack elements
ATTACK = /<(?:ELEMENT_ATTACK_ADD|element attack add)[ ]*(\d+)>/i
UNATTACK = /<(?:ELEMENT_ATTACK_SUB|element attack sub)[ ]*(\d+)>/i
# these adjust skill elements
SKILL = /<(?:ELEMENT_SKILL|element skill add)[ ]*(\d+)>/i
UNSKILL = /<(?:ELEMENT_SKILL|element skill sub)[ ]*(\d+)>/i
ELE_LOCK = /<(?:ELEMENT_LOCK|element lock)>/i
CUSTOM_E = /<(?:CUSTOM_ELEMENT|custom element)[ ]*(\d+)>/i
end # ELEMENT
end # REGEXP
end # YE
#===============================================================================
# RPG::BaseItem
#===============================================================================
class RPG::BaseItem
#--------------------------------------------------------------------------
# Yanfly Cache Skill CEA
#--------------------------------------------------------------------------
def yanfly_cache_skill_cea
@element_lock = false
@custom_element = 0
self.note.split(/[\r\n]+/).each { |line|
case line
when YE::REGEXP::ELEMENT::ELE_LOCK
@element_lock = true
when YE::REGEXP::ELEMENT::CUSTOM_E
@custom_element = $1.to_i
end
}
end
#--------------------------------------------------------------------------
# element lock
#--------------------------------------------------------------------------
def element_lock
yanfly_cache_skill_cea if @element_lock == nil
return @element_lock
end
#--------------------------------------------------------------------------
# custom element
#--------------------------------------------------------------------------
def custom_element
yanfly_cache_skill_cea if @custom_element == nil
return @custom_element
end
end # end RPG::BaseItem
#===============================================================================
# RPG::Enemy
#===============================================================================
class RPG::Enemy
#--------------------------------------------------------------------------
# Yanfly Cache Enemy CEA
#--------------------------------------------------------------------------
def yanfly_cache_enemy_cea
@element_attack = []; @element_unattack = []
@element_skill = []; @element_unskill = []
self.note.split(/[\r\n]+/).each { |line|
case line
when YE::REGEXP::ELEMENT::ATTACK
@element_attack.push($1.to_i)
when YE::REGEXP::ELEMENT::UNATTACK
@element_unattack.push($1.to_i)
when YE::REGEXP::ELEMENT::SKILL
@element_skill.push($1.to_i)
when YE::REGEXP::ELEMENT::UNSKILL
@element_unskill.push($1.to_i)
end
}
end
#--------------------------------------------------------------------------
# Element Attack/Unattack
#--------------------------------------------------------------------------
def element_attack
yanfly_cache_enemy_cea if @element_attack == nil
return @element_attack
end
def element_unattack
yanfly_cache_enemy_cea if @element_unattack == nil
return @element_unattack
end
#--------------------------------------------------------------------------
# Element Skill/Unskill
#--------------------------------------------------------------------------
def element_skill
yanfly_cache_enemy_cea if @element_skill == nil
return @element_skill
end
def element_unskill
yanfly_cache_enemy_cea if @element_unskill == nil
return @element_unskill
end
end
#===============================================================================
# RPG::State
#===============================================================================
class RPG::State
#--------------------------------------------------------------------------
# Yanfly Cache State CEA
#--------------------------------------------------------------------------
def yanfly_cache_state_cea
@element_rank_mod = 0; @element_rank_mid = 0
@element_rank_set = 7; @element_rank_sid = 0
@element_attack = []; @element_unattack = []
@element_skill = []; @element_unskill = []
self.note.split(/[\r\n]+/).each { |line|
case line
when YE::REGEXP::ELEMENT::RANK_ADD
@element_rank_mid = $1.to_i
@element_rank_mod = $2.to_i
when YE::REGEXP::ELEMENT::RANK_SUB
@element_rank_mid = $1.to_i
@element_rank_mod = $2.to_i * -1
when YE::REGEXP::ELEMENT::ATTACK
element = $1.to_i
@element_attack.push(element)
when YE::REGEXP::ELEMENT::UNATTACK
element = $1.to_i
@element_unattack.push(element)
when YE::REGEXP::ELEMENT::RANK_SET
@element_rank_sid = $1.to_i
case $2.upcase
when "F"
@element_rank_set = 6
when "E"
@element_rank_set = 5
when "D"
@element_rank_set = 4
when "C"
@element_rank_set = 3
when "B"
@element_rank_set = 2
when "A"
@element_rank_set = 1
when "Z"
@element_rank_set = 0
end
when YE::REGEXP::ELEMENT::SKILL
@element_skill.push($1.to_i)
when YE::REGEXP::ELEMENT::UNSKILL
@element_unskill.push($1.to_i)
end
}
end
#--------------------------------------------------------------------------
# Element Rank Mod
#--------------------------------------------------------------------------
def element_rank_mod
yanfly_cache_state_cea if @element_rank_mod == nil
return @element_rank_mod
end
def element_rank_mid
yanfly_cache_state_cea if @element_rank_mid == nil
return @element_rank_mid
end
#--------------------------------------------------------------------------
# Element Rank set
#--------------------------------------------------------------------------
def element_rank_set
yanfly_cache_state_cea if @element_rank_set == nil
return @element_rank_set
end
def element_rank_sid
yanfly_cache_state_cea if @element_rank_sid == nil
return @element_rank_sid
end
#--------------------------------------------------------------------------
# Element Attack/Unattack
#--------------------------------------------------------------------------
def element_attack
yanfly_cache_state_cea if @element_attack == nil
return @element_attack
end
def element_unattack
yanfly_cache_state_cea if @element_unattack == nil
return @element_unattack
end
#--------------------------------------------------------------------------
# Element Skill/Unskill
#--------------------------------------------------------------------------
def element_skill
yanfly_cache_state_cea if @element_skill == nil
return @element_skill
end
def element_unskill
yanfly_cache_state_cea if @element_unskill == nil
return @element_unskill
end
end # RPG::State
#==============================================================================
# RPG::Weapon
#==============================================================================
class RPG::Weapon < RPG::BaseItem
#--------------------------------------------------------------------------
# Yanfly Cache Weapon CEA
#--------------------------------------------------------------------------
def yanfly_cache_wpn_cea
@element_rank_mod = 0; @element_rank_mid = 0
@element_rank_set = 7; @element_rank_sid = 0
@element_attack = []; @element_unattack = []
@element_skill = []; @element_unskill = []
self.note.split(/[\r\n]+/).each { |line|
case line
when YE::REGEXP::ELEMENT::RANK_ADD
@element_rank_mid = $1.to_i
@element_rank_mod = $2.to_i
when YE::REGEXP::ELEMENT::RANK_SUB
@element_rank_mid = $1.to_i
@element_rank_mod = $2.to_i * -1
when YE::REGEXP::ELEMENT::ATTACK
element = $1.to_i
@element_attack.push(element)
when YE::REGEXP::ELEMENT::UNATTACK
element = $1.to_i
@element_unattack.push(element)
when YE::REGEXP::ELEMENT::RANK_SET
@element_rank_sid = $1.to_i
case $2.upcase
when "F"
@element_rank_set = 6
when "E"
@element_rank_set = 5
when "D"
@element_rank_set = 4
when "C"
@element_rank_set = 3
when "B"
@element_rank_set = 2
when "A"
@element_rank_set = 1
when "Z"
@element_rank_set = 0
end
when YE::REGEXP::ELEMENT::SKILL
@element_skill.push($1.to_i)
when YE::REGEXP::ELEMENT::UNSKILL
@element_unskill.push($1.to_i)
end
}
end
#--------------------------------------------------------------------------
# Element Rank Mod
#--------------------------------------------------------------------------
def element_rank_mod
yanfly_cache_wpn_cea if @element_rank_mod == nil
return @element_rank_mod
end
def element_rank_mid
yanfly_cache_wpn_cea if @element_rank_mid == nil
return @element_rank_mid
end
#--------------------------------------------------------------------------
# Element Rank set
#--------------------------------------------------------------------------
def element_rank_set
yanfly_cache_wpn_cea if @element_rank_set == nil
return @element_rank_set
end
def element_rank_sid
yanfly_cache_wpn_cea if @element_rank_sid == nil
return @element_rank_sid
end
#--------------------------------------------------------------------------
# Element Bestow/Unattack/Resist/Unresist
#--------------------------------------------------------------------------
def element_attack
yanfly_cache_wpn_cea if @element_attack == nil
return @element_attack
end
def element_unattack
yanfly_cache_wpn_cea if @element_unattack == nil
return @element_unattack
end
#--------------------------------------------------------------------------
# Element Skill/Unskill
#--------------------------------------------------------------------------
def element_skill
yanfly_cache_wpn_cea if @element_skill == nil
return @element_skill
end
def element_unskill
yanfly_cache_wpn_cea if @element_unskill == nil
return @element_unskill
end
end # RPG::Weapon
#==============================================================================
# RPG::Armor
#==============================================================================
class RPG::Armor < RPG::BaseItem
#--------------------------------------------------------------------------
# Yanfly Cache Armour CEA
#--------------------------------------------------------------------------
def yanfly_cache_arm_cea
@element_rank_mod = 0; @element_rank_mid = 0
@element_rank_set = 7; @element_rank_sid = 0
@element_attack = []; @element_unattack = []
@element_skill = []; @element_unskill = []
self.note.split(/[\r\n]+/).each { |line|
case line
when YE::REGEXP::ELEMENT::RANK_ADD
@element_rank_mid = $1.to_i
@element_rank_mod = $2.to_i
when YE::REGEXP::ELEMENT::RANK_SUB
@element_rank_mid = $1.to_i
@element_rank_mod = $2.to_i * -1
when YE::REGEXP::ELEMENT::ATTACK
element = $1.to_i
@element_attack.push(element)
when YE::REGEXP::ELEMENT::UNATTACK
element = $1.to_i
@element_unattack.push(element)
when YE::REGEXP::ELEMENT::RANK_SET
@element_rank_sid = $1.to_i
case $2.upcase
when "F"
@element_rank_set = 6
when "E"
@element_rank_set = 5
when "D"
@element_rank_set = 4
when "C"
@element_rank_set = 3
when "B"
@element_rank_set = 2
when "A"
@element_rank_set = 1
when "Z"
@element_rank_set = 0
end
when YE::REGEXP::ELEMENT::SKILL
@element_skill.push($1.to_i)
when YE::REGEXP::ELEMENT::UNSKILL
@element_unskill.push($1.to_i)
end
}
end
#--------------------------------------------------------------------------
# Element Rank Mod
#--------------------------------------------------------------------------
def element_rank_mod
yanfly_cache_arm_cea if @element_rank_mod == nil
return @element_rank_mod
end
def element_rank_mid
yanfly_cache_arm_cea if @element_rank_mid == nil
return @element_rank_mid
end
#--------------------------------------------------------------------------
# Element Rank set
#--------------------------------------------------------------------------
def element_rank_set
yanfly_cache_arm_cea if @element_rank_set == nil
return @element_rank_set
end
def element_rank_sid
yanfly_cache_arm_cea if @element_rank_sid == nil
return @element_rank_sid
end
#--------------------------------------------------------------------------
# Element Bestow/Unattack/Resist/Unresist
#--------------------------------------------------------------------------
def element_attack
yanfly_cache_arm_cea if @element_attack == nil
return @element_attack
end
def element_unattack
yanfly_cache_arm_cea if @element_unattack == nil
return @element_unattack
end
#--------------------------------------------------------------------------
# Element Skill/Unskill
#--------------------------------------------------------------------------
def element_skill
yanfly_cache_arm_cea if @element_skill == nil
return @element_skill
end
def element_unskill
yanfly_cache_arm_cea if @element_unskill == nil
return @element_unskill
end
end # RPG::Armor
#==============================================================================
# Game_Battler
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# Element Rank Mod
#--------------------------------------------------------------------------
def element_rank_mod(rank, element_id)
#---------------------------
for state in states
if state.element_rank_sid == element_id
return state.element_rank_set unless state.element_rank_set > 6
end
end
#---------------------------
if self.actor?
for weapon in weapons.compact
next if weapon == nil
if weapon.element_rank_mid == element_id
return weapon.element_rank_set unless weapon.element_rank_set > 6
end
end
for armor in armors.compact
next if armor == nil
if armor.element_rank_mid == element_id
return armor.element_rank_set unless armor.element_rank_set > 6
end
end
#---------------------------
for weapon in weapons.compact
next if weapon == nil
if weapon.element_rank_mid == element_id
rank += weapon.element_rank_mod
end
end
for armor in armors.compact
next if armor == nil
if armor.element_rank_mid == element_id
rank += armor.element_rank_mod
end
end
end
#---------------------------
for state in states
if state.element_rank_mid == element_id
rank += state.element_rank_mod
end
end
#---------------------------
rank = [[rank, 0].max, 6].min
return rank
end
#--------------------------------------------------------------------------
# Set Element Rates
#--------------------------------------------------------------------------
def set_element_rate(element_id)
if YE::BATTLE::ELEMENT::CUSTOM_RATES.include?(element_id)
ray = YE::BATTLE::ELEMENT::CUSTOM_RATES[element_id]
rz = ray[0]
ra = ray[1]
rb = ray[2]
rc = ray[3]
rd = ray[4]
re = ray[5]
rf = ray[6]
else
rz = YE::BATTLE::ELEMENT::RATE_Z
ra = YE::BATTLE::ELEMENT::RATE_A
rb = YE::BATTLE::ELEMENT::RATE_B
rc = YE::BATTLE::ELEMENT::RATE_C
rd = YE::BATTLE::ELEMENT::RATE_D
re = YE::BATTLE::ELEMENT::RATE_E
rf = YE::BATTLE::ELEMENT::RATE_F
end
rate_hash = [rz,ra,rb,rc,rd,re,rf]
return rate_hash
end
#--------------------------------------------------------------------------
# Element Reduction
#--------------------------------------------------------------------------
def element_reduction(result)
result *= YE::BATTLE::ELEMENT::REDUCTION
result /= 100
return result
end
#--------------------------------------------------------------------------
# Overwrite Element_Set (for enemies)
#--------------------------------------------------------------------------
def element_set
result = []
for state in states
result = state.element_attack
end
result += enemy.element_attack
result -= enemy.element_unattack
result.uniq
return result
end
#--------------------------------------------------------------------------
# Overwrite Elements Max Rate
#--------------------------------------------------------------------------
def elements_max_rate(element_set, attacker = nil)
#--------------------------------------
if attacker != nil and attacker.action.skill?
obj = attacker.action.skill
if obj.custom_element > 0
rce_id = obj.custom_element
element_set = run_custom_element(rce_id, element_set, attacker, self)
end
unless obj.element_lock
if attacker.actor?
for weapon in attacker.weapons.compact
next if weapon == nil
element_set += weapon.element_skill
end
for armor in attacker.armors.compact
next if armor == nil
element_set += armor.element_skill
end
end
#--------------------------------------
for state in attacker.states do
element_set += state.element_skill
end
for state in attacker.states do
element_set -= state.element_unskill
end
#--------------------------------------
if attacker.actor?
for weapon in attacker.weapons.compact
next if weapon == nil
element_set -= weapon.element_unskill
end
for armor in attacker.armors.compact
next if armor == nil
element_set -= armor.element_unskill
end
end
end
end
#----------------------------------------------------
element_set = common_element(element_set, attacker, self)
return 100 if element_set.empty?
rate_list = []
for i in element_set
rate_list.push(element_rate(i))
end
return rate_list.max
end
end # end Game_Battler
#==============================================================================
# Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# Overwrite Element_Rate
#--------------------------------------------------------------------------
def element_rate(element_id)
rank = element_rank_mod(self.class.element_ranks[element_id], element_id)
rate_hash = self.set_element_rate(element_id)
result = rate_hash[rank]
for armor in armors.compact
if armor.element_set.include?(element_id)
result = self.element_reduction(result)
end
end
for state in states
if state.element_set.include?(element_id)
result = self.element_reduction(result)
end
end
return result
end
#--------------------------------------------------------------------------
# Overwrite Element_Set
#--------------------------------------------------------------------------
def element_set
result = []
if weapons.compact == []
# Unarmed: melee attribute
unele = YE::BATTLE::ELEMENT::UNARMED
result.push(unele) unless unele == nil
return result
end
for weapon in weapons.compact
next if weapon == nil
result |= weapon == nil ? [] : weapon.element_set
end
for state in states
result += state.element_attack
end
for weapon in weapons.compact
next if weapon == nil
result += weapon.element_attack
end
for armor in armors.compact
next if armor == nil
result += armor.element_attack
end
result.uniq
for state in states
result -= state.element_unattack
end
for weapon in weapons.compact
next if weapon == nil
result -= weapon.element_unattack
end
for armor in armors.compact
next if armor == nil
result -= armor.element_unattack
end
result.uniq
return result
end
end #end Game_Actor
#==============================================================================
# Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# Overwrite Element_Rate
#--------------------------------------------------------------------------
def element_rate(element_id)
rank = element_rank_mod(enemy.element_ranks[element_id], element_id)
rate_hash = self.set_element_rate(element_id)
result = rate_hash[rank]
for state in states
if state.element_set.include?(element_id)
result = self.element_reduction(result)
end
end
return result
end
end # end Game_Enemy
#===============================================================================
#
# END OF FILE
#
#===============================================================================