26 lines
981 B
C#
26 lines
981 B
C#
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
|
|
}
|
|
} |