if hit_result == true
# Calculate basic damage
if attacker.weapon_id == nil || attacker.weapon_id >= 17
atk = [(attacker.atk + rand(Integer(attacker.dex/2))) - self.pdef, 0].max
else
atk = [(attacker.atk + attacker.str + rand(Integer(attacker.agi/2))) - self.pdef, 0].max
# used to read completely differently
end #might have to move end down edited by shintashi
self.damage = atk * (atk + 2)
self.damage *= elements_correct(attacker.element_set)
self.damage /= 100
# If damage value is strictly positive
if self.damage > 0
# Critical correction
if rand(100) < 10 * attacker.dex / self.agi # was 4%
self.damage *= 2
self.critical = true
end
# Guard correction
if self.guarding?
self.damage /= 2
end
end
This is my refined script. It does different damage for melee weapons than ranged weapons. Ranged weapons do damage based on the weapon, slightly modified by dexterity. Melee weapons, like swords and knives, do damage based on the weapon, plus strength, modified slightly by agility. Note that you will want to either greatly reduce melee damage or greatly increase ranged damage of weapons to compensate the difference.