#===============================================================================
# Heal Harms Undead and Resurrect can cause Instant Death
# Target Anyone Scope Enhancement
#
# Author: Heretic
# Version: 1.0
#
# This script is most useful when combined with KK20's Target Anyone Script
# http://forum.chaos-project.com/index.php/topic,12640.0.html
#
#===============================================================================
#
# This script will cause Undead to have the opposite reaction to Healing and
# Resurrection Spells and Items. It is based on Elemental Resistance, so you
# can give Actors and Enemies Resistance to being healed. If you decide to
# have an Undead Actor, your Armor will use Elemental Defense and cut the
# effective rate by Half for each piece of Armor with Defense against your
# specified Elements. If you don't plan on having an Undead Actor, then
# you'll be better off by not putting on an Elemental Resistance to
# Healing as it just cuts its effectiveness.
#
# In plain English, Healing and Resurrection are now Elemental Effects and will
# work the same as Fire and what not. Healing will cause Damage. Resurrection
# has a chance to cause Instant Death. If you don't like the idea of Instant
# Death, dont use Resurrection as an Element and just replace it with Healing
# if you wish.
#
# To get this going takes some work.
#
# First, go to your Database -> System, Element Names and add Healing and / or
# Resurrection. Name them as you wish. Then you'll want to edit your Items
# Armor, Weapons, and Enemies and set them up as you wish. Check Resurrection
# (if you use it) for Items and Spells that Resurrect. Same goes for Healing.
# Give your Enemies (or Actors) Resistances to these Elements.
#
# A Rank of "A" will be the most effective. So if you use Healing on an Undead
# that has a Healing Rank of "A", it will do Maximum Damage. Ranks "B" to "D"
# will cause less and less damage.
#
# A Rank of "E" will do nothing. It results in 0 points of Damage. Nuff said.
#
# If the Rank is "F", it will cause the Opposite Effect. That is to say using
# a Rank of "F" on an Enemy for Healing will cause an Enemy to be Healed.
#
# --- CONFIGURATION ---
#
# Just in case you want to name your Healing and Resurrection Tags to something
# else, you can change the Tags below to whatever you want. I hope this will
# be helpful for Non English users of this little add on.
UNDEAD_ELEMENT_TAG = "vs Undead"
HEALING_ELEMENT_TAG = "Healing"
RESURRECTION_ELEMENT_TAG = "Resurrection"
#==============================================================================
# ** Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Get Element Effectiveness
#--------------------------------------------------------------------------
def element_ranks
return $data_classes[@class_id].element_ranks
end
end
#==============================================================================
# ** Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# * Get Element Effectiveness
#--------------------------------------------------------------------------
def element_ranks
return $data_enemies[@enemy_id].element_ranks
end
end
#-------------------------------------------------------------------------
# Class Game Battler
#-------------------------------------------------------------------------
class Game_Battler
#--------------------------------------------------------------------------
# * State Knockout - True if State has Knockout Properties
#--------------------------------------------------------------------------
def state_knockout?(state)
# If State Restriction Can't Move, Cant Get EXP and Regard as HP 0
if state.restriction == 4 and state.cant_get_exp and state.zero_hp
# True to State has Knockout Properties
return true
end
end
#--------------------------------------------------------------------------
# * Undead? - True if "vs Undead" is A or B (weak against)
#--------------------------------------------------------------------------
def undead?
# Get Element ID by Index of Element Tag
undead_index = $data_system.elements.index(UNDEAD_ELEMENT_TAG)
# If UNDEAD_ELEMENT_TAG doesn't exist in Database in System -> Element Names
return false if not undead_index
# Return True if "vs Undead" has a Element Rate of A or B (weak against)
return true if element_rate(undead_index) >= 150
end
#--------------------------------------------------------------------------
# * Healing? - True if Skill or Item has a Healing Element checked
#--------------------------------------------------------------------------
def healing?(element_cast)
# Get Element ID used for Element with Healing Tag
element_id = $data_system.elements.index(HEALING_ELEMENT_TAG)
# If Element does not exist in Database in System -> Element Names
return false if not element_id
# If Skill or Item has a Element ID of Healing
return true if element_cast.element_set.include?(element_id)
# Return that Element does not have Healing
return false
end
#--------------------------------------------------------------------------
# * Healing Rank Resistance by Undead
#--------------------------------------------------------------------------
def healing_rank
# Get Element ID used for Element with Healing Tag
element_id = $data_system.elements.index(HEALING_ELEMENT_TAG)
# Chance to resist Healing based on Element Efficiency
rank = [0,200,80,60,40,20,-100][self.element_ranks[element_id]]
# Undead / Unholy States make Actor Resistant to Healing
for i in @states
# If protected by state, this element is reduced by half
if $data_states[i].guard_element_set.include?(element_id)
rank /= 2
end
end
# If Actor is Undead, Defense Against Healing
if self.is_a?(Game_Actor) and self.undead?
for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
armor = $data_armors[i]
# If this element is protected by armor, then it's reduced by half
if armor != nil and armor.guard_element_set.include?(element_id)
rank /= 2
end
end
end
# Return modified Value
return rank
end
#--------------------------------------------------------------------------
# * Resurrection? - True if Skill or Item removes Knockout
#--------------------------------------------------------------------------
def resurrection?(minus_state_set)
# If Ressurect Element doesn't exist in Database in System -> Element Names
return false if not $data_system.elements.index(RESURRECTION_ELEMENT_TAG)
# For each of the States to be Removed
for state_id in minus_state_set
# If this State has Knockout Properties
return state_id if state_knockout?($data_states[state_id])
end
# Return that Knockout States not removed, Non Resurrection
return false
end
#--------------------------------------------------------------------------
# * Resurrection Rank Resistance for Undead
#--------------------------------------------------------------------------
def resurrection_rank
# Get Element ID used for Element with Resurrection Tag
element_id = $data_system.elements.index(RESURRECTION_ELEMENT_TAG)
# Chance to resist Resurrection based on Element Efficiency
rank = [0,200,80,60,40,20,-100][self.element_ranks[element_id]]
# Chance to resist Resurrection Death based on Element Efficiency
for i in @states
# If protected by state, this element is reduced by half
if $data_states[i].guard_element_set.include?(element_id)
rank /= 2
end
end
# Armor not calculated due to only Actors wear Armor
# and Resurrection not effective on the Living
# Return modified Value
return rank
end
#--------------------------------------------------------------------------
# * Undead Knockout - Add Knockout State to Undead, Opposite Effect
#--------------------------------------------------------------------------
def undead_knockout(element_cast)
# If States Removes Knockout
if self.undead? and resurrection?(element_cast.minus_state_set)
# If not Immortal
unless self.immortal
# Last Chance to Resist - Get Resurrection Resistance Rank
rank = resurrection_rank
# Add Knockout State if Effective
if (self.damage >= self.hp or rand(100) < rank) and rank > 0
# Set state change flag
@state_changed = true
# Add States that Resurrection will Remove
for i in element_cast.minus_state_set
# Force Add a State of Knockout
add_state(i, true)
end
# Return that Effect is True
return true
end
end
end
end
#--------------------------------------------------------------------------
# * Apply Skill Effects
# user : the one using skills (battler)
# skill : skill
#--------------------------------------------------------------------------
def skill_effect(user, skill)
# Clear critical flag
self.critical = false
# If skill scope is for ally with 1 or more HP, and your own HP = 0,
# or skill scope is for ally with 0, and your own HP = 1 or more or more
# and skill used on a Game Actor
if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
((skill.scope == 5 or skill.scope == 6) and self.hp >= 1 and
self.is_a?(Game_Actor) )
# End Method
return false
end
# Clear effective flag
effective = false
# Set effective flag if common ID is effective
effective |= skill.common_event_id > 0
# If Target is Undead
if self.undead?
# If Skill removes Knockout (found by State Changes) and is an Enemy
if resurrection?(skill.minus_state_set) and self.is_a?(Game_Enemy)
# Determine chance to hit for Resurrecting Undead
hit_result = rand(100) < resurrection_rank
# Skill Healing on Undead causes Damage (Rank F causes Heal, not Injury)
if resurrection_rank < 0
# Thanks for the Heal! I'm not even going to try to Dodge!
effective = true
end
# Invert Recovery to Damage
recover_inversion = true
# is a Healing Item - Heal will harm Undead Actors
elsif healing?(skill)
# Determine chance to hit for Healing Undead
hit_result = rand(100) < healing_rank
# Skill Healing on Undead causes Damage (Rank F causes Heal, not Injury)
if healing_rank < 0
# Thanks for the Heal! I'm not even going to try to Dodge!
effective = true
end
# Invert Recovery to Damage
recover_inversion = true
end
# Skill is Effective with a Hit Result
effective |= hit_result
end
# First hit detection
hit = skill.hit
if skill.atk_f > 0
hit *= user.hit / 100
end
hit_result = (rand(100) < hit)
# Set effective flag if skill is uncertain
effective |= hit < 100
# If hit occurs
if hit_result == true
# Calculate power
power = skill.power + user.atk * skill.atk_f / 100
if power > 0
power -= self.pdef * skill.pdef_f / 200
power -= self.mdef * skill.mdef_f / 200
power = [power, 0].max
end
# Calculate rate
rate = 20
rate += (user.str * skill.str_f / 100)
rate += (user.dex * skill.dex_f / 100)
rate += (user.agi * skill.agi_f / 100)
rate += (user.int * skill.int_f / 100)
# If Recovery Inversion - Convert Recovery to Damage
if recover_inversion
# Invert Damage to Recovery
rate *= -1
end
# Calculate basic damage
self.damage = power * rate / 20
# Element correction
self.damage *= elements_correct(skill.element_set)
self.damage /= 100
# If damage value is strictly positive
if self.damage > 0
# Guard correction
if self.guarding?
self.damage /= 2
end
end
# Dispersion
if skill.variance > 0 and self.damage.abs > 0
amp = [self.damage.abs * skill.variance / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
# Second hit detection
eva = 8 * self.agi / user.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
# Set effective flag if skill is uncertain
effective |= hit < 100
end
# If hit occurs
if hit_result == true
# If physical attack has power other than 0
if skill.power != 0 and skill.atk_f > 0
# State Removed by Shock
remove_states_shock
# Set to effective flag
effective = true
end
# Substract damage from HP
last_hp = self.hp
self.hp -= self.damage
effective |= self.hp != last_hp
# State change
@state_changed = false
# Determine if Skill is Instant Death for Undead
effective |= undead_knockout(skill)
# Determine Normal Effectiveness if it is not already Effective
effective |= states_plus(skill.plus_state_set)
effective |= states_minus(skill.minus_state_set)
# If power is 0
if skill.power == 0
# Set damage to an empty string
self.damage = ""
# If state is unchanged
unless @state_changed
# Set damage to "Miss"
self.damage = "Miss"
end
end
# If miss occurs
else
# Set damage to "Miss"
self.damage = "Miss"
end
# If not in battle
unless $game_temp.in_battle
# Set damage to nil
self.damage = nil
end
# End Method
return effective
end
#--------------------------------------------------------------------------
# * Application of Item Effects
# item : item
#--------------------------------------------------------------------------
def item_effect(item)
# Clear critical flag
self.critical = false
# Ineffective if one of the following:
# If item scope is for ally with 1 or more HP, and your own HP = 0,
# or item scope is for ally with 0 HP, and your own HP = 1 or more
# and item used on a Game Actor
if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
((item.scope == 5 or item.scope == 6) and self.hp >= 1 and
self.is_a?(Game_Actor) )
# End Method
return false
end
# Clear effective flag
effective = false
# Set effective flag if common ID is effective
effective |= item.common_event_id > 0
# If Target is Undead
if self.undead?
# If item removes Knockout (found by State Changes) and is an Enemy
if resurrection?(item.minus_state_set) and self.is_a?(Game_Enemy)
# Determine chance to hit for Resurrecting Undead
hit_result = rand(100) < resurrection_rank
# Item Healing on Undead causes Damage (Rank F causes Heal, not Injury)
if resurrection_rank < 0
# Thanks for the Heal! I'm not even going to try to Dodge!
effective = true
end
# Invert Recovery to Damage
recover_inversion = true
# is a Healing Item - Heal will harm Undead Actors
elsif healing?(item)
# Determine chance to hit for Healing Undead
hit_result = rand(100) < healing_rank
# Item Healing on Undead causes Damage (Rank F causes Heal, not Injury)
if healing_rank < 0
# Thanks for the Heal! I'm not even going to try to Dodge!
effective = true
end
# Invert Recovery to Damage
recover_inversion = true
end
# Item is Effective with a Hit Result
effective |= hit_result
end
# Determine hit for Item
hit_result = (rand(100) < item.hit)
# Set effective flag is skill is uncertain and Effective not already true
effective |= item.hit < 100
# If hit occurs
if hit_result == true
# Calculate amount of recovery
recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
# If Recovery Inversion - Convert Recovery to Damage
if recover_inversion
# Invert Damage to Recovery
recover_hp = recover_hp * -1
recover_sp = recover_sp * -1
end
# If Recovering HP
if recover_hp < 0
recover_hp += self.pdef * item.pdef_f / 20
recover_hp += self.mdef * item.mdef_f / 20
recover_hp = [recover_hp, 0].min
end
# Element correction
recover_hp *= elements_correct(item.element_set)
recover_hp /= 100
recover_sp *= elements_correct(item.element_set)
recover_sp /= 100
# Dispersion
if item.variance > 0 and recover_hp.abs > 0
amp = [recover_hp.abs * item.variance / 100, 1].max
recover_hp += rand(amp+1) + rand(amp+1) - amp
end
if item.variance > 0 and recover_sp.abs > 0
amp = [recover_sp.abs * item.variance / 100, 1].max
recover_sp += rand(amp+1) + rand(amp+1) - amp
end
# If recovery code is negative
if recover_hp < 0
# Guard correction
if self.guarding?
recover_hp /= 2
end
end
# Set damage value and reverse HP recovery amount
self.damage = -recover_hp
# HP and SP recovery
last_hp = self.hp
last_sp = self.sp
self.hp += recover_hp
self.sp += recover_sp
effective |= self.hp != last_hp
effective |= self.sp != last_sp
# State change
@state_changed = false
# Determine if Item is Instant Death for Undead
effective |= undead_knockout(item)
# Determine Normal Effectiveness if it is not already Effective
effective |= states_plus(item.plus_state_set)
effective |= states_minus(item.minus_state_set)
# If parameter value increase is effective
if item.parameter_type > 0 and item.parameter_points != 0
# Branch by parameter
case item.parameter_type
when 1 # Max HP
@maxhp_plus += item.parameter_points
when 2 # Max SP
@maxsp_plus += item.parameter_points
when 3 # Strength
@str_plus += item.parameter_points
when 4 # Dexterity
@dex_plus += item.parameter_points
when 5 # Agility
@agi_plus += item.parameter_points
when 6 # Intelligence
@int_plus += item.parameter_points
end
# Set to effective flag
effective = true
end
# If HP recovery rate and recovery amount are 0
if item.recover_hp_rate == 0 and item.recover_hp == 0
# Set damage to empty string
self.damage = ""
# If SP recovery rate / recovery amount are 0, and parameter increase
# value is ineffective.
if item.recover_sp_rate == 0 and item.recover_sp == 0 and
(item.parameter_type == 0 or item.parameter_points == 0)
# If state is unchanged
unless @state_changed
# Set damage to "Miss"
self.damage = "Miss"
end
end
end
# If miss occurs
else
# Set damage to "Miss"
self.damage = "Miss"
end
# If not in battle
unless $game_temp.in_battle
# Set damage to nil
self.damage = nil
end
# End Method
return effective
end
end