- 18
- Posts
- 10
- Years
- Seen Jun 22, 2015
I am trying to make a move that works like bide but only lasts 2 as opposed to 3 turns and only returns with 1.5 times the damage received and then heals you half of the damage dealt. I thought I was coding it all correctly but I am getting an error when I try to use the move in game.
The code for my move:
In the moves PBS file it is listed as:
Finally, the error message reads:
I added Fish, FishDamage, and FishTarget to the PBEffects script as well.
If you have any insight into where I am getting an error I would greatly appreciate the help.
Thanks in advance!
The code for my move:
Spoiler:
class PokeBattle_Move_163 < PokeBattle_Move
def pbDisplayUseMessage(attacker)
if attacker.effects[PBEffects::Fish]==0
@battle.pbDisplayBrief(_INTL("{1} put out bait!",attacker.pbThis,name))
attacker.effects[PBEffects::Fish]=1
attacker.effects[PBEffects::FishDamage]=0
attacker.effects[PBEffects::FishTarget]=-1
attacker.currentMove=@id
pbShowAnimation(@id,attacker,nil)
return 1
else
attacker.effects[PBEffects::Fish]-=1
if attacker.effects[PBEffects::Fish]==0
@battle.pbDisplayBrief(_INTL("{1} hooked something!",attacker.pbThis))
return 0
else
@battle.pbDisplayBrief(_INTL("{1} is waiting...",attacker.pbThis))
return 2
end
end
end
def pbAddTarget(targets,attacker)
if attacker.effects[PBEffects::FishTarget]>=0
if !attacker.pbAddTarget(targets,@battle.battlers[attacker.effects[PBEffects::FishTarget]])
attacker.pbRandomTarget(targets)
end
end
end
def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
if attacker.effects[PBEffects::FishDamage]==0 || !opponent
@battle.pbDisplay(_INTL("But it failed!"))
return -1
end
ret=pbEffectFixedDamage(attacker.effects[PBEffects::FishDamage]*1.5,attacker,opponent,hitnum,alltargets,showanimation).floor
attacker.effects[PBEffects::FishDamage]=0
if opponent.damagestate.calcdamage>0
hpgain=((opponent.damagestate.hplost+1)/2).floor
if opponent.hasWorkingAbility(:LIQUIDOOZE)
@battle.pbDisplayEffect(opponent)
attacker.pbReduceHP(hpgain,true)
@battle.pbDisplay(_INTL("{1} sucked up the liquid ooze!",attacker.pbThis))
elsif attacker.effects[PBEffects::HealBlock]==0
hpgain=(hpgain*1.3).floor if attacker.hasWorkingItem(:BIGROOT)
attacker.pbRecoverHP(hpgain,true)
@battle.pbDisplay(_INTL("{1} had its energy drained!",opponent.pbThis))
end
end
return ret
end
end
def pbDisplayUseMessage(attacker)
if attacker.effects[PBEffects::Fish]==0
@battle.pbDisplayBrief(_INTL("{1} put out bait!",attacker.pbThis,name))
attacker.effects[PBEffects::Fish]=1
attacker.effects[PBEffects::FishDamage]=0
attacker.effects[PBEffects::FishTarget]=-1
attacker.currentMove=@id
pbShowAnimation(@id,attacker,nil)
return 1
else
attacker.effects[PBEffects::Fish]-=1
if attacker.effects[PBEffects::Fish]==0
@battle.pbDisplayBrief(_INTL("{1} hooked something!",attacker.pbThis))
return 0
else
@battle.pbDisplayBrief(_INTL("{1} is waiting...",attacker.pbThis))
return 2
end
end
end
def pbAddTarget(targets,attacker)
if attacker.effects[PBEffects::FishTarget]>=0
if !attacker.pbAddTarget(targets,@battle.battlers[attacker.effects[PBEffects::FishTarget]])
attacker.pbRandomTarget(targets)
end
end
end
def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
if attacker.effects[PBEffects::FishDamage]==0 || !opponent
@battle.pbDisplay(_INTL("But it failed!"))
return -1
end
ret=pbEffectFixedDamage(attacker.effects[PBEffects::FishDamage]*1.5,attacker,opponent,hitnum,alltargets,showanimation).floor
attacker.effects[PBEffects::FishDamage]=0
if opponent.damagestate.calcdamage>0
hpgain=((opponent.damagestate.hplost+1)/2).floor
if opponent.hasWorkingAbility(:LIQUIDOOZE)
@battle.pbDisplayEffect(opponent)
attacker.pbReduceHP(hpgain,true)
@battle.pbDisplay(_INTL("{1} sucked up the liquid ooze!",attacker.pbThis))
elsif attacker.effects[PBEffects::HealBlock]==0
hpgain=(hpgain*1.3).floor if attacker.hasWorkingItem(:BIGROOT)
attacker.pbRecoverHP(hpgain,true)
@battle.pbDisplay(_INTL("{1} had its energy drained!",opponent.pbThis))
end
end
return ret
end
end
In the moves PBS file it is listed as:
Spoiler:
622,FISH,Fish,163,1,WATER,Physical,0,10,0,10,1,abf,"The user baits attacks for a turn, then strikes back healing some of the damage taken."
Finally, the error message reads:
Spoiler:
Exception: NoMethodError Message: undefined method `-' for nil:NilClass PokeBattle_MoveEffects:325:in `pbDisplayUseMessage' PokeBattle_Battler:3402:in `pbUseMove' PokeBattle_Battler:3719:in `pbProcessTurn' PokeBattle_Battler:3718:in `logonerr' PokeBattle_Battler:3718:in `pbProcessTurn' PokeBattle_Battle:3087:in `pbAttackPhase' PokeBattle_Battle:3058:in `each' PokeBattle_Battle:3058:in `pbAttackPhase' EliteBattle_Battle:211:in `pbStartBattleCore' EliteBattle_Battle:210:in `logonerr'
I added Fish, FishDamage, and FishTarget to the PBEffects script as well.
If you have any insight into where I am getting an error I would greatly appreciate the help.
Thanks in advance!