- 19
- Posts
- 5
- Years
- Seen Jul 21, 2022
So basically I'm trying to add a move that deals damage, and lowers the users defense and the opponents accuracy (both 1 stage). Here is the code I have:
class PokeBattle_Move_159 < PokeBattle_Move
def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
ret=super(attacker,opponent,hitnum,alltargets,showanimation)
if !attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self) &&
!attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self) &&
!attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
@battle.pbDisplay(_INTL("{1}'s stats won't go any higher!",attacker.pbThis))
return -1
end
pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
showanim=true
if attacker.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
attacker.pbReduceStat(PBStats::DEFENSE,1,attacker,false,self,showanim)
showanim=false
return -1 if pbTypeImmunityByAbility(pbType(@type,attacker,opponent),attacker,opponent)
return -1 if !opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,true,self)
pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
ret=opponent.pbReduceStat(PBStats::SPATK,2,attacker,false,self)
return ret ? 0 : -1
end
end
return !attacker.pokemon || !attacker.pokemon.sweetbomb
end
I am getting the error: "undefined local variable or method 'attacker' for pokebattle_move_159:class pokemon essentials"
If anyone knows why this is, please let me know!
Link to error message: https://ibb.co/cT4LdZg
Thanks!
class PokeBattle_Move_159 < PokeBattle_Move
def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
ret=super(attacker,opponent,hitnum,alltargets,showanimation)
if !attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,attacker,false,self) &&
!attacker.pbCanIncreaseStatStage?(PBStats::SPATK,attacker,false,self) &&
!attacker.pbCanIncreaseStatStage?(PBStats::SPEED,attacker,false,self)
@battle.pbDisplay(_INTL("{1}'s stats won't go any higher!",attacker.pbThis))
return -1
end
pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
showanim=true
if attacker.pbCanReduceStatStage?(PBStats::DEFENSE,attacker,false,self)
attacker.pbReduceStat(PBStats::DEFENSE,1,attacker,false,self,showanim)
showanim=false
return -1 if pbTypeImmunityByAbility(pbType(@type,attacker,opponent),attacker,opponent)
return -1 if !opponent.pbCanReduceStatStage?(PBStats::SPATK,attacker,true,self)
pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
ret=opponent.pbReduceStat(PBStats::SPATK,2,attacker,false,self)
return ret ? 0 : -1
end
end
return !attacker.pokemon || !attacker.pokemon.sweetbomb
end
I am getting the error: "undefined local variable or method 'attacker' for pokebattle_move_159:class pokemon essentials"
If anyone knows why this is, please let me know!
Link to error message: https://ibb.co/cT4LdZg
Thanks!