More abilities
This commit is contained in:
31
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/InnerFocus.cs
Normal file
31
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/InnerFocus.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
|
||||
/// <summary>
|
||||
/// Inner Focus is an ability that prevents the Pokémon from flinching.
|
||||
///
|
||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Inner_Focus_(Ability)">Bulbapedia - Inner Focus</see>
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Ability, "inner_focus")]
|
||||
public class InnerFocus : Script
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
throw new InvalidOperationException("Illusion can only be added to a Pokemon script source.");
|
||||
_pokemon = pokemon;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void PreventVolatileAdd(Script script, ref bool preventVolatileAdd)
|
||||
{
|
||||
if (script is not FlinchEffect)
|
||||
return;
|
||||
_pokemon?.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(_pokemon));
|
||||
preventVolatileAdd = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user