34 lines
1.2 KiB
C#
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, IScriptOnIncomingHit
|
|
{
|
|
/// <inheritdoc />
|
|
public 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());
|
|
}
|
|
} |