Fixes, tests for Aftermath
All checks were successful
Build / Build (push) Successful in 1m53s

This commit is contained in:
2026-01-09 15:17:54 +01:00
parent 123c3773d2
commit 391edd98f1
3 changed files with 429 additions and 16 deletions

View File

@@ -9,12 +9,14 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
[Script(ScriptCategory.Ability, "aftermath")]
public class Aftermath : Script, IScriptOnIncomingHit, IScriptOnFaint
{
private static readonly StringKey DampAbilityName = new("damp");
private IExecutingMove? _lastAttack;
/// <inheritdoc />
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
{
_lastAttack = !move.GetHitData(target, hit).IsContact ? move : null;
_lastAttack = move.GetHitData(target, hit).IsContact ? move : null;
}
/// <inheritdoc />
@@ -29,8 +31,16 @@ public class Aftermath : Script, IScriptOnIncomingHit, IScriptOnFaint
return;
if (user.BattleData is null)
return;
// Aftermath does not trigger if a Pokémon with Damp is on the field
var battle = user.BattleData.Battle;
var hasDamp = battle.Sides.SelectMany(side => side.Pokemon).WhereNotNull()
.Any(p => p.ActiveAbility?.Name == DampAbilityName);
if (hasDamp)
return;
EventBatchId eventBatchId = new();
user.BattleData.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
{
BatchId = eventBatchId,
});