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

[Scripting Question] An ability like intimidate that causes a status ailment when switching in?

  • 5
    Posts
    6
    Years
    • Seen Oct 10, 2021
    Does anyone know how to script an ability that works like Intimidate, where when the user is sent into battle it triggers the ability, but instead of lowering a stat it causes paralysis or poison?
     

    StCooler

    Mayst thou thy peace discover.
  • 9,304
    Posts
    4
    Years
    • Seen yesterday
    Hey,
    Look at the code that defines Intimidate in the file BattleHandlers_Abilities:
    Code:
    BattleHandlers::AbilityOnSwitchIn.add(:INTIMIDATE,
      proc { |ability,battler,battle|
        battle.pbShowAbilitySplash(battler)
        battle.eachOtherSideBattler(battler.index) do |b|
          next if !b.near?(battler)
          b.pbLowerAttackStatStageIntimidate(battler)
          b.pbItemOnIntimidatedCheck
        end
        battle.pbHideAbilitySplash(battler)
      }
    )
    Basically this code says that Intimidate activates on switching in ("AbilityOnSwitchIn"). In the body of the code, it displays the ability (with the function "pbShowAbilitySplash"), then it intimidates all POkémons, and it hides the ability thing.

    Also, you can look for the code for STATIK for example:
    Code:
    BattleHandlers::TargetAbilityOnHit.add(:STATIC,
      proc { |ability,user,target,move,battle|
        next if !move.pbContactMove?(user)
        next if user.paralyzed? || battle.pbRandom(100)>=30
        battle.pbShowAbilitySplash(target)
        if user.pbCanParalyze?(target,PokeBattle_SceneConstants::USE_ABILITY_SPLASH) &&
           user.affectedByContactEffect?(PokeBattle_SceneConstants::USE_ABILITY_SPLASH)
          msg = nil
          if !PokeBattle_SceneConstants::USE_ABILITY_SPLASH
            msg = _INTL("{1}'s {2} paralyzed {3}! It may be unable to move!",
               target.pbThis,target.abilityName,user.pbThis(true))
          end
          user.pbParalyze(target,msg)
        end
        battle.pbHideAbilitySplash(target)
      }
    )

    Then you can combine those two codes :)

    Do you need more detail?
     
  • 5
    Posts
    6
    Years
    • Seen Oct 10, 2021
    Hey,
    Look at the code that defines Intimidate in the file BattleHandlers_Abilities:
    Code:
    BattleHandlers::AbilityOnSwitchIn.add(:INTIMIDATE,
      proc { |ability,battler,battle|
        battle.pbShowAbilitySplash(battler)
        battle.eachOtherSideBattler(battler.index) do |b|
          next if !b.near?(battler)
          b.pbLowerAttackStatStageIntimidate(battler)
          b.pbItemOnIntimidatedCheck
        end
        battle.pbHideAbilitySplash(battler)
      }
    )
    Basically this code says that Intimidate activates on switching in ("AbilityOnSwitchIn"). In the body of the code, it displays the ability (with the function "pbShowAbilitySplash"), then it intimidates all POkémons, and it hides the ability thing.

    Also, you can look for the code for STATIK for example:
    Code:
    BattleHandlers::TargetAbilityOnHit.add(:STATIC,
      proc { |ability,user,target,move,battle|
        next if !move.pbContactMove?(user)
        next if user.paralyzed? || battle.pbRandom(100)>=30
        battle.pbShowAbilitySplash(target)
        if user.pbCanParalyze?(target,PokeBattle_SceneConstants::USE_ABILITY_SPLASH) &&
           user.affectedByContactEffect?(PokeBattle_SceneConstants::USE_ABILITY_SPLASH)
          msg = nil
          if !PokeBattle_SceneConstants::USE_ABILITY_SPLASH
            msg = _INTL("{1}'s {2} paralyzed {3}! It may be unable to move!",
               target.pbThis,target.abilityName,user.pbThis(true))
          end
          user.pbParalyze(target,msg)
        end
        battle.pbHideAbilitySplash(target)
      }
    )

    Then you can combine those two codes :)

    Do you need more detail?

    I tried combining the two codes before, but I kept getting error messages whenever the user is sent into battle. This is the code I have for the ability.

    BattleHandlers::AbilityOnSwitchIn.add( :STUNSHOCK,
    proc { |ability,battler,target,battle|
    battle.pbShowAbilitySplash(battler)
    battle.eachOtherSideBattler(battler.index) do |b|
    next if !b.near?(battler)
    if target.pbCanParalyze?(battler,PokeBattle_SceneConstants::USE_ABILITY_SPLASH)
    msg = nil
    if !PokeBattle_SceneConstants::USE_ABILITY_SPLASH
    msg = _INTL("{1}'s {2} paralyzed the foe! It may be unable to move!",
    battler.pbThis,battler.abilityName)
    end
    battler.pbParalyze(target,msg)
    end
    battle.pbHideAbilitySplash(battler)
    end
    }
    )

    I have a feeling that there's an issue with the way the battler object is being used, but I don't know how to fix it.
     
    Last edited:

    StCooler

    Mayst thou thy peace discover.
  • 9,304
    Posts
    4
    Years
    • Seen yesterday
    I tried combining the two codes before, but I kept getting error messages whenever the user is sent into battle. This is the code I have for the ability.

    BattleHandlers::AbilityOnSwitchIn.add( :STUNSHOCK,
    proc { |ability,battler,target,battle|
    battle.pbShowAbilitySplash(battler)
    battle.eachOtherSideBattler(battler.index) do |b|
    next if !b.near?(battler)
    if target.pbCanParalyze?(battler,PokeBattle_SceneConstants::USE_ABILITY_SPLASH)
    msg = nil
    if !PokeBattle_SceneConstants::USE_ABILITY_SPLASH
    msg = _INTL("{1}'s {2} paralyzed the foe! It may be unable to move!",
    battler.pbThis,battler.abilityName)
    end
    battler.pbParalyze(target,msg)
    end
    battle.pbHideAbilitySplash(battler)
    end
    }
    )

    I have a feeling that there's an issue with the way the battler object is being used, but I don't know how to fix it.

    It's because it's the wrong combination. A battle handler is a kind of dictionary that associates an ability constant (here :STUNSHOCK) to an function (here, the "proc" thing), and that function needs to have the right format (the right signature).
    Two different battle handlers AbilityOnSwitchIn and TargetAbilityOnHit take different functions. In particular, there is no "target" when you switch in, so it makes no sense to have a function with an argument called "target" in an AbilityOnSwitchIn handler.

    So, the first lines of your ability should be from AbilityOnSwitchIn:
    Code:
    BattleHandlers::AbilityOnSwitchIn.add(:STUNSHOCK,
      proc { |ability,battler,battle|

    So basically you need to use the "frame" of Intimidate, but instead of intimidating battlers, you only have to paralyse.

    Now try again :)
     
  • 5
    Posts
    6
    Years
    • Seen Oct 10, 2021
    It's because it's the wrong combination. A battle handler is a kind of dictionary that associates an ability constant (here :STUNSHOCK) to an function (here, the "proc" thing), and that function needs to have the right format (the right signature).
    Two different battle handlers AbilityOnSwitchIn and TargetAbilityOnHit take different functions. In particular, there is no "target" when you switch in, so it makes no sense to have a function with an argument called "target" in an AbilityOnSwitchIn handler.

    So, the first lines of your ability should be from AbilityOnSwitchIn:
    Code:
    BattleHandlers::AbilityOnSwitchIn.add(:STUNSHOCK,
      proc { |ability,battler,battle|

    So basically you need to use the "frame" of Intimidate, but instead of intimidating battlers, you only have to paralyse.

    Now try again :)

    I got it to work (after accidentally making myself paralyzed a few times), thank you so much for your help, it has been invaluable! If anyone is searching for code that functions like this and stumbles upon this forum post, I will attach my code to this.


    BattleHandlers::AbilityOnSwitchIn.add(ABILITYNAME,
    proc { |ability,battler,battle|
    battle.pbShowAbilitySplash(battler)
    battle.eachOtherSideBattler(battler.index) do |b|
    next if !b.near?(battler)
    if b.pbCanParalyze?(battler,PokeBattle_SceneConstants::USE_ABILITY_SPLASH)
    msg = nil
    if !PokeBattle_SceneConstants::USE_ABILITY_SPLASH
    msg = _INTL("{1}'s {2} paralyzed the foe! It may be unable to move!",
    battler.pbThis,battler.abilityName)
    end
    b.pbParalyze(msg)
    end
    battle.pbHideAbilitySplash(battler)
    end
    }
    )
     
    Back
    Top