49 lines
1.7 KiB
C#
49 lines
1.7 KiB
C#
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
///
|
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Effect_Spore_(Ability)">Bulbapedia - Effect Spore</see>
|
|
/// </summary>
|
|
[Script(ScriptCategory.Ability, "effect_spore")]
|
|
public class EffectSpore : Script
|
|
{
|
|
/// <inheritdoc />
|
|
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<Status.Poisoned>(), move.User, batchId);
|
|
break;
|
|
case < 19:
|
|
move.User.SetStatus(ScriptUtils.ResolveName<Status.Paralyzed>(), move.User, batchId);
|
|
break;
|
|
case < 30:
|
|
move.User.SetStatus(ScriptUtils.ResolveName<Status.Sleep>(), move.User, batchId);
|
|
break;
|
|
}
|
|
}
|
|
} |