More abilities
This commit is contained in:
35
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/InnardsOut.cs
Normal file
35
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/InnardsOut.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
///
|
||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Innards_Out_(Ability)">Bulbapedia - Innards Out</see>
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Ability, "innards_out")]
|
||||
public class InnardsOut : Script
|
||||
{
|
||||
private IPokemon? _lastPokemonToHit;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
_lastPokemonToHit = move.User;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user