• 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!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll 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.

A move that uses a random move from a set group of moves

  • 24
    Posts
    11
    Years
    • Seen Jul 5, 2018
    Is it possible to create a move effect that selects a move from a select group of moves?
    For example, it chooses a random move from either Fire Blast, Solarbeam, Hydro Pump or Hurricane?
     
    Code:
    class PokeBattle_Move_nnn < PokeBattle_Move [COLOR="Green"]# change to a new function code[/COLOR]
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        movelist=[
           :FIREBLAST,
           :SOLARBEAM,
           :HYDROPUMP,
           :HURRICANE
        ]
        [email protected](movelist.length)
        pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
        attacker.pbUseMoveSimple(move)
        return 0
      end
    end
     
    Well, it is similar to Metronome in the sense that Metronome has some moves it doesn't call. The fix to the code is as follows:
    Code:
    class PokeBattle_Move_nnn < PokeBattle_Move [COLOR="Green"]# change to a new function code[/COLOR]
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        movelist=[
           :FIREBLAST,
           :SOLARBEAM,
           :HYDROPUMP,
           :HURRICANE
        ]
        [email protected](movelist.length)
        pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
        attacker.pbUseMoveSimple([COLOR="Red"]movelist[move][/COLOR])
        return 0
      end
    end
     
    Last edited:
    I get this error when I use the move in battle.
    Exception: NoMethodError

    Message: undefined method `*' for :SOLARBEAM:Symbol

    PBMove:48:in `initialize'

    PBMove:86:in `new'

    PBMove:86:in `initialize'

    PokeBattle_Battler:2635:in `new'

    PokeBattle_Battler:2635:in `pbUseMoveSimple'

    PokeBattle_MoveEffects:2724:in `pbEffect'

    PokeBattle_Battler:2803:in `pbUseMove'

    PokeBattle_Battler:2802:in `logonerr'

    PokeBattle_Battler:2802:in `pbUseMove'

    PokeBattle_Battler:2977:in `pbProcessTurn'
     
    Looking at how the function pbUseMoveSimple works, it needs a move ID so try this code:
    Code:
    class PokeBattle_Move_nnn < PokeBattle_Move [COLOR="Green"]# change to a new function code[/COLOR]
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        movelist=[
           :FIREBLAST,
           :SOLARBEAM,
           :HYDROPUMP,
           :HURRICANE
        ]
        [COLOR="Red"][email protected](movelist.length)
        move=getConst(pbMoves,movelist[index])[/COLOR]
        pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
        attacker.pbUseMoveSimple([COLOR="red"]move[/COLOR])
        return 0
      end
    end
     
    Last edited:
    I get this error now, I should mention that I am using an older version of essentials (v15) so it must mean that pbMoves does not exist in this version.
    Exception: NameError

    Message: undefined local variable or method `pbMoves' for #<PokeBattle_Move_218:0x10ff4b60>

    PokeBattle_MoveEffects:2723:in `pbEffect'

    PokeBattle_Battler:2803:in `pbUseMove'

    PokeBattle_Battler:2802:in `logonerr'

    PokeBattle_Battler:2802:in `pbUseMove'

    PokeBattle_Battler:2977:in `pbProcessTurn'

    PokeBattle_Battler:2976:in `logonerr'

    PokeBattle_Battler:2976:in `pbProcessTurn'

    PokeBattle_Battle:2593:in `pbAttackPhase'

    PokeBattle_Battle:2592:in `each'

    PokeBattle_Battle:2592:in `pbAttackPhase'
     
    It does exist, but the method of implementation is a little different. See if this code works:
    Code:
    class PokeBattle_Move_nnn < PokeBattle_Move # change to a new function code
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        movelist=[
           :FIREBLAST,
           :SOLARBEAM,
           :HYDROPUMP,
           :HURRICANE
        ]
        [email protected](movelist.length)
        [COLOR="red"]move=getID(PBMoves,movelist[index])[/COLOR]
        pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
        attacker.pbUseMoveSimple(move)
        return 0
      end
    end
     
    Back
    Top