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