42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using PkmnLib.Plugin.Gen7.Scripts.MoveVolatile;
|
|
using PkmnLib.Plugin.Gen7.Scripts.Utils;
|
|
using PkmnLib.Static.Moves;
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
|
|
|
[Script(ScriptCategory.Move, "me_first")]
|
|
public class MeFirst : Script, IScriptChangeMove
|
|
{
|
|
/// <inheritdoc />
|
|
public void ChangeMove(IMoveChoice choice, ref StringKey moveName)
|
|
{
|
|
var battleData = choice.User;
|
|
if (battleData == null)
|
|
return;
|
|
|
|
var target = battleData.Battle.Sides[choice.TargetSide].Pokemon[choice.TargetPosition];
|
|
if (target == null)
|
|
{
|
|
choice.Fail();
|
|
return;
|
|
}
|
|
if (battleData.Battle.ChoiceQueue?.FirstOrDefault(x => x.User == target) is not IMoveChoice
|
|
{
|
|
ChosenMove.MoveData.Category: MoveCategory.Physical or MoveCategory.Special,
|
|
} targetMove)
|
|
{
|
|
choice.Fail();
|
|
return;
|
|
}
|
|
if (!targetMove.ChosenMove.MoveData.CanCopyMove() ||
|
|
targetMove.ChosenMove.MoveData.Name == MoveNames.MetalBurst ||
|
|
battleData.Battle.Library.MiscLibrary.IsReplacementChoice(targetMove))
|
|
{
|
|
choice.Fail();
|
|
return;
|
|
}
|
|
var targetMoveData = targetMove.ChosenMove.MoveData;
|
|
moveName = targetMoveData.Name;
|
|
choice.Volatile.Add(new MeFirstPowerBoost());
|
|
}
|
|
} |