namespace PkmnLib.Plugin.Gen7.Scripts.Abilities; /// /// Innards Out is an ability that deals damage to the attacker equal to the amount of HP lost when the Pokémon with this ability faints. /// /// Bulbapedia - Innards Out /// [Script(ScriptCategory.Ability, "innards_out")] public class InnardsOut : Script, IScriptOnIncomingHit, IScriptOnDamage { private IPokemon? _lastPokemonToHit; /// public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit) { _lastPokemonToHit = move.User; } /// public void OnDamage(IPokemon pokemon, DamageSource source, uint oldHealth, uint newHealth) { if (newHealth != 0 || source is not DamageSource.MoveDamage) return; if (_lastPokemonToHit is null || !_lastPokemonToHit.IsUsable) return; EventBatchId batchId = new(); pokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon) { BatchId = batchId, }); _lastPokemonToHit.Damage(oldHealth, DamageSource.Misc, batchId); } }