40 lines
943 B
C#
40 lines
943 B
C#
using PkmnLib.Static.Moves;
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Scripts.Side;
|
|
|
|
[Script(ScriptCategory.Side, "reflect")]
|
|
public class ReflectEffect(int turns) : Script
|
|
{
|
|
private int _turns = turns;
|
|
|
|
/// <inheritdoc />
|
|
public override void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
|
|
{
|
|
var hitData = move.GetHitData(target, hit);
|
|
if (move.UseMove.Category != MoveCategory.Physical)
|
|
return;
|
|
if (hitData.IsCritical)
|
|
return;
|
|
switch (move.Battle.PositionsPerSide)
|
|
{
|
|
case 1:
|
|
damage /= 2;
|
|
break;
|
|
default:
|
|
damage *= 2 / 3;
|
|
break;
|
|
}
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void OnEndTurn(IBattle battle)
|
|
{
|
|
if (_turns > 0)
|
|
{
|
|
_turns--;
|
|
return;
|
|
}
|
|
|
|
RemoveSelf();
|
|
}
|
|
} |