29 lines
1008 B
C#
29 lines
1008 B
C#
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
|
|
|
[Script(ScriptCategory.Move, "forests_curse")]
|
|
public class ForestsCurse : Script, IScriptOnSecondaryEffect
|
|
{
|
|
/// <inheritdoc />
|
|
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
|
{
|
|
var battleData = target.BattleData;
|
|
if (battleData == null)
|
|
return;
|
|
var typeLibrary = battleData.Battle.Library.StaticLibrary.Types;
|
|
if (!typeLibrary.TryGetTypeIdentifier(TypeNames.Grass, out var grassType) || target.Types.Contains(grassType))
|
|
{
|
|
move.GetHitData(target, hit).Fail();
|
|
return;
|
|
}
|
|
if (target.Volatile.TryGet<HasHadTypeAddedEffect>(out var effect))
|
|
{
|
|
target.RemoveType(effect.TypeIdentifier);
|
|
target.Volatile.Remove<HasHadTypeAddedEffect>();
|
|
}
|
|
|
|
target.AddType(grassType);
|
|
target.Volatile.Add(new HasHadTypeAddedEffect(grassType));
|
|
}
|
|
} |