Deukhoofd bf83b25238
All checks were successful
Build / Build (push) Successful in 58s
Implements AI Switching
2025-07-12 13:03:00 +02:00

27 lines
787 B
C#

using PkmnLib.Dynamic.BattleFlow;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "instruct")]
public class Instruct : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
if (!target.IsUsable)
return;
var battleData = move.User.BattleData;
if (battleData == null)
return;
var lastMoveChoiceByTarget = target.BattleData?.LastMoveChoice;
if (lastMoveChoiceByTarget == null || !battleData.Battle.CanUse(lastMoveChoiceByTarget))
{
move.GetHitData(target, hit).Fail();
return;
}
TurnRunner.ExecuteChoice(battleData.Battle, lastMoveChoiceByTarget);
}
}