Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -6,7 +6,8 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class BanefulBunkerEffect : ProtectionEffectScript
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
|
||||
public override void BlockIncomingHit(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
ref bool block)
|
||||
{
|
||||
base.BlockIncomingHit(executingMove, target, hitIndex, ref block);
|
||||
if (block && executingMove.UseMove.Category != MoveCategory.Status &&
|
||||
|
||||
@@ -4,10 +4,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
public abstract class BaseChargeEffect : Script, IScriptForceTurnSelection
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
private readonly StringKey _moveName;
|
||||
|
||||
public BaseChargeEffect(IPokemon owner, StringKey moveName)
|
||||
public BaseChargeEffect(IBattlePokemon owner, StringKey moveName)
|
||||
{
|
||||
_owner = owner;
|
||||
_moveName = moveName;
|
||||
@@ -16,7 +16,7 @@ public abstract class BaseChargeEffect : Script, IScriptForceTurnSelection
|
||||
/// <inheritdoc />
|
||||
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
var opposingSideIndex = (byte)(_owner.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, _moveName, opposingSideIndex, position);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class BeakBlastEffect : Script, IScriptOnIncomingHit
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
public void OnIncomingHit(IExecutingMove move, IBattlePokemon target, byte hit)
|
||||
{
|
||||
if (move.GetHitData(target, hit).IsContact)
|
||||
{
|
||||
|
||||
@@ -5,28 +5,28 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "bide")]
|
||||
public class BideEffect : Script, IScriptForceTurnSelection, IScriptOnIncomingHit, IScriptOnDamage
|
||||
{
|
||||
private readonly IPokemon? _owner;
|
||||
private readonly IBattlePokemon? _owner;
|
||||
public byte Turns;
|
||||
public uint DamageTaken;
|
||||
public readonly List<IPokemon> HitBy = [];
|
||||
public readonly List<IBattlePokemon> HitBy = [];
|
||||
|
||||
private BideEffect()
|
||||
{
|
||||
}
|
||||
|
||||
public BideEffect(IPokemon owner)
|
||||
public BideEffect(IBattlePokemon owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
public void OnIncomingHit(IExecutingMove move, IBattlePokemon target, byte hit)
|
||||
{
|
||||
HitBy.Add(move.User);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnDamage(IPokemon pokemon, DamageSource source, uint oldHealth, uint newHealth)
|
||||
public void OnDamage(IBattlePokemon pokemon, DamageSource source, uint oldHealth, uint newHealth)
|
||||
{
|
||||
DamageTaken += oldHealth - newHealth;
|
||||
}
|
||||
@@ -38,16 +38,15 @@ public class BideEffect : Script, IScriptForceTurnSelection, IScriptOnIncomingHi
|
||||
{
|
||||
if (_owner == null)
|
||||
return;
|
||||
var ownerBattleData = _owner.BattleData;
|
||||
if (ownerBattleData == null)
|
||||
if (_owner == null)
|
||||
return;
|
||||
if (ownerBattleData.SideIndex != sideIndex || ownerBattleData.Position != position)
|
||||
if (_owner.SideIndex != sideIndex || _owner.Position != position)
|
||||
return;
|
||||
if (_choice != null)
|
||||
{
|
||||
choice = _choice;
|
||||
return;
|
||||
}
|
||||
choice = _choice = TurnChoiceHelper.CreateMoveChoice(_owner, "bide", ownerBattleData.SideIndex, position);
|
||||
choice = _choice = TurnChoiceHelper.CreateMoveChoice(_owner, "bide", _owner.SideIndex, position);
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,11 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class BindEffect : Script, IScriptOnEndTurn, IScriptPreventSelfSwitch, IScriptPreventSelfRunAway,
|
||||
IAIInfoScriptExpectedEndOfTurnDamage
|
||||
{
|
||||
private readonly IPokemon? _owner;
|
||||
private readonly IBattlePokemon? _owner;
|
||||
private int _turns;
|
||||
private readonly float _percentOfMaxHealth;
|
||||
|
||||
public BindEffect(IPokemon owner, int turns, float percentOfMaxHealth)
|
||||
public BindEffect(IBattlePokemon owner, int turns, float percentOfMaxHealth)
|
||||
{
|
||||
_owner = owner;
|
||||
_turns = turns;
|
||||
@@ -36,7 +36,7 @@ public class BindEffect : Script, IScriptOnEndTurn, IScriptPreventSelfSwitch, IS
|
||||
public void PreventSelfRunAway(IFleeChoice choice, ref bool prevent) => prevent = _turns > 0;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ExpectedEndOfTurnDamage(IPokemon pokemon, ref int damage)
|
||||
public void ExpectedEndOfTurnDamage(IBattlePokemon pokemon, ref int damage)
|
||||
{
|
||||
damage += (int)(_owner?.MaxHealth * _percentOfMaxHealth ?? 0);
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class ChargeBounceEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage,
|
||||
IScriptBlockIncomingHit, IScriptOnAfterMoveChoice
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsSemiInvulnerableTurn => true;
|
||||
|
||||
public ChargeBounceEffect(IPokemon owner)
|
||||
public ChargeBounceEffect(IBattlePokemon owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
@@ -19,19 +19,19 @@ public class ChargeBounceEffect : Script, IScriptForceTurnSelection, IScriptChan
|
||||
/// <inheritdoc />
|
||||
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
var opposingSideIndex = (byte)(_owner.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "bounce", opposingSideIndex, position);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
|
||||
public void BlockIncomingHit(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex, ref bool block)
|
||||
{
|
||||
if (!executingMove.UseMove.HasFlag(MoveFlags.HitFlying))
|
||||
block = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
|
||||
public void ChangeIncomingMoveDamage(IExecutingMove move, IBattlePokemon target, byte hit, ref uint damage)
|
||||
{
|
||||
if (move.UseMove.HasFlag(MoveFlags.EffectiveAgainstFly))
|
||||
damage *= 2;
|
||||
|
||||
@@ -6,9 +6,9 @@ public class ChargeEffect : Script, IScriptChangeDamageModifier, IScriptOnEndTur
|
||||
private bool _turnOfUse = true;
|
||||
|
||||
/// <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 library = target.BattleData?.Battle.Library;
|
||||
var library = target.Battle.Library;
|
||||
if (library == null)
|
||||
return;
|
||||
if (!library.StaticLibrary.Types.TryGetTypeIdentifier(TypeNames.Electric, out var electricType))
|
||||
|
||||
@@ -6,12 +6,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class ChargeFlyEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage,
|
||||
IScriptBlockIncomingHit, IScriptOnAfterMoveChoice
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsSemiInvulnerableTurn => true;
|
||||
|
||||
public ChargeFlyEffect(IPokemon owner)
|
||||
public ChargeFlyEffect(IBattlePokemon owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
@@ -19,19 +19,19 @@ public class ChargeFlyEffect : Script, IScriptForceTurnSelection, IScriptChangeI
|
||||
/// <inheritdoc />
|
||||
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
var opposingSideIndex = (byte)(_owner.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "fly", opposingSideIndex, position);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
|
||||
public void BlockIncomingHit(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex, ref bool block)
|
||||
{
|
||||
if (!executingMove.UseMove.HasFlag(MoveFlags.HitFlying))
|
||||
block = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
|
||||
public void ChangeIncomingMoveDamage(IExecutingMove move, IBattlePokemon target, byte hit, ref uint damage)
|
||||
{
|
||||
if (move.UseMove.HasFlag(MoveFlags.EffectiveAgainstFly))
|
||||
damage *= 2;
|
||||
|
||||
@@ -6,11 +6,11 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class ChargeMoveEffect : Script, IScriptForceTurnSelection
|
||||
{
|
||||
public readonly StringKey MoveName;
|
||||
private readonly IPokemon _user;
|
||||
private readonly IBattlePokemon _user;
|
||||
private readonly byte _targetSide;
|
||||
private readonly byte _targetPosition;
|
||||
|
||||
public ChargeMoveEffect(StringKey moveName, IPokemon user, byte targetSide, byte targetPosition)
|
||||
public ChargeMoveEffect(StringKey moveName, IBattlePokemon user, byte targetSide, byte targetPosition)
|
||||
{
|
||||
MoveName = moveName;
|
||||
_user = user;
|
||||
|
||||
@@ -6,12 +6,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class ChargeSkyDropEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage,
|
||||
IScriptBlockIncomingHit, IScriptOnAfterMoveChoice
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsSemiInvulnerableTurn => true;
|
||||
|
||||
public ChargeSkyDropEffect(IPokemon owner)
|
||||
public ChargeSkyDropEffect(IBattlePokemon owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
@@ -19,19 +19,19 @@ public class ChargeSkyDropEffect : Script, IScriptForceTurnSelection, IScriptCha
|
||||
/// <inheritdoc />
|
||||
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
var opposingSideIndex = (byte)(_owner.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "sky_drop", opposingSideIndex, position);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
|
||||
public void BlockIncomingHit(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex, ref bool block)
|
||||
{
|
||||
if (!executingMove.UseMove.HasFlag(MoveFlags.HitFlying))
|
||||
block = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
|
||||
public void ChangeIncomingMoveDamage(IExecutingMove move, IBattlePokemon target, byte hit, ref uint damage)
|
||||
{
|
||||
if (!move.UseMove.HasFlag(MoveFlags.EffectiveAgainstFly))
|
||||
damage *= 2;
|
||||
|
||||
@@ -10,9 +10,9 @@ public class Confusion : Script, IScriptStopBeforeMove
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
throw new InvalidOperationException("Confusion script can only be added to a Pokemon.");
|
||||
var battleData = pokemon.BattleData;
|
||||
var battleData = pokemon;
|
||||
if (battleData == null)
|
||||
throw new InvalidOperationException("Confusion script requires a Pokemon to be in a battle.");
|
||||
_turnsConfused = battleData.Battle.Random.GetInt(2, 5);
|
||||
|
||||
@@ -5,11 +5,11 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "counterhelper")]
|
||||
public class CounterHelperEffect : Script, IScriptOnIncomingHit
|
||||
{
|
||||
public IPokemon? LastHitBy { get; private set; }
|
||||
public IBattlePokemon? LastHitBy { get; private set; }
|
||||
public uint LastDamage { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
public void OnIncomingHit(IExecutingMove move, IBattlePokemon target, byte hit)
|
||||
{
|
||||
if (move.UseMove.Category == MoveCategory.Physical)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "defense_curl")]
|
||||
public class DefenseCurlEffect : 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)
|
||||
{
|
||||
if (move.UseMove.Name == MoveNames.Rollout || move.UseMove.Name == MoveNames.IceBall)
|
||||
basePower = basePower.MultiplyOrMax(2);
|
||||
|
||||
@@ -4,11 +4,11 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class DestinyBondEffect : Script, IScriptOnBeforeMove, IScriptOnFaint
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnFaint(IPokemon pokemon, DamageSource source)
|
||||
public void OnFaint(IBattlePokemon pokemon, DamageSource source)
|
||||
{
|
||||
if (source == DamageSource.MoveDamage)
|
||||
{
|
||||
if (pokemon.BattleData?.Battle.ChoiceQueue?.LastRanChoice is not IMoveChoice lastChoice)
|
||||
if (pokemon.Battle.ChoiceQueue?.LastRanChoice is not IMoveChoice lastChoice)
|
||||
return;
|
||||
lastChoice.User.Damage(lastChoice.User.BoostedStats.Hp * 10, DamageSource.Misc, forceDamage: true);
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class DigEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage, IScriptBlockIncomingHit,
|
||||
IScriptOnAfterMoveChoice
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsSemiInvulnerableTurn => true;
|
||||
|
||||
public DigEffect(IPokemon owner)
|
||||
public DigEffect(IBattlePokemon owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
@@ -19,19 +19,19 @@ public class DigEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomin
|
||||
/// <inheritdoc />
|
||||
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
var opposingSideIndex = (byte)(_owner.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "dig", opposingSideIndex, position);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
|
||||
public void BlockIncomingHit(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex, ref bool block)
|
||||
{
|
||||
if (!executingMove.UseMove.HasFlag(MoveFlags.HitUnderground))
|
||||
block = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
|
||||
public void ChangeIncomingMoveDamage(IExecutingMove move, IBattlePokemon target, byte hit, ref uint damage)
|
||||
{
|
||||
if (move.UseMove.HasFlag(MoveFlags.EffectiveAgainstUnderground))
|
||||
damage *= 2;
|
||||
|
||||
@@ -6,12 +6,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class DiveEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage, IScriptBlockIncomingHit,
|
||||
IScriptOnAfterMoveChoice
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsSemiInvulnerableTurn => true;
|
||||
|
||||
public DiveEffect(IPokemon owner)
|
||||
public DiveEffect(IBattlePokemon owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
@@ -19,19 +19,19 @@ public class DiveEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomi
|
||||
/// <inheritdoc />
|
||||
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
var opposingSideIndex = (byte)(_owner.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "dive", opposingSideIndex, position);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
|
||||
public void BlockIncomingHit(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex, ref bool block)
|
||||
{
|
||||
if (!executingMove.UseMove.HasFlag(MoveFlags.HitUnderwater))
|
||||
block = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
|
||||
public void ChangeIncomingMoveDamage(IExecutingMove move, IBattlePokemon target, byte hit, ref uint damage)
|
||||
{
|
||||
if (move.UseMove.HasFlag(MoveFlags.EffectiveAgainstUnderwater))
|
||||
damage *= 2;
|
||||
|
||||
@@ -6,7 +6,7 @@ public class EmbargoEffect : Script, IScriptOnEndTurn, IScriptStack, IScriptPrev
|
||||
private int _turns = 5;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void PreventHeldItemConsume(IPokemon pokemon, IItem heldItem, ref bool prevented)
|
||||
public void PreventHeldItemConsume(IBattlePokemon pokemon, IItem heldItem, ref bool prevented)
|
||||
{
|
||||
prevented = true;
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "encore")]
|
||||
public class EncoreEffect : Script, IScriptForceTurnSelection, IScriptOnEndTurn
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
private readonly StringKey _move;
|
||||
private int _turns;
|
||||
|
||||
public EncoreEffect(IPokemon owner, StringKey move, int turns)
|
||||
public EncoreEffect(IBattlePokemon owner, StringKey move, int turns)
|
||||
{
|
||||
_owner = owner;
|
||||
_move = move;
|
||||
@@ -19,12 +19,11 @@ public class EncoreEffect : Script, IScriptForceTurnSelection, IScriptOnEndTurn
|
||||
/// <inheritdoc />
|
||||
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
var opposingSideIndex = (byte)(_owner.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, _move, opposingSideIndex, position);
|
||||
if (choice is IMoveChoice { ChosenMove.CurrentPp: <= 0 } moveChoice)
|
||||
{
|
||||
choice = moveChoice.User.BattleData?.Battle.Library.MiscLibrary.ReplacementChoice(_owner, opposingSideIndex,
|
||||
position);
|
||||
choice = moveChoice.User.Battle.Library.MiscLibrary.ReplacementChoice(_owner, opposingSideIndex, position);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class EndureEffect : Script, IScriptOnEndTurn, IScriptChangeIncomingDamage
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingDamage(IPokemon pokemon, DamageSource source, ref uint damage)
|
||||
public void ChangeIncomingDamage(IBattlePokemon pokemon, DamageSource source, ref uint damage)
|
||||
{
|
||||
if (damage >= pokemon.CurrentHealth)
|
||||
damage = pokemon.CurrentHealth - 1;
|
||||
|
||||
@@ -4,11 +4,11 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class FireSpinEffect : Script, IScriptOnEndTurn, IScriptPreventSelfRunAway, IScriptPreventSelfSwitch,
|
||||
IAIInfoScriptExpectedEndOfTurnDamage
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
private int _turns;
|
||||
private readonly float _modifier;
|
||||
|
||||
public FireSpinEffect(IPokemon owner, int turns, IPokemon user)
|
||||
public FireSpinEffect(IBattlePokemon owner, int turns, IBattlePokemon user)
|
||||
{
|
||||
_owner = owner;
|
||||
_turns = turns;
|
||||
@@ -39,7 +39,7 @@ public class FireSpinEffect : Script, IScriptOnEndTurn, IScriptPreventSelfRunAwa
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ExpectedEndOfTurnDamage(IPokemon pokemon, ref int damage)
|
||||
public void ExpectedEndOfTurnDamage(IBattlePokemon pokemon, ref int damage)
|
||||
{
|
||||
damage += (int)(pokemon.MaxHealth / _modifier);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class FlashFireEffect : Script, IScriptChangeOffensiveStatValue
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeOffensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint defensiveStat,
|
||||
public void ChangeOffensiveStatValue(IExecutingMove move, IBattlePokemon target, byte hit, uint defensiveStat,
|
||||
ImmutableStatisticSet<uint> targetStats, Statistic stat, ref uint value)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name == TypeNames.Fire)
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "increased_critical_stage")]
|
||||
public class FocusEnergyEffect : Script, IScriptChangeCriticalStage
|
||||
{
|
||||
public void ChangeCriticalStage(IExecutingMove move, IPokemon target, byte hit, ref byte stage)
|
||||
public void ChangeCriticalStage(IExecutingMove move, IBattlePokemon target, byte hit, ref byte stage)
|
||||
{
|
||||
if (stage == byte.MaxValue)
|
||||
{
|
||||
|
||||
@@ -8,15 +8,14 @@ public class FocusPunchEffect : Script, IScriptOnIncomingHit
|
||||
public bool WasHit { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
public void OnIncomingHit(IExecutingMove move, IBattlePokemon target, byte hit)
|
||||
{
|
||||
if (move.UseMove.SecondaryEffect?.Name == MoveEffectNames.OneHitKo)
|
||||
return;
|
||||
WasHit = true;
|
||||
target.BattleData?.Battle.EventHook.Invoke(new DialogEvent("focus_punch_lost_focus",
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "pokemon", target },
|
||||
}));
|
||||
target.Battle.EventHook.Invoke(new DialogEvent("focus_punch_lost_focus", new Dictionary<string, object>
|
||||
{
|
||||
{ "pokemon", target },
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ public class ForesightEffect : Script, IScriptPreventStatBoostChange, IScriptCha
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void PreventStatBoostChange(IPokemon target, Statistic stat, sbyte amount, bool selfInflicted,
|
||||
public void PreventStatBoostChange(IBattlePokemon target, Statistic stat, sbyte amount, bool selfInflicted,
|
||||
ref bool prevent)
|
||||
{
|
||||
if (stat == Statistic.Evasion)
|
||||
@@ -25,7 +25,7 @@ public class ForesightEffect : Script, IScriptPreventStatBoostChange, IScriptCha
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
IList<TypeIdentifier> types)
|
||||
{
|
||||
if (executingMove.UseMove.MoveType == _normalType || executingMove.UseMove.MoveType == _fightingType)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "require_charge")]
|
||||
public class RequireChargeEffect(IPokemon owner, StringKey moveName) : BaseChargeEffect(owner, moveName);
|
||||
public class RequireChargeEffect(IBattlePokemon owner, StringKey moveName) : BaseChargeEffect(owner, moveName);
|
||||
@@ -3,9 +3,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "ghostcurse")]
|
||||
public class GhostCurseEffect : Script, IScriptOnEndTurn, IAIInfoScriptExpectedEndOfTurnDamage
|
||||
{
|
||||
private IPokemon _pokemon;
|
||||
private IBattlePokemon _pokemon;
|
||||
|
||||
public GhostCurseEffect(IPokemon pokemon)
|
||||
public GhostCurseEffect(IBattlePokemon pokemon)
|
||||
{
|
||||
_pokemon = pokemon;
|
||||
}
|
||||
@@ -17,7 +17,7 @@ public class GhostCurseEffect : Script, IScriptOnEndTurn, IAIInfoScriptExpectedE
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ExpectedEndOfTurnDamage(IPokemon pokemon, ref int damage)
|
||||
public void ExpectedEndOfTurnDamage(IBattlePokemon pokemon, ref int damage)
|
||||
{
|
||||
damage += (int)(_pokemon.MaxHealth / 4f);
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@ public class GrudgeEffect : Script, IScriptOnIncomingHit, IScriptOnFaint
|
||||
private ILearnedMove? _lastMove;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
public void OnIncomingHit(IExecutingMove move, IBattlePokemon target, byte hit)
|
||||
{
|
||||
_lastMove = move.ChosenMove;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnFaint(IPokemon pokemon, DamageSource source)
|
||||
public void OnFaint(IBattlePokemon pokemon, DamageSource source)
|
||||
{
|
||||
if (_lastMove != null && source == DamageSource.MoveDamage)
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ public class HealBlockEffect : Script, IScriptPreventMoveSelection, IScriptPreve
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void PreventHeal(IPokemon pokemon, uint heal, bool allowRevive, ref bool prevented)
|
||||
public void PreventHeal(IBattlePokemon pokemon, uint heal, bool allowRevive, ref bool prevented)
|
||||
{
|
||||
prevented = true;
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class HealEachEndOfTurnEffect : Script, IScriptOnEndTurn
|
||||
{
|
||||
private readonly float _healPercentage;
|
||||
private readonly IPokemon? _pokemon;
|
||||
private readonly IBattlePokemon? _pokemon;
|
||||
|
||||
private HealEachEndOfTurnEffect()
|
||||
{
|
||||
}
|
||||
|
||||
public HealEachEndOfTurnEffect(float healPercentage, IPokemon pokemon)
|
||||
public HealEachEndOfTurnEffect(float healPercentage, IBattlePokemon pokemon)
|
||||
{
|
||||
_healPercentage = healPercentage;
|
||||
_pokemon = pokemon;
|
||||
@@ -23,7 +23,7 @@ public class HealEachEndOfTurnEffect : Script, IScriptOnEndTurn
|
||||
{
|
||||
if (_pokemon is null)
|
||||
return;
|
||||
if (_pokemon.BattleData?.IsOnBattlefield != true)
|
||||
if (_pokemon.IsOnBattlefield != true)
|
||||
return;
|
||||
|
||||
var amount = _pokemon.BoostedStats.Hp * _healPercentage;
|
||||
|
||||
@@ -6,7 +6,7 @@ public class HelpingHandEffect : Script, IScriptChangeBasePower, IScriptOnEndTur
|
||||
private int _stacks = 1;
|
||||
|
||||
/// <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 = basePower.MultiplyOrMax((float)Math.Pow(1.5f, _stacks));
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -5,11 +5,11 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "ice_ball")]
|
||||
public class IceBallEffect : Script, IScriptForceTurnSelection, IScriptOnMoveMiss, IScriptOnEndTurn
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
private readonly StringKey _moveName;
|
||||
public int TurnCount { get; set; }
|
||||
|
||||
public IceBallEffect(IPokemon owner, StringKey moveName)
|
||||
public IceBallEffect(IBattlePokemon owner, StringKey moveName)
|
||||
{
|
||||
_owner = owner;
|
||||
_moveName = moveName;
|
||||
@@ -19,12 +19,12 @@ public class IceBallEffect : Script, IScriptForceTurnSelection, IScriptOnMoveMis
|
||||
/// <inheritdoc />
|
||||
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
var opposingSideIndex = (byte)(_owner.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, _moveName, opposingSideIndex, position);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnMoveMiss(IExecutingMove move, IPokemon target)
|
||||
public void OnMoveMiss(IExecutingMove move, IBattlePokemon target)
|
||||
{
|
||||
RemoveSelf();
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "imprison")]
|
||||
public class ImprisonEffect : Script, IScriptPreventMoveSelection
|
||||
{
|
||||
private readonly IPokemon _user;
|
||||
private readonly IBattlePokemon _user;
|
||||
|
||||
public ImprisonEffect(IPokemon user)
|
||||
public ImprisonEffect(IBattlePokemon user)
|
||||
{
|
||||
_user = user;
|
||||
}
|
||||
@@ -13,7 +13,7 @@ public class ImprisonEffect : Script, IScriptPreventMoveSelection
|
||||
/// <inheritdoc />
|
||||
public void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
|
||||
{
|
||||
if (choice.User.BattleData?.BattleSide == _user.BattleData?.BattleSide)
|
||||
if (choice.User.BattleSide == _user.BattleSide)
|
||||
return;
|
||||
|
||||
if (_user.Moves.WhereNotNull().Any(x => x.MoveData.Name == choice.ChosenMove.MoveData.Name))
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class IncreasedCriticalStage : 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)
|
||||
{
|
||||
// Extreme edge case, should never happen
|
||||
if (stage == byte.MaxValue)
|
||||
|
||||
@@ -15,7 +15,7 @@ public class Infatuated : Script, IScriptPreventMove
|
||||
/// <inheritdoc />
|
||||
public void PreventMove(IExecutingMove move, ref bool prevent)
|
||||
{
|
||||
if (move.User.BattleData?.Battle.Random.GetBool() == true)
|
||||
if (move.User.Battle.Random.GetBool() == true)
|
||||
prevent = true;
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,11 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class InfestationEffect : Script, IScriptOnEndTurn, IScriptPreventSelfSwitch, IScriptPreventSelfRunAway,
|
||||
IAIInfoScriptExpectedEndOfTurnDamage
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
private int _turns;
|
||||
private readonly float _bindDamage;
|
||||
|
||||
public InfestationEffect(IPokemon owner, int turns, float bindDamage)
|
||||
public InfestationEffect(IBattlePokemon owner, int turns, float bindDamage)
|
||||
{
|
||||
_owner = owner;
|
||||
_turns = turns;
|
||||
@@ -35,7 +35,7 @@ public class InfestationEffect : Script, IScriptOnEndTurn, IScriptPreventSelfSwi
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ExpectedEndOfTurnDamage(IPokemon pokemon, ref int damage)
|
||||
public void ExpectedEndOfTurnDamage(IBattlePokemon pokemon, ref int damage)
|
||||
{
|
||||
damage += (int)(_owner.MaxHealth * _bindDamage);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class IngrainEffect : Script, IScriptFailIncomingMove, IScriptOnEndTurn, IScriptPreventSelfSwitch,
|
||||
IScriptPreventSelfRunAway, IScriptChangeTypesForIncomingMove
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
|
||||
public IngrainEffect(IPokemon owner)
|
||||
public IngrainEffect(IBattlePokemon owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class IngrainEffect : Script, IScriptFailIncomingMove, IScriptOnEndTurn,
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void FailIncomingMove(IExecutingMove move, IPokemon target, ref bool fail)
|
||||
public void FailIncomingMove(IExecutingMove move, IBattlePokemon target, ref bool fail)
|
||||
{
|
||||
if (move.UseMove.Name == MoveNames.Roar || move.UseMove.Name == MoveNames.Whirlwind)
|
||||
{
|
||||
@@ -42,7 +42,7 @@ public class IngrainEffect : Script, IScriptFailIncomingMove, IScriptOnEndTurn,
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
IList<TypeIdentifier> types)
|
||||
{
|
||||
if (executingMove.UseMove.MoveType.Name == TypeNames.Ground)
|
||||
|
||||
@@ -6,7 +6,8 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class KingsShieldEffect : ProtectionEffectScript
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
|
||||
public override void BlockIncomingHit(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
ref bool block)
|
||||
{
|
||||
// Kings Shield doesnt protect from status moves
|
||||
if (executingMove.UseMove.Category == MoveCategory.Status)
|
||||
|
||||
@@ -6,7 +6,7 @@ public class LaserFocusEffect : Script, IScriptChangeCriticalStage, IScriptOnEnd
|
||||
private bool _hasHadEndTurn;
|
||||
|
||||
/// <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;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "leech_seed")]
|
||||
public class LeechSeedEffect : Script, IScriptOnEndTurn, IAIInfoScriptExpectedEndOfTurnDamage
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IPokemon _placer;
|
||||
private readonly IBattlePokemon _owner;
|
||||
private readonly IBattlePokemon _placer;
|
||||
|
||||
public LeechSeedEffect(IPokemon owner, IPokemon placer)
|
||||
public LeechSeedEffect(IBattlePokemon owner, IBattlePokemon placer)
|
||||
{
|
||||
_owner = owner;
|
||||
_placer = placer;
|
||||
@@ -27,7 +27,7 @@ public class LeechSeedEffect : Script, IScriptOnEndTurn, IAIInfoScriptExpectedEn
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ExpectedEndOfTurnDamage(IPokemon pokemon, ref int damage)
|
||||
public void ExpectedEndOfTurnDamage(IBattlePokemon pokemon, ref int damage)
|
||||
{
|
||||
damage += (int)(_owner.MaxHealth / 8f);
|
||||
}
|
||||
|
||||
@@ -3,15 +3,15 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "lock_on")]
|
||||
public class LockOnEffect : Script, IScriptOnEndTurn, IScriptChangeIncomingAccuracy
|
||||
{
|
||||
private readonly IPokemon _placer;
|
||||
private readonly IBattlePokemon _placer;
|
||||
private bool _hasHadEndTurn;
|
||||
|
||||
public LockOnEffect(IPokemon placer)
|
||||
public LockOnEffect(IBattlePokemon placer)
|
||||
{
|
||||
_placer = placer;
|
||||
}
|
||||
|
||||
public void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||
public void ChangeIncomingAccuracy(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
ref int modifiedAccuracy)
|
||||
{
|
||||
if (_placer != executingMove.User)
|
||||
|
||||
@@ -4,11 +4,11 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class MagmaStormEffect : Script, IScriptOnEndTurn, IScriptPreventSelfRunAway, IScriptPreventSelfSwitch,
|
||||
IAIInfoScriptExpectedEndOfTurnDamage
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
private int _turns;
|
||||
private readonly float _percentOfMaxHealth;
|
||||
|
||||
public MagmaStormEffect(IPokemon owner, int turns, float percentOfMaxHealth)
|
||||
public MagmaStormEffect(IBattlePokemon owner, int turns, float percentOfMaxHealth)
|
||||
{
|
||||
_owner = owner;
|
||||
_turns = turns;
|
||||
@@ -42,7 +42,7 @@ public class MagmaStormEffect : Script, IScriptOnEndTurn, IScriptPreventSelfRunA
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ExpectedEndOfTurnDamage(IPokemon pokemon, ref int damage)
|
||||
public void ExpectedEndOfTurnDamage(IBattlePokemon pokemon, ref int damage)
|
||||
{
|
||||
damage += (int)(pokemon.MaxHealth * _percentOfMaxHealth);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ public class MagnetRiseEffect : Script, IScriptChangeEffectiveness, IScriptOnEnd
|
||||
private int _turnsRemaining = 4;
|
||||
|
||||
/// <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)
|
||||
{
|
||||
if (move.User.HasHeldItem(ItemNames.IronBall))
|
||||
return;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class MiracleEyeEffect : Script, IScriptPreventStatBoostChange, IScriptChangeTypesForIncomingMove
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void PreventStatBoostChange(IPokemon target, Statistic stat, sbyte amount, bool selfInflicted,
|
||||
public void PreventStatBoostChange(IBattlePokemon target, Statistic stat, sbyte amount, bool selfInflicted,
|
||||
ref bool prevent)
|
||||
{
|
||||
if (stat == Statistic.Evasion && amount > 0)
|
||||
@@ -12,7 +12,7 @@ public class MiracleEyeEffect : Script, IScriptPreventStatBoostChange, IScriptCh
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
IList<TypeIdentifier> types)
|
||||
{
|
||||
if (executingMove.UseMove.MoveType.Name != TypeNames.Psychic)
|
||||
|
||||
@@ -5,9 +5,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "nightmare")]
|
||||
public class NightmareEffect : Script, IScriptOnEndTurn, IAIInfoScriptExpectedEndOfTurnDamage
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
|
||||
public NightmareEffect(IPokemon owner)
|
||||
public NightmareEffect(IBattlePokemon owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public class NightmareEffect : Script, IScriptOnEndTurn, IAIInfoScriptExpectedEn
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ExpectedEndOfTurnDamage(IPokemon pokemon, ref int damage)
|
||||
public void ExpectedEndOfTurnDamage(IBattlePokemon pokemon, ref int damage)
|
||||
{
|
||||
damage += (int)(_owner.MaxHealth / 4f);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "outrage")]
|
||||
public class OutrageEffect : OutrageLikeEffect
|
||||
{
|
||||
public OutrageEffect(IPokemon owner, int turns, byte targetSide, byte targetPosition) : base(owner, turns,
|
||||
public OutrageEffect(IBattlePokemon owner, int turns, byte targetSide, byte targetPosition) : base(owner, turns,
|
||||
targetSide, targetPosition, "outrage")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
public abstract class OutrageLikeEffect : Script, IScriptForceTurnSelection, IScriptOnAfterHits
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
private int _turns;
|
||||
private readonly byte _targetSide;
|
||||
private readonly byte _targetPosition;
|
||||
private readonly StringKey _move;
|
||||
|
||||
public OutrageLikeEffect(IPokemon owner, int turns, byte targetSide, byte targetPosition, StringKey move)
|
||||
public OutrageLikeEffect(IBattlePokemon owner, int turns, byte targetSide, byte targetPosition, StringKey move)
|
||||
{
|
||||
_owner = owner;
|
||||
_turns = turns;
|
||||
@@ -26,7 +26,7 @@ public abstract class OutrageLikeEffect : Script, IScriptForceTurnSelection, ISc
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnAfterHits(IExecutingMove move, IPokemon target)
|
||||
public void OnAfterHits(IExecutingMove move, IBattlePokemon target)
|
||||
{
|
||||
_turns--;
|
||||
if (_turns <= 0)
|
||||
|
||||
@@ -4,9 +4,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class PerishSongEffect : Script, IScriptOnEndTurn
|
||||
{
|
||||
internal int Turns { get; private set; }
|
||||
private IPokemon _owner;
|
||||
private IBattlePokemon _owner;
|
||||
|
||||
public PerishSongEffect(IPokemon owner, int turns = 3)
|
||||
public PerishSongEffect(IBattlePokemon owner, int turns = 3)
|
||||
{
|
||||
_owner = owner;
|
||||
Turns = turns;
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "petal_dance")]
|
||||
public class PetalDanceEffect : OutrageLikeEffect
|
||||
{
|
||||
public PetalDanceEffect(IPokemon owner, int turns, byte targetSide, byte targetPosition) : base(owner, turns,
|
||||
public PetalDanceEffect(IBattlePokemon owner, int turns, byte targetSide, byte targetPosition) : base(owner, turns,
|
||||
targetSide, targetPosition, "petal_dance")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "phantom_force")]
|
||||
public class PhantomForceCharge : Script, IScriptForceTurnSelection, IScriptBlockIncomingHit, IScriptOnAfterMoveChoice
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsSemiInvulnerableTurn => true;
|
||||
|
||||
public PhantomForceCharge(IPokemon owner)
|
||||
public PhantomForceCharge(IBattlePokemon owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
@@ -18,12 +18,12 @@ public class PhantomForceCharge : Script, IScriptForceTurnSelection, IScriptBloc
|
||||
/// <inheritdoc />
|
||||
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
var opposingSideIndex = (byte)(_owner.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "phantom_force", opposingSideIndex, position);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
|
||||
public void BlockIncomingHit(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex, ref bool block)
|
||||
{
|
||||
block = true;
|
||||
}
|
||||
|
||||
@@ -5,17 +5,16 @@ public class PowderEffect : Script, IScriptBlockOutgoingHit
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <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 hit = executingMove.GetHitData(target, hitIndex);
|
||||
if (hit.Type?.Name == TypeNames.Fire)
|
||||
{
|
||||
executingMove.User.BattleData?.Battle.EventHook.Invoke(new DialogEvent("powder_explodes",
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "user", executingMove.User },
|
||||
{ "target", target },
|
||||
}));
|
||||
executingMove.User.Battle.EventHook.Invoke(new DialogEvent("powder_explodes", new Dictionary<string, object>
|
||||
{
|
||||
{ "user", executingMove.User },
|
||||
{ "target", target },
|
||||
}));
|
||||
|
||||
var health = executingMove.User.MaxHealth / 4;
|
||||
executingMove.User.Damage(health, DamageSource.Misc);
|
||||
|
||||
@@ -4,14 +4,14 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class PowerTrickEffect : Script, IScriptChangeOffensiveStatValue, IScriptChangeDefensiveStatValue
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeOffensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint defensiveStat,
|
||||
public void ChangeOffensiveStatValue(IExecutingMove move, IBattlePokemon target, byte hit, uint defensiveStat,
|
||||
ImmutableStatisticSet<uint> targetStats, Statistic stat, ref uint value)
|
||||
{
|
||||
value = defensiveStat;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeDefensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint offensiveStat,
|
||||
public void ChangeDefensiveStatValue(IExecutingMove move, IBattlePokemon target, byte hit, uint offensiveStat,
|
||||
ImmutableStatisticSet<uint> targetStats, Statistic stat, ref uint value)
|
||||
{
|
||||
value = offensiveStat;
|
||||
|
||||
@@ -4,11 +4,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class ProtectionEffectScript : Script, IScriptBlockIncomingHit
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public virtual void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
|
||||
public virtual void BlockIncomingHit(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
ref bool block)
|
||||
{
|
||||
if (target.BattleData == null)
|
||||
return;
|
||||
|
||||
if (!executingMove.UseMove.HasFlag(MoveFlags.Protect))
|
||||
return;
|
||||
var args = new CustomTriggers.BypassProtectionArgs(executingMove, target, hitIndex, false);
|
||||
|
||||
@@ -13,9 +13,9 @@ public class PursuitEffect : Script, IScriptOnSwitchOut
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchOut(IPokemon oldPokemon, byte position)
|
||||
public void OnSwitchOut(IBattlePokemon oldPokemon, byte position)
|
||||
{
|
||||
var battleData = oldPokemon.BattleData;
|
||||
var battleData = oldPokemon;
|
||||
if (battleData == null)
|
||||
return;
|
||||
if (battleData.Battle.HasEnded)
|
||||
@@ -25,7 +25,7 @@ public class PursuitEffect : Script, IScriptOnSwitchOut
|
||||
return;
|
||||
if (!_choice.User.IsUsable)
|
||||
return;
|
||||
if (_choice.User.BattleData?.IsOnBattlefield != true)
|
||||
if (_choice.User.IsOnBattlefield != true)
|
||||
return;
|
||||
|
||||
var choiceQueue = battleData.Battle.ChoiceQueue;
|
||||
@@ -43,7 +43,7 @@ public class PursuitEffect : Script, IScriptOnSwitchOut
|
||||
private class PursuitDoublePowerEffect : 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 = basePower.MultiplyOrMax(2);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class RageEffect : Script, IScriptOnIncomingHit, IScriptOnEndTurn
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
public void OnIncomingHit(IExecutingMove move, IBattlePokemon target, byte hit)
|
||||
{
|
||||
move.User.ChangeStatBoost(Statistic.Attack, 1, true, false);
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "requires_recharge")]
|
||||
public class RequiresRechargeEffect : Script, IScriptForceTurnSelection, IScriptOnBeforeTurnStart
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
|
||||
public RequiresRechargeEffect(IPokemon owner)
|
||||
public RequiresRechargeEffect(IBattlePokemon owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
@@ -20,10 +20,9 @@ public class RequiresRechargeEffect : Script, IScriptForceTurnSelection, IScript
|
||||
public void OnBeforeTurnStart(ITurnChoice choice)
|
||||
{
|
||||
RemoveSelf();
|
||||
_owner.BattleData?.Battle.EventHook.Invoke(new DialogEvent("pokemon_must_recharge",
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "pokemon", _owner },
|
||||
}));
|
||||
_owner.Battle.EventHook.Invoke(new DialogEvent("pokemon_must_recharge", new Dictionary<string, object>
|
||||
{
|
||||
{ "pokemon", _owner },
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class RoostEffect : Script, IScriptOnEndTurn, IScriptChangeTypesForIncomingMove
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
IList<TypeIdentifier> types)
|
||||
{
|
||||
types.RemoveAll(x => x.Name == TypeNames.Flying);
|
||||
|
||||
@@ -5,12 +5,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "shadow_force")]
|
||||
public class ShadowForceCharge : Script, IScriptForceTurnSelection, IScriptBlockIncomingHit, IScriptOnAfterMoveChoice
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsSemiInvulnerableTurn => true;
|
||||
|
||||
public ShadowForceCharge(IPokemon owner)
|
||||
public ShadowForceCharge(IBattlePokemon owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
@@ -18,12 +18,12 @@ public class ShadowForceCharge : Script, IScriptForceTurnSelection, IScriptBlock
|
||||
/// <inheritdoc />
|
||||
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
var opposingSideIndex = (byte)(_owner.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "shadow_force", opposingSideIndex, position);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
|
||||
public void BlockIncomingHit(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex, ref bool block)
|
||||
{
|
||||
block = true;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public class ShellTrapHelper : Script, IScriptOnIncomingHit
|
||||
public bool HasHit { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
public void OnIncomingHit(IExecutingMove move, IBattlePokemon target, byte hit)
|
||||
{
|
||||
if (move.UseMove.Category == MoveCategory.Physical)
|
||||
HasHit = true;
|
||||
|
||||
@@ -5,9 +5,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "skull_bash")]
|
||||
public class SkullBashEffect : Script, IScriptForceTurnSelection
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
|
||||
public SkullBashEffect(IPokemon owner)
|
||||
public SkullBashEffect(IBattlePokemon owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "sky_attack")]
|
||||
public class SkyAttackEffect : Script, IScriptForceTurnSelection
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly IBattlePokemon _owner;
|
||||
|
||||
public SkyAttackEffect(IPokemon owner)
|
||||
public SkyAttackEffect(IBattlePokemon owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class SlowStartEffect : Script, IScriptChangeSpeed, IScriptChangeOffensiv
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeOffensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint defensiveStat,
|
||||
public void ChangeOffensiveStatValue(IExecutingMove move, IBattlePokemon target, byte hit, uint defensiveStat,
|
||||
ImmutableStatisticSet<uint> targetStats, Statistic stat, ref uint value)
|
||||
{
|
||||
if (stat == Statistic.Attack)
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class SmackDownEffect : Script, IScriptChangeTypesForIncomingMove, IScriptIsFloating
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
IList<TypeIdentifier> types)
|
||||
{
|
||||
var typeLibrary = target.Library.StaticLibrary.Types;
|
||||
@@ -16,7 +16,7 @@ public class SmackDownEffect : Script, IScriptChangeTypesForIncomingMove, IScrip
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void IsFloating(IPokemon pokemon, ref bool isFloating)
|
||||
public void IsFloating(IBattlePokemon pokemon, ref bool isFloating)
|
||||
{
|
||||
isFloating = false;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "spider_web_effect")]
|
||||
public class SpiderWebEffect : Script, IScriptPreventOpponentRunAway, IScriptPreventOpponentSwitch
|
||||
{
|
||||
private HashSet<IPokemon> _targets = new();
|
||||
private HashSet<IBattlePokemon> _targets = new();
|
||||
|
||||
/// <inheritdoc />
|
||||
public void PreventOpponentRunAway(IFleeChoice choice, ref bool prevent)
|
||||
@@ -19,7 +19,7 @@ public class SpiderWebEffect : Script, IScriptPreventOpponentRunAway, IScriptPre
|
||||
prevent = true;
|
||||
}
|
||||
|
||||
public void AddTarget(IPokemon target)
|
||||
public void AddTarget(IBattlePokemon target)
|
||||
{
|
||||
_targets.Add(target);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class SpikyShieldEffect : ProtectionEffectScript
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
|
||||
public override void BlockIncomingHit(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
ref bool block)
|
||||
{
|
||||
base.BlockIncomingHit(executingMove, target, hitIndex, ref block);
|
||||
if (block)
|
||||
|
||||
@@ -3,13 +3,13 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "stockpile_effect")]
|
||||
public class StockpileEffect : Script, IScriptStack
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
private IBattlePokemon? _pokemon;
|
||||
public int StockpileCount { get; set; } = 1;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
{
|
||||
throw new InvalidOperationException("StockpileEffect can only be added to a Pokemon.");
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ public class SubstituteEffect(uint health) : Script, IScriptBlockIncomingHit
|
||||
public uint Health { get; private set; } = health;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
|
||||
public void BlockIncomingHit(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex, ref bool block)
|
||||
{
|
||||
if (executingMove.UseMove.HasFlag(MoveFlags.IgnoreSubstitute))
|
||||
return;
|
||||
|
||||
@@ -5,20 +5,20 @@ public class TelekinesisEffect : Script, IScriptChangeIncomingEffectiveness, ISc
|
||||
IScriptChangeIncomingAccuracy
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||
public void ChangeIncomingAccuracy(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
ref int modifiedAccuracy)
|
||||
{
|
||||
modifiedAccuracy = 255;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void IsFloating(IPokemon pokemon, ref bool isFloating)
|
||||
public void IsFloating(IBattlePokemon pokemon, ref bool isFloating)
|
||||
{
|
||||
isFloating = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingEffectiveness(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||
public void ChangeIncomingEffectiveness(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
ref float effectiveness)
|
||||
{
|
||||
if (executingMove.UseMove.MoveType.Name == TypeNames.Ground)
|
||||
|
||||
@@ -4,13 +4,13 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class ThousandArrowsEffect : Script, IScriptChangeTypesForIncomingMove, IScriptIsFloating
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void IsFloating(IPokemon pokemon, ref bool isFloating)
|
||||
public void IsFloating(IBattlePokemon pokemon, ref bool isFloating)
|
||||
{
|
||||
isFloating = false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
IList<TypeIdentifier> types)
|
||||
{
|
||||
if (executingMove.UseMove.MoveType.Name == TypeNames.Ground)
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "thrash")]
|
||||
public class ThrashEffect : OutrageLikeEffect
|
||||
{
|
||||
public ThrashEffect(IPokemon owner, int turns, byte targetSide, byte targetPosition) : base(owner, turns,
|
||||
public ThrashEffect(IBattlePokemon owner, int turns, byte targetSide, byte targetPosition) : base(owner, turns,
|
||||
targetSide, targetPosition, "thrash")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "truant_effect")]
|
||||
public class TruantEffect(IPokemon owner) : Script, IScriptForceTurnSelection, IScriptOnEndTurn
|
||||
public class TruantEffect(IBattlePokemon owner) : Script, IScriptForceTurnSelection, IScriptOnEndTurn
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
|
||||
@@ -6,25 +6,25 @@ public class WhirlpoolEffect : Script, IScriptOnEndTurn, IScriptPreventOpponentR
|
||||
{
|
||||
public record PokemonTurn
|
||||
{
|
||||
public PokemonTurn(IPokemon pokemon, int turns, float damagePercent)
|
||||
public PokemonTurn(IBattlePokemon pokemon, int turns, float damagePercent)
|
||||
{
|
||||
Pokemon = pokemon;
|
||||
Turns = turns;
|
||||
DamagePercent = damagePercent;
|
||||
}
|
||||
|
||||
public IPokemon Pokemon { get; }
|
||||
public IBattlePokemon Pokemon { get; }
|
||||
public int Turns { get; set; }
|
||||
public float DamagePercent { get; }
|
||||
}
|
||||
|
||||
private IPokemon? _user;
|
||||
private IBattlePokemon? _user;
|
||||
private readonly IList<PokemonTurn> _targetedPokemon = [];
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is IPokemon pokemon)
|
||||
if (source is IBattlePokemon pokemon)
|
||||
{
|
||||
_user = pokemon;
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class WhirlpoolEffect : Script, IScriptOnEndTurn, IScriptPreventOpponentR
|
||||
}
|
||||
}
|
||||
|
||||
public void AddTargetedPokemon(IPokemon pokemon, int turns, float damagePercent)
|
||||
public void AddTargetedPokemon(IBattlePokemon pokemon, int turns, float damagePercent)
|
||||
{
|
||||
if (_targetedPokemon.All(x => x.Pokemon != pokemon))
|
||||
{
|
||||
@@ -63,7 +63,7 @@ public class WhirlpoolEffect : Script, IScriptOnEndTurn, IScriptPreventOpponentR
|
||||
return;
|
||||
|
||||
List<PokemonTurn>? pokemonToRemove = null;
|
||||
foreach (var pokemonTurn in _targetedPokemon.Where(x => x.Pokemon.BattleData?.IsOnBattlefield == true))
|
||||
foreach (var pokemonTurn in _targetedPokemon.Where(x => x.Pokemon.IsOnBattlefield == true))
|
||||
{
|
||||
var pokemon = pokemonTurn.Pokemon;
|
||||
pokemon.Damage((uint)(pokemon.MaxHealth * pokemonTurn.DamagePercent), DamageSource.Misc);
|
||||
@@ -83,7 +83,7 @@ public class WhirlpoolEffect : Script, IScriptOnEndTurn, IScriptPreventOpponentR
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ExpectedEndOfTurnDamage(IPokemon pokemon, ref int damage)
|
||||
public void ExpectedEndOfTurnDamage(IBattlePokemon pokemon, ref int damage)
|
||||
{
|
||||
var turn = _targetedPokemon.FirstOrDefault(x => x.Pokemon == pokemon);
|
||||
if (turn != null)
|
||||
|
||||
@@ -3,13 +3,13 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
[Script(ScriptCategory.Pokemon, "wish")]
|
||||
public class WishEffect : Script, IScriptOnEndTurn
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
private IBattlePokemon? _pokemon;
|
||||
private bool _hasDoneFirstTurn;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
{
|
||||
throw new InvalidOperationException("Wish script can only be added to a Pokemon.");
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class WishEffect : Script, IScriptOnEndTurn
|
||||
return;
|
||||
}
|
||||
|
||||
if (_pokemon.BattleData?.IsOnBattlefield == true)
|
||||
if (_pokemon.IsOnBattlefield == true)
|
||||
{
|
||||
_pokemon.Heal(_pokemon.MaxHealth / 2);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public class YawnEffect : Script, IScriptOnEndTurn
|
||||
/// <inheritdoc />
|
||||
public void OnEndTurn(IScriptSource owner, IBattle battle)
|
||||
{
|
||||
if (owner is not IPokemon pokemon)
|
||||
if (owner is not IBattlePokemon pokemon)
|
||||
return;
|
||||
if (!_hasDoneFirstTurn)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user