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

[Error] Abilities that depend on the target's HP won't activate.

68
Posts
4
Years
    • Seen Nov 9, 2023
    I have no idea why, but for some reason, abilities that depend on the target's HP, like Moxie, Beast Boost, and Wimp Out, won't work in my game. Does anyone know why this could possibly be the case?
     
    285
    Posts
    5
    Years
    • Seen Oct 1, 2023
    Can you send the section of code that deals with one of the abilities that were affected?
     
    68
    Posts
    4
    Years
    • Seen Nov 9, 2023
    Here are 5 abilities that are supposed to activate when a Pokemon faints:
    Code:
    # Moxie
        if user.hasWorkingAbility(:MOXIE) && target.fainted? #user.hp>0 && target.hp<=0
          if user.pbIncreaseStatWithCause(PBStats::ATTACK,1,user,PBAbilities.getName(user.ability))
            PBDebug.log("[Ability triggered] #{user.pbThis}'s Moxie")
          end
        end
        # Battle Bond
        if isConst?(user.species,PBSpecies,:GRENINJA) && user.hasWorkingAbility(:BATTLEBOND)
          if target.fainted? && user.form!=1
            user.form=1
            pbUpdate(true)
            @battle.scene.pbChangePokemon(user,user.pokemon)
            @battle.pbDisplay(_INTL("{1} made a bond with his trainer!",user.pbThis))
            PBDebug.log("[Ability triggered] #{user.pbThis}'s Battle Bond")
            PBDebug.log("[Form changed] #{user.pbThis} changed to form #{self.form}")
          end
        end
        # Beast Boost
        if user.hasWorkingAbility(:BEASTBOOST) && user.hp>0 && target.hp<=0
          if user.attack >= user.defense &&
             user.attack >= user.spatk &&
             user.attack >= user.spdef &&
             user.attack >= user.speed
             if user.pbIncreaseStatWithCause(PBStats::ATTACK,1,user,PBAbilities.getName(user.ability))
              PBDebug.log("[Ability triggered] #{user.pbThis}'s Beast Boost (raising Attack)")
            end
          elsif user.defense >= user.spatk &&
             user.defense >= user.spdef &&
             user.defense >= user.speed &&
             user.defense >= user.attack
             if user.pbIncreaseStatWithCause(PBStats::DEFENSE,1,user,PBAbilities.getName(user.ability))
              PBDebug.log("[Ability triggered] #{user.pbThis}'s Beast Boost (raising Defense)")
            end
          elsif user.spatk >= user.spdef &&
             user.spatk >= user.speed &&
             user.spatk >= user.attack &&
             user.spatk >= user.defense
             if user.pbIncreaseStatWithCause(PBStats::SPATK,1,user,PBAbilities.getName(user.ability))
              PBDebug.log("[Ability triggered] #{user.pbThis}'s Beast Boost (raising Special Attack)")
            end
          elsif user.spdef >= user.speed &&
             user.spdef >= user.spatk &&
             user.spdef >= user.attack &&
             user.spdef >= user.defense
             if user.pbIncreaseStatWithCause(PBStats::SPDEF,1,user,PBAbilities.getName(user.ability))
              PBDebug.log("[Ability triggered] #{user.pbThis}'s Beast Boost (raising Special Defense)")
            end
          elsif user.speed >= user.spdef &&
             user.speed >= user.spatk &&
             user.speed >= user.attack &&
             user.speed >= user.defense
             if user.pbIncreaseStatWithCause(PBStats::SPEED,1,user,PBAbilities.getName(user.ability))
              PBDebug.log("[Ability triggered] #{user.pbThis}'s Beast Boost (raising Speed)")
            end
          end
        end
        # Power of Alchemy, Receiver
        if (user.hasWorkingAbility(:POWEROFALCHEMY) ||
          user.hasWorkingAbility(:RECEIVER)) && @battle.doublebattle &&
            user.pbPartner.fainted?
          usable=false
          abil=user.pbPartner.ability
          if abil>0 &&
                 !isConst?(abil,PBAbilities,:POWEROFALCHEMY) &&
                 !isConst?(abil,PBAbilities,:TRACE) &&
                 !isConst?(abil,PBAbilities,:MULTITYPE) &&
                 !isConst?(abil,PBAbilities,:ILLUSION) &&
                 !isConst?(abil,PBAbilities,:FLOWERGIFT) &&
                 !isConst?(abil,PBAbilities,:IMPOSTER) &&
                 !isConst?(abil,PBAbilities,:STANCECHANGE) &&
                 !isConst?(abil,PBAbilities,:COMATOSE) &&
                 !isConst?(abil,PBAbilities,:BATTLEBOND) &&
                 !isConst?(abil,PBAbilities,:POWERCONSTRUCT) &&
                 !isConst?(abil,PBAbilities,:RECEIVER) &&
                 !isConst?(abil,PBAbilities,:FORECAST) &&
                 !isConst?(abil,PBAbilities,:WONDERGUARD) &&
                 !isConst?(abil,PBAbilities,:DISGUISE) &&
                 !isConst?(abil,PBAbilities,:ZENMODE) &&
                 !isConst?(abil,PBAbilities,:SCHOOLING) &&
                 !isConst?(abil,PBAbilities,:SHIELDSDOWN) &&
                 !isConst?(abil,PBAbilities,:RKSSYSTEM)
                usable=true
          end
          if usable
            abilityname=PBAbilities.getName(abil)
            PBDebug.log("[Ability triggered] #{user.pbThis}'s #{PBAbilities.getName(user.ability)} turned into #{abilityname} from #{user.pbPartner}")
            user.ability=abil
            @battle.pbDisplay(_INTL("{1} copied {2}'s {3}!",user.pbThis,user.pbPartner,abilityname))
          end
        end
    And here are 2 abilities that are supposed to activate when a Pokemon's HP is under half:
    Code:
    # Wimp Out/ Emergency Exit
          if (target.hasWorkingAbility(:WIMPOUT) || target.hasWorkingAbility(:EMERGENCYEXIT)) &&
             !target.effects[PBEffects::SkyDrop] && thismove.function!=0x0EC # Circle Throw, Dragon Tail
            if target.hp+turneffects[PBEffects::TotalDamage]>(target.totalhp/2).floor && 
               target.hp<=(target.totalhp/2).floor
              PBDebug.log("[Ability triggered] #{target.pbThis}'s #{PBAbilities.getName(target.ability)}")
              if [email protected]
                pbSEPlay("Battle flee"); @battle.pbDisplay(_INTL("{1} fled!",target.pbThis))
                for i in 0...4
                  @battle.choices[@battle.battlers[i].index][0]=-1
                end
                @battle.decision=3
                PBDebug.log("[Escape] #{target.pbThis} fled")
              else
                if @battle.pbCanSwitch?(target.index,-1,false) && [email protected]?(@battle.pbParty(target.index))
                  newpoke=0
                  [email protected](target.index,true,false)
                  newpokename=newpoke
                  if isConst?(@battle.pbParty(target.index)[newpoke].ability,PBAbilities,:ILLUSION)
                    newpokename=pbGetLastPokeInTeam(target.index)
                  end
                  target.pbResetForm
                  @battle.pbRecallAndReplace(target.index,newpoke,newpokename)
                  @battle.choices[target.index]=[0,0,nil,-1]   # Replacement Pokémon does nothing this round
                  target.pbAbilitiesOnSwitchIn(true)
                end
              end
            end
          end
        end
    For some reason, none of these will activate in my game.
     
    68
    Posts
    4
    Years
    • Seen Nov 9, 2023
    Do you see anything wrong with these codes?
    (By the way, I'm sorry about posting it twice. I'm not really used to posting on forums.)
     
    285
    Posts
    5
    Years
    • Seen Oct 1, 2023
    I don't see anything wrong with these codes, so there must be a problem in methods checking the HP of Pokemon. Does this also affect items like with Sitrus Berry or is it only affecting abilities.
     
    68
    Posts
    4
    Years
    • Seen Nov 9, 2023
    I don't see anything wrong with these codes, so there must be a problem in methods checking the HP of Pokemon. Does this also affect items like with Sitrus Berry or is it only affecting abilities.

    It only seems to be affecting abilities. I tested to see if Sitrus Berries worked, and they do (however, they don't eat them until the very end of the turn; I'm not sure if it's supposed to be that way)
     
    285
    Posts
    5
    Years
    • Seen Oct 1, 2023
    That's odd. Assuming Moxie, Beast Boost, etc. are in the pbEffectsAfterHit method and Wimp Out/Emergency Exit are in the pbProcessMoveAgainstTarget method, I'm not sure what would cause this. Though I'm not an expert on these scripts, so someone else might see something that I don't.
     
    68
    Posts
    4
    Years
    • Seen Nov 9, 2023
    That's odd. Assuming Moxie, Beast Boost, etc. are in the pbEffectsAfterHit method and Wimp Out/Emergency Exit are in the pbProcessMoveAgainstTarget method, I'm not sure what would cause this. Though I'm not an expert on these scripts, so someone else might see something that I don't.

    I'm guessing that pbEffectsAfterHit is affected by another part of the script that I may have accidentally messed up. I'm hoping that somebody knows what parts of the script I should check to make sure all these abilities are working.
     
    Back
    Top