Apply State Equipment
Version: 1.0
Author: modern algebra
Date: May 14, 2010
Version History
- <Version 1.0> 05.14.2010 - Original Release
Planned Future Versions
- <Version 1.1> If anyone expresses interest, I am thinking of making an addon to show what states would be applied and removed in the Equip scene. I will not do this if no one posts asking for it though.
Description
This script allows you to assign states to equipment that will be applied to an actor for as long as he/she has that weapon or armor equipped.
Features
- Allows you to make equipment that adds states
- Very easy configuration - just add a code to the note field.
Instructions
Please see the header of the script.
However, one quick note about priority - if a state applied in the normal manner would cancel a state given by equipment, then that state will cancel the equipment state until its duration is over. If a state that is applied in a normal manner would be cancelled by an equipment state, then it will be removed. If the two states would cancel each other out, the one applied normally takes priority until it is extinguished.
Script
#==============================================================================
# Apply State Equipment
# Version: 1.0
# Author: modern algebra (rmrk.net)
# Date: May 14, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script allows you to assign states to equipment that will be applied
# to an actor for as long as he/she has that weapon or armor equipped.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
#
# Paste this script into its own slot in the Script Editor (F11), somewhere
# below Materials but above Main.
#
# To assign states to a weapon or armor, simply put in the code:
# \equip_states[state_1, state_2, ..., state_n]
#
# where state_1 ... state_n are the IDs of the states you want this
# equipment to apply to the actor.
#
# EXAMPLES:
# \equip_state[1] - would apply an Incapacitated state to the actor
# \equip_state[10, 13] would apply the states DEF UP and ATK Down
#==============================================================================
# ** RPG::BaseItem
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new method - ma_equip_states
#==============================================================================
class RPG::BaseItem
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Equip States
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def ma_equip_states
if !@ma_equip_states
@ma_equip_states = []
if self.note[/\\EQUIP_STATES\[([\d,\s]*?)\]/i] != nil
state_s = $1.to_s
state_s.gsub (/(\d+)/) { |i| @ma_equip_states.push (i.to_i) }
end
end
return @ma_equip_states
end
end
#==============================================================================
# ** Game Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - initialize; states; change_equip
# new method - add_equip_state
#==============================================================================
class Game_Actor
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias maa_ase_initz_6rv2 initialize
def initialize (*args)
@ase_equipstates = []
maa_ase_initz_6rv2 (*args) # Run Original Method
equips.each { |equip|
next if !equip # Next if slot is nil
equip.ma_equip_states.each { |state_id| add_equip_state (state_id) }
}
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Change Equipment
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias moda_eqstates_chnguip_8ik2 change_equip
def change_equip(equip_type, item, test = false, *args)
last = equips[equip_type]
if !test
last.ma_equip_states.each { |id| @ase_equipstates.delete (id) } if last
item.ma_equip_states.each { |id| add_equip_state (id) } if item
end
moda_eqstates_chnguip_8ik2 (equip_type, item, test, *args) # Run Original Method
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * States
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias malga_apsteq_stts_7uj2 states
def states (*args)
result = malga_apsteq_stts_7uj2 (*args)
for state_id in @ase_equipstates
state = $data_states[state_id]
next if result.include? (state)
skip = false
result.each { |state2|
if state2.state_set.include? (state.id)
skip = true
break
end
}
next if skip
state.state_set.each { |state_id|
result.delete ($data_states[state_id])
remove_state (state_id)
@removed_states.delete (state_id) # Don't report its removal
}
result.push (state)
end
return result
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Add Equip State
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def add_equip_state (state_id)
real_states = @states
@states = []
add_state (state_id)
@ase_equipstates += @states
@states = real_states
end
end
Credit
Support
Please post here, in this topic at RMRK.net for help with this script.
Known Compatibility Issues
No compatibility errors that I am currently aware of.