namespace PkmnLib.Plugin.Gen7.Scripts.Abilities; /// /// 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. /// /// Bulbapedia - Gluttony /// [Script(ScriptCategory.Ability, "gluttony")] public class Gluttony : Script, IScriptOnDamage { /// public 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 } }