Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper

This commit is contained in:
2026-08-28 15:20:26 +02:00
parent 942be8eaeb
commit 8a2733a0a9
859 changed files with 4408 additions and 5331 deletions

View File

@@ -10,7 +10,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Acrobatics : Script, IScriptChangeBasePower
{
/// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
public void ChangeBasePower(IExecutingMove move, IBattlePokemon target, byte hit, ref ushort basePower)
{
if (move.User.HeldItem == null)
basePower = basePower.MultiplyOrMax(2);

View File

@@ -12,7 +12,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Acupressure : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var possibleStats = target.StatBoost.Where(x => x.statistic != Statistic.Hp && x.value < 6).ToArray();
// If the target has no stats to raise, the move fails
@@ -22,7 +22,7 @@ public class Acupressure : Script, IScriptOnSecondaryEffect
return;
}
var index = move.User.BattleData!.Battle.Random.GetInt(0, possibleStats.Length);
var index = move.User.Battle.Random.GetInt(0, possibleStats.Length);
var stat = possibleStats[index].statistic;
target.ChangeStatBoost(stat, 2, false, false);
}

View File

@@ -13,9 +13,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class AfterYou : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var queue = move.User.BattleData!.Battle.ChoiceQueue;
var queue = move.User.Battle.ChoiceQueue;
if (queue == null)
return;

View File

@@ -20,16 +20,14 @@ public class Assist : Script, IScriptChangeMove
public void ChangeMove(IMoveChoice choice, ref StringKey moveName)
{
var user = choice.User;
if (user.BattleData == null)
return;
var battle = user.BattleData.Battle;
var party = battle.Parties.FirstOrDefault(p => p.Party.Contains(user));
var battle = user.Battle;
var party = battle.Parties.FirstOrDefault(p => p.BattlePokemon.Contains(user));
if (party == null)
{
choice.Fail();
return;
}
var moves = GetPartyMoves(party.Party, user).ToList();
var moves = GetPartyMoves(party.BattlePokemon, user).ToList();
if (moves.Count == 0)
{
choice.Fail();
@@ -39,7 +37,7 @@ public class Assist : Script, IScriptChangeMove
moveName = moves[random].Name;
}
private static IEnumerable<IMoveData> GetPartyMoves(IPokemonParty party, IPokemon user)
private static IEnumerable<IMoveData> GetPartyMoves(IReadOnlyList<IBattlePokemon?> party, IBattlePokemon user)
{
foreach (var pokemon in party.WhereNotNull())
{

View File

@@ -21,7 +21,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Attract : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
if (target.Gender == move.User.Gender)
{

View File

@@ -25,9 +25,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class AuroraVeil : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battle = move.User.BattleData?.Battle;
var battle = move.User.Battle;
if (battle == null)
return;
@@ -37,7 +37,7 @@ public class AuroraVeil : Script, IScriptOnSecondaryEffect
return;
}
var side = battle.Sides[move.User.BattleData!.SideIndex];
var side = battle.Sides[move.User.SideIndex];
var args = new CustomTriggers.AuroraVeilDurationArgs(move, 5);
move.User.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.AuroraVeilDuration, args));

View File

@@ -20,7 +20,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Autotomize : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var user = move.User;
if (!user.ChangeStatBoost(Statistic.Speed, 2, true, false))
@@ -30,7 +30,7 @@ public class Autotomize : Script, IScriptOnSecondaryEffect
return;
user.Volatile.StackOrAdd(ScriptUtils.ResolveName<AutotomizeEffect>(), () => new AutotomizeEffect());
var battle = user.BattleData?.Battle;
var battle = user.Battle;
battle?.EventHook.Invoke(new DialogEvent("pokemon_became_nimble", new Dictionary<string, object>
{
{ "pokemon", user },

View File

@@ -5,7 +5,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public abstract class BaseChargeMove<TVolatile> : Script, IScriptPreventMove, IScriptOnBeforeMove,
IScriptOnSecondaryEffect where TVolatile : RequireChargeEffect
{
public abstract TVolatile CreateVolatile(IPokemon user);
public abstract TVolatile CreateVolatile(IBattlePokemon user);
public void PreventMove(IExecutingMove move, ref bool prevent)
{
@@ -18,7 +18,7 @@ public abstract class BaseChargeMove<TVolatile> : Script, IScriptPreventMove, IS
return;
move.User.Volatile.Add(CreateVolatile(move.User));
move.User.BattleData?.Battle.EventHook.Invoke(new DialogEvent("began_charging", new Dictionary<string, object>
move.User.Battle.EventHook.Invoke(new DialogEvent("began_charging", new Dictionary<string, object>
{
{ "user", move.User },
}));
@@ -32,7 +32,7 @@ public abstract class BaseChargeMove<TVolatile> : Script, IScriptPreventMove, IS
}
/// <inheritdoc />
public virtual void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public virtual void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
}
}

View File

@@ -6,15 +6,15 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class BatonPass : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var user = move.User;
var additionalData = move.MoveChoice.AdditionalData;
if (additionalData == null)
return;
if (additionalData["to_switch"] is not IPokemon toSwitch)
if (additionalData["to_switch"] is not IBattlePokemon toSwitch)
return;
var battleData = user.BattleData;
var battleData = user;
if (battleData == null)
return;

View File

@@ -8,7 +8,7 @@ public class BeakBlast : Script, IScriptOnBeforeTurnStart, IScriptOnSecondaryEff
/// <inheritdoc />
public void OnBeforeTurnStart(ITurnChoice choice)
{
var battleData = choice.User.BattleData;
var battleData = choice.User;
if (battleData == null)
return;
choice.User.Volatile.Add(new BeakBlastEffect());
@@ -19,7 +19,7 @@ public class BeakBlast : Script, IScriptOnBeforeTurnStart, IScriptOnSecondaryEff
}
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
move.User.Volatile.Remove(ScriptUtils.ResolveName<BeakBlastEffect>());
}

View File

@@ -3,16 +3,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "beat_up")]
public class BeatUp : Script, IScriptChangeNumberOfHits, IScriptChangeBasePower
{
private IPokemon[]? _relevantPartyMembers;
private IBattlePokemon[]? _relevantPartyMembers;
private static IEnumerable<IPokemon> GetRelevantPartyMembers(IPokemon user)
private static IEnumerable<IBattlePokemon> GetRelevantPartyMembers(IBattlePokemon user)
{
var battleData = user.BattleData;
if (battleData == null)
return [];
var party = battleData.Battle.Parties.FirstOrDefault(x => x.Party.Contains(user));
return party?.Party.WhereNotNull().Where(x => x.IsUsable && x.StatusScript.IsEmpty) ?? [];
var party = user.Battle.Parties.FirstOrDefault(x => x.BattlePokemon.Contains(user));
return party?.BattlePokemon.WhereNotNull().Where(x => x.IsUsable && x.StatusScript.IsEmpty) ?? [];
}
/// <inheritdoc />
@@ -26,7 +22,7 @@ public class BeatUp : Script, IScriptChangeNumberOfHits, IScriptChangeBasePower
}
/// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
public void ChangeBasePower(IExecutingMove move, IBattlePokemon target, byte hit, ref ushort basePower)
{
var relevantPartyMembers = _relevantPartyMembers ??= GetRelevantPartyMembers(move.User).ToArray();
var hittingPokemon = relevantPartyMembers.ElementAtOrDefault(hit);

View File

@@ -6,7 +6,7 @@ public class Belch : Script, IScriptPreventMoveSelection
/// <inheritdoc />
public void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
{
var battleData = choice.User.BattleData;
var battleData = choice.User;
if (battleData == null)
return;

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class BellyDrum : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var maxHealthHalved = target.BoostedStats.Hp / 2;
if (target.CurrentHealth <= maxHealthHalved)

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Bestow : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var user = move.User;
var userHeldItem = user.HeldItem;

View File

@@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Bide : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var bideEffect = move.User.Volatile.Get<BideEffect>();
if (bideEffect == null)
@@ -24,7 +24,7 @@ public class Bide : Script, IScriptOnSecondaryEffect
}
else
{
var lastPokemon = bideEffect.HitBy.LastOrDefault(x => x.BattleData?.IsOnBattlefield == true);
var lastPokemon = bideEffect.HitBy.LastOrDefault(x => x.IsOnBattlefield == true);
lastPokemon?.Damage(bideEffect.DamageTaken * 2, DamageSource.MoveDamage);
}

View File

@@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Bind : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var args = new CustomTriggers.ModifyBindArgs(move);
move.User.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyBind, args));

View File

@@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Block : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
if (target.Types.Any(x => x.Name == TypeNames.Ghost))
return;

View File

@@ -13,7 +13,7 @@ public class Bounce : Script, IScriptPreventMove, IScriptOnBeforeMove, IScriptOn
move.User.Volatile.Add(new ChargeBounceEffect(move.User));
move.MoveChoice.SetAdditionalData("bounce_charge", true);
move.User.BattleData?.Battle.EventHook.Invoke(new DialogEvent("bounce_charge", new Dictionary<string, object>
move.User.Battle.EventHook.Invoke(new DialogEvent("bounce_charge", new Dictionary<string, object>
{
{ "user", move.User },
}));
@@ -27,9 +27,9 @@ public class Bounce : Script, IScriptPreventMove, IScriptOnBeforeMove, IScriptOn
}
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battle = move.User.BattleData?.Battle;
var battle = move.User.Battle;
if (battle == null)
return;
var random = battle.Random;

View File

@@ -9,7 +9,7 @@ public class BrickBreak : Script, IScriptOnBeforeMove
public void OnBeforeMove(IExecutingMove move)
{
var targets = move.Targets.WhereNotNull();
var sides = targets.Select(x => x.BattleData!.BattleSide).Distinct();
var sides = targets.Select(x => x.BattleSide).Distinct();
foreach (var side in sides)
{
side.VolatileScripts.Remove(ScriptUtils.ResolveName<ReflectEffect>());

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Brine : Script, IScriptChangeBasePower
{
/// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
public void ChangeBasePower(IExecutingMove move, IBattlePokemon target, byte hit, ref ushort basePower)
{
if (target.CurrentHealth <= target.BoostedStats.Hp / 2)
{

View File

@@ -4,10 +4,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class BugBite : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var user = move.User;
var battleData = user.BattleData;
var battleData = user;
if (battleData == null)
return;

View File

@@ -4,9 +4,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class BurnUp : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battleData = move.User.BattleData;
var battleData = move.User;
if (battleData == null)
return;
var typeLibrary = battleData.Battle.Library.StaticLibrary.Types;

View File

@@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Camouflage : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var type = GetTypeIdentifier(move.Battle);
if (type == null)

View File

@@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Captivate : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var user = move.User;
if (target.Gender == Gender.Genderless || target.Gender == user.Gender || user.Gender == Gender.Genderless)

View File

@@ -20,7 +20,7 @@ public class ChangeAllTargetStats : Script, IScriptOnInitialize, IScriptOnSecond
}
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
target.ChangeStatBoost(Statistic.Attack, _amount, target == move.User, false);
target.ChangeStatBoost(Statistic.Defense, _amount, target == move.User, false);

View File

@@ -25,7 +25,7 @@ public class ChangeMultipleTargetStatBoosts : Script, IScriptOnInitialize, IScri
}
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
EventBatchId batchId = new();
foreach (var stat in _statBoosts)

View File

@@ -25,7 +25,7 @@ public class ChangeMultipleUserStatBoosts : Script, IScriptOnInitialize, IScript
}
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
EventBatchId batchId = new();
foreach (var stat in _statBoosts)

View File

@@ -30,7 +30,7 @@ public abstract class ChangeTargetStats : Script, IScriptOnInitialize, IScriptOn
}
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
target.ChangeStatBoost(_stat, _amount, target == move.User, false);
}

View File

@@ -30,7 +30,7 @@ public abstract class ChangeUserStats : Script, IScriptOnInitialize, IScriptOnSe
}
/// <inheritdoc />
public virtual void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public virtual void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
move.User.ChangeStatBoost(_stat, _amount, true, false);
}

View File

@@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Charge : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
move.User.ChangeStatBoost(Statistic.SpecialDefense, 1, true, false);
move.User.Volatile.Add(new ChargeEffect());

View File

@@ -4,10 +4,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class ChipAway : Script, IScriptBypassDefensiveStatBoosts, IScriptBypassEvasionStatBoosts
{
/// <inheritdoc />
public void BypassDefensiveStatBoosts(IExecutingMove move, IPokemon target, byte hit, ref bool bypass) =>
public void BypassDefensiveStatBoosts(IExecutingMove move, IBattlePokemon target, byte hit, ref bool bypass) =>
bypass = true;
/// <inheritdoc />
public void BypassEvasionStatBoosts(IExecutingMove move, IPokemon target, byte hitIndex, ref bool bypass) =>
public void BypassEvasionStatBoosts(IExecutingMove move, IBattlePokemon target, byte hitIndex, ref bool bypass) =>
bypass = true;
}

View File

@@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Confuse : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
target.Volatile.Add(new Confusion());
}

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Conversion : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var moveType = move.User.Moves.WhereNotNull().FirstOrDefault()?.MoveData.MoveType;
if (moveType == null)

View File

@@ -7,21 +7,21 @@ public class Conversion2 : Script, IScriptOnSecondaryEffect
private static readonly StringKey NoneTypeName = "none";
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var lastMoveByTarget = target.BattleData?.LastMoveChoice;
var lastMoveByTarget = target.LastMoveChoice;
if (lastMoveByTarget == null || lastMoveByTarget.ChosenMove.MoveData.MoveType.Name == NoneTypeName)
{
move.GetHitData(target, hit).Fail();
return;
}
var typeLibrary = move.User.BattleData!.Battle.Library.StaticLibrary.Types;
var typeLibrary = move.User.Battle.Library.StaticLibrary.Types;
// Get all types against which the last move would be not very effective
var type = typeLibrary.GetAllEffectivenessFromAttacking(lastMoveByTarget.ChosenMove.MoveData.MoveType)
.Where(x => x.effectiveness < 1 && !move.User.Types.Contains(x.type))
// Shuffle them randomly, but deterministically
.OrderBy(_ => move.User.BattleData.Battle.Random.GetInt()).ThenBy(x => x.type.Value)
.OrderBy(_ => move.User.Battle.Random.GetInt()).ThenBy(x => x.type.Value)
// And grab the first one
.Select(x => x.type).FirstOrDefault();
if (type == null)

View File

@@ -8,7 +8,7 @@ public class Copycat : Script, IScriptChangeMove
/// <inheritdoc />
public void ChangeMove(IMoveChoice choice, ref StringKey moveName)
{
var lastMove = choice.User.BattleData?.LastMoveChoice;
var lastMove = choice.User.LastMoveChoice;
if (lastMove == null || !lastMove.ChosenMove.MoveData.CanCopyMove())
{
choice.Fail();

View File

@@ -4,9 +4,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class CoreEnforcer : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battleData = target.BattleData;
var battleData = target;
if (battleData == null)
return;
var turnChoices = battleData.Battle.PreviousTurnChoices.Last();

View File

@@ -12,7 +12,7 @@ public class Counter : Script, IScriptOnBeforeTurnStart, IScriptChangeTargets, I
}
/// <inheritdoc />
public void ChangeTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
public void ChangeTargets(IMoveChoice moveChoice, ref IReadOnlyList<IBattlePokemon?> targets)
{
var counterHelper = moveChoice.User.Volatile.Get<CounterHelperEffect>();
var lastHitBy = counterHelper?.LastHitBy;
@@ -25,7 +25,7 @@ public class Counter : Script, IScriptOnBeforeTurnStart, IScriptChangeTargets, I
}
/// <inheritdoc />
public void ChangeMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
public void ChangeMoveDamage(IExecutingMove move, IBattlePokemon target, byte hit, ref uint damage)
{
var counterHelper = move.User.Volatile.Get<CounterHelperEffect>();
if (counterHelper == null || counterHelper.LastHitBy == null || counterHelper.LastHitBy != target)

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Covet : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
if (target.HeldItem == null)
return;

View File

@@ -6,9 +6,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class CraftyShield : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battleData = move.User.BattleData;
var battleData = move.User;
if (battleData == null)
return;
var side = battleData.Battle.Sides[battleData.SideIndex];

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class CrushGrip : Script, IScriptChangeBasePower
{
/// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
public void ChangeBasePower(IExecutingMove move, IBattlePokemon target, byte hit, ref ushort basePower)
{
basePower = Math.Max((byte)(120 * target.CurrentHealth / target.BoostedStats.Hp), (byte)1);
}

View File

@@ -4,16 +4,13 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class CurePartyStatus : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var user = move.User;
var battle = user.BattleData?.Battle;
if (battle == null)
return;
var party = battle.Parties.FirstOrDefault(p => p.Party.Contains(user));
var party = user.Battle.Parties.FirstOrDefault(p => p.BattlePokemon.Contains(user));
if (party == null)
return;
foreach (var pokemon in party.Party.WhereNotNull())
foreach (var pokemon in party.BattlePokemon.WhereNotNull())
{
pokemon.ClearStatus();
}

View File

@@ -6,9 +6,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Curse : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battleData = move.User.BattleData;
var battleData = move.User;
if (battleData == null)
return;
var typeLibrary = battleData.Battle.Library.StaticLibrary.Types;

View File

@@ -4,10 +4,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class DarkestLariat : Script, IScriptBypassDefensiveStatBoosts, IScriptBypassEvasionStatBoosts
{
/// <inheritdoc />
public void BypassDefensiveStatBoosts(IExecutingMove move, IPokemon target, byte hit, ref bool bypass) =>
public void BypassDefensiveStatBoosts(IExecutingMove move, IBattlePokemon target, byte hit, ref bool bypass) =>
bypass = true;
/// <inheritdoc />
public void BypassEvasionStatBoosts(IExecutingMove move, IPokemon target, byte hitIndex, ref bool bypass) =>
public void BypassEvasionStatBoosts(IExecutingMove move, IBattlePokemon target, byte hitIndex, ref bool bypass) =>
bypass = true;
}

View File

@@ -5,7 +5,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "defense_curl")]
public class DefenseCurl : ChangeUserDefense
{
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public override void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
base.OnSecondaryEffect(move, target, hit);
move.User.Volatile.StackOrAdd(ScriptUtils.ResolveName<DefenseCurlEffect>(), () => new DefenseCurlEffect());

View File

@@ -20,14 +20,11 @@ public class Defog : Script, IScriptOnSecondaryEffect
];
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
if (target.BattleData == null)
return;
target.ChangeStatBoost(Statistic.Evasion, -1, false, false);
foreach (var sides in target.BattleData.Battle.Sides)
foreach (var sides in target.Battle.Sides)
{
foreach (var effect in DefoggedEffects)
{

View File

@@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class DestinyBond : Script, IScriptOnSecondaryEffect, IScriptFailMove
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
move.User.Volatile.Add(new DestinyBondEffect());
}

View File

@@ -13,7 +13,7 @@ public class Dig : Script, IScriptPreventMove, IScriptOnBeforeMove
move.User.Volatile.Add(new DigEffect(move.User));
move.MoveChoice.SetAdditionalData("dig_charge", true);
move.User.BattleData?.Battle.EventHook.Invoke(new DialogEvent("dig_charge", new Dictionary<string, object>
move.User.Battle.EventHook.Invoke(new DialogEvent("dig_charge", new Dictionary<string, object>
{
{ "user", move.User },
}));

View File

@@ -6,9 +6,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Disable : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battleData = move.User.BattleData;
var battleData = move.User;
if (battleData == null)
return;
if (target.Volatile.Contains<DisableEffect>())
@@ -16,7 +16,7 @@ public class Disable : Script, IScriptOnSecondaryEffect
move.GetHitData(target, hit).Fail();
return;
}
var lastMove = target.BattleData?.LastMoveChoice;
var lastMove = target.LastMoveChoice;
if (lastMove == null)
{
move.GetHitData(target, hit).Fail();

View File

@@ -13,7 +13,7 @@ public class Dive : Script, IScriptPreventMove, IScriptOnSecondaryEffect
move.User.Volatile.Add(new DiveEffect(move.User));
move.MoveChoice.SetAdditionalData("dive_charge", true);
move.User.BattleData?.Battle.EventHook.Invoke(new DialogEvent("dive_charge", new Dictionary<string, object>
move.User.Battle.EventHook.Invoke(new DialogEvent("dive_charge", new Dictionary<string, object>
{
{ "user", move.User },
}));
@@ -21,7 +21,7 @@ public class Dive : Script, IScriptPreventMove, IScriptOnSecondaryEffect
}
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
move.User.Volatile.Remove(ScriptUtils.ResolveName<DiveEffect>());
}

View File

@@ -6,9 +6,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class DoomDesire : Script, IScriptBlockOutgoingHit
{
/// <inheritdoc />
public void BlockOutgoingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
public void BlockOutgoingHit(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex, ref bool block)
{
var battleData = target.BattleData;
var battleData = target;
if (battleData == null)
return;
var side = battleData.Battle.Sides[battleData.SideIndex];

View File

@@ -10,7 +10,7 @@ public class DoublePowerIfTargetDamagedInTurn : Script, IScriptOnBeforeTurnStart
{
if (choice is IMoveChoice moveChoice)
{
var battle = choice.User.BattleData?.Battle;
var battle = choice.User.Battle;
if (battle == null)
return;
var side = battle.Sides[moveChoice.TargetSide];
@@ -19,14 +19,12 @@ public class DoublePowerIfTargetDamagedInTurn : Script, IScriptOnBeforeTurnStart
}
/// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
public void ChangeBasePower(IExecutingMove move, IBattlePokemon target, byte hit, ref ushort basePower)
{
var battle = move.User.BattleData?.Battle;
var battle = move.User.Battle;
if (battle == null)
return;
if (target.BattleData == null)
return;
var side = battle.Sides[target.BattleData.SideIndex];
var side = battle.Sides[target.SideIndex];
var data = side.VolatileScripts.Get<DoublePowerIfTargetDamagedInTurnData>();
if (data == null)
return;

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class DragonAscent : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
EventBatchId batchId = new();
move.User.ChangeStatBoost(Statistic.Defense, -1, true, false, batchId);

View File

@@ -14,7 +14,7 @@ public class Drain : Script, IScriptOnInitialize, IScriptOnSecondaryEffect
}
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var user = move.User;
var damage = move.GetHitData(target, hit).Damage;

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class DreamEater : Script, IScriptOnSecondaryEffect, IScriptBlockOutgoingHit
{
/// <inheritdoc />
public void BlockOutgoingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
public void BlockOutgoingHit(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex, ref bool block)
{
if (!target.HasStatus(ScriptUtils.ResolveName<Status.Sleep>()) &&
target.ActiveAbility?.Name != AbilityNames.Comatose)
@@ -12,7 +12,7 @@ public class DreamEater : Script, IScriptOnSecondaryEffect, IScriptBlockOutgoing
}
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var user = move.User;
var damage = move.GetHitData(target, hit).Damage;

View File

@@ -5,9 +5,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "echoed_voice")]
public class EchoedVoice : Script, IScriptOnSecondaryEffect, IScriptChangeBasePower
{
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
public void ChangeBasePower(IExecutingMove move, IBattlePokemon target, byte hit, ref ushort basePower)
{
var battleData = move.User.BattleData;
var battleData = move.User;
if (battleData == null)
return;
var side = battleData.Battle.Sides[battleData.SideIndex];
@@ -20,9 +20,9 @@ public class EchoedVoice : Script, IScriptOnSecondaryEffect, IScriptChangeBasePo
}
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battleData = move.User.BattleData;
var battleData = move.User;
if (battleData == null)
return;
var side = battleData.Battle.Sides[battleData.SideIndex];

View File

@@ -4,9 +4,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class ElectricTerrain : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battleData = move.User.BattleData;
var battleData = move.User;
battleData?.Battle.SetTerrain(ScriptUtils.ResolveName<Terrain.ElectricTerrain>());
}
}

View File

@@ -6,9 +6,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Electrify : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var choiceQueue = target.BattleData?.Battle.ChoiceQueue;
var choiceQueue = target.Battle.ChoiceQueue;
if (choiceQueue == null)
return;

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class ElectroBall : Script, IScriptChangeBasePower
{
/// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
public void ChangeBasePower(IExecutingMove move, IBattlePokemon target, byte hit, ref ushort basePower)
{
var user = move.User;
var targetSpeed = target.BoostedStats.Speed;

View File

@@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Embargo : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
target.Volatile.Add(new EmbargoEffect());
}

View File

@@ -7,13 +7,13 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Encore : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battle = target.BattleData?.Battle;
var battle = target.Battle;
if (battle == null)
return;
var lastMove = target.BattleData?.LastMoveChoice;
var lastMove = target.LastMoveChoice;
if (lastMove == null || battle.Library.MiscLibrary.IsReplacementChoice(lastMove) ||
lastMove.ChosenMove.MoveData.HasFlag(MoveFlags.CantRepeat))
{

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Endeavor : Script, IScriptChangeMoveDamage
{
/// <inheritdoc />
public void ChangeMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
public void ChangeMoveDamage(IExecutingMove move, IBattlePokemon target, byte hit, ref uint damage)
{
var user = move.User;
var userHealth = user.CurrentHealth;

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Entrainment : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var userAbility = move.User.ActiveAbility;
var targetAbility = target.ActiveAbility;

View File

@@ -3,7 +3,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "eruption")]
public class Eruption : Script, IScriptChangeBasePower
{
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
public void ChangeBasePower(IExecutingMove move, IBattlePokemon target, byte hit, ref ushort basePower)
{
basePower = Math.Max((byte)(150 * move.User.CurrentHealth / move.User.BoostedStats.Hp), (byte)1);
}

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Explosion : Script, IScriptOnAfterHits
{
/// <inheritdoc />
public void OnAfterHits(IExecutingMove move, IPokemon target)
public void OnAfterHits(IExecutingMove move, IBattlePokemon target)
{
move.User.Damage(move.User.CurrentHealth * 10, DamageSource.Misc);
}

View File

@@ -7,7 +7,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Facade : Script, IScriptChangeBasePower, IScriptChangeMoveDamage
{
/// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
public void ChangeBasePower(IExecutingMove move, IBattlePokemon target, byte hit, ref ushort basePower)
{
var status = move.User.StatusScript.Script?.Name;
if (status == ScriptUtils.ResolveName<Paralyzed>() || status == ScriptUtils.ResolveName<Burned>() ||
@@ -17,7 +17,7 @@ public class Facade : Script, IScriptChangeBasePower, IScriptChangeMoveDamage
}
}
public void ChangeMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
public void ChangeMoveDamage(IExecutingMove move, IBattlePokemon target, byte hit, ref uint damage)
{
var status = move.User.StatusScript.Script?.Name;
if (status != ScriptUtils.ResolveName<Burned>())

View File

@@ -6,9 +6,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FairyLock : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battle = target.BattleData?.Battle;
var battle = target.Battle;
battle?.Volatile.Add(new FairyLockEffect());
}
}

View File

@@ -8,7 +8,7 @@ public class FakeOut : Script, IScriptStopBeforeMove, IScriptOnSecondaryEffect
/// <inheritdoc />
public void StopBeforeMove(IExecutingMove move, ref bool stop)
{
var battleData = move.User.BattleData;
var battleData = move.User;
if (battleData == null)
return;
if (battleData.SwitchInTurn != battleData.Battle.CurrentTurnNumber)
@@ -16,7 +16,7 @@ public class FakeOut : Script, IScriptStopBeforeMove, IScriptOnSecondaryEffect
}
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
target.Volatile.Add(new FlinchEffect());
}

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FalseSwipe : Script, IScriptChangeMoveDamage
{
/// <inheritdoc />
public void ChangeMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
public void ChangeMoveDamage(IExecutingMove move, IBattlePokemon target, byte hit, ref uint damage)
{
if ((int)target.CurrentHealth - damage < 1)
{

View File

@@ -7,7 +7,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Feint : Script, IScriptOnBeforeHit
{
/// <inheritdoc />
public void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
public void OnBeforeHit(IExecutingMove move, IBattlePokemon target, byte hitIndex)
{
var toRemove = new List<ScriptContainer>();
foreach (var script in target.Volatile)
@@ -22,7 +22,7 @@ public class Feint : Script, IScriptOnBeforeHit
script.Clear();
}
var battleData = target.BattleData;
var battleData = target;
if (battleData is not null)
{
if (battleData.BattleSide.VolatileScripts.Contains<CraftyShieldEffect>())

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FellStinger : Script, IScriptOnAfterHits
{
/// <inheritdoc />
public void OnAfterHits(IExecutingMove move, IPokemon target)
public void OnAfterHits(IExecutingMove move, IBattlePokemon target)
{
if (target.IsFainted)
{

View File

@@ -4,13 +4,13 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FinalGambit : Script, IScriptOnSecondaryEffect, IScriptChangeMoveDamage
{
/// <inheritdoc />
public void ChangeMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
public void ChangeMoveDamage(IExecutingMove move, IBattlePokemon target, byte hit, ref uint damage)
{
damage = move.User.CurrentHealth;
}
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
move.User.Damage(move.User.CurrentHealth * 10, DamageSource.Misc);
}

View File

@@ -6,9 +6,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FireFang : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battleData = target.BattleData;
var battleData = target;
if (battleData == null)
return;
var random = battleData.Battle.Random;

View File

@@ -15,7 +15,7 @@ public class FirePledge : Script, IScriptStopBeforeMove
}
var pledgeMove = (IMoveChoice?)move.Battle.ChoiceQueue?.FirstOrDefault(x =>
x is IMoveChoice mc && mc.User.BattleData?.SideIndex == move.User.BattleData?.SideIndex &&
x is IMoveChoice mc && mc.User.SideIndex == move.User.SideIndex &&
(mc.ChosenMove.MoveData.Name == MoveNames.WaterPledge ||
mc.ChosenMove.MoveData.Name == MoveNames.GrassPledge));
if (pledgeMove is null)

View File

@@ -6,11 +6,11 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FireSpin : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
target.Volatile.StackOrAdd("fire_spin", () =>
{
var turns = target.BattleData!.Battle.Random.GetInt(4, 6);
var turns = target.Battle.Random.GetInt(4, 6);
return new FireSpinEffect(target, turns, move.User);
});
}

View File

@@ -5,7 +5,7 @@ public class FirstImpression : Script, IScriptStopBeforeMove
{
public void StopBeforeMove(IExecutingMove move, ref bool stop)
{
var battleData = move.User.BattleData;
var battleData = move.User;
if (battleData == null)
return;
if (battleData.SwitchInTurn != battleData.Battle.CurrentTurnNumber)

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Flail : Script, IScriptChangeBasePower
{
/// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
public void ChangeBasePower(IExecutingMove move, IBattlePokemon target, byte hit, ref ushort basePower)
{
var remainingHealth = move.User.CurrentHealth / (float)move.User.BoostedStats.Hp;
var fraction = remainingHealth * 48;

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FlameBurst : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var adjacentFoes = GetAdjacentFoes(target).WhereNotNull();
EventBatchId batchId = new();
@@ -14,9 +14,9 @@ public class FlameBurst : Script, IScriptOnSecondaryEffect
}
}
private static IEnumerable<IPokemon?> GetAdjacentFoes(IPokemon pokemon)
private static IEnumerable<IBattlePokemon?> GetAdjacentFoes(IBattlePokemon pokemon)
{
var battleData = pokemon.BattleData;
var battleData = pokemon;
if (battleData == null)
yield break;
if (battleData.Battle.PositionsPerSide == 1)

View File

@@ -17,7 +17,7 @@ public class FlameWheel : Script, IScriptOnInitialize, IScriptOnSecondaryEffect
}
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
if (move.User.HasStatus(ScriptUtils.ResolveName<Status.Frozen>()))
{

View File

@@ -4,9 +4,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FlareBlitz : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battleData = target.BattleData;
var battleData = target;
if (battleData == null)
return;

View File

@@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Flatter : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
target.ChangeStatBoost(Statistic.SpecialAttack, 1, false, false);
target.Volatile.StackOrAdd("confusion", () => new Confusion());

View File

@@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Flinch : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
target.Volatile.Add(new FlinchEffect());
}

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Fling : Script, IScriptOnSecondaryEffect, IScriptChangeBasePower
{
/// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
public void ChangeBasePower(IExecutingMove move, IBattlePokemon target, byte hit, ref ushort basePower)
{
var item = move.User.HeldItem;
if (item == null)
@@ -29,6 +29,6 @@ public class Fling : Script, IScriptOnSecondaryEffect, IScriptChangeBasePower
}
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit) =>
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit) =>
move.User.RemoveHeldItemForBattle();
}

View File

@@ -4,11 +4,11 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FloralHealing : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
if (target.IsFainted)
return;
var battleData = target.BattleData;
var battleData = target;
if (battleData == null)
return;

View File

@@ -6,9 +6,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FlowerShield : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battleData = target.BattleData;
var battleData = target;
if (battleData == null)
return;
if (!battleData.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier(TypeNames.Grass, out var grassType))

View File

@@ -13,7 +13,7 @@ public class Fly : Script, IScriptPreventMove, IScriptOnBeforeMove
move.User.Volatile.Add(new ChargeFlyEffect(move.User));
move.MoveChoice.SetAdditionalData("fly_charge", true);
move.User.BattleData?.Battle.EventHook.Invoke(new DialogEvent("fly_charge", new Dictionary<string, object>
move.User.Battle.EventHook.Invoke(new DialogEvent("fly_charge", new Dictionary<string, object>
{
{ "user", move.User },
}));

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FlyingPress : Script, IScriptChangeTypesForMove
{
/// <inheritdoc />
public void ChangeTypesForMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
public void ChangeTypesForMove(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
IList<TypeIdentifier> types)
{
var typeLibrary = executingMove.User.Library.StaticLibrary.Types;

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FocusEnergy : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
if (target.Volatile.Contains<Pokemon.FocusEnergyEffect>())
{

View File

@@ -9,11 +9,10 @@ public class FocusPunch : Script, IScriptOnBeforeTurnStart, IScriptPreventMove
public void OnBeforeTurnStart(ITurnChoice choice)
{
choice.User.Volatile.Add(new FocusPunchEffect());
choice.User.BattleData?.Battle.EventHook.Invoke(new DialogEvent("focus_punch_charge",
new Dictionary<string, object>
{
{ "pokemon", choice.User },
}));
choice.User.Battle.EventHook.Invoke(new DialogEvent("focus_punch_charge", new Dictionary<string, object>
{
{ "pokemon", choice.User },
}));
}
/// <inheritdoc />

View File

@@ -5,9 +5,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "follow_me")]
public class FollowMe : Script, IScriptOnSecondaryEffect
{
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
move.User.BattleData!.BattleSide.VolatileScripts.StackOrAdd(ScriptUtils.ResolveName<FollowMeEffect>(),
move.User.BattleSide.VolatileScripts.StackOrAdd(ScriptUtils.ResolveName<FollowMeEffect>(),
() => new FollowMeEffect(move.User));
}
}

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class ForceCritical : Script, IScriptChangeCriticalStage
{
/// <inheritdoc />
public void ChangeCriticalStage(IExecutingMove move, IPokemon target, byte hit, ref byte stage)
public void ChangeCriticalStage(IExecutingMove move, IBattlePokemon target, byte hit, ref byte stage)
{
stage = 100;
}

View File

@@ -6,9 +6,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Foresight : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battleData = target.BattleData;
var battleData = target;
if (battleData == null)
return;
if (target.StatBoost.Evasion > 0)

View File

@@ -6,9 +6,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class ForestsCurse : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battleData = target.BattleData;
var battleData = target;
if (battleData == null)
return;
var typeLibrary = battleData.Battle.Library.StaticLibrary.Types;

View File

@@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FoulPlay : Script, IScriptChangeOffensiveStatValue
{
/// <inheritdoc />
public void ChangeOffensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint _,
public void ChangeOffensiveStatValue(IExecutingMove move, IBattlePokemon target, byte hit, uint _,
ImmutableStatisticSet<uint> targetStats, Statistic stat, ref uint value)
{
value = move.UseMove.Category == MoveCategory.Physical

View File

@@ -4,9 +4,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FreezeDry : Script, IScriptChangeEffectiveness, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void ChangeEffectiveness(IExecutingMove move, IPokemon target, byte hit, ref float effectiveness)
public void ChangeEffectiveness(IExecutingMove move, IBattlePokemon target, byte hit, ref float effectiveness)
{
var battleData = target.BattleData;
var battleData = target;
if (battleData == null)
return;
@@ -24,9 +24,9 @@ public class FreezeDry : Script, IScriptChangeEffectiveness, IScriptOnSecondaryE
}
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battleData = target.BattleData;
var battleData = target;
if (battleData == null)
return;

View File

@@ -6,12 +6,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FreezeShock : BaseChargeMove<RequireChargeEffect>
{
/// <inheritdoc />
public override RequireChargeEffect CreateVolatile(IPokemon user) => new(user, "freeze_shock");
public override RequireChargeEffect CreateVolatile(IBattlePokemon user) => new(user, "freeze_shock");
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
public override void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var battleData = target.BattleData;
var battleData = target;
if (battleData == null)
return;

View File

@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Frustration : Script, IScriptChangeBasePower
{
/// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
public void ChangeBasePower(IExecutingMove move, IBattlePokemon target, byte hit, ref ushort basePower)
{
var friendship = move.User.Happiness;
basePower = Math.Max((byte)1, (byte)((255 - friendship) * 2 / 5));

View File

@@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FuryCutter : Script, IScriptChangeBasePower
{
/// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
public void ChangeBasePower(IExecutingMove move, IBattlePokemon target, byte hit, ref ushort basePower)
{
var userEffect = move.User.Volatile.Get<FuryCutterEffect>();
if (userEffect == null)

View File

@@ -4,9 +4,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FusionBolt : Script, IScriptChangeDamageModifier
{
/// <inheritdoc />
public void ChangeDamageModifier(IExecutingMove move, IPokemon target, byte hit, ref float modifier)
public void ChangeDamageModifier(IExecutingMove move, IBattlePokemon target, byte hit, ref float modifier)
{
var battleData = target.BattleData;
var battleData = target;
if (battleData == null)
return;

View File

@@ -4,9 +4,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class FusionFlare : Script, IScriptChangeDamageModifier
{
/// <inheritdoc />
public void ChangeDamageModifier(IExecutingMove move, IPokemon target, byte hit, ref float modifier)
public void ChangeDamageModifier(IExecutingMove move, IBattlePokemon target, byte hit, ref float modifier)
{
var battleData = target.BattleData;
var battleData = target;
if (battleData == null)
return;

View File

@@ -9,7 +9,7 @@ public class FutureSight : Script, IScriptStopBeforeMove
/// <inheritdoc />
public void StopBeforeMove(IExecutingMove move, ref bool prevent)
{
var battleData = move.User.BattleData;
var battleData = move.User;
if (battleData == null)
return;
var battle = battleData.Battle;

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