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.
I was a bit confused about what this did at first. But now that I've seen it, it seems to be a pretty nice script.
Amazing. It may be a simple script, but that's more useful than you can imagine. I love it. And I'd love even more to see this version 1.1. I hope the offer is still valid. Well, is it? ???
I tried this script but it doesn't seem to apply the state I want a weapon or armor to have. I did place this on the note for the weapon or armor \equip_state[1]
I did also paste the whole script on the script editor below materials but above main. It doesn't show any error. What could be causing this? :)
Well, it should be \equip_states[1] - state should be plural.
Also, you realize that 1 is the incapacitated state?
ohhh so that's why, i just copied and pasted the example on the script :p
yes, its incapacitated just like in the example. ^^
Quote from: Robot Unicorn on May 15, 2010, 01:26:20 AM
- <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.
Do want do want
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg138.imageshack.us%2Fimg138%2F2934%2Fsadaasda.png&hash=544c075b70e4b07e183bd804c8ee2a7d03c88303) :-[
I dont know why I'm getting this error whenever I'm about to enter a battle... Any ideas? u_u
It's probably an incompatibility with another script. Try placing this script below all your other custom scripts, but still above Main.
Quote from: grafikal on October 12, 2010, 08:23:14 PM
Quote from: Robot Unicorn on May 15, 2010, 01:26:20 AM
- <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.
Do want do want
I'm also interested :D It'd be super cool
Quote from: modern algebra on December 04, 2010, 05:58:17 PM
It's probably an incompatibility with another script. Try placing this script below all your other custom scripts, but still above Main.
Yep, i tried it but the error keeps popping before the battle begins :S This script could be very determinant in my game's development since the usage I'm planning for this script is to have something like "weapon modes", i.e. if you equip a saber you'll have a series of skills available only for that kind of weapon, as well with swords, spears, etc. :'(
But I'm also planning to have Low, Mid and High rate weapons and depending on their rating they'll have 2 or more modes available (for example a high-rate 2h sword which has 3 modes: low guard, mid guard and high guard, each mode having it's own skills (formation skills [parameter changing skills] and damage/recovery skills [standard skills)]
So I'm guessing if this script could help me do that kind of stuff or if there's any alternative way, like engines or scripts :-\
Ty in advance
Well, see if you can diagnose which script this one is conflicting with and send me a link to it. To do so, just make a new project and start by just putting the Apply State Equipment script in. Then, add your other scripts one-by-one, testing in between. When the error occurs, report the last script you had added.