39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
|
|
|
[Script(ScriptCategory.Move, "infestation")]
|
|
public class Infestation : Script, IScriptOnSecondaryEffect
|
|
{
|
|
/// <inheritdoc />
|
|
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
|
{
|
|
var infestationEffect = ScriptUtils.ResolveName<InfestationEffect>();
|
|
if (target.Volatile.Contains(infestationEffect))
|
|
{
|
|
move.GetHitData(target, hit).Fail();
|
|
return;
|
|
}
|
|
|
|
var battleData = move.User.BattleData;
|
|
if (battleData == null)
|
|
return;
|
|
|
|
var turns = 4;
|
|
if (battleData.Battle.Random.GetBool())
|
|
{
|
|
turns = 5;
|
|
}
|
|
|
|
var args = new CustomTriggers.ModifyBindArgs(move)
|
|
{
|
|
Duration = turns,
|
|
DamagePercent = 1 / 8f,
|
|
};
|
|
move.User.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyBind, args));
|
|
var bindTurns = args.Duration;
|
|
var bindDamage = args.DamagePercent;
|
|
|
|
target.Volatile.Add(new InfestationEffect(target, bindTurns, bindDamage));
|
|
}
|
|
} |