It doesn't make sense that every skill draws upon the same resistance table. As RMXP stands, the skill "Punch" is as likely as the skill "Stab" to cause the state "Bleeding," assuming that both having "Bleeding" checked as a State Change. By default, the table reads [100,80,60,40,20,0], which works fine for "Stab," though "Punch" would work better as [6,5,4,3,2,0], as knuckles are less likely (though still capable) of causing their target to bleed. Is there a way to assign a unique resistance table to each skill for each state?
Currently, I'm using a modified version of Trickster's Elem_State_Rate. I've altered it so that state rates actually change based on the armor equipped, as well as for compatibility with Atoa's Equipment Multi Slots. Currently, it works fine, though it only alters the table per state, as opposed to per skill per state.
The script as-is:
It seems that the best way to proceed is to create a hash for each skill, which itself contains a hash of resistance tables for each state. Then, when the skill is used in battle, it will cycle through its resistance tables, compare them to the target's resistance, and then assign states as appropriate.
I think with a little more time I can figure out how to make the hashes by examining Trickster's code, since he uses hashes himself. I'm not sure how I'll call this script from battle, though. In other words, how can I tell Ruby to check this script when a battler uses a skill?
Thanks for your help. I'm a novice at Ruby, but I'm also committed to figuring it out. Any guidance will go a long way.
-tuatha
Currently, I'm using a modified version of Trickster's Elem_State_Rate. I've altered it so that state rates actually change based on the armor equipped, as well as for compatibility with Atoa's Equipment Multi Slots. Currently, it works fine, though it only alters the table per state, as opposed to per skill per state.
The script as-is:
Code:
module Elem_State_Rate
#--------------
# * Elemental Rates
# - syntax: Element_Id => [A, B, C, D, E, F]
#--------------
Elemental = {
1 => [100, 70, 50, 30, 10, 5],
2 => [100, 70, 50, 30, 10, 5],
3 => [100, 70, 50, 30, 10, 5],
4 => [100, 70, 50, 30, 10, 5],
5 => [100, 70, 50, 30, 10, 5],
6 => [100, 70, 50, 30, 10, 5],
7 => [100, 70, 50, 30, 10, 5],
8 => [100, 70, 50, 30, 10, 5],
9 => [100, 70, 50, 30, 10, 5],
10 => [100, 70, 50, 30, 10, 5],
11 => [100, 70, 50, 30, 10, 5],
12 => [100, 70, 50, 30, 10, 5],
13 => [100, 70, 50, 30, 10, 5],
14 => [100, 70, 50, 30, 10, 5],
15 => [100, 70, 50, 30, 10, 5],
16 => [100, 70, 50, 30, 10, 5],
17 => [100, 70, 50, 30, 10, 5],
18 => [100, 70, 50, 30, 10, 5],
19 => [100, 70, 50, 30, 10, 5],
20 => [100, 70, 50, 30, 10, 5]
}
#--------------
# * Default Elemental Rate
# - syntax: [A, B, C, D, E, F]
#--------------
Elemental.default = [200,150,100,50,0,-100]
#--------------
# * State Rates
# - syntax: Element_Id => [A, B, C, D, E, F]
#--------------
States = {
60 => [90, 75, 60, 45, 30, 10],
61 => [65, 50, 35, 20, 10, 2],
62 => [30, 23, 17, 11, 6, 1],
63 => [100, 100, 85, 50, 20, 5],
64 => [100, 100, 50, 30, 15, 3],
65 => [100, 100, 15, 10, 5, 1],
68 => [100, 100, 85, 40, 5, 0],
69 => [100, 100, 50, 20, 3, 0],
70 => [100, 100, 15, 6, 1, 0],
73 => [100, 100, 85, 5, 0, 0],
74 => [100, 100, 50, 3, 0, 0],
75 => [100, 100, 15, 1, 0, 0],
124 => [30, 23, 17, 11, 6, 3],
125 => [95, 85, 75, 50, 25, 10],
126 => [50, 40, 30, 20, 10, 3],
129 => [40, 32, 24, 16, 8, 4],
130 => [20, 16, 12, 8, 4, 2],
131 => [10, 8, 6, 4, 2, 1]
}
#--------------
# * Default State Rate
# - syntax: [A, B, C, D, E, F]
#--------------
States.default = [100,80,60,40,20,0]
end
class Game_Battler
#--------------
# * State Change (+) Application
# plus_state_set : State Change (+)
#--------------
def states_plus(plus_state_set)
# Clear effective flag
effective = false
# Loop (added state)
for i in plus_state_set
# 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)
# If this state is not full
elsif self.state_full?(i) == false
# Get Table
table = Elem_State_Rate::States[i]
# Random Chance
if rand(100) < table[self.state_rate(i)]
# Set state change flag
@state_changed = true
# Add a state
add_state(i)
end
end
end
# End Method
return effective
end
end
class Game_Actor < Game_Battler
def armor_ids
result = []
for i in 0...@equip_kind.size
id = @equip_kind[i]
if id > 0 and not ($atoa_script['Atoa Two Hands'] and id == 1 and two_swords_style)
result << eval("@armor#{id}_id = @equip_id[i].nil? ? 0 : @equip_id[i]")
end
end
return result
end
#--------------
# * Get State Revision Value
# state_id : state ID
#--------------
def state_rate(status_id)
# Get values corresponding to element effectiveness
table = Elem_State_Rate::States[status_id]
# Get Value Minus 1 (0 in front was removed)
value = $data_classes[@class_id].state_ranks[status_id] - 1
# Run Through each armor
self.armor_ids.each do |armor_id|
# Get Armor
armor = $data_armors[armor_id]
# Skip if state is nil or doesn't guard
next if armor == nil or !armor.guard_state_set.include?(status_id)
# Add 1 (Bump up)
value += 1
end
# Restrict to[0,5]
value = [[value, 0].max, 5].min
# End Method
return value
end
#--------------
# * Get Element Revision Value
# element_id : element ID
#--------------
def element_rate(element_id)
# Get values corresponding to element effectiveness
table = Elem_State_Rate::Elemental[element_id]
# Get Value Minus 1 (0 in front was removed)
value = $data_classes[@class_id].element_ranks[element_id] - 1
# Run Through each armor
self.armor_ids.each do |armor_id|
# Get Armor
armor = $data_armors[armor_id]
# Skip if state is nil or doesn't guard
next if armor == nil or !armor.guard_element_set.include?(element_id)
# Add 1 (Bump up)
value += 1
end
# Run Through each state
@states.each do |state_id|
# Get State
state = $data_states[state_id]
# Skip if state is nil or doesn't guard against element
next if state == nil or !state.guard_element_set.include?(element_id)
# Add 1 (Bump up)
value += 1
end
# Restrict to[0,5]
value = [[value, 0].max, 5].min
# End Method
return table[value]
end
end
class Game_Enemy < Game_Battler
#--------------
# * Get State Revision Value
# state_id : state ID
#--------------
def state_rate(status_id)
# Get values corresponding to element effectiveness
table = Elem_State_Rate::States[status_id]
# Get Value Minus 1 (0 in front was removed)
value = $data_enemies[@enemy_id].state_ranks[status_id] - 1
# Run Through each state
# Restrict to[0,5]
value = [[value, 0].max, 5].min
# End Method
return value
end
#--------------
# * Get Element Revision Value
# element_id : Element ID
#--------------
def element_rate(element_id)
# Get values corresponding to element effectiveness
table = Elem_State_Rate::Elemental[element_id]
# Get Value Minus 1 (0 in front was removed)
value = $data_enemies[@enemy_id].element_ranks[element_id] - 1
# Run Through each state
@states.each do |state_id|
# Get State
state = $data_states[state_id]
# Skip if state is nil or doesn't guard against element
next if state == nil or !state.guard_element_set.include?(element_id)
# Add 1 (Bump up)
value += 1
end
# Restrict to[0,5]
value = [[value, 0].max, 5].min
# End Method
return table[value]
end
end
It seems that the best way to proceed is to create a hash for each skill, which itself contains a hash of resistance tables for each state. Then, when the skill is used in battle, it will cycle through its resistance tables, compare them to the target's resistance, and then assign states as appropriate.
I think with a little more time I can figure out how to make the hashes by examining Trickster's code, since he uses hashes himself. I'm not sure how I'll call this script from battle, though. In other words, how can I tell Ruby to check this script when a battler uses a skill?
Thanks for your help. I'm a novice at Ruby, but I'm also committed to figuring it out. Any guidance will go a long way.
-tuatha