• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Trading Card Game 2 protagonist in the poll by clicking here.
  • 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
    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!
     

    Attachments

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