50 lines
1.6 KiB
C#
50 lines
1.6 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, IScriptChangeIncomingDamage
|
|
{
|
|
/// <inheritdoc />
|
|
public 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 == FormNames.Busted || pokemon.Form.Name == FormNames.TotemBusted)
|
|
return;
|
|
IForm form;
|
|
if (pokemon.Form.Name == FormNames.Default)
|
|
{
|
|
if (!pokemon.Species.TryGetForm(FormNames.Busted, out form!))
|
|
return;
|
|
}
|
|
else if (pokemon.Form.Name == FormNames.TotemDisguised)
|
|
{
|
|
if (!pokemon.Species.TryGetForm(FormNames.TotemBusted, out form!))
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
|
|
EventBatchId batchId = new();
|
|
|
|
pokemon.BattleData.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
|
|
{
|
|
BatchId = batchId,
|
|
});
|
|
pokemon.ChangeForm(form, batchId);
|
|
|
|
damage = 0;
|
|
}
|
|
} |