eharper256
Member
Hi guys, I've had this little issue for some time now, but I still can't for the life of me figure out what causes it.
Basically:
http://img.photobucket.com/albums/v487/ ... alProb.jpg[/img]
As can be seen, HP gets a .0 tagged on the end. This occurs when a status effect (positive or otherwise) is applied to a target without any damage. Also, when an attack hits for a small amount of damage, strange things can sometimes occur, and an absurdly long number with a huge amount of decimal places can show, like 0.194162582831487901254, or something, for damage, which then shows in the health bar which tragically tries to squish all of those decimals in and looks horrid.
I assume that there's something amiss with my game_battler code for attacks (which is pretty modified), but despite all my attempts to ensure damages of less than 1 are truncated and rounded off, nothing ever seems to work.
Here's the attack section from the game_battler 3 in question
Though I suppose its a minor issue, It looks stupid, and I've had quite enough headbanging trying to figure it out. So any help will be appreciated and credited in game.
EDIT: Ah yes, sorry, I suppose I should note the other battle scripts in use, ne?
They are: Tricksters State Cycling, Blizzards Stat Stimulation and Sandgolems center Battlers.
But none of these apply to damage.
Basically:
http://img.photobucket.com/albums/v487/ ... alProb.jpg[/img]
As can be seen, HP gets a .0 tagged on the end. This occurs when a status effect (positive or otherwise) is applied to a target without any damage. Also, when an attack hits for a small amount of damage, strange things can sometimes occur, and an absurdly long number with a huge amount of decimal places can show, like 0.194162582831487901254, or something, for damage, which then shows in the health bar which tragically tries to squish all of those decimals in and looks horrid.
I assume that there's something amiss with my game_battler code for attacks (which is pretty modified), but despite all my attempts to ensure damages of less than 1 are truncated and rounded off, nothing ever seems to work.
Here's the attack section from the game_battler 3 in question
Code:
#--------------------------------------------------------------------------
# * Applying Normal Attack Effects
# attacker : battler
#--------------------------------------------------------------------------
def attack_effect(attacker)
# Clear critical flag
self.critical = false
# First hit detection
# JT NOTE: Remember, a weapons ATK is now its Accuracy!!!
# To give more Strength to weapon, have it add STR.
# Also, please keep accuracy rounded off to the nearest 10.
phyhit = (attacker.atk + attacker.dex + 10) #Accuracy + Skill + 10
phyeva = (self.agi + self.eva + 10) #Speed + Luck + 10
phyhitres = (phyhit - phyeva)
#Weapons with Seeking property always hit 99% of the time.
if attacker.element_set.include?(SEEK_ELEMENT)
hit_result = (rand(1) < phyhitres)
else
hit_result = (rand(100) < phyhitres)
end
# If hit occurs
if hit_result == true
# Calculate basic damage
# JT- New Basic damage method!
#OLDMETHOD: atk = [attacker.atk - self.pdef / 2, 0].max
#OLDMETHOD: self.damage = atk * (20 + attacker.str) / 20
# Its easier to calculate now, as its pretty much just str - pdef
# However, if a weapon is does NOT include the Slashing, Piercing, or
# Bludgeoning elements, it is considered a Magical attack.
if attacker.element_set.include?(5)
atkpow = attacker.str + rand(2) - rand(1)
defpow = self.pdef
elsif attacker.element_set.include?(9)
atkpow = attacker.str + rand(3) - rand(2)
defpow = self.pdef
elsif attacker.element_set.include?(10)
atkpow = attacker.str + rand(1) - rand(1)
defpow = self.pdef
elsif attacker.is_a?(Game_Enemy)
atkpow = attacker.str + rand(1) - rand(1)
defpow = self.pdef
else
atkpow = attacker.int + rand(3) - rand(2)
defpow = self.mdef
end
self.damage = atkpow - defpow
# Element correction
self.damage *= elements_correct(attacker.element_set)
self.damage /= 100
# If damage value is strictly positive
if self.damage > 0
# Critical correction
# JT- New Critical Method!
critchance = (attacker.dex / 2) + (attacker.eva + 1) - (attacker.atk/10)
# ie. 20 Skill (Becomes 10) + 6 Luck - 70% Accuracy (Becomes 7) = 9% chance of crit
# Yes, higher accuracy weapons are harder to critical with.
# Higher finesse = Less likely to causing brutal damage. Fair play, right?
if critchance < 1
critchance = 1
end
# But, theres always at least 1% chance of criticalling.
if attacker.element_set.include?(16) #Keen weapons give +10% chance!
critchance += 10
end
critcheck = rand(100)
if critcheck < critchance
self.damage *= 2
self.critical = true
end
#OLDMETHOD: if rand(100) < 4 * attacker.dex / self.agi
#OLDMETHOD: self.damage *= 2
#OLDMETHOD: self.critical = true
#OLDMETHOD: end
# Guard correction
# Guard can be pierced by a piercing weapon, negating it.
if self.guarding?
self.damage /= 2
if attacker.element_set.include?(PIERCE_ELEMENT)
self.damage *= 2
self.animation_id = 297
self.animation_hit = true
else
self.animation_id = 295
self.animation_hit = true
end
end
#Parrying weapon gives 20% chance of Auto-Guard.
if self.element_set.include?(PARRY_ELEMENT)
parrychance = 0
parrychance = rand(100)
if parrychance > 80
self.damage /= 2
self.animation_id = 296
self.animation_hit = true
end
end
# Allow bloodsucking swords and the like.
if attacker.element_set.include?(LIFEDRAIN_ELEMENT)
percent = LIFEDRAIN_AMOUNT
slurp = self.damage * percent / 100
attacker.hp += slurp
end
# Protect Status Correction
if self.states.include?(PROTECT_STATUS)
self.damage /= 2
self.animation_id = PROTECT_ANIMATION
self.animation_hit = true
end
else
self.damage = "Miss"
hit_result = false
return false
end
# JT- Stupid Healing prevention
if self.damage < 1
self.damage = 0
end
self.damage.truncate
# Dispersion is now included in the main attack.
#if self.damage.abs > 0
# amp = [self.damage.abs * 15 / 100, 1].max
# self.damage += rand(amp+1) + rand(amp+1) - amp
#end
# Second hit detection - JT: There is no longer 2nd hit detect. Eva is included in 1st.
#eva = 8 * self.agi / attacker.dex + self.eva
#hit = self.damage < 0 ? 100 : 100 - eva
#hit = self.cant_evade? ? 100 : hit
#hit_result = (rand(100) < hit)
end
# If hit occurs
if hit_result == true
# Subtract damage from HP
if self.damage != 0 and self.damage >= 1
self.hp -= self.damage
# State Removed by Shock
remove_states_shock
end
#JT- Added a 'No Damage!' string- better than just showing 0.
if self.damage == 0
self.damage = "No Damage!"
end
# State change
@state_changed = false
states_plus(attacker.plus_state_set)
states_minus(attacker.minus_state_set)
# When missing
else
# Set damage to "Miss"
self.damage = "Miss"
# Clear critical flag
self.critical = false
end
# End Method
return true
end
Though I suppose its a minor issue, It looks stupid, and I've had quite enough headbanging trying to figure it out. So any help will be appreciated and credited in game.
EDIT: Ah yes, sorry, I suppose I should note the other battle scripts in use, ne?
They are: Tricksters State Cycling, Blizzards Stat Stimulation and Sandgolems center Battlers.
But none of these apply to damage.