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

@@ -52,19 +52,21 @@ public class Gen7BattleStatCalculator : IBattleStatCalculator
byte moveAccuracy)
{
var accuracyModifier = 1.0f;
executingMove.RunScriptHookInterface<IScriptChangeAccuracyModifier>(x =>
executingMove.RunScriptHook<IScriptChangeAccuracyModifier>(x =>
x.ChangeAccuracyModifier(executingMove, target, hitIndex, ref accuracyModifier));
var modifiedAccuracy = (int)(moveAccuracy * accuracyModifier);
// ReSharper disable once AccessToModifiedClosure
executingMove.RunScriptHook(x => x.ChangeAccuracy(executingMove, target, hitIndex, ref modifiedAccuracy));
executingMove.RunScriptHook<IScriptChangeAccuracy>(x =>
x.ChangeAccuracy(executingMove, target, hitIndex, ref modifiedAccuracy));
if (modifiedAccuracy >= 255)
return 255;
target.RunScriptHook(x => x.ChangeIncomingAccuracy(executingMove, target, hitIndex, ref modifiedAccuracy));
target.RunScriptHook<IScriptChangeIncomingAccuracy>(x =>
x.ChangeIncomingAccuracy(executingMove, target, hitIndex, ref modifiedAccuracy));
if (modifiedAccuracy >= 255)
return 255;
var targetEvasion = target.StatBoost.Evasion;
var ignoreEvasion = false;
executingMove.RunScriptHookInterface<IScriptBypassEvasionStatBoosts>(x =>
executingMove.RunScriptHook<IScriptBypassEvasionStatBoosts>(x =>
x.BypassEvasionStatBoosts(executingMove, target, hitIndex, ref ignoreEvasion));
if (ignoreEvasion)
targetEvasion = 0;

View File

@@ -26,7 +26,8 @@ public class Gen7CaptureLibrary : ICaptureLibrary
}
byte bonusStatus = 1;
target.RunScriptHook(x => x.ChangeCatchRateBonus(target, captureItem, ref bonusStatus));
target.RunScriptHook<IScriptChangeCatchRateBonus>(x =>
x.ChangeCatchRateBonus(target, captureItem, ref bonusStatus));
var modifiedCatchRate = (3.0f * maxHealth - 2.0f * currentHealth) * catchRate * bonusBall / (3.0f * maxHealth);
modifiedCatchRate *= bonusStatus;

View File

@@ -29,7 +29,7 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
if (hitData.IsCritical)
{
var critModifier = 1.5f;
executingMove?.RunScriptHookInterface<IScriptChangeCriticalModifier>(script =>
executingMove?.RunScriptHook<IScriptChangeCriticalModifier>(script =>
script.ChangeCriticalModifier(executingMove, target, hitNumber, ref critModifier));
floatDamage = MathF.Floor(floatDamage * critModifier);
}
@@ -51,7 +51,7 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
stabModifier = 1.5f;
isStab = true;
}
executingMove?.RunScriptHookInterface<IScriptChangeStabModifier>(script =>
executingMove?.RunScriptHook<IScriptChangeStabModifier>(script =>
script.ChangeStabModifier(executingMove, target, hitNumber, isStab, ref stabModifier));
floatDamage = MathF.Floor(floatDamage * stabModifier);
@@ -65,9 +65,9 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
if (executingMove is not null)
{
executingMove.RunScriptHookInterface<IScriptChangeMoveDamage>(script =>
executingMove.RunScriptHook<IScriptChangeMoveDamage>(script =>
script.ChangeMoveDamage(executingMove, target, hitNumber, ref damage));
target.RunScriptHookInterface<IScriptChangeIncomingMoveDamage>(script =>
target.RunScriptHook<IScriptChangeIncomingMoveDamage>(script =>
script.ChangeIncomingMoveDamage(executingMove, target, hitNumber, ref damage));
}
@@ -80,7 +80,7 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
if (executingMove.UseMove.Category == MoveCategory.Status)
return 0;
var basePower = (ushort)executingMove.UseMove.BasePower;
executingMove.RunScriptHookInterface<IScriptChangeBasePower>(script =>
executingMove.RunScriptHook<IScriptChangeBasePower>(script =>
script.ChangeBasePower(executingMove, target, hitNumber, ref basePower));
return basePower;
}
@@ -91,7 +91,7 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
if (executingMove.UseMove.Category == MoveCategory.Status)
return false;
byte critStage = 0;
executingMove.RunScriptHookInterface<IScriptChangeCriticalStage>(script =>
executingMove.RunScriptHook<IScriptChangeCriticalStage>(script =>
script.ChangeCriticalStage(executingMove, target, hitNumber, ref critStage));
var random = battle.Random;
@@ -120,14 +120,14 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
// move is critical, and the target has a defensive stat boost of > 0, but a script is
// allowed to change this.
var bypassDefense = hitData.IsCritical && target.StatBoost.GetStatistic(defensive) > 0;
executingMove?.RunScriptHookInterface<IScriptBypassDefensiveStatBoosts>(script =>
executingMove?.RunScriptHook<IScriptBypassDefensiveStatBoosts>(script =>
script.BypassDefensiveStatBoosts(executingMove, target, hitNumber, ref bypassDefense));
// Check if we can bypass the offensive stat boost on the user. We default to this if the
// move is critical, and the user has an offensive stat boost of < 0, but a script is
// allowed to change this.
var bypassOffense = hitData.IsCritical && user.StatBoost.GetStatistic(offensive) < 0;
executingMove?.RunScriptHookInterface<IScriptBypassOffensiveStatBoosts>(script =>
executingMove?.RunScriptHook<IScriptBypassOffensiveStatBoosts>(script =>
script.BypassOffensiveStatBoosts(executingMove, target, hitNumber, ref bypassOffense));
var userStats = user.BoostedStats;
@@ -143,22 +143,22 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
if (executingMove != null)
{
executingMove.RunScriptHookInterface<IScriptChangeOffensiveStatValue>(script =>
executingMove.RunScriptHook<IScriptChangeOffensiveStatValue>(script =>
script.ChangeOffensiveStatValue(executingMove, target, hitNumber, defensiveStat, targetStats, offensive,
ref offensiveStat));
executingMove.RunScriptHookInterface<IScriptChangeDefensiveStatValue>(script =>
executingMove.RunScriptHook<IScriptChangeDefensiveStatValue>(script =>
script.ChangeDefensiveStatValue(executingMove, target, hitNumber, origOffensiveStat, targetStats,
defensive, ref defensiveStat));
target.RunScriptHookInterface<IScriptChangeIncomingMoveOffensiveStatValue>(script =>
target.RunScriptHook<IScriptChangeIncomingMoveOffensiveStatValue>(script =>
script.ChangeIncomingMoveOffensiveStatValue(executingMove, target, hitNumber, defensiveStat,
targetStats, offensive, ref offensiveStat));
target.RunScriptHookInterface<IScriptChangeIncomingMoveDefensiveStatValue>(script =>
target.RunScriptHook<IScriptChangeIncomingMoveDefensiveStatValue>(script =>
script.ChangeIncomingMoveDefensiveStatValue(executingMove, target, hitNumber, origOffensiveStat,
targetStats, defensive, ref defensiveStat));
}
var modifier = (float)offensiveStat / defensiveStat;
executingMove?.RunScriptHookInterface<IScriptChangeDamageStatModifier>(script =>
executingMove?.RunScriptHook<IScriptChangeDamageStatModifier>(script =>
script.ChangeDamageStatModifier(executingMove, target, hitNumber, ref modifier));
return modifier;
@@ -172,9 +172,9 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
{
var modifier = 1.0f;
executingMove.RunScriptHookInterface<IScriptChangeDamageModifier>(script =>
executingMove.RunScriptHook<IScriptChangeDamageModifier>(script =>
script.ChangeDamageModifier(executingMove, target, hitNumber, ref modifier));
target.RunScriptHookInterface<IScriptChangeIncomingMoveDamageModifier>(script =>
target.RunScriptHook<IScriptChangeIncomingMoveDamageModifier>(script =>
script.ChangeIncomingMoveDamageModifier(executingMove, target, hitNumber, ref modifier));
return modifier;

View File

@@ -7,10 +7,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Aura_Break_(Ability)">Bulbapedia - Aura Break</see>
/// </summary>
[Script(ScriptCategory.Ability, "aura_break")]
public class AuraBreak : Script
public class AuraBreak : Script, IScriptCustomTrigger
{
/// <inheritdoc />
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
{
if (eventName != CustomTriggers.ModifyAuraEffect || args is not CustomTriggers.ModifyAuraEffectArgs auraArgs)
return;

View File

@@ -8,11 +8,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Comatose_(Ability)">Bulbapedia - Comatose</see>
/// </summary>
[Script(ScriptCategory.Ability, "comatose")]
public class Comatose : Script
public class Comatose : Script, IScriptPreventStatusChange, IScriptCustomTrigger
{
/// <inheritdoc />
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
ref bool preventStatus)
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
{
if (status == ScriptUtils.ResolveName<Status.Sleep>())
{
@@ -21,7 +20,7 @@ public class Comatose : Script
}
/// <inheritdoc />
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
{
if (eventName == CustomTriggers.BypassSleep && args is CustomTriggers.BypassSleepArgs bypassArgs)
{

View File

@@ -7,10 +7,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Compound_Eyes_(Ability)">Bulbapedia - Compound Eyes</see>
/// </summary>
[Script(ScriptCategory.Ability, "compound_eyes")]
public class CompoundEyes : Script
public class CompoundEyes : Script, IScriptChangeAccuracy
{
/// <inheritdoc />
public override void ChangeAccuracy(IExecutingMove move, IPokemon target, byte hit, ref int modifiedAccuracy)
public void ChangeAccuracy(IExecutingMove move, IPokemon target, byte hit, ref int modifiedAccuracy)
{
move.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User));
modifiedAccuracy = (int)(modifiedAccuracy * 1.3f);

View File

@@ -17,7 +17,7 @@ public class DarkAura : Script, IScriptChangeDamageModifier
var auraModifier = 5448f / 4096f;
var args = new CustomTriggers.ModifyAuraEffectArgs(move, target, hit, auraModifier);
move.Battle.Sides.SelectMany(side => side.Pokemon).WhereNotNull()
.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ModifyAuraEffect, args));
.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyAuraEffect, args));
auraModifier = args.AuraEffect;
modifier *= auraModifier;
move.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User));

View File

@@ -8,10 +8,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Early_Bird_(Ability)">Bulbapedia - Early Bird</see>
/// </summary>
[Script(ScriptCategory.Ability, "early_bird")]
public class EarlyBird : Script
public class EarlyBird : Script, IScriptCustomTrigger
{
/// <inheritdoc />
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
{
if (eventName != CustomTriggers.ModifySleepTurns)
return;

View File

@@ -18,7 +18,7 @@ public class FairyAura : Script, IScriptChangeDamageModifier
var auraModifier = 5448f / 4096f;
var args = new CustomTriggers.ModifyAuraEffectArgs(move, target, hit, auraModifier);
move.Battle.Sides.SelectMany(side => side.Pokemon).WhereNotNull()
.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ModifyAuraEffect, args));
.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyAuraEffect, args));
auraModifier = args.AuraEffect;
modifier *= auraModifier;
move.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User));

View File

@@ -7,7 +7,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Flower_Gift_(Ability)">Bulbapedia - Flower Gift</see>
/// </summary>
[Script(ScriptCategory.Ability, "flower_gift")]
public class FlowerGift : Script
public class FlowerGift : Script, IScriptOnWeatherChange
{
private IPokemon? _pokemon;
@@ -22,7 +22,7 @@ public class FlowerGift : Script
}
/// <inheritdoc />
public override void OnWeatherChange(IBattle battle, StringKey? weatherName, StringKey? oldWeatherName)
public void OnWeatherChange(IBattle battle, StringKey? weatherName, StringKey? oldWeatherName)
{
if (_pokemon is null)
return;

View File

@@ -7,7 +7,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Forecast_(Ability)">Bulbapedia - Forecast</see>
/// </summary>
[Script(ScriptCategory.Ability, "forecast")]
public class Forecast : Script, IScriptOnSwitchIn
public class Forecast : Script, IScriptOnSwitchIn, IScriptOnWeatherChange
{
private IPokemon? _pokemon;
@@ -26,7 +26,7 @@ public class Forecast : Script, IScriptOnSwitchIn
}
/// <inheritdoc />
public override void OnWeatherChange(IBattle battle, StringKey? weatherName, StringKey? oldWeatherName)
public void OnWeatherChange(IBattle battle, StringKey? weatherName, StringKey? oldWeatherName)
{
if (_pokemon is null)
return;

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Heavy_Metal_(Ability)">Bulbapedia - Heavy Metal</see>
/// </summary>
[Script(ScriptCategory.Ability, "heavy_metal")]
public class HeavyMetal : Script
public class HeavyMetal : Script, IScriptModifyWeight
{
/// <inheritdoc />
public override void ModifyWeight(ref float weight)
public void ModifyWeight(ref float weight)
{
weight *= 2f;
}

View File

@@ -8,7 +8,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Hustle_(Ability)">Bulbapedia - Hustle</see>
/// </summary>
[Script(ScriptCategory.Ability, "hustle")]
public class Hustle : Script, IScriptChangeOffensiveStatValue
public class Hustle : Script, IScriptChangeOffensiveStatValue, IScriptChangeAccuracy
{
/// <inheritdoc />
public void ChangeOffensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint defensiveStat,
@@ -20,8 +20,7 @@ public class Hustle : Script, IScriptChangeOffensiveStatValue
}
/// <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 (executingMove.UseMove.Category == MoveCategory.Physical)
{

View File

@@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Ice_Body_(Ability)">Bulbapedia - Ice Body</see>
/// </summary>
[Script(ScriptCategory.Ability, "ice_body")]
public class IceBody : Script, IScriptOnEndTurn
public class IceBody : Script, IScriptOnEndTurn, IScriptCustomTrigger
{
private IPokemon? _pokemon;
@@ -41,7 +41,7 @@ public class IceBody : Script, IScriptOnEndTurn
}
/// <inheritdoc />
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
{
if (eventName != CustomTriggers.IgnoreHail || args is not CustomTriggers.IgnoreHailArgs ignoreHailArgs)
return;

View File

@@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Immunity_(Ability)">Bulbapedia - Immunity</see>
/// </summary>
[Script(ScriptCategory.Ability, "immunity")]
public class Immunity : Script
public class Immunity : Script, IScriptPreventStatusChange
{
/// <inheritdoc />
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
ref bool preventStatus)
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
{
if (status == ScriptUtils.ResolveName<Status.Poisoned>() ||
status == ScriptUtils.ResolveName<Status.BadlyPoisoned>())

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Infiltrator_(Ability)">Bulbapedia - Infiltrator</see>
/// </summary>
[Script(ScriptCategory.Ability, "infiltrator")]
public class Infiltrator : Script
public class Infiltrator : Script, IScriptCustomTrigger
{
/// <inheritdoc />
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
{
if (eventName == CustomTriggers.BypassSubstitute && args is CustomTriggers.BypassSubstituteArgs bypassArgs)
{

View File

@@ -8,7 +8,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Inner_Focus_(Ability)">Bulbapedia - Inner Focus</see>
/// </summary>
[Script(ScriptCategory.Ability, "inner_focus")]
public class InnerFocus : Script
public class InnerFocus : Script, IScriptPreventVolatileAdd
{
private IPokemon? _pokemon;
@@ -21,7 +21,7 @@ public class InnerFocus : Script
}
/// <inheritdoc />
public override void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
public void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
{
if (script is not FlinchEffect)
return;

View File

@@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Insomnia_(Ability)">Bulbapedia - Insomnia</see>
/// </summary>
[Script(ScriptCategory.Ability, "insomnia")]
public class Insomnia : Script
public class Insomnia : Script, IScriptPreventStatusChange
{
/// <inheritdoc />
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
ref bool preventStatus)
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
{
if (status != ScriptUtils.ResolveName<Status.Sleep>())
return;

View File

@@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Leaf_Guard_(Ability)">Bulbapedia - Leaf Guard</see>
/// </summary>
[Script(ScriptCategory.Ability, "leaf_guard")]
public class LeafGuard : Script
public class LeafGuard : Script, IScriptPreventStatusChange
{
/// <inheritdoc />
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
ref bool preventStatus)
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
{
if (pokemon.BattleData?.Battle.WeatherName != ScriptUtils.ResolveName<Weather.HarshSunlight>())
return;

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Levitate_(Ability)">Bulbapedia - Levitate</see>
/// </summary>
[Script(ScriptCategory.Ability, "levitate")]
public class Levitate : Script
public class Levitate : Script, IScriptIsFloating
{
/// <inheritdoc />
public override void IsFloating(IPokemon pokemon, ref bool isFloating)
public void IsFloating(IPokemon pokemon, ref bool isFloating)
{
isFloating = true;
}

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Light_Metal_(Ability)">Bulbapedia - Light Metal</see>
/// </summary>
[Script(ScriptCategory.Ability, "light_metal")]
public class LightMetal : Script
public class LightMetal : Script, IScriptModifyWeight
{
/// <inheritdoc />
public override void ModifyWeight(ref float weight)
public void ModifyWeight(ref float weight)
{
weight *= 0.5f;
}

View File

@@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Limber_(Ability)">Bulbapedia - Limber</see>
/// </summary>
[Script(ScriptCategory.Ability, "limber")]
public class Limber : Script
public class Limber : Script, IScriptPreventStatusChange
{
/// <inheritdoc />
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
ref bool preventStatus)
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
{
if (status != ScriptUtils.ResolveName<Status.Paralyzed>())
return;

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Liquid_Ooze_(Ability)">Bulbapedia - Liquid Ooze</see>
/// </summary>
[Script(ScriptCategory.Ability, "liquid_ooze")]
public class LiquidOoze : Script
public class LiquidOoze : Script, IScriptCustomTrigger
{
/// <inheritdoc />
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
{
if (eventName != CustomTriggers.ModifyDrain || args is not CustomTriggers.ModifyDrainArgs parameters)
return;

View File

@@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Long_Reach_(Ability)">Bulbapedia - Long Reach</see>
/// </summary>
[Script(ScriptCategory.Ability, "long_reach")]
public class LongReach : Script
public class LongReach : Script, IScriptModifyIsContact
{
/// <inheritdoc />
public override void ModifyIsContact(IExecutingMove executingMove, IPokemon target, byte hitIndex,
ref bool isContact)
public void ModifyIsContact(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool isContact)
{
isContact = false;
}

View File

@@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Magma_Armor_(Ability)">Bulbapedia - Magma Armor</see>
/// </summary>
[Script(ScriptCategory.Ability, "magma_armor")]
public class MagmaArmor : Script, IScriptOnSwitchIn
public class MagmaArmor : Script, IScriptOnSwitchIn, IScriptPreventStatusChange
{
/// <inheritdoc />
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
ref bool preventStatus)
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
{
if (status == ScriptUtils.ResolveName<Status.Frozen>())
{

View File

@@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Mega_Launcher_(Ability)">Bulbapedia - Mega Launcher</see>
/// </summary>
[Script(ScriptCategory.Ability, "mega_launcher")]
public class MegaLauncher : Script, IScriptChangeBasePower
public class MegaLauncher : Script, IScriptChangeBasePower, IScriptCustomTrigger
{
/// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
@@ -18,7 +18,7 @@ public class MegaLauncher : Script, IScriptChangeBasePower
}
/// <inheritdoc />
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
{
if (eventName != CustomTriggers.ModifyHealPercent || args is not CustomTriggers.ModifyHealPercentArgs healArgs)
return;

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Multitype_(Ability)">Bulbapedia - Multitype</see>
/// </summary>
[Script(ScriptCategory.Ability, "multitype")]
public class Multitype : Script
public class Multitype : Script, IScriptOnAfterHeldItemChange
{
/// <inheritdoc />
public override void OnAfterHeldItemChange(IPokemon pokemon, IItem? previous, IItem? item)
public void OnAfterHeldItemChange(IPokemon pokemon, IItem? previous, IItem? item)
{
if (pokemon.Species.Name != "arceus")
return;

View File

@@ -6,18 +6,17 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/No_Guard_(Ability)">Bulbapedia - No Guard</see>
/// </summary>
[Script(ScriptCategory.Ability, "no_guard")]
public class NoGuard : Script
public class NoGuard : Script, IScriptChangeAccuracy, 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 = 2000;
}
/// <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)
{
modifiedAccuracy = 2000;
}

View File

@@ -8,10 +8,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Oblivious_(Ability)">Bulbapedia - Oblivious</see>
/// </summary>
[Script(ScriptCategory.Ability, "oblivious")]
public class Oblivious : Script
public class Oblivious : Script, IScriptPreventVolatileAdd
{
/// <inheritdoc />
public override void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
public void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
{
preventVolatileAdd = script switch
{

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Overcoat_(Ability)">Bulbapedia - Overcoat</see>
/// </summary>
[Script(ScriptCategory.Ability, "overcoat")]
public class Overcoat : Script, IScriptIsInvulnerableToMove
public class Overcoat : Script, IScriptIsInvulnerableToMove, IScriptCustomTrigger
{
/// <inheritdoc />
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
{
if (eventName == CustomTriggers.IgnoreHail && args is CustomTriggers.IgnoreHailArgs hailArgs)
{

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Own_Tempo_(Ability)">Bulbapedia - Own Tempo</see>
/// </summary>
[Script(ScriptCategory.Ability, "own_tempo")]
public class OwnTempo : Script
public class OwnTempo : Script, IScriptPreventVolatileAdd
{
/// <inheritdoc />
public override void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
public void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
{
if (script is Pokemon.Confusion)
preventVolatileAdd = true;

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Poison_Heal_(Ability)">Bulbapedia - Poison Heal</see>
/// </summary>
[Script(ScriptCategory.Ability, "poison_heal")]
public class PoisonHeal : Script
public class PoisonHeal : Script, IScriptCustomTrigger
{
/// <inheritdoc />
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
{
if (eventName != CustomTriggers.PoisonedDamage)
return;

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Pressure_(Ability)">Bulbapedia - Pressure</see>
/// </summary>
[Script(ScriptCategory.Ability, "pressure")]
public class Pressure : Script
public class Pressure : Script, IScriptModifyPPUsedForIncomingMove
{
/// <inheritdoc />
public override void ModifyPPUsedForIncomingMove(IExecutingMove executingMove, ref byte ppUsed)
public void ModifyPPUsedForIncomingMove(IExecutingMove executingMove, ref byte ppUsed)
{
if (ppUsed == byte.MaxValue)
return;

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/RKS_System_(Ability)">Bulbapedia - RKS System</see>
/// </summary>
[Script(ScriptCategory.Ability, "rks_system")]
public class RKSSystem : Script
public class RKSSystem : Script, IScriptOnAfterHeldItemChange
{
/// <inheritdoc />
public override void OnAfterHeldItemChange(IPokemon pokemon, IItem? previous, IItem? item)
public void OnAfterHeldItemChange(IPokemon pokemon, IItem? previous, IItem? item)
{
if (pokemon.Species.Name != "silvally")
return;

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Rock_Head_(Ability)">Bulbapedia - Rock Head</see>
/// </summary>
[Script(ScriptCategory.Ability, "rock_head")]
public class RockHead : Script
public class RockHead : Script, IScriptCustomTrigger
{
/// <inheritdoc />
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
{
if (eventName != CustomTriggers.ModifyRecoil)
return;

View File

@@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sand_Force_(Ability)">Bulbapedia - Sand Force</see>
/// </summary>
[Script(ScriptCategory.Ability, "sand_force")]
public class SandForce : Script, IScriptChangeBasePower
public class SandForce : Script, IScriptChangeBasePower, IScriptCustomTrigger
{
/// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
@@ -23,7 +23,7 @@ public class SandForce : Script, IScriptChangeBasePower
}
/// <inheritdoc />
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
{
if (eventName == CustomTriggers.BypassSandstormDamage &&
args is CustomTriggers.BypassSandstormDamageArgs bypassArgs)

View File

@@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sand_Rush_(Ability)">Bulbapedia - Sand Rush</see>
/// </summary>
[Script(ScriptCategory.Ability, "sand_rush")]
public class SandRush : Script, IScriptChangeSpeed
public class SandRush : Script, IScriptChangeSpeed, IScriptCustomTrigger
{
/// <inheritdoc />
public void ChangeSpeed(ITurnChoice choice, ref uint speed)
@@ -18,7 +18,7 @@ public class SandRush : Script, IScriptChangeSpeed
}
/// <inheritdoc />
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
{
if (eventName == CustomTriggers.BypassSandstormDamage &&
args is CustomTriggers.BypassSandstormDamageArgs bypassArgs)

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sand_Veil_(Ability)">Bulbapedia - Sand Veil</see>
/// </summary>
[Script(ScriptCategory.Ability, "sand_veil")]
public class SandVeil : Script
public class SandVeil : Script, IScriptCustomTrigger, IScriptChangeIncomingAccuracy
{
/// <inheritdoc />
public override void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
public void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
ref int modifiedAccuracy)
{
if (executingMove.Battle.WeatherName != ScriptUtils.ResolveName<Weather.Sandstorm>())
@@ -19,7 +19,7 @@ public class SandVeil : Script
}
/// <inheritdoc />
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
{
if (eventName == CustomTriggers.BypassSandstormDamage &&
args is CustomTriggers.BypassSandstormDamageArgs bypassArgs)

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Scrappy_(Ability)">Bulbapedia - Scrappy</see>
/// </summary>
[Script(ScriptCategory.Ability, "scrappy")]
public class Scrappy : Script
public class Scrappy : Script, IScriptChangeTypesForMove
{
/// <inheritdoc />
public override void ChangeTypesForMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
public void ChangeTypesForMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
IList<TypeIdentifier> types)
{
var hitType = executingMove.GetHitData(target, hitIndex).Type;

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Skill_Link_(Ability)">Bulbapedia - Skill Link</see>
/// </summary>
[Script(ScriptCategory.Ability, "skill_link")]
public class SkillLink : Script
public class SkillLink : Script, IScriptCustomTrigger
{
/// <inheritdoc />
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
{
if (eventName != CustomTriggers.Modify2_5HitMove)
return;

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Snow_Cloak_(Ability)">Bulbapedia - Snow Cloak</see>
/// </summary>
[Script(ScriptCategory.Ability, "snow_cloak")]
public class SnowCloak : Script
public class SnowCloak : Script, IScriptCustomTrigger, IScriptChangeIncomingAccuracy
{
/// <inheritdoc />
public override void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
public void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
ref int modifiedAccuracy)
{
// If the weather is hail, increase evasion by 20%
@@ -19,7 +19,7 @@ public class SnowCloak : Script
}
}
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
{
if (eventName == CustomTriggers.IgnoreHail && args is CustomTriggers.IgnoreHailArgs hailArgs)
hailArgs.Ignore = true;

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Steadfast_(Ability)">Bulbapedia - Steadfast</see>
/// </summary>
[Script(ScriptCategory.Ability, "steadfast")]
public class Steadfast : Script
public class Steadfast : Script, IScriptCustomTrigger
{
/// <inheritdoc />
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
{
if (eventName != CustomTriggers.OnFlinch)
return;

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sticky_Hold_(Ability)">Bulbapedia - Sticky Hold</see>
/// </summary>
[Script(ScriptCategory.Ability, "sticky_hold")]
public class StickyHold : Script
public class StickyHold : Script, IScriptPreventHeldItemSteal
{
/// <inheritdoc />
public override void PreventHeldItemSteal(IPokemon pokemon, IItem heldItem, ref bool prevent)
public void PreventHeldItemSteal(IPokemon pokemon, IItem heldItem, ref bool prevent)
{
prevent = true;
}

View File

@@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sweet_Veil_(Ability)">Bulbapedia - Sweet Veil</see>
/// </summary>
[Script(ScriptCategory.Ability, "sweet_veil")]
public class SweetVeil : Script
public class SweetVeil : Script, IScriptPreventStatusChange
{
/// <inheritdoc />
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
ref bool preventStatus)
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
{
if (status == ScriptUtils.ResolveName<Status.Sleep>())
{

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Synchronize_(Ability)">Bulbapedia - Synchronize</see>
/// </summary>
[Script(ScriptCategory.Ability, "synchronize")]
public class Synchronize : Script
public class Synchronize : Script, IScriptOnAfterStatusChange
{
/// <inheritdoc />
public override void OnAfterStatusChange(IPokemon pokemon, StringKey status, IPokemon? originPokemon)
public void OnAfterStatusChange(IPokemon pokemon, StringKey status, IPokemon? originPokemon)
{
if (originPokemon == null || pokemon == originPokemon)
return;

View File

@@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Tangled_Feet_(Ability)">Bulbapedia - Tangled Feet</see>
/// </summary>
[Script(ScriptCategory.Ability, "tangled_feet")]
public class TangledFeet : Script
public class TangledFeet : Script, IScriptChangeIncomingAccuracy
{
/// <inheritdoc />
public override void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
public void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
ref int modifiedAccuracy)
{
if (modifiedAccuracy != 255 && target.Volatile.Contains<Pokemon.Confusion>())

View File

@@ -8,10 +8,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Teravolt_(Ability)">Bulbapedia - Teravolt</see>
/// </summary>
[Script(ScriptCategory.Ability, "teravolt")]
public class Teravolt : Script
public class Teravolt : Script, IScriptOnBeforeMoveChoice, IScriptOnAfterMoveChoice
{
/// <inheritdoc />
public override void OnBeforeMoveChoice(IMoveChoice moveChoice)
public void OnBeforeMoveChoice(IMoveChoice moveChoice)
{
var battleData = moveChoice.User.BattleData;
if (battleData is null)
@@ -25,7 +25,7 @@ public class Teravolt : Script
}
/// <inheritdoc />
public override void OnAfterMoveChoice(IMoveChoice move)
public void OnAfterMoveChoice(IMoveChoice move)
{
var battleData = move.User.BattleData;
if (battleData is null)

View File

@@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Victory_Star_(Ability)">Bulbapedia - Victory Star</see>
/// </summary>
[Script(ScriptCategory.Ability, "victory_star")]
public class VictoryStar : Script
public class VictoryStar : Script, IScriptChangeAccuracy
{
/// <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)
{
modifiedAccuracy = modifiedAccuracy.MultiplyOrMax(1.1f);
}

View File

@@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Vital_Spirit_(Ability)">Bulbapedia - Vital Spirit</see>
/// </summary>
[Script(ScriptCategory.Ability, "vital_spirit")]
public class VitalSpirit : Script
public class VitalSpirit : Script, IScriptPreventStatusChange
{
/// <inheritdoc />
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
ref bool preventStatus)
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
{
if (status == ScriptUtils.ResolveName<Status.Sleep>() && !selfInflicted)
{

View File

@@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Water_Bubble_(Ability)">Bulbapedia - Water Bubble</see>
/// </summary>
[Script(ScriptCategory.Ability, "water_bubble")]
public class WaterBubble : Script, IScriptChangeIncomingMoveDamage, IScriptChangeMoveDamage
public class WaterBubble : Script, IScriptChangeIncomingMoveDamage, IScriptChangeMoveDamage, IScriptPreventStatusChange
{
/// <inheritdoc />
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
ref bool preventStatus)
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
{
if (status == ScriptUtils.ResolveName<Status.Burned>())
preventStatus = true;

View File

@@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Water_Veil_(Ability)">Bulbapedia - Water Veil</see>
/// </summary>
[Script(ScriptCategory.Ability, "water_veil")]
public class WaterVeil : Script
public class WaterVeil : Script, IScriptPreventStatusChange
{
/// <inheritdoc />
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
ref bool preventStatus)
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
{
if (status == ScriptUtils.ResolveName<Status.Burned>())
preventStatus = true;

View File

@@ -8,10 +8,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Wonder_Skin_(Ability)">Bulbapedia - Wonder Skin</see>
/// </summary>
[Script(ScriptCategory.Ability, "wonder_skin")]
public class WonderSkin : Script
public class WonderSkin : Script, IScriptChangeIncomingAccuracy
{
/// <inheritdoc />
public override void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
public void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
ref int modifiedAccuracy)
{
if (executingMove.UseMove.Category == MoveCategory.Status && executingMove.UseMove.Accuracy != 255)

View File

@@ -1,12 +1,13 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Battle;
[Script(ScriptCategory.Battle, "gravity")]
public class Gravity : Script, IScriptFailIncomingMove, IScriptOnEndTurn
public class Gravity : Script, IScriptFailIncomingMove, IScriptOnEndTurn, IScriptChangeTypesForIncomingMove,
IScriptIsFloating
{
private int _turns = 5;
/// <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;
@@ -25,7 +26,7 @@ public class Gravity : Script, IScriptFailIncomingMove, IScriptOnEndTurn
}
/// <inheritdoc />
public override void IsFloating(IPokemon pokemon, ref bool isFloating)
public void IsFloating(IPokemon pokemon, ref bool isFloating)
{
// Gravity makes all Pokémon susceptible to Ground-type moves
isFloating = false;

View File

@@ -1,7 +1,8 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Battle;
[Script(ScriptCategory.Battle, "uproar_effect")]
public class UproarEffect : Script, IScriptOnBeforeTurnStart, IScriptOnSecondaryEffect, IScriptOnEndTurn
public class UproarEffect : Script, IScriptOnBeforeTurnStart, IScriptOnSecondaryEffect, IScriptOnEndTurn,
IScriptPreventStatusChange
{
private IPokemon? _placer;
private bool _hasUsedUproar;
@@ -14,8 +15,7 @@ public class UproarEffect : Script, IScriptOnBeforeTurnStart, IScriptOnSecondary
}
/// <inheritdoc />
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
ref bool preventStatus)
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
{
if (status == ScriptUtils.ResolveName<Status.Sleep>())
{

View File

@@ -1,10 +1,10 @@
namespace PkmnLib.Plugin.Gen7.Scripts.MoveVolatile;
[Script(ScriptCategory.MoveVolatile, "bypass_sleep")]
public class BypassSleepVolatile : Script
public class BypassSleepVolatile : Script, IScriptCustomTrigger
{
/// <inheritdoc />
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
{
if (eventName == CustomTriggers.BypassSleep && args is CustomTriggers.BypassSleepArgs bypassArgs)
bypassArgs.Bypass = true;

View File

@@ -40,7 +40,7 @@ public class AuroraVeil : Script, IScriptOnSecondaryEffect
var side = battle.Sides[move.User.BattleData!.SideIndex];
var args = new CustomTriggers.AuroraVeilDurationArgs(move, 5);
move.User.RunScriptHook(x => x.CustomTrigger(CustomTriggers.AuroraVeilDuration, args));
move.User.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.AuroraVeilDuration, args));
var numberOfTurns = args.Duration;
var script = side.VolatileScripts.StackOrAdd(ScriptUtils.ResolveName<AuroraVeilEffect>(), () =>

View File

@@ -9,7 +9,7 @@ public class Bind : Script, IScriptOnSecondaryEffect
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var args = new CustomTriggers.ModifyBindArgs(move);
move.User.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ModifyBind, args));
move.User.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyBind, args));
var bindTurns = args.Duration;
var bindDamage = args.DamagePercent;

View File

@@ -8,7 +8,7 @@ public class ChargeMove : Script, IScriptPreventMove
public void PreventMove(IExecutingMove move, ref bool prevent)
{
var args = new CustomTriggers.BypassChargeMoveArgs(move, false);
move.RunScriptHook(script => script.CustomTrigger(CustomTriggers.BypassChargeMove, args));
move.RunScriptHook<IScriptCustomTrigger>(script => script.CustomTrigger(CustomTriggers.BypassChargeMove, args));
if (args.Bypass)
return;

View File

@@ -24,7 +24,7 @@ public class Drain : Script, IScriptOnInitialize, IScriptOnSecondaryEffect
var invert = false;
var args = new CustomTriggers.ModifyDrainArgs(move, target, hit, damage, healed, invert);
target.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ModifyDrain, args));
target.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyDrain, args));
invert = args.Invert;
healed = args.Healed;

View File

@@ -20,7 +20,7 @@ public class DreamEater : Script, IScriptOnSecondaryEffect, IScriptBlockOutgoing
healed = (uint)(healed * 1.3f);
var args = new CustomTriggers.ModifyDrainArgs(move, target, hit, damage, healed, false);
target.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ModifyDrain, args));
target.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyDrain, args));
var invert = args.Invert;
healed = args.Healed;

View File

@@ -3,10 +3,10 @@ using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "feint")]
public class Feint : Script
public class Feint : Script, IScriptOnBeforeHit
{
/// <inheritdoc />
public override void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
public void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
{
if (target.Volatile.Contains<ProtectionEffectScript>())
{

View File

@@ -14,7 +14,7 @@ public class FlareBlitz : Script, IScriptOnSecondaryEffect
var recoilDamage = hitData.Damage * (1 / 3);
var triggerArgs = new CustomTriggers.ModifyRecoilArgs(move, target, hit, hitData.Damage, recoilDamage);
move.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ModifyRecoil, triggerArgs));
move.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyRecoil, triggerArgs));
if (triggerArgs.Prevent)
return;

View File

@@ -1,10 +1,10 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "flying_press")]
public class FlyingPress : Script
public class FlyingPress : Script, IScriptChangeTypesForMove
{
/// <inheritdoc />
public override void ChangeTypesForMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
public void ChangeTypesForMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
IList<TypeIdentifier> types)
{
var typeLibrary = executingMove.User.Library.StaticLibrary.Types;

View File

@@ -18,7 +18,7 @@ public class HealPercent : Script, IScriptOnInitialize, IScriptOnSecondaryEffect
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var args = new CustomTriggers.ModifyHealPercentArgs(move, target, hit, _healPercent);
move.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ModifyHealPercent, args));
move.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyHealPercent, args));
var healPercent = args.HealPercent;
target.Heal(target.BoostedStats.Hp.MultiplyOrMax(healPercent));

View File

@@ -13,7 +13,7 @@ public class LightScreen : Script, IScriptOnSecondaryEffect
return;
var args = new CustomTriggers.LightScreenNumberOfTurnsArgs(move, 5);
move.RunScriptHook(x => x.CustomTrigger(CustomTriggers.LightScreenNumberOfTurns, args));
move.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.LightScreenNumberOfTurns, args));
var turns = args.Duration;
battleData.BattleSide.VolatileScripts.StackOrAdd(ScriptUtils.ResolveName<LightScreenEffect>(),

View File

@@ -20,7 +20,7 @@ public class MultiHitMove : Script, IScriptChangeNumberOfHits
_ => 5,
};
var triggerArgs = new CustomTriggers.Modify2_5HitMoveArgs(choice, (byte)newHits);
choice.RunScriptHook(x => x.CustomTrigger(CustomTriggers.Modify2_5HitMove, triggerArgs));
choice.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.Modify2_5HitMove, triggerArgs));
newHits = triggerArgs.NumberOfHits;
numberOfHits = (byte)newHits;

View File

@@ -1,11 +1,10 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "one_hit_ko")]
public class OneHitKo : Script, IScriptChangeMoveDamage
public class OneHitKo : Script, IScriptChangeMoveDamage, IScriptChangeAccuracy
{
/// <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)
{
var levelDifference = executingMove.User.Level - target.Level;
if (levelDifference < 0)

View File

@@ -3,11 +3,11 @@ using PkmnLib.Static.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "pollen_puff")]
public class PollenPuff : Script, IScriptOnSecondaryEffect
public class PollenPuff : Script, IScriptOnSecondaryEffect, IScriptChangeCategory
{
/// <inheritdoc />
/// <inheritdoc />
public override void ChangeCategory(IExecutingMove move, IPokemon target, byte hitIndex, ref MoveCategory category)
public void ChangeCategory(IExecutingMove move, IPokemon target, byte hitIndex, ref MoveCategory category)
{
var battleData = move.User.BattleData;
var targetBattleData = target.BattleData;

View File

@@ -3,13 +3,14 @@ using PkmnLib.Static.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "present")]
public class Present : Script, IScriptOnSecondaryEffect, IScriptChangeBasePower
public class Present : Script, IScriptOnSecondaryEffect, IScriptChangeBasePower, IScriptChangeCategory,
IScriptOnBeforeHit
{
private bool _isHealing;
private byte _basePower;
/// <inheritdoc />
public override void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
public void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
{
var battleRandom = move.User.BattleData?.Battle.Random;
if (battleRandom == null)
@@ -33,7 +34,7 @@ public class Present : Script, IScriptOnSecondaryEffect, IScriptChangeBasePower
}
/// <inheritdoc />
public override void ChangeCategory(IExecutingMove move, IPokemon target, byte hitIndex, ref MoveCategory category)
public void ChangeCategory(IExecutingMove move, IPokemon target, byte hitIndex, ref MoveCategory category)
{
if (_isHealing)
category = MoveCategory.Status;

View File

@@ -23,7 +23,7 @@ public class Recoil : Script, IScriptOnInitialize, IScriptOnSecondaryEffect
var recoilDamage = (uint)(hitData.Damage * _recoilPercentage);
var triggerArgs = new CustomTriggers.ModifyRecoilArgs(move, target, hit, hitData.Damage, recoilDamage);
move.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ModifyRecoil, triggerArgs));
move.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyRecoil, triggerArgs));
if (triggerArgs.Prevent)
return;

View File

@@ -12,7 +12,7 @@ public class Reflect : Script, IScriptOnSecondaryEffect
var numberOfTurns = 5;
var args = new CustomTriggers.ReflectNumberOfTurnsArgs(move, numberOfTurns);
move.User.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ReflectNumberOfTurns, args));
move.User.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ReflectNumberOfTurns, args));
numberOfTurns = args.Duration;
battleData.BattleSide.VolatileScripts.Add(new Side.ReflectEffect(numberOfTurns));

View File

@@ -1,10 +1,10 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "spectral_thief")]
public class SpectralThief : Script
public class SpectralThief : Script, IScriptOnBeforeHit
{
/// <inheritdoc />
public override void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
public void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
{
var positiveStats = target.StatBoost.Where(x => x.value > 0).ToArray();
if (positiveStats.Length > 0)

View File

@@ -3,10 +3,10 @@ using PkmnLib.Static.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "sucker_punch")]
public class SuckerPunch : Script
public class SuckerPunch : Script, IScriptOnBeforeHit
{
/// <inheritdoc />
public override void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
public void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
{
var targetChoice = move.Battle.ChoiceQueue?.Where(x => x.User == target).FirstOrDefault();
if (targetChoice is not IMoveChoice moveChoice ||

View File

@@ -14,7 +14,7 @@ public class Whirlpool : Script, IScriptOnSecondaryEffect
var turns = move.Battle.Random.GetInt(4, 6);
var damagePercent = 0.125f;
var args = new CustomTriggers.WhirlpoolArgs(move, target, hit, turns, damagePercent);
move.RunScriptHook(x => x.CustomTrigger(CustomTriggers.Whirlpool, args));
move.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.Whirlpool, args));
turns = args.Turns;
damagePercent = args.DamagePercent;
whirlpoolEffect.AddTargetedPokemon(target, turns, damagePercent);

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")

View File

@@ -1,7 +1,7 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Side;
[Script(ScriptCategory.Side, "flower_veil")]
public class FlowerVeilEffect : Script, IScriptPreventStatBoostChange
public class FlowerVeilEffect : Script, IScriptPreventStatBoostChange, IScriptPreventStatusChange
{
private readonly HashSet<IPokemon> _placerPokemon = [];
@@ -36,8 +36,7 @@ public class FlowerVeilEffect : Script, IScriptPreventStatBoostChange
}
/// <inheritdoc />
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
ref bool preventStatus)
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
{
if (selfInflicted)
return;

View File

@@ -3,17 +3,16 @@ using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
namespace PkmnLib.Plugin.Gen7.Scripts.Side;
[Script(ScriptCategory.Side, "safe_guard")]
public class SafeguardEffect : Script
public class SafeguardEffect : Script, IScriptPreventStatusChange, IScriptPreventVolatileAdd
{
/// <inheritdoc />
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
ref bool preventStatus)
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
{
preventStatus = true;
}
/// <inheritdoc />
public override void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
public void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
{
if (script.Category == ScriptCategory.Pokemon && script.Name == ScriptUtils.ResolveName<Confusion>())
preventVolatileAdd = true;

View File

@@ -29,7 +29,7 @@ public class Poisoned : Script, IScriptOnEndTurn
var battleData = _pokemon.BattleData;
var args = new CustomTriggers.PoisonedDamageArgs(_pokemon, damage);
_pokemon.RunScriptHook(x => x.CustomTrigger(CustomTriggers.PoisonedDamage, args));
_pokemon.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.PoisonedDamage, args));
var eventBatchId = new EventBatchId();
battleData?.Battle.EventHook.Invoke(new DialogEvent("poisoned_damage", new Dictionary<string, object>

View File

@@ -21,7 +21,7 @@ public class Sleep : Script, IScriptPreventMove
// 1-3 turns of sleep
Turns = battleData.Battle.Random.GetInt(1, 4);
var args = new CustomTriggers.ModifySleepTurnsArgs(pokemon, Turns);
source.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ModifySleepTurns, args));
source.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifySleepTurns, args));
Turns = Math.Max(1, args.Turns);
}
}
@@ -40,7 +40,7 @@ public class Sleep : Script, IScriptPreventMove
return;
var args = new CustomTriggers.BypassSleepArgs(move, false);
move.RunScriptHook(x => x.CustomTrigger(CustomTriggers.BypassSleep, args));
move.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.BypassSleep, args));
if (args.Bypass)
return;
prevent = true;

View File

@@ -1,7 +1,7 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Terrain;
[Script(ScriptCategory.Terrain, "electric_terrain")]
public class ElectricTerrain : Script, IScriptChangeBasePower
public class ElectricTerrain : Script, IScriptChangeBasePower, IScriptPreventStatusChange, IScriptPreventVolatileAdd
{
private static bool IsAffectedByTerrain(IPokemon pokemon) =>
!pokemon.IsFloating;
@@ -17,8 +17,7 @@ public class ElectricTerrain : Script, IScriptChangeBasePower
}
/// <inheritdoc />
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
ref bool preventStatus)
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
{
if (!IsAffectedByTerrain(pokemon))
return;
@@ -27,7 +26,7 @@ public class ElectricTerrain : Script, IScriptChangeBasePower
}
/// <inheritdoc />
public override void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
public void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
{
if (parent is IPokemon pokemon && !IsAffectedByTerrain(pokemon))
return;

View File

@@ -1,7 +1,7 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Terrain;
[Script(ScriptCategory.Terrain, "misty_terrain")]
public class MistyTerrain : Script, IScriptChangeBasePower
public class MistyTerrain : Script, IScriptChangeBasePower, IScriptPreventStatusChange
{
private static bool IsAffectedByTerrain(IPokemon pokemon) =>
!pokemon.IsFloating;
@@ -18,8 +18,7 @@ public class MistyTerrain : Script, IScriptChangeBasePower
}
/// <inheritdoc />
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
ref bool preventStatus)
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
{
if (!IsAffectedByTerrain(pokemon))
return;

Some files were not shown because too many files have changed in this diff Show More