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

Adding a new move effect

  • 9
    Posts
    9
    Years
    • Seen Jan 31, 2015
    hey guys,
    i would really like to have a move which lowers one random stat of the enemy by one stage.
    Does anyone know what i would have to put in the move effect section for this?
    It would be really nice if someone could help me out with this . ;D ;D
     

    SoulfulLex

    Empiricist-at-Large
  • 10
    Posts
    10
    Years
    • Seen Aug 19, 2019
    In my opinion, making new move effects should warrant a page or topic on the wiki.

    In your case, you can make use of the case rnd and pbRandom(X) in the effect, where X represents how many cases there are. In the event of lowering a random stat, you'll want to make X either 5 (Attack, Defense, Sp. Atk, Sp. Def, and Speed) or 7 (if you want to include Accuracy and Evasion). This way, whenever the attack lands, the effect will choose one of the cases (i.e. Stat-Lowering codes defined) and follow what's there. Also, since this is an added effect, the def should be AdditionalEffect.

    Taking a look at the Function code for Tri Attack and Secret Power should give you an idea of how to do similar things.

    Tl;dr - Something like this:

    Code:
    ################################################################################
    # Decreases a target's stat at random by 1 stage.
    ################################################################################
    class PokeBattle_Move_### < PokeBattle_Move
      def pbAdditionalEffect(attacker,opponent)
        [email protected](7)
        case rnd
          when 0
            return false if !opponent.pbCanReduceStatStage?(PBStats::ATTACK,1,false)
            opponent.pbReduceStat(PBStats::ATTACK,1,false)
          when 1
            return false if !opponent.pbCanReduceStatStage?(PBStats::DEFENSE,1,false)
            opponent.pbReduceStat(PBStats::DEFENSE,1,false)
          when 2
            return false if !opponent.pbCanReduceStatStage?(PBStats::SPATK,1,false)
            opponent.pbReduceStat(PBStats::SPATK,1,false)
          when 3
            return false if !opponent.pbCanReduceStatStage?(PBStats::SPDEF,1,false)
            opponent.pbReduceStat(PBStats::SPDEF,1,false)
          when 4
            return false if !opponent.pbCanReduceStatStage?(PBStats::SPEED,1,false)
            opponent.pbReduceStat(PBStats::SPEED,1,false)
          when 5
            return false if !opponent.pbCanReduceStatStage?(PBStats::ACCURACY,1,false)
            opponent.pbReduceStat(PBStats::ACCURACY,1,false)
          when 6
            return false if !opponent.pbCanReduceStatStage?(PBStats::EVASION,1,false)
            opponent.pbReduceStat(PBStats::EVASION,1,false)
        end
        return true
      end
    end
    This would go in PokeBattle_MoveEffects at the bottom, with the "###" in class PokeBattle_Move_### being assigned a hex number above 132 (like 133, 134, 13A, 1A3, etc. but it's easier to assign numbers in sequential order)

    There is probably a more concise version that can be written (i.e. One that uses an array to represent stat selection), but it should get the job done. Good luck.
     
  • 9
    Posts
    9
    Years
    • Seen Jan 31, 2015
    Hey, first off all thank you very much for your quick and helpful reply. ;D;D;D
    I still have one problem now, the attack seems to not lower the enemy stat, atleast i dont get a message saying : xxx`s Attack was lowed !
    What would i have to do so this would also work?
     
  • 1,224
    Posts
    10
    Years
    Hey, first off all thank you very much for your quick and helpful reply. ;D;D;D
    I still have one problem now, the attack seems to not lower the enemy stat, atleast i dont get a message saying : xxx`s Attack was lowed !
    What would i have to do so this would also work?

    This is coding for an additional effect chance. Add this inside the class to be the move's effect

    Code:
    def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        return super(attacker,opponent,hitnum,alltargets,showanimation) if @basedamage>0
         [email protected](7)
        case rnd
          when 0
            return -1 if !attacker.pbCanIncreaseStatStage?(PBStats::ATTACK,true)
            pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
            ret=attacker.pbIncreaseStat(PBStats::ATTACK,1,false)
            return ret ? 0 : -1
          when 1
            return -1 if !attacker.pbCanIncreaseStatStage?(PBStats::DEFENSE,true)
            pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
            ret=attacker.pbIncreaseStat(PBStats::DEFENSE,1,false)
            return ret ? 0 : -1
          when 2
            return -1 if !attacker.pbCanIncreaseStatStage?(PBStats::SPATK,true)
            pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
            ret=attacker.pbIncreaseStat(PBStats::SPATK,1,false)
            return ret ? 0 : -1
          when 3
            return -1 if !attacker.pbCanIncreaseStatStage?(PBStats::SPDEF,true)
            pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
            ret=attacker.pbIncreaseStat(PBStats::SPDEF,1,false)
            return ret ? 0 : -1
          when 4
            return -1 if !attacker.pbCanIncreaseStatStage?(PBStats::SPEED,true)
            pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
            ret=attacker.pbIncreaseStat(PBStats::SPEED,1,false)
            return ret ? 0 : -1
          when 5
            return -1 if !attacker.pbCanIncreaseStatStage?(PBStats::ACCURACY,true)
            pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
            ret=attacker.pbIncreaseStat(PBStats::ACCURACY,1,false)
            return ret ? 0 : -1
          when 6
            return -1 if !attacker.pbCanIncreaseStatStage?(PBStats::EVASION,true)
            pbShowAnimation(@id,attacker,opponent,hitnum,alltargets,showanimation)
            ret=attacker.pbIncreaseStat(PBStats::EVASION,1,false)
            return ret ? 0 : -1
        end
      end

    Untested. You could also just set the move's additional effect chance to 100 instead.

    Edit: Question for anybody who knows: why do these things use pbRandom, when it literally just returns rand(x) and you could do that without using/writing a new method for it?
     
  • 9
    Posts
    9
    Years
    • Seen Jan 31, 2015
    I think you should change something in this code.
    I dont see the moves animation anymore and the move doesnt deal damage anymore using your code. (no flame) :D
    Also there doesnt appear any text to say which stat was lowered .
    Is there any possibility to change the first code the way, that there appear texts to show which stat is lowered?
    Cause the first code seems to probably work fine .:D

     

    SoulfulLex

    Empiricist-at-Large
  • 10
    Posts
    10
    Years
    • Seen Aug 19, 2019
    Edit: Question for anybody who knows: why do these things use pbRandom, when it literally just returns rand(x) and you could do that without using/writing a new method for it?

    I just use what's there in the code. I'm a novice at best when it comes to writing code, but I understand existing syntax. That's why I just reuse it, more or less. I didn't see how I could make a pbEffect in this case since Tri-Attack (the effect I based my post on) didn't have one.


    Is there any possibility to change the first code the way, that there appear texts to show which stat is lowered?
    Cause the first code seems to probably work fine .:D

    I retested it in Vanilla Essentials, and I don't have any problems with it on my end. The message should show up when the stat-lowering occurs.

    As for how I have it set up in moves.txt:
    Code:
    560,ALPHASTRIKE,Alpha Strike,155,40,NORMAL,Physical,100,10,100,00,0,abe,Cute,Randomly lowers a target's stat.

    The "155" is the move effect number I assigned to it, while the second "100" makes it so that the additional effect always happens.
     

    Maruno

    Lead Dev of Pokémon Essentials
  • 5,286
    Posts
    16
    Years
    • Seen May 3, 2024
    In my opinion, making new move effects should warrant a page or topic on the wiki.
    In my opinion, there are hundreds of examples of move effects to reference, and this wiki page already exists.

    For this particular effect, Acupressure (code 37) is a good move to look at (although it's a status move rather than Lex's damaging move, so Lex's move would need to use pbAdditionalEffect).

    Code:
      def pbAdditionalEffect(attacker,opponent)
        array=[]
        for i in [PBStats::ATTACK,PBStats::DEFENSE,PBStats::SPEED,
                  PBStats::SPATK,PBStats::SPDEF,PBStats::ACCURACY,PBStats::EVASION]
          array.push(i) if opponent.pbCanReduceStatStage?(i)
        end
        return if array.length==0   # Can't lower any stat
        stat=array[@battle.pbRandom(array.length)]
        opponent.pbReduceStat(stat,1,true)
      end
     
    Back
    Top