• 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!
  • Akari, Selene, Mint, Solana - which Pokémon protagonist is your favorite? Let us know by voting in our 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.

Creating a move that poisons the user if you're poisoned

  • 143
    Posts
    11
    Years
    • Seen Jun 11, 2021
    I'm having difficulty trying to create a new move. It's supposed to poison the opponent, but only if you're poisoned. It also has a chance to slow the opponent down. However, when I try to use it, it doesn't work. Here's what the code looks like:
    Code:
    ################################################################################
    # If user is poisoned, then it poisons the foe. (Sneeze)
    ################################################################################
    class PokeBattle_Move_159 < PokeBattle_Move
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        return false if !opponent.pbCanPoison?(attacker,false,self)
        if attacker.status==PBStatuses::POISON && opponent.status!=PBStatuses::POISON
        opponent.pbPoison(attacker)
        @battle.pbDisplay(_INTL("{1} was poisoned!",opponent.pbThis))
        return true
        end
      end
    
      def pbAdditionalEffect(attacker,opponent)
        if opponent.pbCanReduceStatStage?(PBStats::SPEED,false)
          opponent.pbReduceStat(PBStats::SPEED,1,false)
        end
        return true
      end
    end
    Can anyone help me clean it up?
     
    I'm having difficulty trying to create a new move. It's supposed to poison the opponent, but only if you're poisoned. It also has a chance to slow the opponent down. However, when I try to use it, it doesn't work. Here's what the code looks like:
    Code:
    ################################################################################
    # If user is poisoned, then it poisons the foe. (Sneeze)
    ################################################################################
    class PokeBattle_Move_159 < PokeBattle_Move
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        success=false
        if attacker.status==PBStatuses::POISON && opponent.pbCanPoison?(attacker,false,self)
          opponent.pbPoison(attacker)
          @battle.pbDisplay(_INTL("{1} was poisoned!",opponent.pbThis))
          success=true
    [COLOR="Blue"]    end[/COLOR]
        if opponent.pbCanReduceStatStage?(PBStats::SPEED,false) && rand(100)<[COLOR="Red"]chance[/COLOR]
          opponent.pbReduceStat(PBStats::SPEED,1,false)
    [COLOR="blue"]      success=true[/COLOR]
    [COLOR="Lime"]    end[/COLOR]
        return success
      end
    end
    Can anyone help me clean it up?

    pbAdditionalEffect will only trigger for damaging moves. Change the red "chance" to the actual chance you want the move to have of making the target's Speed drop, and it should work.

    If you want the Speed drop to only happen if the target gets poisoned, then get rid of the blue lines and add a second end after the green one.
     
    Last edited:
    That's the thing though. It actually is meant to be a damaging move. Not a strong one, but still, a damaging move.
     
    This could do the job.
    Code:
    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.status==PBStatuses::POISON && opponent.status!=PBStatuses::POISON &&
          opponent.pbCanPoison?(attacker,true,self)
          opponent.pbPoison(attacker,_INTL("{1} was poisoned!",opponent.pbThis)) if !opponent.isFainted?
        end
        return ret
      end
    
      def pbAdditionalEffect(attacker,opponent)
        if opponent.pbCanReduceStatStage?(PBStats::SPEED,attacker,false,self)
          opponent.pbReduceStat(PBStats::SPEED,2,attacker,false,self)
        end
        return true
      end
    end
     
    Last edited:
    Tested the code out. It worked while poisoned, but then this error popped up:
    Code:
    Exception: ArgumentError
    
    Message: wrong number of arguments(3 for 4)
    
    PokeBattle_MoveEffects:1334:in `pbReduceStat'
    
    PokeBattle_MoveEffects:1334:in `pbAdditionalEffect'
    
    PokeBattle_Battler:2738:in `pbProcessMoveAgainstTarget'
    
    PokeBattle_Battler:2661:in `each'
    
    PokeBattle_Battler:2661:in `pbProcessMoveAgainstTarget'
    
    PokeBattle_Battler:3149:in `pbUseMove'
    
    PokeBattle_Battler:3129:in `loop'
    
    PokeBattle_Battler:3152:in `pbUseMove'
    
    PokeBattle_Battler:3348:in `pbProcessTurn'
    
    PokeBattle_Battler:3347:in `logonerr'
    Also tested it while not poisoned, and it just went straight into the enemy's turn instead.
     
    My mistake. I used an old version of the def pbReduceStats. I updated the post and now it should work.
    Thanks! That fixed the second problem I have, but the move's still not doing anything when the user's not poisoned.
     
    Back
    Top