Even more abilities
This commit is contained in:
26
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Gluttony.cs
Normal file
26
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Gluttony.cs
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user