Deukhoofd 4326794611
All checks were successful
Build / Build (push) Successful in 49s
More abilities
2025-06-09 18:16:29 +02:00

34 lines
1.2 KiB
C#

using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static.Species;
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary>
/// Cute Charm is an ability that has a 30% chance to infatuate the opponent when hit by a contact move.
/// Infatuation prevents the affected Pokémon from attacking 50% of the time.
/// This ability only works on Pokémon of the opposite gender.
///
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Cute_Charm_(Ability)">Bulbapedia - Cute Charm</see>
/// </summary>
[Script(ScriptCategory.Ability, "cute_charm")]
public class CuteCharm : Script
{
/// <inheritdoc />
public override void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
{
// Only trigger on contact moves
if (!move.GetHitData(target, hit).IsContact)
return;
// 30% chance to infatuate
if (move.Battle.Random.GetFloat() > 0.3f)
return;
if (target.Gender == move.User.Gender || target.Gender == Gender.Genderless ||
move.User.Gender == Gender.Genderless)
return;
target.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
move.User.Volatile.Add(new Infatuated());
}
}