namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
///
/// Effect Spore is an ability that has a 30% chance of inflicting a status condition on the attacker
/// when hit by a contact move. The status condition can be poison (9%), paralysis (10%), or sleep (11%).
/// This ability is commonly associated with Paras and Shroomish.
///
/// Bulbapedia - Effect Spore
///
[Script(ScriptCategory.Ability, "effect_spore")]
public class EffectSpore : Script
{
///
public override void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
{
if (move.User.Types.Any(x => x.Name == "grass"))
return;
if (move.User.ActiveAbility?.Name == "effect_spore")
return;
if (move.User.HasHeldItem("safety_goggles"))
return;
if (!move.GetHitData(target, hit).IsContact)
return;
var rng = move.Battle.Random;
var chance = rng.GetInt(0, 100);
EventBatchId batchId = new();
if (chance < 30)
{
move.Battle.EventHook.Invoke(new AbilityTriggerEvent(target)
{
BatchId = batchId,
});
}
switch (chance)
{
case < 9:
move.User.SetStatus(ScriptUtils.ResolveName(), move.User, batchId);
break;
case < 19:
move.User.SetStatus(ScriptUtils.ResolveName(), move.User, batchId);
break;
case < 30:
move.User.SetStatus(ScriptUtils.ResolveName(), move.User, batchId);
break;
}
}
}