• 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!
  • Dawn, Gloria, Juliana, or Summer - 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.

[Scripting Question] Strength Sap not taking stat stages into account

  • 79
    Posts
    9
    Years
    • Seen Jan 12, 2024
    Hello, using the following script will successfully heal based on the opponent's attack, and then lower it 1 stage.

    Code:
    class PokeBattle_Move_CF13 < PokeBattle_Move
      def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
        if attacker.effects[PBEffects::HealBlock]>0
          bob="heal"
          bob=_INTL("use {1}",name) if !opponent.pbCanReduceStatStage?(PBStats::ATTACK,true,false,attacker)
          @battle.pbDisplay(_INTL("{1} can't {2} because of Heal Block!",attacker.pbThis,bob))
          return -1 if !opponent.pbCanReduceStatStage?(PBStats::ATTACK,true,false,attacker)
        elsif attacker.hp==attacker.totalhp
          @battle.pbDisplay(_INTL("{1}'s HP is full!",attacker.pbThis))
          return -1 if !opponent.pbCanReduceStatStage?(PBStats::ATTACK,true,false,attacker)
        else
          oatk=opponent.attack
          attacker.pbRecoverHP(oatk,true)
          @battle.pbDisplay(_INTL("{1}'s HP was restored.",attacker.pbThis))
        end
        if opponent.pbCanReduceStatStage?(PBStats::ATTACK,true,false,attacker)
          opponent.pbReduceStat(PBStats::ATTACK,1,true,true,false,attacker)
        end
        return 0
      end
    end

    However, it doesn't appear to take stat changes into account, so using Strength Sap repeatedly doesn't decrease the amount of HP it heals. How do I go about fixing this?
     
    Back
    Top