- 5
- Posts
- 7
- 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?
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)
}
)
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)
}
)
Hey,
Look at the code that defines Intimidate in the file BattleHandlers_Abilities:
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.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) } )
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.
BattleHandlers::AbilityOnSwitchIn.add(:STUNSHOCK,
proc { |ability,battler,battle|
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 :)
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
}
)