Deukhoofd 00005aa4bf
All checks were successful
Build / Build (push) Successful in 47s
Implements more abilities
2025-06-09 12:10:25 +02:00

50 lines
1.5 KiB
C#

using PkmnLib.Static.Species;
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary>
/// Disguise is an ability that allows the Pokémon to avoid damage from one attack.
/// After being hit, the disguise is broken and the Pokémon's appearance changes.
/// This ability is exclusive to Mimikyu.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Disguise_(Ability)">Bulbapedia - Disguise</see>
/// </summary>
[Script(ScriptCategory.Ability, "disguise")]
public class Disguise : Script
{
/// <inheritdoc />
public override void ChangeIncomingDamage(IPokemon pokemon, DamageSource source, ref uint damage)
{
if (pokemon.BattleData == null)
return;
if (source is not DamageSource.MoveDamage and not DamageSource.Confusion)
return;
if (pokemon.Form.Name == "busted" || pokemon.Form.Name == "totem-busted")
return;
IForm form;
if (pokemon.Form.Name == "default")
{
if (!pokemon.Species.TryGetForm("busted", out form!))
return;
}
else if (pokemon.Form.Name == "totem-disguised")
{
if (!pokemon.Species.TryGetForm("totem-busted", out form!))
return;
}
else
{
return;
}
EventBatchId batchId = new();
pokemon.BattleData.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
{
BatchId = batchId,
});
pokemon.ChangeForm(form, batchId);
damage = 0;
}
}