This commit is contained in:
@@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user