Help - Search - Members - Calendar
Full Version: Timed Hit script error
RPG RPG Revolution Forums > Scripting > Script Development and Support > RGSS
Xeto
I'm using Zephren's Timed Hit script [which can be found here http://houseslashers.b1.jcink.com/index.php?showtopic=116 ] and have been running into a strange problem.

Problem is, when I use a skill like remedy [anything that removes status effects] or I use a skill that would cause a status effect, it says "Script 'Timed Hit 1' line 38: TypeError occurred. String can't be coerced into fixnum" then closes.

Line 38 is this part: "Integer((@timed_hit_hit_percent * self.damage) / 100.0)"

Strangely when I add power to the skills that give or cure status effects and make it cause damage it works fine without the error.

Though obviously I don't want to get hurt every time I use a remedy skill.

Here is the whole script in case anyone can see why this is happening:

class Game_Battler
attr_accessor :timed_hit_hit_percent
attr_accessor :timed_hit_use_percent
attr_accessor :timed_hit_state_to_add

alias timed_hit_attack_effect attack_effect
def attack_effect(attacker)
if @timed_hit_use_percent
hp = self.hp

timed_hit_attack_effect(attacker)

if self.damage != "Miss"
self.hp = hp
self.damage = Integer((@timed_hit_hit_percent * self.damage) / 100.0)
self.hp -= Integer(self.damage)
if @timed_hit_state_to_add != nil
self.add_state(@timed_hit_state_to_add)
end
end
elsif attacker.is_a?(Game_Enemy)
timed_hit_attack_effect(attacker)
end

@timed_hit_use_percent = false
@timed_hit_state_to_add = nil
end

alias timed_hit_skill_effect skill_effect
def skill_effect(user, skill)
if @timed_hit_use_percent
hp = self.hp

timed_hit_skill_effect(user, skill)

if self.damage != "Miss"
self.hp = hp
self.damage = Integer((@timed_hit_hit_percent * self.damage) / 100.0)
self.hp -= Integer(self.damage)
end
elsif user.is_a?(Game_Enemy)
timed_hit_skill_effect(user, skill)
end

@timed_hit_use_percent = false
end
end

Shaddow
This actually belongs in the script support section, I'll gladly move that over for you so you can get the help you are looking for.
Xeto
QUOTE (Shaddowval @ Dec 1 2012, 12:39 AM) *
This actually belongs in the script support section, I'll gladly move that over for you so you can get the help you are looking for.


Oh, that was stupid of me - thank you smile.gif
Jens of Zanicuud
Try replacing this
CODE
if self.damage != "Miss"

with this:
CODE
if self.damage.is_a?(Numeric)

I don't know if this will fix the problem, however there's a high chance it could be the solution.
I think that skills which give status has a damage expressed by the blank string "" which is different from "Miss" but isn't a number.
This could cause that script crisis.

I hope this can help,

Jens
Xeto
QUOTE (Jens of Zanicuud @ Dec 1 2012, 10:44 AM) *
Try replacing this
CODE
if self.damage != "Miss"

with this:
CODE
if self.damage.is_a?(Numeric)

I don't know if this will fix the problem, however there's a high chance it could be the solution.
I think that skills which give status has a damage expressed by the blank string "" which is different from "Miss" but isn't a number.
This could cause that script crisis.

I hope this can help,

Jens


Thank you!!!

This fixed the problem, I seriously love you!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.