• 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.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Serena, Kris, Dawn, Red - which Pokémon protagonist is your favorite? Let us know by voting in our grand final favorite protagonist poll!
  • 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