• 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.

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

24
Posts
10
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?
     
    188
    Posts
    9
    Years
    • Seen Jan 21, 2024
    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
     
    188
    Posts
    9
    Years
    • Seen Jan 21, 2024
    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:
    24
    Posts
    10
    Years
    • Seen Jul 5, 2018
    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'
     
    188
    Posts
    9
    Years
    • Seen Jan 21, 2024
    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:
    24
    Posts
    10
    Years
    • Seen Jul 5, 2018
    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'
     
    188
    Posts
    9
    Years
    • Seen Jan 21, 2024
    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