=begin
Side-Note: For any element-resist state configured below, it will ignore the
default RMXP system of handling element rates. This means that if the actor has
a state that makes him immune to fire damage, but has a shield that is set to
absorb fire damage, the state will trump the shield, meaning he will not absorb.
As for state success rates, armors that guard against a state will remain
fully resistant to that state regardless if the actor is applied with a state
that makes them more susceptible to gaining the state. For example, if the actor
has a Poison Pin that resists Poison and is affected with a state that increases
the rate of Poison being applied, the Poison Pin will still protect him from
ever being Poisoned.
Also, any state that is set to "Nonresistance" will always work 100% of the
time, regardless of any configuration you do below.
=end
module State_Element
#:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.
# B E G I N C O N F I G U R A T I O N
#:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.
def self.element_resist(state_id)
return case state_id
#---------------------------------------------------------------------------
# Defines element resistance rates when applied with a certain state. This
# number will overrule the default system. If multiple states change the
# rate, only the lowest will be applied. Do not use decimal numbers.
# Format:
# when STATE_ID then {ELEMENT_ID => RATE, ELEMENT_ID => RATE, ...}
#---------------------------------------------------------------------------
when 1 then {1 => 150} # When applied with state 1, element 1 will do 1.5x more damage
when 2 then {2 => -100, 3 => 50} # When applied with state 2, element 2 will heal, element 3 will do half damage
#---------------------------------------------------------------------------
else
{}
end
end
def self.state_resist(state_id)
return case state_id
#---------------------------------------------------------------------------
# Defines state resistance rates when applied with a certain state. This
# number will overrule the default system. A state applied with the
# 'Nonresistance' attribute will still have a 100% success rate. If multiple
# states change the rate, only the lowest will be applied. Do not use
# decimal numbers.
# Format:
# when STATE_ID then {STATE_ID => RATE, STATE_ID => RATE, ...}
#---------------------------------------------------------------------------
when 1 then {3 => 100} # When applied with state 1, state 3 will be applied all the time
when 2 then {4 => 0, 5 => 50} # When applied with state 2, immune to state 4, state 5 applied half the time
#---------------------------------------------------------------------------
else
{}
end
end
#:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.
# E N D C O N F I G U R A T I O N
#:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.
end
#==============================================================================
# ** Game_Battler
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * State Change (+) Application
# plus_state_set : State Change (+)
#--------------------------------------------------------------------------
alias check_for_state_resist_statesplus states_plus
def states_plus(plus_state_set)
# Clear effective flag
effective = false
# Create list for states that have customized resistances
evaluated_states = []
# Loop (added state)
for i in plus_state_set
# If this state is not guarded
unless self.state_guard?(i)
# Initialize resistance effects
success_rate = 101
# Cycle through all the battler's applied states
@states.each{|applied_state|
# Get the resistance data for this state
resist = State_Element.state_resist(applied_state)[i]
# Go to the next applied state if no resistance data
next if resist.nil?
effect_applied = true
# Pick the smaller of the two success rates
success_rate = [success_rate, resist].min
}
next unless success_rate != 101
# Set effective flag if this state is not full
effective |= self.state_full?(i) == false
# If states offer [no resistance]
if $data_states[i].nonresistance
# Set state change flag
@state_changed = true
# Add a state
add_state(i)
evaluated_states.push(i)
# If this state is not full
elsif self.state_full?(i) == false
# Convert state effectiveness to probability,
# compare to random numbers
if rand(100) < success_rate
# Set state change flag
@state_changed = true
# Add a state
add_state(i)
end
evaluated_states.push(i)
end
end
end
# Call alias
also_effective = check_for_state_resist_statesplus(plus_state_set - evaluated_states)
# End Method
return effective || also_effective
end
end
#==============================================================================
# ** Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Get Element Revision Value
# element_id : element ID
#--------------------------------------------------------------------------
alias set_element_rate_statically element_rate
def element_rate(element_id)
# Run through all applied states
rate = nil
for i in @states
resist = State_Element.element_resist(i)[element_id]
# Go to the next applied state if no resistance data
next if resist.nil?
# Pick the smaller of the two rates
rate = [rate, resist].min
end
# If no customized rate for states, use default resistance
if rate.nil?
return set_element_rate_statically(element_id)
else
return rate
end
end
end
#==============================================================================
# ** Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# * Get Element Revision Value
# element_id : Element ID
#--------------------------------------------------------------------------
alias set_element_rate_statically element_rate
def element_rate(element_id)
# Run through all applied states
rate = nil
for i in @states
resist = State_Element.element_resist(i)[element_id]
# Go to the next applied state if no resistance data
next if resist.nil?
# Pick the smaller of the two rates
rate = [rate, resist].min
end
# If no customized rate for states, use default resistance
if rate.nil?
return set_element_rate_statically(element_id)
else
return rate
end
end
end