cocicookie
Member
Any assistance for this? I've been carving out my battle system and I'm doing skills now. But for some reason instead of calculating damage, the stupid program gives me a no method error, saying that there is no '+' method.
I fixed it once, but when I went back to allow healing, it suddenly decided it was going to flip out on me and start again -.-
Anyone able to help? The entirety of the skill code is below.
I fixed it once, but when I went back to allow healing, it suddenly decided it was going to flip out on me and start again -.-
Anyone able to help? The entirety of the skill code is below.
Code:
#--------------------------------------------------------------------------
# * Apply Skill Effects
# user : the one using skills (battler)
# skill : skill
#--------------------------------------------------------------------------
def skill_effect(user, skill)
# Clear critical flag
self.critical = false
if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
return false
end
# Clear effective flag
effective = false
# Set effective flag if common ID is effective
effective |= skill.common_event_id > 0
# Casting Chance - 1d10 - user.int / 4 is smaller than remaining Sanity
hit_result = ((rand(9) + 1) - [user.int / 4, 0].min < user.sp)
# If hit occurs
if hit_result == true
# Calculate Damage
self.damage = nil
for x in (1..skill.atk_f)
self.damage += rand(skill.power - 1) + 1
end
# Element correction
self.damage *= elements_correct(skill.element_set)
self.damage /= 100
# If damage value is strictly positive
if self.damage > 0
# Guard correction
if self.guarding?
self.damage /= 2
end
end
# If physical attack has power other than 0
if skill.power != 0 and skill.atk_f > 0
# State Removed by Shock
remove_states_shock
# Set to effective flag
effective = true
end
# Substract damage from HP
last_hp = self.hp
if skill.scope == 3 or skill.scope == 4
self.hp += self.damage
else
self.hp -= self.damage
end
effective |= self.hp != last_hp
# State change
@state_changed = false
effective |= states_plus(skill.plus_state_set)
effective |= states_minus(skill.minus_state_set)
# If power is 0
if skill.power == 0
# Set damage to an empty string
self.damage = ""
# If state is unchanged
unless @state_changed
# Set damage to "Miss"
self.damage = "Fail"
end
end
# If miss occurs
else
self.damage = nil
# Calculate Damage
for x in (1..skill.atk_f)
self.damage = rand(skill.power - 1) + 1
end
# Deal damage to user and Set damage to "Fail"
user.hp -= self.damage
self.damage = "Fail"
end
# If not in battle
unless $game_temp.in_battle
# Set damage to nil
self.damage = nil
end
# End Method
return effective
end