30 lines
922 B
C#
30 lines
922 B
C#
using System.Linq;
|
|
using PkmnLib.Dynamic.Models;
|
|
using PkmnLib.Dynamic.ScriptHandling;
|
|
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
|
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
|
|
|
[Script(ScriptCategory.Move, "bide")]
|
|
public class Bide : Script
|
|
{
|
|
/// <inheritdoc />
|
|
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
|
{
|
|
var bideEffect = move.User.Volatile.Get<BideEffect>();
|
|
if (bideEffect == null)
|
|
{
|
|
bideEffect = new BideEffect(move.User);
|
|
move.User.Volatile.Add(bideEffect);
|
|
}
|
|
|
|
bideEffect.Turns += 1;
|
|
if (bideEffect.Turns < 2)
|
|
return;
|
|
var lastPokemon = bideEffect.HitBy.LastOrDefault(x => x.BattleData?.IsOnBattlefield == true);
|
|
lastPokemon?.Damage(bideEffect.DamageTaken, DamageSource.MoveDamage);
|
|
|
|
RemoveSelf();
|
|
}
|
|
} |