Make moveflags of gen 7 plugin shared statically

This commit is contained in:
2025-07-26 14:36:47 +02:00
parent 77d7b86a3c
commit 6eba332096
33 changed files with 223 additions and 146 deletions

View File

@@ -1,3 +1,5 @@
using PkmnLib.Plugin.Gen7.Common;
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary>
@@ -12,7 +14,7 @@ public class Bulletproof : Script, IScriptFailIncomingMove
/// <inheritdoc />
public void FailIncomingMove(IExecutingMove move, IPokemon target, ref bool fail)
{
if (move.UseMove.HasFlag("ballistics"))
if (move.UseMove.HasFlag(MoveFlags.Ballistics))
fail = true;
}
}

View File

@@ -11,7 +11,7 @@ public class IronFist : Script, IScriptChangeBasePower
/// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
if (move.UseMove.HasFlag("punch"))
if (move.UseMove.HasFlag(MoveFlags.Punch))
basePower = basePower.MultiplyOrMax(1.2f);
}
}

View File

@@ -11,7 +11,7 @@ public class LiquidVoice : Script, IScriptChangeMoveType
/// <inheritdoc />
public void ChangeMoveType(IExecutingMove move, IPokemon target, byte hit, ref TypeIdentifier? typeIdentifier)
{
if (move.UseMove.HasFlag("sound") &&
if (move.UseMove.HasFlag(MoveFlags.Sound) &&
move.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier("water", out var waterType))
{
typeIdentifier = waterType;

View File

@@ -11,7 +11,7 @@ public class MagicBounce : Script, IScriptChangeIncomingTargets
/// <inheritdoc />
public void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
{
if (moveChoice.ChosenMove.MoveData.HasFlag("reflectable"))
if (moveChoice.ChosenMove.MoveData.HasFlag(MoveFlags.Reflectable))
{
var target = targets[0];
target?.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));

View File

@@ -11,7 +11,7 @@ public class MegaLauncher : Script, IScriptChangeBasePower, IScriptCustomTrigger
/// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
if (move.UseMove.HasFlag("pulse"))
if (move.UseMove.HasFlag(MoveFlags.Pulse))
{
basePower = basePower.MultiplyOrMax(1.5f);
}
@@ -23,7 +23,7 @@ public class MegaLauncher : Script, IScriptChangeBasePower, IScriptCustomTrigger
if (eventName != CustomTriggers.ModifyHealPercent || args is not CustomTriggers.ModifyHealPercentArgs healArgs)
return;
if (healArgs.Move.UseMove.HasFlag("pulse"))
if (healArgs.Move.UseMove.HasFlag(MoveFlags.Pulse))
healArgs.HealPercent *= 1.5f;
}
}

View File

@@ -25,7 +25,7 @@ public class Overcoat : Script, IScriptIsInvulnerableToMove, IScriptCustomTrigge
/// <inheritdoc />
public void IsInvulnerableToMove(IExecutingMove move, IPokemon target, ref bool invulnerable)
{
if (move.UseMove.HasFlag("powder"))
if (move.UseMove.HasFlag(MoveFlags.Powder))
{
invulnerable = true;
}

View File

@@ -11,7 +11,7 @@ public class Reckless : Script, IScriptChangeBasePower
/// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
if (move.UseMove.HasFlag("recoil"))
if (move.UseMove.HasFlag(MoveFlags.Recoil))
{
basePower = basePower.MultiplyOrMax(1.2f);
}

View File

@@ -11,7 +11,7 @@ public class Soundproof : Script, IScriptIsInvulnerableToMove
/// <inheritdoc />
public void IsInvulnerableToMove(IExecutingMove move, IPokemon target, ref bool invulnerable)
{
if (move.UseMove.HasFlag("sound"))
if (move.UseMove.HasFlag(MoveFlags.Sound))
invulnerable = true;
}
}

View File

@@ -1,3 +1,5 @@
using PkmnLib.Plugin.Gen7.Common;
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary>
@@ -11,7 +13,7 @@ public class StrongJaw : Script, IScriptChangeBasePower
/// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
if (move.UseMove.HasFlag("bite"))
if (move.UseMove.HasFlag(MoveFlags.Bite))
{
basePower = basePower.MultiplyOrMax(1.5f);
}

View File

@@ -11,7 +11,7 @@ public class Triage : Script, IScriptChangePriority
/// <inheritdoc />
public void ChangePriority(IMoveChoice choice, ref sbyte priority)
{
if (!choice.ChosenMove.MoveData.HasFlag("heal"))
if (!choice.ChosenMove.MoveData.HasFlag(MoveFlags.Heal))
return;
if (priority == sbyte.MaxValue)
return;

View File

@@ -21,7 +21,7 @@ public class Gravity : Script, IScriptFailIncomingMove, IScriptOnEndTurn, IScrip
/// <inheritdoc />
public void FailIncomingMove(IExecutingMove move, IPokemon target, ref bool fail)
{
if (move.UseMove.HasFlag("gravity"))
if (move.UseMove.HasFlag(MoveFlags.Gravity))
fail = true;
}

View File

@@ -35,7 +35,7 @@ public class SnatchEffect : Script, IScriptStopBeforeMove, IScriptOnEndTurn
/// <inheritdoc />
public void StopBeforeMove(IExecutingMove move, ref bool stop)
{
if (move.UseMove.HasFlag("snatch") && TryGetSnatcher(out var snatcher))
if (move.UseMove.HasFlag(MoveFlags.Snatch) && TryGetSnatcher(out var snatcher))
{
stop = true;
var battleData = snatcher.BattleData;

View File

@@ -22,7 +22,7 @@ public class Sketch : Script, IScriptOnSecondaryEffect
}
var lastMove = target.BattleData?.LastMoveChoice;
if (lastMove == null || lastMove.ChosenMove.MoveData.HasFlag("not_sketchable"))
if (lastMove == null || lastMove.ChosenMove.MoveData.HasFlag(MoveFlags.NotSketchable))
{
move.GetHitData(target, hit).Fail();
return;

View File

@@ -23,14 +23,14 @@ public class ChargeBounceEffect : Script, IScriptForceTurnSelection, IScriptChan
/// <inheritdoc />
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{
if (!executingMove.UseMove.HasFlag("hit_flying"))
if (!executingMove.UseMove.HasFlag(MoveFlags.HitFlying))
block = true;
}
/// <inheritdoc />
public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
{
if (!move.UseMove.HasFlag("effective_against_fly"))
if (!move.UseMove.HasFlag(MoveFlags.EffectiveAgainstFly))
damage *= 2;
}

View File

@@ -23,14 +23,14 @@ public class ChargeFlyEffect : Script, IScriptForceTurnSelection, IScriptChangeI
/// <inheritdoc />
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{
if (!executingMove.UseMove.HasFlag("hit_flying"))
if (!executingMove.UseMove.HasFlag(MoveFlags.HitFlying))
block = true;
}
/// <inheritdoc />
public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
{
if (!move.UseMove.HasFlag("effective_against_fly"))
if (!move.UseMove.HasFlag(MoveFlags.EffectiveAgainstFly))
damage *= 2;
}

View File

@@ -23,14 +23,14 @@ public class ChargeSkyDropEffect : Script, IScriptForceTurnSelection, IScriptCha
/// <inheritdoc />
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{
if (!executingMove.UseMove.HasFlag("hit_flying"))
if (!executingMove.UseMove.HasFlag(MoveFlags.HitFlying))
block = true;
}
/// <inheritdoc />
public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
{
if (!move.UseMove.HasFlag("effective_against_fly"))
if (!move.UseMove.HasFlag(MoveFlags.EffectiveAgainstFly))
damage *= 2;
}

View File

@@ -23,14 +23,14 @@ public class DigEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomin
/// <inheritdoc />
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{
if (!executingMove.UseMove.HasFlag("hit_underground"))
if (!executingMove.UseMove.HasFlag(MoveFlags.HitUnderground))
block = true;
}
/// <inheritdoc />
public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
{
if (!move.UseMove.HasFlag("effective_against_underground"))
if (!move.UseMove.HasFlag(MoveFlags.EffectiveAgainstUnderground))
damage *= 2;
}

View File

@@ -23,14 +23,14 @@ public class DiveEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomi
/// <inheritdoc />
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{
if (!executingMove.UseMove.HasFlag("hit_underwater"))
if (!executingMove.UseMove.HasFlag(MoveFlags.HitUnderwater))
block = true;
}
/// <inheritdoc />
public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
{
if (!move.UseMove.HasFlag("effective_against_underwater"))
if (!move.UseMove.HasFlag(MoveFlags.EffectiveAgainstUnderwater))
damage *= 2;
}

View File

@@ -22,14 +22,14 @@ public class HealBlockEffect : Script, IScriptPreventMoveSelection, IScriptPreve
/// <inheritdoc />
public void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
{
if (choice.ChosenMove.MoveData.HasFlag("heal"))
if (choice.ChosenMove.MoveData.HasFlag(MoveFlags.Heal))
prevent = true;
}
/// <inheritdoc />
public void PreventMove(IExecutingMove move, ref bool prevent)
{
if (move.ChosenMove.MoveData.HasFlag("heal"))
if (move.ChosenMove.MoveData.HasFlag(MoveFlags.Heal))
prevent = true;
}

View File

@@ -1,3 +1,5 @@
using PkmnLib.Plugin.Gen7.Common;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "protect")]
@@ -9,7 +11,7 @@ public class ProtectionEffectScript : Script, IScriptBlockIncomingHit
if (target.BattleData == null)
return;
if (!executingMove.UseMove.HasFlag("protect"))
if (!executingMove.UseMove.HasFlag(MoveFlags.Protect))
return;
var args = new CustomTriggers.BypassProtectionArgs(executingMove, target, hitIndex, false);
executingMove.User.RunScriptHook<IScriptCustomTrigger>(x =>

View File

@@ -8,7 +8,7 @@ public class SubstituteEffect(uint health) : Script, IScriptBlockIncomingHit
/// <inheritdoc />
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{
if (executingMove.UseMove.HasFlag("ignore-substitute"))
if (executingMove.UseMove.HasFlag(MoveFlags.IgnoreSubstitute))
return;
var args = new CustomTriggers.BypassSubstituteArgs(executingMove, target, hitIndex, false);

View File

@@ -8,14 +8,14 @@ public class ThroatChopEffect : Script, IScriptPreventMoveSelection, IScriptFail
/// <inheritdoc />
public void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
{
if (choice.ChosenMove.MoveData.HasFlag("sound"))
if (choice.ChosenMove.MoveData.HasFlag(MoveFlags.Sound))
prevent = true;
}
/// <inheritdoc />
public void FailMove(IExecutingMove move, ref bool fail)
{
if (move.UseMove.HasFlag("sound"))
if (move.UseMove.HasFlag(MoveFlags.Sound))
fail = true;
}

View File

@@ -19,14 +19,14 @@ public class AromaVeilEffect : Script, IScriptFailIncomingMove, IScriptPreventIn
/// <inheritdoc />
public void FailIncomingMove(IExecutingMove move, IPokemon target, ref bool fail)
{
if (move.UseMove.HasFlag("mental") && move.UseMove.Category == MoveCategory.Status)
if (move.UseMove.HasFlag(MoveFlags.Mental) && move.UseMove.Category == MoveCategory.Status)
fail = true;
}
/// <inheritdoc />
public void PreventIncomingSecondaryEffect(IExecutingMove move, IPokemon target, byte hit, ref bool prevent)
{
if (move.UseMove.HasFlag("mental"))
if (move.UseMove.HasFlag(MoveFlags.Mental))
prevent = true;
}
}

View File

@@ -1,3 +1,5 @@
using PkmnLib.Plugin.Gen7.Common;
namespace PkmnLib.Plugin.Gen7.Scripts.Status;
[Script(ScriptCategory.Status, "frozen")]
@@ -18,7 +20,7 @@ public class Frozen : Script, IScriptPreventMove, IScriptOnEndTurn
/// <inheritdoc />
public void PreventMove(IExecutingMove move, ref bool prevent)
{
if (move.UseMove.MoveType.Name == "fire" || move.UseMove.HasFlag("defrost"))
if (move.UseMove.MoveType.Name == "fire" || move.UseMove.HasFlag(MoveFlags.Defrost))
{
_pokemon?.ClearStatus();
return;

View File

@@ -36,7 +36,7 @@ public class Sleep : Script, IScriptPreventMove, IAIInfoScriptNumberTurnsLeft
return;
}
if (move.UseMove.HasFlag("usable_while_asleep"))
if (move.UseMove.HasFlag(MoveFlags.UsableWhileAsleep))
return;
var args = new CustomTriggers.BypassSleepArgs(move, false);