This script allows your RPG Maker XP project to have state effects that stack like in Pokemon or MegaTen.
It does this by applying a more powerful version of the state whenever the specified state already exists.
class RPG::State
#-----------------------------------------------------------------------------
# * Tiered States
# States are applied left to right, starting at the state before the =>.
#
# The example provided allows for negative states (stat-downs) to be
# counteracted by positive states (stat-ups)
#-----------------------------------------------------------------------------
Tiered_States = {
20 => [24, 23, 22, 21, 20, 19, 18],
22 => [18, 19, 20, 21, 22, 23, 24]
}
#-----------------------------------------------------------------------------
# * has Additive State?
#-----------------------------------------------------------------------------
def tiered?
Tiered_States.include?(@id)
end
#-----------------------------------------------------------------------------
# * How many tiers?
#-----------------------------------------------------------------------------
def tiers
return Tiered_States.fetch(@id, [])
end
end
#===============================================================================
# ** Game_Battler
#===============================================================================
class Game_Battler
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :mpen_default_add_state, :add_state
#-----------------------------------------------------------------------------
# * Add State
#-----------------------------------------------------------------------------
def add_state(state_id, force = false)
if $data_states[state_id].tiered?
for i in 0...$data_states[state_id].tiers.size
current_tier = $data_states[state_id].tiers[i]
next_tier = $data_states[state_id].tiers[i+1]
if self.state?(current_tier)
if next_tier == nil
#tier at maximum, regular state rules apply
mpen_default_add_state(current_tier, force)
return
else
remove_state(current_tier)
mpen_default_add_state(next_tier, force)
return
end
end
end
#no tiers applyed yet, default behavior.
mpen_default_add_state(state_id, force)
else
#no tiers exist, default behavior
mpen_default_add_state(state_id, force)
end
end
end
Instructions
A hash of states with tiers needs to be provided at the beginning of the script. The key is the default state, the one that is applied when no states of this type are currently attached to the battler. The value is an array of the different tiers, in order of power from left to right.
In the demo provided, a way to have negative effects cancel out positive effects is shown.
Credits and Thanks
This script is based on Kain Nobel's States : Toggle script.