eharper256
Member
Having been stumped for the umpteenth time on how exactly RMXP calculates damage from skills (and damage from normal attacks, for that matter), I decided to try rewriting Game_Battler3 into something more logical that I could understand.
To begin with, I figured, I'd just concentrate on skills, then if that was successful, I'd try modding the basic attack. I also wanted to change some things in any case; I didn't think that the actors atk value should have any bearing on skills that were purely magical (So, a sharper sword makes me cast spells better! WTF?). Therefore, I also needed a way for the system to differenciate between a skill with 'Power' (magical power) and 'Atk_f' (physical power) that were assigned in the database.
The Result was this (taken from my Game_battler3):
Now, for some part, this rewrite was successful; I figured out damage for a spell knowing all of the factors, like INT, POW, MDEF, etc. on paper, and then checked the value in RMXP; and it was almost correct (it seems to be adding another random value somewhere that I can't find; but this value is consistent, so after removing it, my calculations were correct)
HOWEVER. I then went and checked a purely physical skill (One which has 0 Power, and like 14 atk_f in the database). It returns a 'miss' each time; WHILE doing damage! (Admittedly a comically small amount of damage, like 1 or 4)':|
This is repeated regardless of how high the atk_f is set. I then gave the skill a power of 1 (effectively 0, given my calculations). It now hits, but still always
does the same tiny damage.
Despite my changes, therefore, it seems that atk_f is not being taken into account for damage calculation at all. O_o
So what am I doing wrong here? Or can I simply not use Atk_f for a base damage value? The latter would kinda suck...:-/
EDIT: Oh yeah, I'm using pretty low stats for my characters, hence the division by 1000 for the multiplier and such. Low as in Lvl 1 character has 20 HP, 3 MP, 7 ATK, that sort of thing...
To begin with, I figured, I'd just concentrate on skills, then if that was successful, I'd try modding the basic attack. I also wanted to change some things in any case; I didn't think that the actors atk value should have any bearing on skills that were purely magical (So, a sharper sword makes me cast spells better! WTF?). Therefore, I also needed a way for the system to differenciate between a skill with 'Power' (magical power) and 'Atk_f' (physical power) that were assigned in the database.
The Result was this (taken from my Game_battler3):
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 is for ally with 1 or more HP, and your own HP = 0,
# or skill scope is for ally with 0, and your own HP = 1 or more
if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
# End Method
return false
end
# Clear effective flag
effective = false
# Set effective flag if common ID is effective
effective |= skill.common_event_id > 0
# First hit detection
hit = skill.hit
#if skill.atk_f > 0
# hit *= user.hit / 100
#end
hit_result = (rand(100) < hit)
# Set effective flag if skill is uncertain
effective |= hit < 100
# If hit occurs. START JT DAMAGE SYSTEM. DELETE UP TO COMMENTED ORIGINAL TO RETURN.
if hit_result == true
# First, the Base Damage of the skill is determined.
basepow = 0
if (skill.power - 1) > 0
basepow += (skill.power + user.int - 1)
end
if (skill.atk_f - 1) > 0
basepow += (skill.atk_f + user.atk - 1)
end
# Then, if the skill isn't harmless, a multiplier is determined, based on stat relevance.
if basepow > 0
powermult = 1
powermult += ((user.str * skill.str_f) / 1000)
powermult += ((user.dex * skill.dex_f) / 1000)
powermult += ((user.agi * skill.agi_f) / 1000)
powermult += ((user.int * skill.int_f) / 1000)
else
powermult = 1
end
# Then, the Base damage is multiplied to create the Raw Damage potential.
rawdamage = 0
rawdamage += (basepow * powermult)
# Then, a dampening value; based upon the PhysDef and MDef of the target is created.
if (rawdamage - 1) > 0
dampen = 0
if (skill.power - 1) > 0
dampen += ((self.mdef * skill.mdef_f) / 50)
end
if (skill.atk.f - 1) > 0
dampen += ((self.pdef * skill.pdef_f) / 100)
end
else
dampen = 0
end
# The net damage is then determined by subtracting the dampen from the Raw Damage.
# It should only return an absolute value, thanks to the []
self.damage == [rawdamage - dampen]
# Then elements affect the skill appropriately
self.damage *= (elements_correct(skill.element_set) / 100)
# Then guarding activates.
if self.damage > 0
#Guard correction
if self.guarding?
self.damage /= 2
end
end
if skill.variance > 0 and self.damage.abs > 0
self.damage += [rand(skill.variance.max)]
end
# Second hit detection
eva = 8 * self.agi / user.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
# Set effective flag if skill is uncertain
effective |= hit < 100
end
# If hit occurs
if hit_result == true
# 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
self.hp -= self.damage
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 and skill.atk_f == 0
# Set damage to an empty string
self.damage = ""
# If state is unchanged
unless @state_changed
# Set damage to "Miss"
self.damage = "Miss"
end
end
# If miss occurs
else
# Set damage to "Miss"
self.damage = "Miss"
end
# If not in battle
unless $game_temp.in_battle
# Set damage to nil
self.damage = nil
end
# End Method
return effective
end
Now, for some part, this rewrite was successful; I figured out damage for a spell knowing all of the factors, like INT, POW, MDEF, etc. on paper, and then checked the value in RMXP; and it was almost correct (it seems to be adding another random value somewhere that I can't find; but this value is consistent, so after removing it, my calculations were correct)
HOWEVER. I then went and checked a purely physical skill (One which has 0 Power, and like 14 atk_f in the database). It returns a 'miss' each time; WHILE doing damage! (Admittedly a comically small amount of damage, like 1 or 4)':|
This is repeated regardless of how high the atk_f is set. I then gave the skill a power of 1 (effectively 0, given my calculations). It now hits, but still always
does the same tiny damage.
Despite my changes, therefore, it seems that atk_f is not being taken into account for damage calculation at all. O_o
So what am I doing wrong here? Or can I simply not use Atk_f for a base damage value? The latter would kinda suck...:-/
EDIT: Oh yeah, I'm using pretty low stats for my characters, hence the division by 1000 for the multiplier and such. Low as in Lvl 1 character has 20 HP, 3 MP, 7 ATK, that sort of thing...