27 lines
807 B
C#
27 lines
807 B
C#
|
using System.Linq;
|
||
|
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();
|
||
|
}
|
||
|
}
|