Finish script interface refactor
All checks were successful
Build / Build (push) Successful in 1m1s

This commit is contained in:
2025-07-06 10:27:56 +02:00
parent 83f6a183e3
commit 7c270a6d52
117 changed files with 669 additions and 648 deletions

View File

@@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "autotomize")]
public class AutotomizeEffect : Script, IBatonPassException, IScriptStack
public class AutotomizeEffect : Script, IBatonPassException, IScriptStack, IScriptModifyWeight
{
public int Stacks { get; private set; } = 1;
@@ -14,7 +14,7 @@ public class AutotomizeEffect : Script, IBatonPassException, IScriptStack
}
/// <inheritdoc />
public override void ModifyWeight(ref float weight)
public void ModifyWeight(ref float weight)
{
weight -= 100f * Stacks;
}

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "charge_bounce")]
public class ChargeBounceEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage,
IScriptBlockIncomingHit
IScriptBlockIncomingHit, IScriptOnAfterMoveChoice
{
private readonly IPokemon _owner;
@@ -35,7 +35,7 @@ public class ChargeBounceEffect : Script, IScriptForceTurnSelection, IScriptChan
}
/// <inheritdoc />
public override void OnAfterMoveChoice(IMoveChoice moveChoice)
public void OnAfterMoveChoice(IMoveChoice moveChoice)
{
if (moveChoice.AdditionalData?.ContainsKey("bounce_charge") != true)
{

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "charge_fly")]
public class ChargeFlyEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage,
IScriptBlockIncomingHit
IScriptBlockIncomingHit, IScriptOnAfterMoveChoice
{
private readonly IPokemon _owner;
@@ -35,7 +35,7 @@ public class ChargeFlyEffect : Script, IScriptForceTurnSelection, IScriptChangeI
}
/// <inheritdoc />
public override void OnAfterMoveChoice(IMoveChoice moveChoice)
public void OnAfterMoveChoice(IMoveChoice moveChoice)
{
if (moveChoice.AdditionalData?.ContainsKey("fly_charge") != true)
{

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "charge_sky_drop")]
public class ChargeSkyDropEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage,
IScriptBlockIncomingHit
IScriptBlockIncomingHit, IScriptOnAfterMoveChoice
{
private readonly IPokemon _owner;
@@ -35,7 +35,7 @@ public class ChargeSkyDropEffect : Script, IScriptForceTurnSelection, IScriptCha
}
/// <inheritdoc />
public override void OnAfterMoveChoice(IMoveChoice moveChoice)
public void OnAfterMoveChoice(IMoveChoice moveChoice)
{
if (moveChoice.AdditionalData?.ContainsKey("sky_drop_charge") != true)
{

View File

@@ -3,7 +3,8 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "dig")]
public class DigEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage, IScriptBlockIncomingHit
public class DigEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage, IScriptBlockIncomingHit,
IScriptOnAfterMoveChoice
{
private readonly IPokemon _owner;
@@ -34,7 +35,7 @@ public class DigEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomin
}
/// <inheritdoc />
public override void OnAfterMoveChoice(IMoveChoice moveChoice)
public void OnAfterMoveChoice(IMoveChoice moveChoice)
{
if (moveChoice.AdditionalData?.ContainsKey("dig_charge") != true)
{

View File

@@ -3,7 +3,8 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "dive")]
public class DiveEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage, IScriptBlockIncomingHit
public class DiveEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage, IScriptBlockIncomingHit,
IScriptOnAfterMoveChoice
{
private readonly IPokemon _owner;
@@ -34,7 +35,7 @@ public class DiveEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomi
}
/// <inheritdoc />
public override void OnAfterMoveChoice(IMoveChoice moveChoice)
public void OnAfterMoveChoice(IMoveChoice moveChoice)
{
if (moveChoice.AdditionalData?.ContainsKey("dive_charge") != true)
{

View File

@@ -8,7 +8,7 @@ public class FlinchEffect : Script, IScriptPreventMove
{
prevent = true;
var args = new CustomTriggers.OnFlinchArgs(move);
move.RunScriptHook(x => x.CustomTrigger(CustomTriggers.OnFlinch, args));
move.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.OnFlinch, args));
if (args.Prevent)
return;

View File

@@ -3,7 +3,7 @@ using PkmnLib.Static.Libraries;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "foresight")]
public class ForesightEffect : Script, IScriptPreventStatBoostChange
public class ForesightEffect : Script, IScriptPreventStatBoostChange, IScriptChangeTypesForIncomingMove
{
private readonly TypeIdentifier _normalType;
private readonly TypeIdentifier _fightingType;
@@ -25,7 +25,7 @@ public class ForesightEffect : Script, IScriptPreventStatBoostChange
}
/// <inheritdoc />
public override void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
IList<TypeIdentifier> types)
{
if (executingMove.UseMove.MoveType == _normalType || executingMove.UseMove.MoveType == _fightingType)

View File

@@ -1,7 +1,8 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "heal_block")]
public class HealBlockEffect : Script, IScriptPreventMoveSelection, IScriptPreventMove, IScriptOnEndTurn
public class HealBlockEffect : Script, IScriptPreventMoveSelection, IScriptPreventMove, IScriptOnEndTurn,
IScriptPreventHeal
{
private int _duration;
@@ -33,7 +34,7 @@ public class HealBlockEffect : Script, IScriptPreventMoveSelection, IScriptPreve
}
/// <inheritdoc />
public override void PreventHeal(IPokemon pokemon, uint heal, bool allowRevive, ref bool prevented)
public void PreventHeal(IPokemon pokemon, uint heal, bool allowRevive, ref bool prevented)
{
prevented = true;
}

View File

@@ -2,7 +2,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "ingrain")]
public class IngrainEffect : Script, IScriptFailIncomingMove, IScriptOnEndTurn, IScriptPreventSelfSwitch,
IScriptPreventSelfRunAway
IScriptPreventSelfRunAway, IScriptChangeTypesForIncomingMove
{
private readonly IPokemon _owner;
@@ -34,7 +34,7 @@ public class IngrainEffect : Script, IScriptFailIncomingMove, IScriptOnEndTurn,
}
/// <inheritdoc />
public override void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
IList<TypeIdentifier> types)
{
if (executingMove.UseMove.MoveType.Name == "ground")

View File

@@ -1,7 +1,7 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "lock_on")]
public class LockOnEffect : Script, IScriptOnEndTurn
public class LockOnEffect : Script, IScriptOnEndTurn, IScriptChangeAccuracy
{
private readonly IPokemon _placer;
@@ -11,8 +11,7 @@ public class LockOnEffect : Script, IScriptOnEndTurn
}
/// <inheritdoc />
public override void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
ref int modifiedAccuracy)
public void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref int modifiedAccuracy)
{
if (_placer != target)
return;

View File

@@ -1,7 +1,7 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "miracle_eye")]
public class MiracleEyeEffect : Script, IScriptPreventStatBoostChange
public class MiracleEyeEffect : Script, IScriptPreventStatBoostChange, IScriptChangeTypesForIncomingMove
{
/// <inheritdoc />
public void PreventStatBoostChange(IPokemon target, Statistic stat, sbyte amount, bool selfInflicted,
@@ -12,7 +12,7 @@ public class MiracleEyeEffect : Script, IScriptPreventStatBoostChange
}
/// <inheritdoc />
public override void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
IList<TypeIdentifier> types)
{
if (executingMove.UseMove.MoveType.Name != "psychic")

View File

@@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "phantom_force")]
public class PhantomForceCharge : Script, IScriptForceTurnSelection, IScriptBlockIncomingHit
public class PhantomForceCharge : Script, IScriptForceTurnSelection, IScriptBlockIncomingHit, IScriptOnAfterMoveChoice
{
private readonly IPokemon _owner;
@@ -26,7 +26,7 @@ public class PhantomForceCharge : Script, IScriptForceTurnSelection, IScriptBloc
}
/// <inheritdoc />
public override void OnAfterMoveChoice(IMoveChoice moveChoice)
public void OnAfterMoveChoice(IMoveChoice moveChoice)
{
if (moveChoice.AdditionalData?.ContainsKey("phantom_force_charge") != true)
{

View File

@@ -12,7 +12,8 @@ public class ProtectionEffectScript : Script, IScriptBlockIncomingHit
if (!executingMove.UseMove.HasFlag("protect"))
return;
var args = new CustomTriggers.BypassProtectionArgs(executingMove, target, hitIndex, false);
executingMove.User.RunScriptHook(x => x.CustomTrigger(CustomTriggers.BypassProtection, args));
executingMove.User.RunScriptHook<IScriptCustomTrigger>(x =>
x.CustomTrigger(CustomTriggers.BypassProtection, args));
if (args.Bypass)
return;

View File

@@ -1,10 +1,10 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "roost_effect")]
public class RoostEffect : Script, IScriptOnEndTurn
public class RoostEffect : Script, IScriptOnEndTurn, IScriptChangeTypesForIncomingMove
{
/// <inheritdoc />
public override void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
IList<TypeIdentifier> types)
{
types.RemoveAll(x => x.Name == "flying");

View File

@@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "shadow_force")]
public class ShadowForceCharge : Script, IScriptForceTurnSelection, IScriptBlockIncomingHit
public class ShadowForceCharge : Script, IScriptForceTurnSelection, IScriptBlockIncomingHit, IScriptOnAfterMoveChoice
{
private readonly IPokemon _owner;
@@ -26,7 +26,7 @@ public class ShadowForceCharge : Script, IScriptForceTurnSelection, IScriptBlock
}
/// <inheritdoc />
public override void OnAfterMoveChoice(IMoveChoice moveChoice)
public void OnAfterMoveChoice(IMoveChoice moveChoice)
{
if (moveChoice.AdditionalData?.ContainsKey("shadow_force_charge") != true)
{

View File

@@ -1,10 +1,10 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "smack_down")]
public class SmackDownEffect : Script
public class SmackDownEffect : Script, IScriptChangeTypesForIncomingMove, IScriptIsFloating
{
/// <inheritdoc />
public override void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
IList<TypeIdentifier> types)
{
var typeLibrary = target.Library.StaticLibrary.Types;
@@ -16,7 +16,7 @@ public class SmackDownEffect : Script
}
/// <inheritdoc />
public override void IsFloating(IPokemon pokemon, ref bool isFloating)
public void IsFloating(IPokemon pokemon, ref bool isFloating)
{
isFloating = false;
}

View File

@@ -12,7 +12,8 @@ public class SubstituteEffect(uint health) : Script, IScriptBlockIncomingHit
return;
var args = new CustomTriggers.BypassSubstituteArgs(executingMove, target, hitIndex, false);
executingMove.User.RunScriptHook(x => x.CustomTrigger(CustomTriggers.BypassSubstitute, args));
executingMove.User.RunScriptHook<IScriptCustomTrigger>(x =>
x.CustomTrigger(CustomTriggers.BypassSubstitute, args));
if (args.Bypass)
return;

View File

@@ -1,17 +1,18 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "telekinesis")]
public class TelekinesisEffect : Script, IScriptChangeIncomingEffectiveness
public class TelekinesisEffect : Script, IScriptChangeIncomingEffectiveness, IScriptIsFloating,
IScriptChangeIncomingAccuracy
{
/// <inheritdoc />
public override void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
public void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
ref int modifiedAccuracy)
{
modifiedAccuracy = 255;
}
/// <inheritdoc />
public override void IsFloating(IPokemon pokemon, ref bool isFloating)
public void IsFloating(IPokemon pokemon, ref bool isFloating)
{
isFloating = true;
}

View File

@@ -1,16 +1,16 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Move, "thousand_arrows")]
public class ThousandArrowsEffect : Script
public class ThousandArrowsEffect : Script, IScriptChangeTypesForIncomingMove, IScriptIsFloating
{
/// <inheritdoc />
public override void IsFloating(IPokemon pokemon, ref bool isFloating)
public void IsFloating(IPokemon pokemon, ref bool isFloating)
{
isFloating = false;
}
/// <inheritdoc />
public override void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
IList<TypeIdentifier> types)
{
if (executingMove.UseMove.MoveType.Name == "ground")