28 lines
1.0 KiB
C#
28 lines
1.0 KiB
C#
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|
|
|
/// <summary>
|
|
/// Intimidate is an ability that lowers the opposing Pokémon's Attack stat when the Pokémon enters battle.
|
|
///
|
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Intimidate_(Ability)">Bulbapedia - Intimidate</see>
|
|
/// </summary>
|
|
[Script(ScriptCategory.Ability, "intimidate")]
|
|
public class Intimidate : Script
|
|
{
|
|
/// <inheritdoc />
|
|
public override void OnSwitchIn(IPokemon pokemon, byte position)
|
|
{
|
|
var battle = pokemon.BattleData?.Battle;
|
|
if (battle is null)
|
|
return;
|
|
|
|
var opponents = battle.Sides.Where(side => side != pokemon.BattleData?.BattleSide)
|
|
.SelectMany(side => side.Pokemon).WhereNotNull().Where(opponent => opponent.IsUsable);
|
|
EventBatchId batchId = new();
|
|
|
|
battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
|
|
foreach (var opponent in opponents)
|
|
{
|
|
opponent.ChangeStatBoost(Statistic.Attack, -1, true, true, batchId);
|
|
}
|
|
}
|
|
} |