2025-06-28 12:02:24 +02:00

30 lines
1.0 KiB
C#

using PkmnLib.Static.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary>
/// Stance Change is an ability that changes Aegislash's form depending on the move used.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Stance_Change_(Ability)">Bulbapedia - Stance Change</see>
/// </summary>
[Script(ScriptCategory.Ability, "stance_change")]
public class StanceChange : Script, IScriptOnBeforeMove
{
/// <inheritdoc />
public void OnBeforeMove(IExecutingMove move)
{
if (move.User.Species.Name != "aegislash")
return;
if (move.UseMove.Category is not (MoveCategory.Physical or MoveCategory.Special) ||
move.User.Form.Name == "blade" || !move.User.Species.TryGetForm("blade", out var bladeForm))
return;
EventBatchId batchId = new();
move.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User)
{
BatchId = batchId,
});
move.User.ChangeForm(bladeForm, batchId);
// Kings shield is handled in the move script.
}
}