If there's another way to make this with other script, I'd be glad to hear it. It doesn't have to be with Victor's script
You said it.
I made this script originally for my game. Where my character has two modes, offensive and defensive. Applying the state, remove the other one. So both can't be applied. I named this script "State Links"
Code:
class RPG::State
attr_accessor :link_rem
attr_accessor :link_add
def load_link_states
@link_rem = []
@link_add = []
note.split(/[\r\n]+/).each do |line|
case line
when /<link[\s_]+remove\s*:\s*(.+)>/i
$1.to_s.split(/,/).each do |state|
@link_rem.push(state.to_i)
end
when /<link[\s_]+add\s*:\s*(.+)>/i
$1.to_s.split(/,/).each do |state|
@link_add.push(state.to_i)
end
end
end
end
end
class << DataManager
alias theo_state_link_load_db load_database
def load_database
theo_state_link_load_db
$data_states.compact.each do |st|
st.load_link_states
end
end
end
class Game_Battler
alias theo_state_link_add_new_state add_new_state
def add_new_state(state_id)
theo_state_link_add_new_state(state_id)
link_states(state_id)
end
def link_states(state_id)
$data_states[state_id].link_rem.each do |stid|
remove_state(stid)
end
$data_states[state_id].link_add.each do |stid|
add_state(stid)
end
end
end
The usage would be putting notetag <link remove: 1,2,3,4>
If state 5 is applied, then state 10, 31, 32, 34 will be removed. The tag would be <link remove: 10,31,32,33,34>
If state 10 is applied, then state 5 will be removed. The tag would be <link remove: 5>
If state 1 is applied, it will also apply other states. The tag would be <link add: 2,3,4>
Tell me how it goes.
Edit: Also, is there any reason why you can't just use database for removing states and then add the new one?