• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Script issue when trying to add a move!

19
Posts
4
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!
     

    Attachments

    • move effects.txt
      369.1 KB · Views: 1
    Back
    Top