Even more abilities

This commit is contained in:
2025-06-09 14:23:51 +02:00
parent 97868ab4c6
commit 074f92bfc0
31 changed files with 319 additions and 51 deletions

View File

@@ -0,0 +1,26 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary>
/// Gluttony is an ability that causes a Pokémon to eat a held Berry when its HP drops to half or less, rather than a third or less.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Gluttony_(Ability)">Bulbapedia - Gluttony</see>
/// </summary>
[Script(ScriptCategory.Ability, "gluttony")]
public class Gluttony : Script
{
/// <inheritdoc />
public override void OnDamage(IPokemon pokemon, DamageSource source, uint oldHealth, uint newHealth)
{
if (pokemon.BattleData is null)
return;
var oldHealthFraction = (float)oldHealth / pokemon.MaxHealth;
var newHealthFraction = (float)newHealth / pokemon.MaxHealth;
if (!(oldHealthFraction >= 0.5f) || !(newHealthFraction < 0.5f))
return;
if (pokemon.HeldItem?.Category != ItemCategory.Berry)
return;
// FIXME: Implement after Berry triggers are implemented
}
}