This commit is contained in:
43
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Frisk.cs
Normal file
43
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Frisk.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
|
||||
/// <summary>
|
||||
/// Frisk is an ability that reveals the held items of opposing Pokémon when the Pokémon enters battle.
|
||||
/// This ability is commonly associated with Banette and Gothitelle.
|
||||
///
|
||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Frisk_(Ability)">Bulbapedia - Frisk</see>
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Ability, "frisk")]
|
||||
public class Frisk : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
{
|
||||
if (pokemon.BattleData?.BattleSide is null)
|
||||
return;
|
||||
|
||||
// Check if the Pokémon has an opposing side
|
||||
var opposingSide =
|
||||
pokemon.BattleData.Battle.Sides.FirstOrDefault(side => side != pokemon.BattleData.BattleSide);
|
||||
if (opposingSide is null)
|
||||
return;
|
||||
|
||||
EventBatchId batchId = new();
|
||||
// Iterate through the opposing Pokémon
|
||||
foreach (var opponent in opposingSide.Pokemon.WhereNotNull())
|
||||
{
|
||||
// If the opponent has a held item, reveal it
|
||||
if (opponent.HeldItem != null)
|
||||
{
|
||||
pokemon.BattleData.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
|
||||
{
|
||||
Metadata = new Dictionary<StringKey, object?>
|
||||
{
|
||||
{ "opponent", opponent },
|
||||
{ "held_item", opponent.HeldItem },
|
||||
},
|
||||
BatchId = batchId,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user