More abilities
This commit is contained in:
28
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Intimidate.cs
Normal file
28
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Intimidate.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user