More abilities, refactor custom triggers to be typed.
All checks were successful
Build / Build (push) Successful in 48s
All checks were successful
Build / Build (push) Successful in 48s
This commit is contained in:
28
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/MistySurge.cs
Normal file
28
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/MistySurge.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
|
||||
/// <summary>
|
||||
/// Misty Surge is an ability that creates Misty Terrain when the Pokémon enters battle.
|
||||
///
|
||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Misty_Surge_(Ability)">Bulbapedia - Misty Surge</see>
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Ability, "misty_surge")]
|
||||
public class MistySurge : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
{
|
||||
if (pokemon.BattleData?.Battle is null)
|
||||
return;
|
||||
|
||||
var terrainName = ScriptUtils.ResolveName<Terrain.MistyTerrain>();
|
||||
if (pokemon.BattleData.Battle.TerrainName == terrainName)
|
||||
return;
|
||||
|
||||
EventBatchId batchId = new();
|
||||
pokemon.BattleData.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
|
||||
{
|
||||
BatchId = batchId,
|
||||
});
|
||||
pokemon.BattleData.Battle.SetTerrain(terrainName, batchId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user