Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -12,13 +12,13 @@ public class Aftermath : Script, IScriptOnIncomingHit, IScriptOnFaint
|
||||
private IExecutingMove? _lastAttack;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
public void OnIncomingHit(IExecutingMove move, IBattlePokemon target, byte hit)
|
||||
{
|
||||
_lastAttack = move.GetHitData(target, hit).IsContact ? move : null;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnFaint(IPokemon pokemon, DamageSource source)
|
||||
public void OnFaint(IBattlePokemon pokemon, DamageSource source)
|
||||
{
|
||||
if (source != DamageSource.MoveDamage)
|
||||
return;
|
||||
@@ -27,11 +27,9 @@ public class Aftermath : Script, IScriptOnIncomingHit, IScriptOnFaint
|
||||
var user = _lastAttack.User;
|
||||
if (!user.IsUsable)
|
||||
return;
|
||||
if (user.BattleData is null)
|
||||
return;
|
||||
|
||||
// Aftermath does not trigger if a Pokémon with Damp is on the field
|
||||
var battle = user.BattleData.Battle;
|
||||
var battle = user.Battle;
|
||||
var hasDamp = battle.Sides.SelectMany(side => side.Pokemon).WhereNotNull()
|
||||
.Any(p => p.ActiveAbility?.Name == AbilityNames.Damp);
|
||||
if (hasDamp)
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Analytic : 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)
|
||||
{
|
||||
if (move.Battle.ChoiceQueue?.HasNext() == false)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class AngerPoint : 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).IsCritical)
|
||||
{
|
||||
|
||||
@@ -9,18 +9,18 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "anticipation")]
|
||||
public class Anticipation : Script, IScriptOnOpponentSwitchIn
|
||||
{
|
||||
private IPokemon? _owner;
|
||||
private IBattlePokemon? _owner;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
throw new ArgumentException("Anticipation script can only be added to a Pokemon.", nameof(source));
|
||||
_owner = pokemon;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnOpponentSwitchIn(IPokemon pokemon, byte position)
|
||||
public void OnOpponentSwitchIn(IBattlePokemon pokemon, byte position)
|
||||
{
|
||||
if (_owner is null)
|
||||
return;
|
||||
@@ -37,7 +37,7 @@ public class Anticipation : Script, IScriptOnOpponentSwitchIn
|
||||
|
||||
if (relevantMoves)
|
||||
{
|
||||
pokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(_owner));
|
||||
pokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(_owner));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "arena_trap")]
|
||||
public class ArenaTrap : Script, IScriptPreventOpponentRunAway, IScriptPreventOpponentSwitch
|
||||
{
|
||||
private IPokemon? _owner;
|
||||
private IBattlePokemon? _owner;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
throw new InvalidOperationException("ArenaTrap can only be added to a Pokemon.");
|
||||
_owner = pokemon;
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public class ArenaTrap : Script, IScriptPreventOpponentRunAway, IScriptPreventOp
|
||||
if (choice.User.IsFloating)
|
||||
return;
|
||||
if (_owner is not null)
|
||||
choice.User.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(_owner));
|
||||
choice.User.Battle.EventHook.Invoke(new AbilityTriggerEvent(_owner));
|
||||
prevent = true;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ArenaTrap : Script, IScriptPreventOpponentRunAway, IScriptPreventOp
|
||||
if (choice.User.IsFloating)
|
||||
return;
|
||||
if (_owner is not null)
|
||||
choice.User.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(_owner));
|
||||
choice.User.Battle.EventHook.Invoke(new AbilityTriggerEvent(_owner));
|
||||
prevent = true;
|
||||
}
|
||||
}
|
||||
@@ -10,17 +10,17 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class AromaVeil : Script, IScriptOnSwitchIn, IScriptOnSwitchOut
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
public void OnSwitchIn(IBattlePokemon pokemon, byte position)
|
||||
{
|
||||
var side = pokemon.BattleData?.BattleSide;
|
||||
var side = pokemon.BattleSide;
|
||||
var effect = side?.VolatileScripts.Add(new Side.AromaVeilEffect())?.Script as Side.AromaVeilEffect;
|
||||
effect?.PlacerActivated(pokemon);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchOut(IPokemon oldPokemon, byte position)
|
||||
public void OnSwitchOut(IBattlePokemon oldPokemon, byte position)
|
||||
{
|
||||
var side = oldPokemon.BattleData?.BattleSide;
|
||||
var side = oldPokemon.BattleSide;
|
||||
var effect = side?.VolatileScripts.Get<Side.AromaVeilEffect>();
|
||||
effect?.PlacerDeactivated(oldPokemon);
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "bad_dreams")]
|
||||
public class BadDreams : Script, IScriptOnEndTurn
|
||||
{
|
||||
private IPokemon? _owner;
|
||||
private IBattlePokemon? _owner;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
throw new InvalidOperationException("Bad Dreams ability can only be added to a Pokemon.");
|
||||
_owner = pokemon;
|
||||
}
|
||||
@@ -24,8 +24,7 @@ public class BadDreams : Script, IScriptOnEndTurn
|
||||
{
|
||||
if (_owner is null)
|
||||
return;
|
||||
var opponents = battle.Sides.Where(x => x != _owner?.BattleData?.BattleSide).SelectMany(x => x.Pokemon)
|
||||
.WhereNotNull();
|
||||
var opponents = battle.Sides.Where(x => x != _owner?.BattleSide).SelectMany(x => x.Pokemon).WhereNotNull();
|
||||
|
||||
foreach (var opponent in opponents)
|
||||
{
|
||||
|
||||
@@ -10,17 +10,17 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Battery : Script, IScriptOnSwitchIn, IScriptOnSwitchOut
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
public void OnSwitchIn(IBattlePokemon pokemon, byte position)
|
||||
{
|
||||
var side = pokemon.BattleData?.BattleSide;
|
||||
var side = pokemon.BattleSide;
|
||||
var effect = side?.VolatileScripts.Add(new Side.BatteryAbilityEffect())?.Script as Side.BatteryAbilityEffect;
|
||||
effect?.PlacerActivated(pokemon);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchOut(IPokemon oldPokemon, byte position)
|
||||
public void OnSwitchOut(IBattlePokemon oldPokemon, byte position)
|
||||
{
|
||||
var side = oldPokemon.BattleData?.BattleSide;
|
||||
var side = oldPokemon.BattleSide;
|
||||
var effect = side?.VolatileScripts.Get<Side.BatteryAbilityEffect>();
|
||||
effect?.PlacerDeactivated(oldPokemon);
|
||||
}
|
||||
|
||||
@@ -10,18 +10,18 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class BattleBond : Script, IScriptChangeNumberOfHits, IScriptOnOpponentFaints, IScriptChangeBasePower
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnOpponentFaints(IExecutingMove move, IPokemon target, byte hit)
|
||||
public void OnOpponentFaints(IExecutingMove move, IBattlePokemon target, byte hit)
|
||||
{
|
||||
if (move.User.Species.Name == SpeciesNames.Greninja && move.User.Form.Name != FormNames.Ash &&
|
||||
move.User.Species.TryGetForm(FormNames.Ash, out var ashForm))
|
||||
{
|
||||
move.User.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User));
|
||||
move.User.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User));
|
||||
move.User.ChangeForm(ashForm);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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.UseMove.Name == MoveNames.WaterShuriken && move.User.Form.Name == FormNames.Ash)
|
||||
basePower = 20;
|
||||
|
||||
@@ -10,11 +10,11 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class BeastBoost : Script, IScriptOnOpponentFaints
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnOpponentFaints(IExecutingMove move, IPokemon target, byte hit)
|
||||
public void OnOpponentFaints(IExecutingMove move, IBattlePokemon target, byte hit)
|
||||
{
|
||||
var highestStat = move.User.BoostedStats.OrderByDescending(x => x.value).First().statistic;
|
||||
EventBatchId batchId = new();
|
||||
move.User.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User)
|
||||
move.User.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User)
|
||||
{
|
||||
BatchId = batchId,
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Berserk : Script, IScriptOnDamage
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnDamage(IPokemon pokemon, DamageSource source, uint oldHealth, uint newHealth)
|
||||
public void OnDamage(IBattlePokemon pokemon, DamageSource source, uint oldHealth, uint newHealth)
|
||||
{
|
||||
if (source is not DamageSource.MoveDamage)
|
||||
return;
|
||||
@@ -18,7 +18,7 @@ public class Berserk : Script, IScriptOnDamage
|
||||
return;
|
||||
|
||||
EventBatchId batchId = new();
|
||||
pokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
|
||||
pokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
|
||||
{
|
||||
BatchId = batchId,
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Bulletproof : Script, IScriptFailIncomingMove
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void FailIncomingMove(IExecutingMove move, IPokemon target, ref bool fail)
|
||||
public void FailIncomingMove(IExecutingMove move, IBattlePokemon target, ref bool fail)
|
||||
{
|
||||
if (move.UseMove.HasFlag(MoveFlags.Ballistics))
|
||||
fail = true;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ChangeMoveTypeAbility : Script, IScriptOnInitialize, IScriptChangeM
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeMoveType(IExecutingMove move, IPokemon target, byte hit, ref TypeIdentifier? typeIdentifier)
|
||||
public void ChangeMoveType(IExecutingMove move, IBattlePokemon target, byte hit, ref TypeIdentifier? typeIdentifier)
|
||||
{
|
||||
var typeLibrary = target.Library.StaticLibrary.Types;
|
||||
// Both types must be valid and the current type must match the from type
|
||||
@@ -44,7 +44,7 @@ public class ChangeMoveTypeAbility : Script, IScriptOnInitialize, IScriptChangeM
|
||||
}
|
||||
|
||||
/// <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.GetHitData(target, hit).HasFlag("change_move_type_ability"))
|
||||
basePower = basePower.MultiplyOrMax(1.3f);
|
||||
|
||||
@@ -10,11 +10,11 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class CheekPouch : Script, IScriptOnAfterItemConsume
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnAfterItemConsume(IPokemon pokemon, IItem item)
|
||||
public void OnAfterItemConsume(IBattlePokemon pokemon, IItem item)
|
||||
{
|
||||
if (item.Category == ItemCategory.Berry)
|
||||
{
|
||||
pokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
|
||||
pokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
|
||||
pokemon.Heal(pokemon.MaxHealth / 3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class ColorChange : Script, IScriptOnIncomingHit
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
public void OnIncomingHit(IExecutingMove move, IBattlePokemon target, byte hit)
|
||||
{
|
||||
var hitData = move.GetHitData(target, hit);
|
||||
if (hitData.Type != null && (hitData.Type != target.Types.FirstOrDefault() || target.Types.Count > 1))
|
||||
{
|
||||
target.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
target.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
target.SetTypes([hitData.Type.Value]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Comatose : Script, IScriptPreventStatusChange, IScriptCustomTrigger
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
|
||||
public void PreventStatusChange(IBattlePokemon pokemon, StringKey status, bool selfInflicted,
|
||||
ref bool preventStatus)
|
||||
{
|
||||
if (status == ScriptUtils.ResolveName<Status.Sleep>())
|
||||
{
|
||||
|
||||
@@ -11,14 +11,14 @@ public class Competitive : Script, IScriptOnAfterStatBoostChange
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <inheritdoc />
|
||||
public void OnAfterStatBoostChange(IPokemon pokemon, Statistic stat, bool selfInflicted, sbyte change)
|
||||
public void OnAfterStatBoostChange(IBattlePokemon pokemon, Statistic stat, bool selfInflicted, sbyte change)
|
||||
{
|
||||
if (change >= 0)
|
||||
return;
|
||||
if (selfInflicted)
|
||||
return;
|
||||
EventBatchId batchId = new();
|
||||
pokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
|
||||
pokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
|
||||
{
|
||||
BatchId = batchId,
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class CompoundEyes : Script, IScriptChangeAccuracy
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeAccuracy(IExecutingMove move, IPokemon target, byte hit, ref int modifiedAccuracy)
|
||||
public void ChangeAccuracy(IExecutingMove move, IBattlePokemon target, byte hit, ref int modifiedAccuracy)
|
||||
{
|
||||
move.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User));
|
||||
modifiedAccuracy = (int)(modifiedAccuracy * 1.3f);
|
||||
|
||||
@@ -11,10 +11,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Contrary : Script, IScriptChangeStatBoostChange
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeStatBoostChange(IPokemon target, Statistic stat, bool selfInflicted, ref sbyte amount)
|
||||
public void ChangeStatBoostChange(IBattlePokemon target, Statistic stat, bool selfInflicted, ref sbyte amount)
|
||||
{
|
||||
// Invert the stat change
|
||||
amount = (sbyte)-amount;
|
||||
target.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
target.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
}
|
||||
}
|
||||
@@ -13,13 +13,13 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class CursedBody : Script, IScriptOnIncomingHit
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
public void OnIncomingHit(IExecutingMove move, IBattlePokemon target, byte hit)
|
||||
{
|
||||
// 30% chance to disable the move
|
||||
if (move.Battle.Random.GetFloat() > 0.3f)
|
||||
return;
|
||||
|
||||
target.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
target.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
target.Volatile.Add(new DisableEffect(move.ChosenMove.MoveData.Name));
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class CuteCharm : Script, IScriptOnIncomingHit
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
public void OnIncomingHit(IExecutingMove move, IBattlePokemon target, byte hit)
|
||||
{
|
||||
// Only trigger on contact moves
|
||||
if (!move.GetHitData(target, hit).IsContact)
|
||||
@@ -28,7 +28,7 @@ public class CuteCharm : Script, IScriptOnIncomingHit
|
||||
move.User.Gender == Gender.Genderless)
|
||||
return;
|
||||
|
||||
target.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
target.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
move.User.Volatile.Add(new Infatuated());
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Damp : Script, IScriptFailIncomingMove
|
||||
{
|
||||
/// <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.SelfDestruct || move.UseMove.Name == MoveNames.Explosion)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class DarkAura : 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)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name == TypeNames.Dark)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Dazzling : Script, IScriptFailIncomingMove
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void FailIncomingMove(IExecutingMove move, IPokemon target, ref bool fail)
|
||||
public void FailIncomingMove(IExecutingMove move, IBattlePokemon target, ref bool fail)
|
||||
{
|
||||
if (move.UseMove.Priority > 0)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Defeatist : 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)
|
||||
{
|
||||
if (move.User.CurrentHealth < move.User.MaxHealth / 2)
|
||||
{
|
||||
|
||||
@@ -11,14 +11,14 @@ public class Defiant : Script, IScriptOnAfterStatBoostChange
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <inheritdoc />
|
||||
public void OnAfterStatBoostChange(IPokemon pokemon, Statistic stat, bool selfInflicted, sbyte change)
|
||||
public void OnAfterStatBoostChange(IBattlePokemon pokemon, Statistic stat, bool selfInflicted, sbyte change)
|
||||
{
|
||||
if (change >= 0)
|
||||
return;
|
||||
if (selfInflicted)
|
||||
return;
|
||||
EventBatchId batchId = new();
|
||||
pokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
|
||||
pokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
|
||||
{
|
||||
BatchId = batchId,
|
||||
});
|
||||
|
||||
@@ -11,9 +11,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class DeltaStreamAbility : Script, IScriptOnSwitchIn
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
public void OnSwitchIn(IBattlePokemon pokemon, byte position)
|
||||
{
|
||||
var battle = pokemon.BattleData?.Battle;
|
||||
var battle = pokemon.Battle;
|
||||
if (battle == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class DesolateLandAbility : Script, IScriptOnSwitchIn
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
public void OnSwitchIn(IBattlePokemon pokemon, byte position)
|
||||
{
|
||||
var battle = pokemon.BattleData?.Battle;
|
||||
var battle = pokemon.Battle;
|
||||
if (battle == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -13,10 +13,8 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Disguise : Script, IScriptChangeIncomingDamage
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingDamage(IPokemon pokemon, DamageSource source, ref uint damage)
|
||||
public void ChangeIncomingDamage(IBattlePokemon pokemon, DamageSource source, ref uint damage)
|
||||
{
|
||||
if (pokemon.BattleData == null)
|
||||
return;
|
||||
if (source is not DamageSource.MoveDamage and not DamageSource.Confusion)
|
||||
return;
|
||||
if (pokemon.Form.Name == FormNames.Busted || pokemon.Form.Name == FormNames.TotemBusted)
|
||||
@@ -39,7 +37,7 @@ public class Disguise : Script, IScriptChangeIncomingDamage
|
||||
|
||||
EventBatchId batchId = new();
|
||||
|
||||
pokemon.BattleData.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
|
||||
pokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
|
||||
{
|
||||
BatchId = batchId,
|
||||
});
|
||||
|
||||
@@ -11,9 +11,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Download : Script, IScriptOnSwitchIn
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
public void OnSwitchIn(IBattlePokemon pokemon, byte position)
|
||||
{
|
||||
var battleData = pokemon.BattleData;
|
||||
var battleData = pokemon;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Drizzle : Script, IScriptOnSwitchIn
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
public void OnSwitchIn(IBattlePokemon pokemon, byte position)
|
||||
{
|
||||
var battleData = pokemon.BattleData;
|
||||
var battleData = pokemon;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Drought : Script, IScriptOnSwitchIn
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
public void OnSwitchIn(IBattlePokemon pokemon, byte position)
|
||||
{
|
||||
var battleData = pokemon.BattleData;
|
||||
var battleData = pokemon;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "dry_skin")]
|
||||
public class DrySkin : Script, IScriptChangeDamageModifier, IScriptOnEndTurn, IAIInfoScriptExpectedEndOfTurnDamage
|
||||
{
|
||||
private IPokemon? _owningPokemon;
|
||||
private IBattlePokemon? _owningPokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
{
|
||||
throw new ArgumentException("DrySkin script must be added to a Pokemon.", nameof(source));
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class DrySkin : Script, IScriptChangeDamageModifier, IScriptOnEndTurn, IA
|
||||
}
|
||||
|
||||
/// <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 hitType = move.GetHitData(target, hit).Type;
|
||||
if (hitType?.Name == TypeNames.Fire)
|
||||
@@ -33,7 +33,7 @@ public class DrySkin : Script, IScriptChangeDamageModifier, IScriptOnEndTurn, IA
|
||||
else if (hitType?.Name == TypeNames.Water)
|
||||
{
|
||||
modifier = 0;
|
||||
target.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
target.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
target.Heal(target.MaxHealth / 4);
|
||||
}
|
||||
}
|
||||
@@ -46,20 +46,20 @@ public class DrySkin : Script, IScriptChangeDamageModifier, IScriptOnEndTurn, IA
|
||||
var weather = battle.WeatherName;
|
||||
if (weather == ScriptUtils.ResolveName<Weather.Rain>())
|
||||
{
|
||||
_owningPokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(_owningPokemon));
|
||||
_owningPokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(_owningPokemon));
|
||||
_owningPokemon.Heal(_owningPokemon.MaxHealth / 8);
|
||||
}
|
||||
else if (weather == ScriptUtils.ResolveName<Weather.HarshSunlight>())
|
||||
{
|
||||
_owningPokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(_owningPokemon));
|
||||
_owningPokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(_owningPokemon));
|
||||
_owningPokemon.Damage(_owningPokemon.MaxHealth / 8, DamageSource.Weather);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ExpectedEndOfTurnDamage(IPokemon pokemon, ref int damage)
|
||||
public void ExpectedEndOfTurnDamage(IBattlePokemon pokemon, ref int damage)
|
||||
{
|
||||
if (pokemon.BattleData?.Battle.WeatherName == ScriptUtils.ResolveName<Weather.HarshSunlight>())
|
||||
if (pokemon.Battle.WeatherName == ScriptUtils.ResolveName<Weather.HarshSunlight>())
|
||||
{
|
||||
damage += (int)(pokemon.MaxHealth / 8f);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class EffectSpore : Script, IScriptOnIncomingHit
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
public void OnIncomingHit(IExecutingMove move, IBattlePokemon target, byte hit)
|
||||
{
|
||||
if (move.User.Types.Any(x => x.Name == TypeNames.Grass))
|
||||
return;
|
||||
|
||||
@@ -11,9 +11,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class ElectricSurge : Script, IScriptOnSwitchIn
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
public void OnSwitchIn(IBattlePokemon pokemon, byte position)
|
||||
{
|
||||
var battleData = pokemon.BattleData;
|
||||
var battleData = pokemon;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -10,10 +10,8 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class EmergencyExit : Script, IScriptOnDamage
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnDamage(IPokemon pokemon, DamageSource source, uint oldHealth, uint newHealth)
|
||||
public void OnDamage(IBattlePokemon pokemon, DamageSource source, uint oldHealth, uint newHealth)
|
||||
{
|
||||
if (pokemon.BattleData is null)
|
||||
return;
|
||||
if (source is DamageSource.Confusion)
|
||||
return;
|
||||
|
||||
@@ -22,11 +20,11 @@ public class EmergencyExit : Script, IScriptOnDamage
|
||||
if (!(oldHealthFraction >= 0.5f) || !(newHealthFraction < 0.5f))
|
||||
return;
|
||||
|
||||
if (pokemon.BattleData.Battle.IsWildBattle)
|
||||
if (pokemon.Battle.IsWildBattle)
|
||||
{
|
||||
pokemon.BattleData.Battle.ForceEndBattle();
|
||||
pokemon.Battle.ForceEndBattle();
|
||||
return;
|
||||
}
|
||||
pokemon.BattleData.BattleSide.SwapPokemon(pokemon.BattleData.Position, null);
|
||||
pokemon.BattleSide.SwapPokemon(pokemon.Position, null);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class FairyAura : 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)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name == TypeNames.Fairy)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,8 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Filter : Script, IScriptChangeIncomingMoveDamageModifier
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingMoveDamageModifier(IExecutingMove move, IPokemon target, byte hit, ref float modifier)
|
||||
public void ChangeIncomingMoveDamageModifier(IExecutingMove move, IBattlePokemon target, byte hit,
|
||||
ref float modifier)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Effectiveness >= 2.0f)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class FlameBody : 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)
|
||||
return;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class FlareBoost : 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)
|
||||
{
|
||||
if (!move.User.HasStatus(ScriptUtils.ResolveName<Status.Burned>()))
|
||||
return;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class FlashFire : Script, IScriptChangeIncomingEffectiveness
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingEffectiveness(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||
public void ChangeIncomingEffectiveness(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
ref float effectiveness)
|
||||
{
|
||||
if (executingMove.GetHitData(target, hitIndex).Type?.Name != TypeNames.Fire)
|
||||
|
||||
@@ -9,15 +9,15 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "flower_gift")]
|
||||
public class FlowerGift : Script, IScriptOnWeatherChange
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
private IBattlePokemon? _pokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
throw new InvalidOperationException("Flower Gift can only be added to a Pokemon script source.");
|
||||
_pokemon = pokemon;
|
||||
var effect = _pokemon.BattleData?.BattleSide.VolatileScripts.Add(new Side.FlowerGiftEffect());
|
||||
var effect = _pokemon.BattleSide.VolatileScripts.Add(new Side.FlowerGiftEffect());
|
||||
(effect?.Script as Side.FlowerGiftEffect)?.OnAdded(_pokemon);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class FlowerGift : Script, IScriptOnWeatherChange
|
||||
{
|
||||
if (_pokemon is null)
|
||||
return;
|
||||
if (_pokemon.BattleData?.BattleSide.VolatileScripts.TryGet<Side.FlowerGiftEffect>(out var script) == true)
|
||||
if (_pokemon.BattleSide.VolatileScripts.TryGet<Side.FlowerGiftEffect>(out var script) == true)
|
||||
{
|
||||
script.OnRemoved(_pokemon);
|
||||
}
|
||||
|
||||
@@ -9,15 +9,15 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "flower_veil")]
|
||||
public class FlowerVeil : Script
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
private IBattlePokemon? _pokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
throw new InvalidOperationException("Flower Veil can only be added to a Pokemon script source.");
|
||||
_pokemon = pokemon;
|
||||
var effect = _pokemon.BattleData?.BattleSide.VolatileScripts.Add(new Side.FlowerVeilEffect());
|
||||
var effect = _pokemon.BattleSide.VolatileScripts.Add(new Side.FlowerVeilEffect());
|
||||
(effect?.Script as Side.FlowerVeilEffect)?.OnAdded(_pokemon);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class FlowerVeil : Script
|
||||
{
|
||||
if (_pokemon is null)
|
||||
return;
|
||||
if (_pokemon.BattleData?.BattleSide.VolatileScripts.TryGet<Side.FlowerVeilEffect>(out var script) == true)
|
||||
if (_pokemon.BattleSide.VolatileScripts.TryGet<Side.FlowerVeilEffect>(out var script) == true)
|
||||
{
|
||||
script.OnRemoved(_pokemon);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Fluffy : 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)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name == TypeNames.Fire)
|
||||
{
|
||||
|
||||
@@ -9,20 +9,20 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "forecast")]
|
||||
public class Forecast : Script, IScriptOnSwitchIn, IScriptOnWeatherChange
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
private IBattlePokemon? _pokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
throw new InvalidOperationException("Forecast can only be added to a Pokemon script source.");
|
||||
_pokemon = pokemon;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
public void OnSwitchIn(IBattlePokemon pokemon, byte position)
|
||||
{
|
||||
ChangeForm(pokemon, pokemon.BattleData?.Battle.WeatherName);
|
||||
ChangeForm(pokemon, pokemon.Battle.WeatherName);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -43,7 +43,7 @@ public class Forecast : Script, IScriptOnSwitchIn, IScriptOnWeatherChange
|
||||
ChangeForm(_pokemon, null);
|
||||
}
|
||||
|
||||
private static void ChangeForm(IPokemon pokemon, StringKey? weather)
|
||||
private static void ChangeForm(IBattlePokemon pokemon, StringKey? weather)
|
||||
{
|
||||
if (pokemon.Species.Name != SpeciesNames.Castform)
|
||||
return;
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Forewarn : Script, IScriptOnSwitchIn
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
public void OnSwitchIn(IBattlePokemon pokemon, byte position)
|
||||
{
|
||||
var battleData = pokemon.BattleData;
|
||||
var battleData = pokemon;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -9,15 +9,15 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "friend_guard")]
|
||||
public class FriendGuard : Script
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
private IBattlePokemon? _pokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
throw new InvalidOperationException("Friend Guard can only be added to a Pokemon script source.");
|
||||
_pokemon = pokemon;
|
||||
var effect = _pokemon.BattleData?.BattleSide.VolatileScripts.Add(new Side.FriendGuardEffect());
|
||||
var effect = _pokemon.BattleSide.VolatileScripts.Add(new Side.FriendGuardEffect());
|
||||
(effect?.Script as Side.FriendGuardEffect)?.OnAdded(_pokemon);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class FriendGuard : Script
|
||||
{
|
||||
if (_pokemon is null)
|
||||
return;
|
||||
if (_pokemon.BattleData?.BattleSide.VolatileScripts.TryGet<Side.FriendGuardEffect>(out var script) == true)
|
||||
if (_pokemon.BattleSide.VolatileScripts.TryGet<Side.FriendGuardEffect>(out var script) == true)
|
||||
{
|
||||
script.OnRemoved(_pokemon);
|
||||
}
|
||||
|
||||
@@ -10,14 +10,13 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Frisk : Script, IScriptOnSwitchIn
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
public void OnSwitchIn(IBattlePokemon pokemon, byte position)
|
||||
{
|
||||
if (pokemon.BattleData?.BattleSide is null)
|
||||
if (pokemon.BattleSide is null)
|
||||
return;
|
||||
|
||||
// Check if the Pokémon has an opposing side
|
||||
var opposingSide =
|
||||
pokemon.BattleData.Battle.Sides.FirstOrDefault(side => side != pokemon.BattleData.BattleSide);
|
||||
var opposingSide = pokemon.Battle.Sides.FirstOrDefault(side => side != pokemon.BattleSide);
|
||||
if (opposingSide is null)
|
||||
return;
|
||||
|
||||
@@ -28,7 +27,7 @@ public class Frisk : Script, IScriptOnSwitchIn
|
||||
// If the opponent has a held item, reveal it
|
||||
if (opponent.HeldItem != null)
|
||||
{
|
||||
pokemon.BattleData.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
|
||||
pokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
|
||||
{
|
||||
Metadata = new Dictionary<StringKey, object?>
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class FullMetalBody : Script, IScriptPreventStatBoostChange
|
||||
{
|
||||
/// <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 (selfInflicted)
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class FurCoat : Script, IScriptChangeIncomingMoveDamage
|
||||
{
|
||||
/// <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.Category == MoveCategory.Physical)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Galvanize : Script, IScriptChangeMoveType, IScriptChangeDamageModifier
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeMoveType(IExecutingMove move, IPokemon target, byte hit, ref TypeIdentifier? typeIdentifier)
|
||||
public void ChangeMoveType(IExecutingMove move, IBattlePokemon target, byte hit, ref TypeIdentifier? typeIdentifier)
|
||||
{
|
||||
if (typeIdentifier?.Name == TypeNames.Normal &&
|
||||
move.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier(TypeNames.Electric, out var electricType))
|
||||
@@ -20,7 +20,7 @@ public class Galvanize : Script, IScriptChangeMoveType, IScriptChangeDamageModif
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name == TypeNames.Electric)
|
||||
modifier *= 1.2f;
|
||||
|
||||
@@ -9,10 +9,8 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Gluttony : Script, IScriptOnDamage
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnDamage(IPokemon pokemon, DamageSource source, uint oldHealth, uint newHealth)
|
||||
public void OnDamage(IBattlePokemon pokemon, DamageSource source, uint oldHealth, uint newHealth)
|
||||
{
|
||||
if (pokemon.BattleData is null)
|
||||
return;
|
||||
var oldHealthFraction = (float)oldHealth / pokemon.MaxHealth;
|
||||
var newHealthFraction = (float)newHealth / pokemon.MaxHealth;
|
||||
if (!(oldHealthFraction >= 0.5f) || !(newHealthFraction < 0.5f))
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Gooey : 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)
|
||||
return;
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class GrassPelt : Script, IScriptChangeIncomingMoveDefensiveStatValue
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingMoveDefensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint offensiveStat,
|
||||
StatisticSet<uint> statisticSet, Statistic stat, ref uint value)
|
||||
public void ChangeIncomingMoveDefensiveStatValue(IExecutingMove move, IBattlePokemon target, byte hit,
|
||||
uint offensiveStat, StatisticSet<uint> statisticSet, Statistic stat, ref uint value)
|
||||
{
|
||||
if (move.Battle.TerrainName == ScriptUtils.ResolveName<Terrain.GrassyTerrain>() && stat == Statistic.Defense)
|
||||
value = value.MultiplyOrMax(1.5f);
|
||||
|
||||
@@ -9,9 +9,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class GrassySurge : Script, IScriptOnSwitchIn
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
public void OnSwitchIn(IBattlePokemon pokemon, byte position)
|
||||
{
|
||||
var battleData = pokemon.BattleData;
|
||||
var battleData = pokemon;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Guts : 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 (target.StatusScript.IsEmpty)
|
||||
|
||||
@@ -8,12 +8,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "harvest")]
|
||||
public class Harvest : Script, IScriptOnEndTurn
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
private IBattlePokemon? _pokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
throw new InvalidOperationException("Harvest can only be added to a Pokemon script source.");
|
||||
_pokemon = pokemon;
|
||||
}
|
||||
@@ -21,12 +21,12 @@ public class Harvest : Script, IScriptOnEndTurn
|
||||
/// <inheritdoc />
|
||||
public void OnEndTurn(IScriptSource owner, IBattle battle)
|
||||
{
|
||||
if (_pokemon?.BattleData is null)
|
||||
if (_pokemon is null)
|
||||
return;
|
||||
if (_pokemon.HeldItem is not null)
|
||||
return;
|
||||
|
||||
var consumedBerry = _pokemon.BattleData.ConsumedItems.FirstOrDefault(x => x.Category == ItemCategory.Berry);
|
||||
var consumedBerry = _pokemon.ConsumedItems.FirstOrDefault(x => x.Category == ItemCategory.Berry);
|
||||
if (consumedBerry != null)
|
||||
{
|
||||
var rng = battle.Random;
|
||||
|
||||
@@ -8,12 +8,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "healer")]
|
||||
public class Healer : Script, IScriptOnEndTurn
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
private IBattlePokemon? _pokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
throw new InvalidOperationException("Harvest can only be added to a Pokemon script source.");
|
||||
_pokemon = pokemon;
|
||||
}
|
||||
@@ -21,22 +21,22 @@ public class Healer : Script, IScriptOnEndTurn
|
||||
/// <inheritdoc />
|
||||
public void OnEndTurn(IScriptSource owner, IBattle battle)
|
||||
{
|
||||
if (_pokemon?.BattleData is null)
|
||||
if (_pokemon is null)
|
||||
return;
|
||||
|
||||
if (_pokemon.BattleData.Position > 0)
|
||||
if (_pokemon.Position > 0)
|
||||
{
|
||||
var leftAlly = _pokemon.BattleData.BattleSide.Pokemon[_pokemon.BattleData.Position - 1];
|
||||
var leftAlly = _pokemon.BattleSide.Pokemon[_pokemon.Position - 1];
|
||||
TryClearStatus(battle, leftAlly);
|
||||
}
|
||||
if (_pokemon.BattleData.Position < _pokemon.BattleData.BattleSide.Pokemon.Count - 1)
|
||||
if (_pokemon.Position < _pokemon.BattleSide.Pokemon.Count - 1)
|
||||
{
|
||||
var rightAlly = _pokemon.BattleData.BattleSide.Pokemon[_pokemon.BattleData.Position + 1];
|
||||
var rightAlly = _pokemon.BattleSide.Pokemon[_pokemon.Position + 1];
|
||||
TryClearStatus(battle, rightAlly);
|
||||
}
|
||||
}
|
||||
|
||||
private static void TryClearStatus(IBattle battle, IPokemon? leftAlly)
|
||||
private static void TryClearStatus(IBattle battle, IBattlePokemon? leftAlly)
|
||||
{
|
||||
if (leftAlly is null)
|
||||
return;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Heatproof : 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.GetHitData(target, hit).Type?.Name == TypeNames.Fire)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class HugePower : 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 (stat == Statistic.Attack)
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Hustle : Script, IScriptChangeOffensiveStatValue, IScriptChangeAccuracy
|
||||
{
|
||||
/// <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)
|
||||
@@ -20,7 +20,8 @@ public class Hustle : Script, IScriptChangeOffensiveStatValue, IScriptChangeAccu
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref int modifiedAccuracy)
|
||||
public void ChangeAccuracy(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
ref int modifiedAccuracy)
|
||||
{
|
||||
if (executingMove.UseMove.Category == MoveCategory.Physical)
|
||||
{
|
||||
|
||||
@@ -8,12 +8,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "hydration")]
|
||||
public class Hydration : Script, IScriptOnEndTurn
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
private IBattlePokemon? _pokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
throw new InvalidOperationException("Hydration can only be added to a Pokemon script source.");
|
||||
_pokemon = pokemon;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class HyperCutter : Script, IScriptPreventStatBoostChange
|
||||
{
|
||||
/// <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.Attack)
|
||||
|
||||
@@ -8,12 +8,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "ice_body")]
|
||||
public class IceBody : Script, IScriptOnEndTurn, IScriptCustomTrigger
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
private IBattlePokemon? _pokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
throw new InvalidOperationException("Ice Body can only be added to a Pokemon script source.");
|
||||
_pokemon = pokemon;
|
||||
}
|
||||
|
||||
@@ -8,24 +8,21 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "illusion")]
|
||||
public class Illusion : Script, IScriptOnIncomingHit, IScriptOnSwitchIn
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
private IBattlePokemon? _pokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
throw new InvalidOperationException("Illusion can only be added to a Pokemon script source.");
|
||||
_pokemon = pokemon;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
public void OnSwitchIn(IBattlePokemon pokemon, byte position)
|
||||
{
|
||||
var battleData = pokemon.BattleData;
|
||||
if (battleData is null)
|
||||
return;
|
||||
var lastNonFaintedPokemon = battleData.Battle.Parties.FirstOrDefault(p => p.Party.Any(pkmn => pkmn == pokemon))
|
||||
?.Party.WhereNotNull().FirstOrDefault(x => x.IsUsable);
|
||||
var lastNonFaintedPokemon = pokemon.Battle.Parties.FirstOrDefault(p => p.BattlePokemon.Contains(pokemon))
|
||||
?.BattlePokemon.WhereNotNull().FirstOrDefault(x => x.IsUsable);
|
||||
if (lastNonFaintedPokemon is null || lastNonFaintedPokemon == pokemon)
|
||||
return;
|
||||
|
||||
@@ -39,17 +36,17 @@ public class Illusion : Script, IScriptOnIncomingHit, IScriptOnSwitchIn
|
||||
return;
|
||||
|
||||
_pokemon.SetDisplaySpecies(null, null);
|
||||
_pokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(_pokemon));
|
||||
_pokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(_pokemon));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
public void OnIncomingHit(IExecutingMove move, IBattlePokemon target, byte hit)
|
||||
{
|
||||
if (_pokemon?.BattleData?.Battle is null)
|
||||
if (_pokemon?.Battle is null)
|
||||
return;
|
||||
|
||||
// Remove the illusion when the Pokémon takes damage
|
||||
_pokemon.SetDisplaySpecies(null, null);
|
||||
_pokemon.BattleData.Battle.EventHook.Invoke(new AbilityTriggerEvent(_pokemon));
|
||||
_pokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(_pokemon));
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,8 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Immunity : Script, IScriptPreventStatusChange
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
|
||||
public void PreventStatusChange(IBattlePokemon pokemon, StringKey status, bool selfInflicted,
|
||||
ref bool preventStatus)
|
||||
{
|
||||
if (status == ScriptUtils.ResolveName<Status.Poisoned>() ||
|
||||
status == ScriptUtils.ResolveName<Status.BadlyPoisoned>())
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class IncreasedStab : Script, IScriptChangeStabModifier
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeStabModifier(IExecutingMove executingMove, IPokemon target, byte hitNumber, bool isStab,
|
||||
public void ChangeStabModifier(IExecutingMove executingMove, IBattlePokemon target, byte hitNumber, bool isStab,
|
||||
ref float modifier)
|
||||
{
|
||||
if (!isStab || !modifier.IsApproximatelyEqualTo(1.5f))
|
||||
|
||||
@@ -8,16 +8,16 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "innards_out")]
|
||||
public class InnardsOut : Script, IScriptOnIncomingHit, IScriptOnDamage
|
||||
{
|
||||
private IPokemon? _lastPokemonToHit;
|
||||
private IBattlePokemon? _lastPokemonToHit;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
public void OnIncomingHit(IExecutingMove move, IBattlePokemon target, byte hit)
|
||||
{
|
||||
_lastPokemonToHit = 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)
|
||||
{
|
||||
if (newHealth != 0 || source is not DamageSource.MoveDamage)
|
||||
return;
|
||||
@@ -26,7 +26,7 @@ public class InnardsOut : Script, IScriptOnIncomingHit, IScriptOnDamage
|
||||
|
||||
EventBatchId batchId = new();
|
||||
|
||||
pokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
|
||||
pokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
|
||||
{
|
||||
BatchId = batchId,
|
||||
});
|
||||
|
||||
@@ -10,12 +10,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "inner_focus")]
|
||||
public class InnerFocus : Script, IScriptPreventVolatileAdd
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
private IBattlePokemon? _pokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
throw new InvalidOperationException("Illusion can only be added to a Pokemon script source.");
|
||||
_pokemon = pokemon;
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public class InnerFocus : Script, IScriptPreventVolatileAdd
|
||||
{
|
||||
if (script is not FlinchEffect)
|
||||
return;
|
||||
_pokemon?.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(_pokemon));
|
||||
_pokemon?.Battle.EventHook.Invoke(new AbilityTriggerEvent(_pokemon));
|
||||
preventVolatileAdd = true;
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Insomnia : Script, IScriptPreventStatusChange
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
|
||||
public void PreventStatusChange(IBattlePokemon pokemon, StringKey status, bool selfInflicted,
|
||||
ref bool preventStatus)
|
||||
{
|
||||
if (status != ScriptUtils.ResolveName<Status.Sleep>())
|
||||
return;
|
||||
pokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
|
||||
pokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
|
||||
preventStatus = true;
|
||||
}
|
||||
}
|
||||
@@ -9,14 +9,14 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Intimidate : Script, IScriptOnSwitchIn
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
public void OnSwitchIn(IBattlePokemon pokemon, byte position)
|
||||
{
|
||||
var battle = pokemon.BattleData?.Battle;
|
||||
var battle = pokemon.Battle;
|
||||
if (battle is null)
|
||||
return;
|
||||
|
||||
var opponents = battle.Sides.Where(side => side != pokemon.BattleData?.BattleSide)
|
||||
.SelectMany(side => side.Pokemon).WhereNotNull().Where(opponent => opponent.IsUsable);
|
||||
var opponents = battle.Sides.Where(side => side != pokemon.BattleSide).SelectMany(side => side.Pokemon)
|
||||
.WhereNotNull().Where(opponent => opponent.IsUsable);
|
||||
EventBatchId batchId = new();
|
||||
|
||||
battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class IronBarbs : 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)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class IronFist : 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.UseMove.HasFlag(MoveFlags.Punch))
|
||||
basePower = basePower.MultiplyOrMax(1.2f);
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Justified : 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).Type?.Name != TypeNames.Dark)
|
||||
return;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class KeenEye : Script, IScriptPreventStatBoostChange
|
||||
{
|
||||
/// <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.Accuracy && amount < 0)
|
||||
|
||||
@@ -16,7 +16,7 @@ public class Klutz : Script, IScriptOnBeforeAnyHookInvoked, IScriptPreventHeldIt
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void PreventHeldItemConsume(IPokemon pokemon, IItem heldItem, ref bool prevented)
|
||||
public void PreventHeldItemConsume(IBattlePokemon pokemon, IItem heldItem, ref bool prevented)
|
||||
{
|
||||
prevented = true;
|
||||
}
|
||||
|
||||
@@ -9,9 +9,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class LeafGuard : Script, IScriptPreventStatusChange
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
|
||||
public void PreventStatusChange(IBattlePokemon pokemon, StringKey status, bool selfInflicted,
|
||||
ref bool preventStatus)
|
||||
{
|
||||
if (pokemon.BattleData?.Battle.WeatherName != ScriptUtils.ResolveName<Weather.HarshSunlight>())
|
||||
if (pokemon.Battle.WeatherName != ScriptUtils.ResolveName<Weather.HarshSunlight>())
|
||||
return;
|
||||
if (selfInflicted)
|
||||
return;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Levitate : Script, IScriptIsFloating
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void IsFloating(IPokemon pokemon, ref bool isFloating)
|
||||
public void IsFloating(IBattlePokemon pokemon, ref bool isFloating)
|
||||
{
|
||||
isFloating = true;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class LightningRod : Script, IScriptChangeIncomingTargets, IScriptChangeEffectiveness
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
|
||||
public void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IBattlePokemon?> targets)
|
||||
{
|
||||
if (moveChoice.ChosenMove.MoveData.MoveType.Name == TypeNames.Electric && targets.Count == 1)
|
||||
{
|
||||
@@ -18,7 +18,7 @@ public class LightningRod : Script, IScriptChangeIncomingTargets, IScriptChangeE
|
||||
}
|
||||
|
||||
/// <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.GetHitData(target, hit).Type?.Name != TypeNames.Electric)
|
||||
return;
|
||||
|
||||
@@ -9,7 +9,8 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Limber : Script, IScriptPreventStatusChange
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
|
||||
public void PreventStatusChange(IBattlePokemon pokemon, StringKey status, bool selfInflicted,
|
||||
ref bool preventStatus)
|
||||
{
|
||||
if (status != ScriptUtils.ResolveName<Status.Paralyzed>())
|
||||
return;
|
||||
@@ -18,7 +19,7 @@ public class Limber : Script, IScriptPreventStatusChange
|
||||
if (selfInflicted)
|
||||
return;
|
||||
|
||||
pokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
|
||||
pokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
|
||||
preventStatus = true;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class LiquidVoice : Script, IScriptChangeMoveType
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeMoveType(IExecutingMove move, IPokemon target, byte hit, ref TypeIdentifier? typeIdentifier)
|
||||
public void ChangeMoveType(IExecutingMove move, IBattlePokemon target, byte hit, ref TypeIdentifier? typeIdentifier)
|
||||
{
|
||||
if (move.UseMove.HasFlag(MoveFlags.Sound) &&
|
||||
move.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier(TypeNames.Water, out var waterType))
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class LongReach : Script, IScriptModifyIsContact
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ModifyIsContact(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool isContact)
|
||||
public void ModifyIsContact(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex, ref bool isContact)
|
||||
{
|
||||
isContact = false;
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class MagicBounce : Script, IScriptChangeIncomingTargets
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
|
||||
public void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IBattlePokemon?> targets)
|
||||
{
|
||||
if (moveChoice.ChosenMove.MoveData.HasFlag(MoveFlags.Reflectable))
|
||||
{
|
||||
var target = targets[0];
|
||||
target?.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
target?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
targets = [moveChoice.User];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,9 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class MagicGuard : Script, IScriptChangeIncomingDamage
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingDamage(IPokemon pokemon, DamageSource source, ref uint damage)
|
||||
public void ChangeIncomingDamage(IBattlePokemon pokemon, DamageSource source, ref uint damage)
|
||||
{
|
||||
// Magic Guard doesn't work if the Pokémon is not in battle.
|
||||
if (pokemon.BattleData is null)
|
||||
return;
|
||||
|
||||
if (source is DamageSource.MoveDamage or DamageSource.Struggle or DamageSource.FormChange)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Magician : Script, IScriptOnSecondaryEffect
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
|
||||
{
|
||||
if (move.UseMove.Category is MoveCategory.Status)
|
||||
return;
|
||||
|
||||
@@ -9,21 +9,22 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class MagmaArmor : Script, IScriptOnSwitchIn, IScriptPreventStatusChange
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
|
||||
public void PreventStatusChange(IBattlePokemon pokemon, StringKey status, bool selfInflicted,
|
||||
ref bool preventStatus)
|
||||
{
|
||||
if (status == ScriptUtils.ResolveName<Status.Frozen>())
|
||||
{
|
||||
pokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
|
||||
pokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
|
||||
preventStatus = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
public void OnSwitchIn(IBattlePokemon pokemon, byte position)
|
||||
{
|
||||
if (pokemon.HasStatus(ScriptUtils.ResolveName<Status.Frozen>()))
|
||||
{
|
||||
pokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
|
||||
pokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
|
||||
pokemon.ClearStatus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class MarvelScale : Script, IScriptChangeIncomingMoveDefensiveStatValue
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingMoveDefensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint offensiveStat,
|
||||
StatisticSet<uint> statisticSet, Statistic stat, ref uint value)
|
||||
public void ChangeIncomingMoveDefensiveStatValue(IExecutingMove move, IBattlePokemon target, byte hit,
|
||||
uint offensiveStat, StatisticSet<uint> statisticSet, Statistic stat, ref uint value)
|
||||
{
|
||||
if (!target.StatusScript.IsEmpty && stat == Statistic.Defense)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class MegaLauncher : Script, IScriptChangeBasePower, IScriptCustomTrigger
|
||||
{
|
||||
/// <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.UseMove.HasFlag(MoveFlags.Pulse))
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Merciless : 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)
|
||||
{
|
||||
if (target.StatusScript.Script?.Name == ScriptUtils.ResolveName<Poisoned>() ||
|
||||
target.StatusScript.Script?.Name == ScriptUtils.ResolveName<BadlyPoisoned>())
|
||||
|
||||
@@ -9,10 +9,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Minus : 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)
|
||||
{
|
||||
var battleData = move.User.BattleData;
|
||||
var battleData = move.User;
|
||||
if (battleData is null)
|
||||
return;
|
||||
if (battleData.BattleSide.Pokemon.WhereNotNull()
|
||||
|
||||
@@ -9,20 +9,20 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class MistySurge : Script, IScriptOnSwitchIn
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
public void OnSwitchIn(IBattlePokemon pokemon, byte position)
|
||||
{
|
||||
if (pokemon.BattleData?.Battle is null)
|
||||
if (pokemon.Battle is null)
|
||||
return;
|
||||
|
||||
var terrainName = ScriptUtils.ResolveName<Terrain.MistyTerrain>();
|
||||
if (pokemon.BattleData.Battle.TerrainName == terrainName)
|
||||
if (pokemon.Battle.TerrainName == terrainName)
|
||||
return;
|
||||
|
||||
EventBatchId batchId = new();
|
||||
pokemon.BattleData.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
|
||||
pokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
|
||||
{
|
||||
BatchId = batchId,
|
||||
});
|
||||
pokemon.BattleData.Battle.SetTerrain(terrainName, batchId);
|
||||
pokemon.Battle.SetTerrain(terrainName, batchId);
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "moody")]
|
||||
public class Moody : Script, IScriptOnEndTurn
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
private IBattlePokemon? _pokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
throw new InvalidOperationException("Moody script must be attached to a Pokemon.");
|
||||
_pokemon = pokemon;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class MotorDrive : Script, IScriptIsInvulnerableToMove
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void IsInvulnerableToMove(IExecutingMove move, IPokemon target, ref bool invulnerable)
|
||||
public void IsInvulnerableToMove(IExecutingMove move, IBattlePokemon target, ref bool invulnerable)
|
||||
{
|
||||
if (move.UseMove.MoveType.Name != TypeNames.Electric)
|
||||
return;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Moxie : Script, IScriptOnOpponentFaints
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnOpponentFaints(IExecutingMove move, IPokemon target, byte hit)
|
||||
public void OnOpponentFaints(IExecutingMove move, IBattlePokemon target, byte hit)
|
||||
{
|
||||
move.User.ChangeStatBoost(Statistic.Attack, 1, true, false);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Multiscale : Script, IScriptChangeIncomingMoveDamage
|
||||
{
|
||||
/// <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 (target.CurrentHealth == target.BoostedStats.Hp)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Multitype : Script, IScriptOnAfterHeldItemChange
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnAfterHeldItemChange(IPokemon pokemon, IItem? previous, IItem? item)
|
||||
public void OnAfterHeldItemChange(IBattlePokemon pokemon, IItem? previous, IItem? item)
|
||||
{
|
||||
if (pokemon.Species.Name != SpeciesNames.Arceus)
|
||||
return;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Mummy : 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 || move.User.ActiveAbility?.Name == AbilityNames.Mummy ||
|
||||
!move.Battle.Library.StaticLibrary.Abilities.TryGet(AbilityNames.Mummy, out var mummyAbility))
|
||||
|
||||
@@ -9,11 +9,11 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class NaturalCure : Script, IScriptOnSwitchOut
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchOut(IPokemon oldPokemon, byte position)
|
||||
public void OnSwitchOut(IBattlePokemon oldPokemon, byte position)
|
||||
{
|
||||
if (!oldPokemon.StatusScript.IsEmpty)
|
||||
{
|
||||
oldPokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(oldPokemon));
|
||||
oldPokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(oldPokemon));
|
||||
oldPokemon.ClearStatus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,14 +9,15 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class NoGuard : Script, IScriptChangeAccuracy, IScriptChangeIncomingAccuracy
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||
public void ChangeIncomingAccuracy(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
ref int modifiedAccuracy)
|
||||
{
|
||||
modifiedAccuracy = 2000;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref int modifiedAccuracy)
|
||||
public void ChangeAccuracy(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
ref int modifiedAccuracy)
|
||||
{
|
||||
modifiedAccuracy = 2000;
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class Normalize : Script, IScriptChangeMoveType, IScriptChangeBasePower
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void ChangeMoveType(IExecutingMove move, IPokemon target, byte hit, ref TypeIdentifier? typeIdentifier)
|
||||
public void ChangeMoveType(IExecutingMove move, IBattlePokemon target, byte hit, ref TypeIdentifier? typeIdentifier)
|
||||
{
|
||||
if (move.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier(TypeNames.Normal, out var normalType))
|
||||
typeIdentifier = normalType;
|
||||
}
|
||||
|
||||
/// <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.GetHitData(target, hit).Type?.Name == TypeNames.Normal)
|
||||
basePower = (ushort)(basePower * 1.2f); // Boost Normal-type moves by 30%
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user