I actually am not really sure what the problem is. I know the code is working. The only part that isn't is the part
where its supposed to read the chosen variable as the integer. Here's the code:
#----------------------------------------------------------------------
# <damage: -x variable hp> <damage: +x variable hp>
# <damage: -x variable mp> <damage: +x variable mp>
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# This will cause MP and HP damage based on variable X. This damage is
# affected by variance criticals, elements, and guarding.
# --- Example --- - - - - - - - - - - - - - - - - - - - - - - - - - - -
# <damage: -20 variable hp>
# <damage: -20 variable hp>
#----------------------------------------------------------------------
when /([\+\-]\d+)[ ]VARIABLE[ ](.*)/i
var = $game_variables[$1.to_i].to_i
case $2.to_s
when "HP"
hp_dmg = var
when "MP", "SP"
mp_dmg = var
end
healing_formula = true if var < 0
ignore_elements = false
ignore_variance = false
ignore_critical = false
ignore_guarding = false
ignore_inflates = false
The code is derived from another melody code, which it only differs from slightly (and I know this one works under the same conditions I set for my new code):
#----------------------------------------------------------------------
# <damage: -x% current hp> <damage: +x% current hp>
# <damage: -x% current mp> <damage: +x% current mp>
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# This will cause the target to lose x% of their current HP or MP. If
# a negative value is used for x, then the target will take damage of
# that percent. If the value is positive, the target will recover that
# percent instead. The damage is unaffected by variance, criticals, and
# elements and guarding.
# --- Example --- - - - - - - - - - - - - - - - - - - - - - - - - - - -
# <damage: +50% current hp>
# <damage: -25% current mp>
#----------------------------------------------------------------------
when /([\+\-]\d+)([%?])[ ]CURRENT[ ](.*)/i
percent = $1.to_i
case $3.to_s
when "HP"
hp_dmg = target.hp * percent / -100
when "MP", "SP"
mp_dmg = target.mp * percent / -100
end
healing_formula = true if percent > 0
ignore_elements = true
ignore_variance = true
ignore_critical = true
ignore_guarding = true
ignore_inflates = true
I think its breaking down where its supposed to read the variable as an integer, but I don't understand why, seeing as I've done this sort of thing before with variables. When I try to use it in battle, I get 0 damage. I feel like the answer is pretty basic, but it isn't coming to me. I'm going to continue looking.
EDIT: Just as a clarification, I know the code is being read and performed in battle. That can't be the problem. I know because when I futz with the code and put in a value that's not defined, it kicks back an error message when the enemy attempts to use the skill. So, as far as I can tell, it is performing the operations when the skill is being used, and I haven't overlooked anything when it comes to actually getting the operation to perform.
EDIT 2: Okay, I did some experimenting and it is definitely the part where it is supposed to convert the value of the variable into an integer. Thing is, I've done this before, so I have no idea why it won't read the variable's value as the damage value. Any help would be appreciated.