Files
PkmnLib.NET/Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/MetalBurst.cs
Deukhoofd d2a82b5fe3
All checks were successful
Build / Build (push) Successful in 3m12s
Many more tests and fixes
2026-08-27 17:11:12 +02:00

62 lines
1.8 KiB
C#

using PkmnLib.Static.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "metal_burst")]
public class MetalBurst : Script, IScriptOnBeforeTurnStart, IScriptChangeTargets, IScriptChangeMoveDamage
{
/// <inheritdoc />
public void OnBeforeTurnStart(ITurnChoice choice)
{
choice.User.Volatile.Add(new MetalBurstHelper());
}
/// <inheritdoc />
public void ChangeTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
{
var helper = moveChoice.User.Volatile.Get<MetalBurstHelper>();
var lastAttacker = helper?.LastAttacker;
if (lastAttacker == null)
{
moveChoice.Fail();
return;
}
targets = [lastAttacker];
}
/// <inheritdoc />
public void ChangeMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
{
var helper = move.User.Volatile.Get<MetalBurstHelper>();
if (helper?.LastAttacker == null || helper.LastAttacker != target)
{
move.GetHitData(target, hit).Fail();
return;
}
damage = helper.LastDamage.MultiplyOrMax(1.5f);
}
[Script(ScriptCategory.Pokemon, "metal_burst_helper")]
private class MetalBurstHelper : Script, IScriptOnIncomingHit, IScriptOnEndTurn
{
public IPokemon? LastAttacker { get; set; }
public uint LastDamage { get; set; }
/// <inheritdoc />
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
{
if (move.UseMove.Category == MoveCategory.Status)
return;
LastAttacker = move.User;
LastDamage = move.GetHitData(target, hit).Damage;
}
/// <inheritdoc />
public void OnEndTurn(IScriptSource owner, IBattle battle)
{
RemoveSelf();
}
}
}