This commit is contained in:
parent
83f6a183e3
commit
7c270a6d52
@ -19,7 +19,7 @@ public static class MoveTurnExecutor
|
|||||||
var useMove = chosenMove.MoveData;
|
var useMove = chosenMove.MoveData;
|
||||||
|
|
||||||
var moveDataName = useMove.Name;
|
var moveDataName = useMove.Name;
|
||||||
moveChoice.RunScriptHookInterface<IScriptChangeMove>(x => x.ChangeMove(moveChoice, ref moveDataName));
|
moveChoice.RunScriptHook<IScriptChangeMove>(x => x.ChangeMove(moveChoice, ref moveDataName));
|
||||||
if (useMove.Name != moveDataName)
|
if (useMove.Name != moveDataName)
|
||||||
{
|
{
|
||||||
if (!battle.Library.StaticLibrary.Moves.TryGet(moveDataName, out useMove))
|
if (!battle.Library.StaticLibrary.Moves.TryGet(moveDataName, out useMove))
|
||||||
@ -46,12 +46,12 @@ public static class MoveTurnExecutor
|
|||||||
moveChoice.Script.Clear();
|
moveChoice.Script.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
moveChoice.RunScriptHook(x => x.OnBeforeMoveChoice(moveChoice));
|
moveChoice.RunScriptHook<IScriptOnBeforeMoveChoice>(x => x.OnBeforeMoveChoice(moveChoice));
|
||||||
|
|
||||||
var targetType = useMove.Target;
|
var targetType = useMove.Target;
|
||||||
var targets =
|
var targets =
|
||||||
TargetResolver.ResolveTargets(battle, moveChoice.TargetSide, moveChoice.TargetPosition, targetType);
|
TargetResolver.ResolveTargets(battle, moveChoice.TargetSide, moveChoice.TargetPosition, targetType);
|
||||||
moveChoice.RunScriptHookInterface<IScriptChangeTargets>(x => x.ChangeTargets(moveChoice, ref targets));
|
moveChoice.RunScriptHook<IScriptChangeTargets>(x => x.ChangeTargets(moveChoice, ref targets));
|
||||||
if (targets.Count == 0)
|
if (targets.Count == 0)
|
||||||
{
|
{
|
||||||
moveChoice.Fail();
|
moveChoice.Fail();
|
||||||
@ -60,13 +60,11 @@ public static class MoveTurnExecutor
|
|||||||
|
|
||||||
foreach (var target in targets.WhereNotNull())
|
foreach (var target in targets.WhereNotNull())
|
||||||
{
|
{
|
||||||
target.RunScriptHookInterface<IScriptChangeIncomingTargets>(x =>
|
target.RunScriptHook<IScriptChangeIncomingTargets>(x => x.ChangeIncomingTargets(moveChoice, ref targets));
|
||||||
x.ChangeIncomingTargets(moveChoice, ref targets));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
byte numberOfHits = 1;
|
byte numberOfHits = 1;
|
||||||
moveChoice.RunScriptHookInterface<IScriptChangeNumberOfHits>(x =>
|
moveChoice.RunScriptHook<IScriptChangeNumberOfHits>(x => x.ChangeNumberOfHits(moveChoice, ref numberOfHits));
|
||||||
x.ChangeNumberOfHits(moveChoice, ref numberOfHits));
|
|
||||||
if (numberOfHits == 0)
|
if (numberOfHits == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -77,18 +75,20 @@ public static class MoveTurnExecutor
|
|||||||
battle.EventHook.Invoke(new MoveUseEvent(executingMove));
|
battle.EventHook.Invoke(new MoveUseEvent(executingMove));
|
||||||
|
|
||||||
var prevented = false;
|
var prevented = false;
|
||||||
executingMove.RunScriptHookInterface<IScriptPreventMove>(x => x.PreventMove(executingMove, ref prevented));
|
executingMove.RunScriptHook<IScriptPreventMove>(x => x.PreventMove(executingMove, ref prevented));
|
||||||
if (prevented)
|
if (prevented)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
byte ppUsed = 1;
|
byte ppUsed = 1;
|
||||||
executingMove.RunScriptHook(x => x.ModifyPPUsed(executingMove, ref ppUsed));
|
executingMove.RunScriptHook<IScriptModifyPPUsed>(x => x.ModifyPPUsed(executingMove, ref ppUsed));
|
||||||
targets.WhereNotNull().RunScriptHook(x => x.ModifyPPUsedForIncomingMove(executingMove, ref ppUsed));
|
targets.WhereNotNull()
|
||||||
|
.RunScriptHook<IScriptModifyPPUsedForIncomingMove>(x =>
|
||||||
|
x.ModifyPPUsedForIncomingMove(executingMove, ref ppUsed));
|
||||||
if (!executingMove.ChosenMove.TryUse(ppUsed))
|
if (!executingMove.ChosenMove.TryUse(ppUsed))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var failed = false;
|
var failed = false;
|
||||||
executingMove.RunScriptHookInterface<IScriptFailMove>(x => x.FailMove(executingMove, ref failed));
|
executingMove.RunScriptHook<IScriptFailMove>(x => x.FailMove(executingMove, ref failed));
|
||||||
if (failed)
|
if (failed)
|
||||||
{
|
{
|
||||||
// TODO: fail handling
|
// TODO: fail handling
|
||||||
@ -111,16 +111,16 @@ public static class MoveTurnExecutor
|
|||||||
public static void ExecuteMove(IExecutingMove executingMove)
|
public static void ExecuteMove(IExecutingMove executingMove)
|
||||||
{
|
{
|
||||||
var stopped = false;
|
var stopped = false;
|
||||||
executingMove.RunScriptHookInterface<IScriptStopBeforeMove>(x => x.StopBeforeMove(executingMove, ref stopped));
|
executingMove.RunScriptHook<IScriptStopBeforeMove>(x => x.StopBeforeMove(executingMove, ref stopped));
|
||||||
if (stopped)
|
if (stopped)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
executingMove.RunScriptHookInterface<IScriptOnBeforeMove>(x => x.OnBeforeMove(executingMove));
|
executingMove.RunScriptHook<IScriptOnBeforeMove>(x => x.OnBeforeMove(executingMove));
|
||||||
foreach (var target in executingMove.Targets.WhereNotNull())
|
foreach (var target in executingMove.Targets.WhereNotNull())
|
||||||
{
|
{
|
||||||
ExecuteMoveChoiceForTarget(executingMove.Battle, executingMove, target);
|
ExecuteMoveChoiceForTarget(executingMove.Battle, executingMove, target);
|
||||||
}
|
}
|
||||||
executingMove.RunScriptHookInterface<IScriptOnAfterMove>(x => x.OnAfterMove(executingMove));
|
executingMove.RunScriptHook<IScriptOnAfterMove>(x => x.OnAfterMove(executingMove));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly ThreadLocal<List<TypeIdentifier>> TypeListCache = new(() => []);
|
private static readonly ThreadLocal<List<TypeIdentifier>> TypeListCache = new(() => []);
|
||||||
@ -128,8 +128,7 @@ public static class MoveTurnExecutor
|
|||||||
private static void ExecuteMoveChoiceForTarget(IBattle battle, IExecutingMove executingMove, IPokemon target)
|
private static void ExecuteMoveChoiceForTarget(IBattle battle, IExecutingMove executingMove, IPokemon target)
|
||||||
{
|
{
|
||||||
var failed = false;
|
var failed = false;
|
||||||
target.RunScriptHookInterface<IScriptFailIncomingMove>(x =>
|
target.RunScriptHook<IScriptFailIncomingMove>(x => x.FailIncomingMove(executingMove, target, ref failed));
|
||||||
x.FailIncomingMove(executingMove, target, ref failed));
|
|
||||||
if (failed)
|
if (failed)
|
||||||
{
|
{
|
||||||
// TODO: fail handling
|
// TODO: fail handling
|
||||||
@ -137,7 +136,7 @@ public static class MoveTurnExecutor
|
|||||||
}
|
}
|
||||||
|
|
||||||
var isInvulnerable = false;
|
var isInvulnerable = false;
|
||||||
target.RunScriptHookInterface<IScriptIsInvulnerableToMove>(x =>
|
target.RunScriptHook<IScriptIsInvulnerableToMove>(x =>
|
||||||
x.IsInvulnerableToMove(executingMove, target, ref isInvulnerable));
|
x.IsInvulnerableToMove(executingMove, target, ref isInvulnerable));
|
||||||
if (isInvulnerable)
|
if (isInvulnerable)
|
||||||
{
|
{
|
||||||
@ -158,7 +157,7 @@ public static class MoveTurnExecutor
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
var hitIndex = i;
|
var hitIndex = i;
|
||||||
executingMove.RunScriptHook(x => x.OnBeforeHit(executingMove, target, hitIndex));
|
executingMove.RunScriptHook<IScriptOnBeforeHit>(x => x.OnBeforeHit(executingMove, target, hitIndex));
|
||||||
var hitData = (HitData)executingMove.GetDataFromRawIndex(targetHitStat + i);
|
var hitData = (HitData)executingMove.GetDataFromRawIndex(targetHitStat + i);
|
||||||
if (hitData.HasFailed)
|
if (hitData.HasFailed)
|
||||||
break;
|
break;
|
||||||
@ -166,11 +165,12 @@ public static class MoveTurnExecutor
|
|||||||
var useMove = executingMove.UseMove;
|
var useMove = executingMove.UseMove;
|
||||||
|
|
||||||
var isContact = useMove.HasFlag("contact");
|
var isContact = useMove.HasFlag("contact");
|
||||||
executingMove.RunScriptHook(x => x.ModifyIsContact(executingMove, target, hitIndex, ref isContact));
|
executingMove.RunScriptHook<IScriptModifyIsContact>(x =>
|
||||||
|
x.ModifyIsContact(executingMove, target, hitIndex, ref isContact));
|
||||||
hitData.IsContact = isContact;
|
hitData.IsContact = isContact;
|
||||||
|
|
||||||
var hitType = (TypeIdentifier?)useMove.MoveType;
|
var hitType = (TypeIdentifier?)useMove.MoveType;
|
||||||
executingMove.RunScriptHookInterface<IScriptChangeMoveType>(x =>
|
executingMove.RunScriptHook<IScriptChangeMoveType>(x =>
|
||||||
x.ChangeMoveType(executingMove, target, hitIndex, ref hitType));
|
x.ChangeMoveType(executingMove, target, hitIndex, ref hitType));
|
||||||
|
|
||||||
hitData.Type = hitType;
|
hitData.Type = hitType;
|
||||||
@ -180,22 +180,24 @@ public static class MoveTurnExecutor
|
|||||||
types.Clear();
|
types.Clear();
|
||||||
types.AddRange(target.Types);
|
types.AddRange(target.Types);
|
||||||
|
|
||||||
executingMove.RunScriptHook(x => x.ChangeTypesForMove(executingMove, target, hitIndex, types));
|
executingMove.RunScriptHook<IScriptChangeTypesForMove>(x =>
|
||||||
target.RunScriptHook(x => x.ChangeTypesForIncomingMove(executingMove, target, hitIndex, types));
|
x.ChangeTypesForMove(executingMove, target, hitIndex, types));
|
||||||
|
target.RunScriptHook<IScriptChangeTypesForIncomingMove>(x =>
|
||||||
|
x.ChangeTypesForIncomingMove(executingMove, target, hitIndex, types));
|
||||||
|
|
||||||
var effectiveness = hitType == null
|
var effectiveness = hitType == null
|
||||||
? 1
|
? 1
|
||||||
: battle.Library.StaticLibrary.Types.GetEffectiveness(hitType.Value, types);
|
: battle.Library.StaticLibrary.Types.GetEffectiveness(hitType.Value, types);
|
||||||
executingMove.RunScriptHookInterface<IScriptChangeEffectiveness>(x =>
|
executingMove.RunScriptHook<IScriptChangeEffectiveness>(x =>
|
||||||
x.ChangeEffectiveness(executingMove, target, hitIndex, ref effectiveness));
|
x.ChangeEffectiveness(executingMove, target, hitIndex, ref effectiveness));
|
||||||
target.RunScriptHookInterface<IScriptChangeIncomingEffectiveness>(x =>
|
target.RunScriptHook<IScriptChangeIncomingEffectiveness>(x =>
|
||||||
x.ChangeIncomingEffectiveness(executingMove, target, hitIndex, ref effectiveness));
|
x.ChangeIncomingEffectiveness(executingMove, target, hitIndex, ref effectiveness));
|
||||||
hitData.Effectiveness = effectiveness;
|
hitData.Effectiveness = effectiveness;
|
||||||
|
|
||||||
var blockCritical = false;
|
var blockCritical = false;
|
||||||
executingMove.RunScriptHookInterface<IScriptBlockCriticalHit>(x =>
|
executingMove.RunScriptHook<IScriptBlockCriticalHit>(x =>
|
||||||
x.BlockCriticalHit(executingMove, target, hitIndex, ref blockCritical));
|
x.BlockCriticalHit(executingMove, target, hitIndex, ref blockCritical));
|
||||||
target.RunScriptHookInterface<IScriptBlockIncomingCriticalHit>(x =>
|
target.RunScriptHook<IScriptBlockIncomingCriticalHit>(x =>
|
||||||
x.BlockIncomingCriticalHit(executingMove, target, hitIndex, ref blockCritical));
|
x.BlockIncomingCriticalHit(executingMove, target, hitIndex, ref blockCritical));
|
||||||
if (!blockCritical)
|
if (!blockCritical)
|
||||||
{
|
{
|
||||||
@ -220,22 +222,23 @@ public static class MoveTurnExecutor
|
|||||||
|
|
||||||
if (accuracy < 100 && battle.Random.GetInt(100) >= accuracy)
|
if (accuracy < 100 && battle.Random.GetInt(100) >= accuracy)
|
||||||
{
|
{
|
||||||
executingMove.RunScriptHookInterface<IScriptOnMoveMiss>(x => x.OnMoveMiss(executingMove, target));
|
executingMove.RunScriptHook<IScriptOnMoveMiss>(x => x.OnMoveMiss(executingMove, target));
|
||||||
battle.EventHook.Invoke(new MoveMissEvent(executingMove));
|
battle.EventHook.Invoke(new MoveMissEvent(executingMove));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var blockIncomingHit = false;
|
var blockIncomingHit = false;
|
||||||
target.RunScriptHookInterface<IScriptBlockIncomingHit>(x =>
|
target.RunScriptHook<IScriptBlockIncomingHit>(x =>
|
||||||
x.BlockIncomingHit(executingMove, target, hitIndex, ref blockIncomingHit));
|
x.BlockIncomingHit(executingMove, target, hitIndex, ref blockIncomingHit));
|
||||||
executingMove.RunScriptHookInterface<IScriptBlockOutgoingHit>(x =>
|
executingMove.RunScriptHook<IScriptBlockOutgoingHit>(x =>
|
||||||
x.BlockOutgoingHit(executingMove, target, hitIndex, ref blockIncomingHit));
|
x.BlockOutgoingHit(executingMove, target, hitIndex, ref blockIncomingHit));
|
||||||
if (blockIncomingHit)
|
if (blockIncomingHit)
|
||||||
break;
|
break;
|
||||||
if (executingMove.GetHitData(target, hitIndex).HasFailed)
|
if (executingMove.GetHitData(target, hitIndex).HasFailed)
|
||||||
break;
|
break;
|
||||||
var category = useMove.Category;
|
var category = useMove.Category;
|
||||||
executingMove.RunScriptHook(x => x.ChangeCategory(executingMove, target, hitIndex, ref category));
|
executingMove.RunScriptHook<IScriptChangeCategory>(x =>
|
||||||
|
x.ChangeCategory(executingMove, target, hitIndex, ref category));
|
||||||
if (category == MoveCategory.Status)
|
if (category == MoveCategory.Status)
|
||||||
{
|
{
|
||||||
var secondaryEffect = useMove.SecondaryEffect;
|
var secondaryEffect = useMove.SecondaryEffect;
|
||||||
@ -244,7 +247,7 @@ public static class MoveTurnExecutor
|
|||||||
var chance = secondaryEffect.Chance;
|
var chance = secondaryEffect.Chance;
|
||||||
if (chance < 0 || battle.Random.EffectChance(chance, executingMove, target, hitIndex))
|
if (chance < 0 || battle.Random.EffectChance(chance, executingMove, target, hitIndex))
|
||||||
{
|
{
|
||||||
executingMove.RunScriptHookInterface<IScriptOnSecondaryEffect>(x =>
|
executingMove.RunScriptHook<IScriptOnSecondaryEffect>(x =>
|
||||||
x.OnSecondaryEffect(executingMove, target, hitIndex));
|
x.OnSecondaryEffect(executingMove, target, hitIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -268,12 +271,12 @@ public static class MoveTurnExecutor
|
|||||||
target.Damage(damage, DamageSource.MoveDamage, hitEventBatch);
|
target.Damage(damage, DamageSource.MoveDamage, hitEventBatch);
|
||||||
if (!target.IsFainted)
|
if (!target.IsFainted)
|
||||||
{
|
{
|
||||||
target.RunScriptHookInterface<IScriptOnIncomingHit>(x =>
|
target.RunScriptHook<IScriptOnIncomingHit>(x =>
|
||||||
x.OnIncomingHit(executingMove, target, hitIndex));
|
x.OnIncomingHit(executingMove, target, hitIndex));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
executingMove.RunScriptHookInterface<IScriptOnOpponentFaints>(x =>
|
executingMove.RunScriptHook<IScriptOnOpponentFaints>(x =>
|
||||||
x.OnOpponentFaints(executingMove, target, hitIndex));
|
x.OnOpponentFaints(executingMove, target, hitIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,9 +286,9 @@ public static class MoveTurnExecutor
|
|||||||
if (secondaryEffect != null)
|
if (secondaryEffect != null)
|
||||||
{
|
{
|
||||||
var preventSecondary = false;
|
var preventSecondary = false;
|
||||||
executingMove.RunScriptHookInterface<IScriptPreventSecondaryEffect>(x =>
|
executingMove.RunScriptHook<IScriptPreventSecondaryEffect>(x =>
|
||||||
x.PreventSecondaryEffect(executingMove, target, hitIndex, ref preventSecondary));
|
x.PreventSecondaryEffect(executingMove, target, hitIndex, ref preventSecondary));
|
||||||
target.RunScriptHookInterface<IScriptPreventIncomingSecondaryEffect>(x =>
|
target.RunScriptHook<IScriptPreventIncomingSecondaryEffect>(x =>
|
||||||
x.PreventIncomingSecondaryEffect(executingMove, target, hitIndex,
|
x.PreventIncomingSecondaryEffect(executingMove, target, hitIndex,
|
||||||
ref preventSecondary));
|
ref preventSecondary));
|
||||||
|
|
||||||
@ -294,14 +297,14 @@ public static class MoveTurnExecutor
|
|||||||
var chance = secondaryEffect.Chance;
|
var chance = secondaryEffect.Chance;
|
||||||
if (chance < 0 || battle.Random.EffectChance(chance, executingMove, target, hitIndex))
|
if (chance < 0 || battle.Random.EffectChance(chance, executingMove, target, hitIndex))
|
||||||
{
|
{
|
||||||
executingMove.RunScriptHookInterface<IScriptOnSecondaryEffect>(x =>
|
executingMove.RunScriptHook<IScriptOnSecondaryEffect>(x =>
|
||||||
x.OnSecondaryEffect(executingMove, target, hitIndex));
|
x.OnSecondaryEffect(executingMove, target, hitIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (target.IsFainted)
|
if (target.IsFainted)
|
||||||
{
|
{
|
||||||
executingMove.RunScriptHookInterface<IScriptOnOpponentFaints>(x =>
|
executingMove.RunScriptHook<IScriptOnOpponentFaints>(x =>
|
||||||
x.OnOpponentFaints(executingMove, target, hitIndex));
|
x.OnOpponentFaints(executingMove, target, hitIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -311,13 +314,13 @@ public static class MoveTurnExecutor
|
|||||||
|
|
||||||
if (numberOfHits == 0)
|
if (numberOfHits == 0)
|
||||||
{
|
{
|
||||||
target.RunScriptHookInterface<IScriptOnMoveMiss>(x => x.OnMoveMiss(executingMove, target));
|
target.RunScriptHook<IScriptOnMoveMiss>(x => x.OnMoveMiss(executingMove, target));
|
||||||
battle.EventHook.Invoke(new MoveMissEvent(executingMove));
|
battle.EventHook.Invoke(new MoveMissEvent(executingMove));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!executingMove.User.IsFainted)
|
if (!executingMove.User.IsFainted)
|
||||||
{
|
{
|
||||||
executingMove.RunScriptHookInterface<IScriptOnAfterHits>(x => x.OnAfterHits(executingMove, target));
|
executingMove.RunScriptHook<IScriptOnAfterHits>(x => x.OnAfterHits(executingMove, target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -31,7 +31,7 @@ public static class TurnRunner
|
|||||||
// they can then know this later on.)
|
// they can then know this later on.)
|
||||||
foreach (var choice in queue.GetChoices().WhereNotNull())
|
foreach (var choice in queue.GetChoices().WhereNotNull())
|
||||||
{
|
{
|
||||||
choice.RunScriptHookInterface<IScriptOnBeforeTurnStart>(script => script.OnBeforeTurnStart(choice));
|
choice.RunScriptHook<IScriptOnBeforeTurnStart>(script => script.OnBeforeTurnStart(choice));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we can properly begin executing choices.
|
// Now we can properly begin executing choices.
|
||||||
@ -60,15 +60,15 @@ public static class TurnRunner
|
|||||||
{
|
{
|
||||||
scripts.Clear();
|
scripts.Clear();
|
||||||
pokemon.GetOwnScripts(scripts);
|
pokemon.GetOwnScripts(scripts);
|
||||||
scripts.RunScriptHookInterface<IScriptOnEndTurn>(x => x.OnEndTurn(pokemon, battle));
|
scripts.RunScriptHook<IScriptOnEndTurn>(x => x.OnEndTurn(pokemon, battle));
|
||||||
}
|
}
|
||||||
scripts.Clear();
|
scripts.Clear();
|
||||||
side.GetOwnScripts(scripts);
|
side.GetOwnScripts(scripts);
|
||||||
scripts.RunScriptHookInterface<IScriptOnEndTurn>(x => x.OnEndTurn(side, battle));
|
scripts.RunScriptHook<IScriptOnEndTurn>(x => x.OnEndTurn(side, battle));
|
||||||
}
|
}
|
||||||
scripts.Clear();
|
scripts.Clear();
|
||||||
battle.GetOwnScripts(scripts);
|
battle.GetOwnScripts(scripts);
|
||||||
scripts.RunScriptHookInterface<IScriptOnEndTurn>(x => x.OnEndTurn(battle, battle));
|
scripts.RunScriptHook<IScriptOnEndTurn>(x => x.OnEndTurn(battle, battle));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ public static class TurnRunner
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ExecuteChoice(IBattle battle, ITurnChoice choice)
|
public static void ExecuteChoice(IBattle battle, ITurnChoice choice)
|
||||||
{
|
{
|
||||||
choice.RunScriptHook(x => x.ChangeTurnChoice(ref choice));
|
choice.RunScriptHook<IScriptChangeTurnChoice>(x => x.ChangeTurnChoice(ref choice));
|
||||||
if (choice is IPassChoice)
|
if (choice is IPassChoice)
|
||||||
return;
|
return;
|
||||||
if (battle.HasEnded)
|
if (battle.HasEnded)
|
||||||
@ -90,7 +90,7 @@ public static class TurnRunner
|
|||||||
{
|
{
|
||||||
case IMoveChoice moveChoice:
|
case IMoveChoice moveChoice:
|
||||||
MoveTurnExecutor.ExecuteMoveChoice(battle, moveChoice);
|
MoveTurnExecutor.ExecuteMoveChoice(battle, moveChoice);
|
||||||
moveChoice.RunScriptHook(script => script.OnAfterMoveChoice(moveChoice));
|
moveChoice.RunScriptHook<IScriptOnAfterMoveChoice>(script => script.OnAfterMoveChoice(moveChoice));
|
||||||
break;
|
break;
|
||||||
case ISwitchChoice switchChoice:
|
case ISwitchChoice switchChoice:
|
||||||
ExecuteSwitchChoice(battle, switchChoice);
|
ExecuteSwitchChoice(battle, switchChoice);
|
||||||
@ -111,7 +111,7 @@ public static class TurnRunner
|
|||||||
if (battleData == null)
|
if (battleData == null)
|
||||||
return;
|
return;
|
||||||
var preventSwitch = false;
|
var preventSwitch = false;
|
||||||
fleeChoice.RunScriptHookInterface<IScriptPreventSelfSwitch>(script =>
|
fleeChoice.RunScriptHook<IScriptPreventSelfSwitch>(script =>
|
||||||
script.PreventSelfSwitch(fleeChoice, ref preventSwitch));
|
script.PreventSelfSwitch(fleeChoice, ref preventSwitch));
|
||||||
if (preventSwitch)
|
if (preventSwitch)
|
||||||
return;
|
return;
|
||||||
@ -121,7 +121,7 @@ public static class TurnRunner
|
|||||||
continue;
|
continue;
|
||||||
foreach (var pokemon in side.Pokemon.WhereNotNull())
|
foreach (var pokemon in side.Pokemon.WhereNotNull())
|
||||||
{
|
{
|
||||||
pokemon.RunScriptHookInterface<IScriptPreventOpponentSwitch>(script =>
|
pokemon.RunScriptHook<IScriptPreventOpponentSwitch>(script =>
|
||||||
script.PreventOpponentSwitch(fleeChoice, ref preventSwitch));
|
script.PreventOpponentSwitch(fleeChoice, ref preventSwitch));
|
||||||
if (preventSwitch)
|
if (preventSwitch)
|
||||||
return;
|
return;
|
||||||
@ -142,7 +142,7 @@ public static class TurnRunner
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var preventFlee = false;
|
var preventFlee = false;
|
||||||
fleeChoice.RunScriptHookInterface<IScriptPreventSelfRunAway>(script =>
|
fleeChoice.RunScriptHook<IScriptPreventSelfRunAway>(script =>
|
||||||
script.PreventSelfRunAway(fleeChoice, ref preventFlee));
|
script.PreventSelfRunAway(fleeChoice, ref preventFlee));
|
||||||
if (preventFlee)
|
if (preventFlee)
|
||||||
return;
|
return;
|
||||||
@ -153,7 +153,7 @@ public static class TurnRunner
|
|||||||
continue;
|
continue;
|
||||||
foreach (var pokemon in side.Pokemon.WhereNotNull())
|
foreach (var pokemon in side.Pokemon.WhereNotNull())
|
||||||
{
|
{
|
||||||
pokemon.RunScriptHookInterface<IScriptPreventOpponentRunAway>(script =>
|
pokemon.RunScriptHook<IScriptPreventOpponentRunAway>(script =>
|
||||||
script.PreventOpponentRunAway(fleeChoice, ref preventFlee));
|
script.PreventOpponentRunAway(fleeChoice, ref preventFlee));
|
||||||
if (preventFlee)
|
if (preventFlee)
|
||||||
return;
|
return;
|
||||||
|
@ -311,7 +311,7 @@ public class BattleImpl : ScriptSource, IBattle
|
|||||||
}
|
}
|
||||||
|
|
||||||
ITurnChoice? forcedChoice = null;
|
ITurnChoice? forcedChoice = null;
|
||||||
pokemon.RunScriptHookInterface<IScriptForceTurnSelection>(script =>
|
pokemon.RunScriptHook<IScriptForceTurnSelection>(script =>
|
||||||
script.ForceTurnSelection(this, battleData.SideIndex, battleData.Position, ref forcedChoice));
|
script.ForceTurnSelection(this, battleData.SideIndex, battleData.Position, ref forcedChoice));
|
||||||
choice = forcedChoice;
|
choice = forcedChoice;
|
||||||
return choice != null;
|
return choice != null;
|
||||||
@ -336,7 +336,7 @@ public class BattleImpl : ScriptSource, IBattle
|
|||||||
moveChoice.ChosenMove.MoveData.Target, moveChoice.User))
|
moveChoice.ChosenMove.MoveData.Target, moveChoice.User))
|
||||||
return false;
|
return false;
|
||||||
var preventMove = false;
|
var preventMove = false;
|
||||||
choice.RunScriptHookInterface<IScriptPreventMoveSelection>(script =>
|
choice.RunScriptHook<IScriptPreventMoveSelection>(script =>
|
||||||
script.PreventMoveSelection(moveChoice, ref preventMove));
|
script.PreventMoveSelection(moveChoice, ref preventMove));
|
||||||
if (preventMove)
|
if (preventMove)
|
||||||
return false;
|
return false;
|
||||||
@ -394,13 +394,13 @@ public class BattleImpl : ScriptSource, IBattle
|
|||||||
if (choice is IMoveChoice moveChoice)
|
if (choice is IMoveChoice moveChoice)
|
||||||
{
|
{
|
||||||
var priority = moveChoice.ChosenMove.MoveData.Priority;
|
var priority = moveChoice.ChosenMove.MoveData.Priority;
|
||||||
choice.RunScriptHookInterface<IScriptChangePriority>(script =>
|
choice.RunScriptHook<IScriptChangePriority>(script =>
|
||||||
script.ChangePriority(moveChoice, ref priority));
|
script.ChangePriority(moveChoice, ref priority));
|
||||||
moveChoice.Priority = priority;
|
moveChoice.Priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
var speed = choice.User.BoostedStats.Speed;
|
var speed = choice.User.BoostedStats.Speed;
|
||||||
choice.RunScriptHookInterface<IScriptChangeSpeed>(script => script.ChangeSpeed(choice, ref speed));
|
choice.RunScriptHook<IScriptChangeSpeed>(script => script.ChangeSpeed(choice, ref speed));
|
||||||
choice.Speed = speed;
|
choice.Speed = speed;
|
||||||
|
|
||||||
choice.RandomValue = (uint)Random.GetInt();
|
choice.RandomValue = (uint)Random.GetInt();
|
||||||
@ -434,7 +434,8 @@ public class BattleImpl : ScriptSource, IBattle
|
|||||||
public bool SetWeather(StringKey? weatherName, int duration, EventBatchId batchId = default)
|
public bool SetWeather(StringKey? weatherName, int duration, EventBatchId batchId = default)
|
||||||
{
|
{
|
||||||
var preventWeatherChange = false;
|
var preventWeatherChange = false;
|
||||||
this.RunScriptHook(x => x.PreventWeatherChange(weatherName, ref preventWeatherChange));
|
this.RunScriptHook<IScriptPreventWeatherChange>(x =>
|
||||||
|
x.PreventWeatherChange(weatherName, ref preventWeatherChange));
|
||||||
if (preventWeatherChange)
|
if (preventWeatherChange)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -446,7 +447,8 @@ public class BattleImpl : ScriptSource, IBattle
|
|||||||
// Extend duration of existing weather
|
// Extend duration of existing weather
|
||||||
if (_weatherScript.Script is ILimitedTurnsScript existingWeatherScript)
|
if (_weatherScript.Script is ILimitedTurnsScript existingWeatherScript)
|
||||||
{
|
{
|
||||||
this.RunScriptHook(x => x.ChangeWeatherDuration(weatherName.Value, ref duration));
|
this.RunScriptHook<IScriptChangeWeatherDuration>(x =>
|
||||||
|
x.ChangeWeatherDuration(weatherName.Value, ref duration));
|
||||||
if (duration < existingWeatherScript.TurnsRemaining)
|
if (duration < existingWeatherScript.TurnsRemaining)
|
||||||
return true;
|
return true;
|
||||||
existingWeatherScript.SetTurns(duration);
|
existingWeatherScript.SetTurns(duration);
|
||||||
@ -458,7 +460,8 @@ public class BattleImpl : ScriptSource, IBattle
|
|||||||
|
|
||||||
if (script is ILimitedTurnsScript weatherScript)
|
if (script is ILimitedTurnsScript weatherScript)
|
||||||
{
|
{
|
||||||
this.RunScriptHook(x => x.ChangeWeatherDuration(weatherName.Value, ref duration));
|
this.RunScriptHook<IScriptChangeWeatherDuration>(x =>
|
||||||
|
x.ChangeWeatherDuration(weatherName.Value, ref duration));
|
||||||
weatherScript.SetTurns(duration);
|
weatherScript.SetTurns(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,7 +477,7 @@ public class BattleImpl : ScriptSource, IBattle
|
|||||||
BatchId = batchId,
|
BatchId = batchId,
|
||||||
});
|
});
|
||||||
Sides.SelectMany(x => x.Pokemon).WhereNotNull()
|
Sides.SelectMany(x => x.Pokemon).WhereNotNull()
|
||||||
.RunScriptHook(x => x.OnWeatherChange(this, weatherName, oldWeatherName));
|
.RunScriptHook<IScriptOnWeatherChange>(x => x.OnWeatherChange(this, weatherName, oldWeatherName));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class BattleChoiceQueue : IDeepCloneable
|
|||||||
continue;
|
continue;
|
||||||
// Ensure that the speed is up to date
|
// Ensure that the speed is up to date
|
||||||
var speed = choice.User.BoostedStats.Speed;
|
var speed = choice.User.BoostedStats.Speed;
|
||||||
choice.User.RunScriptHookInterface<IScriptChangeSpeed>(script => script.ChangeSpeed(choice, ref speed));
|
choice.User.RunScriptHook<IScriptChangeSpeed>(script => script.ChangeSpeed(choice, ref speed));
|
||||||
choice.Speed = speed;
|
choice.Speed = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,9 +38,9 @@ public class BattleRandomImpl : RandomImpl, IBattleRandom
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool EffectChance(float chance, IExecutingMove executingMove, IPokemon target, byte hitNumber)
|
public bool EffectChance(float chance, IExecutingMove executingMove, IPokemon target, byte hitNumber)
|
||||||
{
|
{
|
||||||
executingMove.RunScriptHookInterface<IScriptChangeEffectChance>(script =>
|
executingMove.RunScriptHook<IScriptChangeEffectChance>(script =>
|
||||||
script.ChangeEffectChance(executingMove, target, hitNumber, ref chance));
|
script.ChangeEffectChance(executingMove, target, hitNumber, ref chance));
|
||||||
target.RunScriptHookInterface<IScriptChangeIncomingEffectChance>(script =>
|
target.RunScriptHook<IScriptChangeIncomingEffectChance>(script =>
|
||||||
script.ChangeIncomingEffectChance(executingMove, target, hitNumber, ref chance));
|
script.ChangeIncomingEffectChance(executingMove, target, hitNumber, ref chance));
|
||||||
if (chance > 100.0)
|
if (chance > 100.0)
|
||||||
return true;
|
return true;
|
||||||
|
@ -248,7 +248,7 @@ public class BattleSideImpl : ScriptSource, IBattleSide
|
|||||||
var pokemon = _pokemon[index];
|
var pokemon = _pokemon[index];
|
||||||
if (pokemon is not null)
|
if (pokemon is not null)
|
||||||
{
|
{
|
||||||
pokemon.RunScriptHook(script => script.OnRemove());
|
pokemon.RunScriptHook<IScriptOnRemove>(script => script.OnRemove());
|
||||||
pokemon.SetOnBattlefield(false);
|
pokemon.SetOnBattlefield(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,8 +261,8 @@ public class BattleSideImpl : ScriptSource, IBattleSide
|
|||||||
var oldPokemon = _pokemon[position];
|
var oldPokemon = _pokemon[position];
|
||||||
if (oldPokemon is not null)
|
if (oldPokemon is not null)
|
||||||
{
|
{
|
||||||
oldPokemon.RunScriptHookInterface<IScriptOnSwitchOut>(script => script.OnSwitchOut(oldPokemon, position));
|
oldPokemon.RunScriptHook<IScriptOnSwitchOut>(script => script.OnSwitchOut(oldPokemon, position));
|
||||||
oldPokemon.RunScriptHook(script => script.OnRemove());
|
oldPokemon.RunScriptHook<IScriptOnRemove>(script => script.OnRemove());
|
||||||
oldPokemon.SetOnBattlefield(false);
|
oldPokemon.SetOnBattlefield(false);
|
||||||
}
|
}
|
||||||
_pokemon[position] = pokemon;
|
_pokemon[position] = pokemon;
|
||||||
@ -272,7 +272,7 @@ public class BattleSideImpl : ScriptSource, IBattleSide
|
|||||||
pokemon.SetOnBattlefield(true);
|
pokemon.SetOnBattlefield(true);
|
||||||
pokemon.SetBattleSidePosition(position);
|
pokemon.SetBattleSidePosition(position);
|
||||||
Battle.EventHook.Invoke(new SwitchEvent(Index, position, pokemon));
|
Battle.EventHook.Invoke(new SwitchEvent(Index, position, pokemon));
|
||||||
pokemon.RunScriptHookInterface<IScriptOnSwitchIn>(script => script.OnSwitchIn(pokemon, position));
|
pokemon.RunScriptHook<IScriptOnSwitchIn>(script => script.OnSwitchIn(pokemon, position));
|
||||||
|
|
||||||
foreach (var side in Battle.Sides)
|
foreach (var side in Battle.Sides)
|
||||||
{
|
{
|
||||||
@ -286,11 +286,10 @@ public class BattleSideImpl : ScriptSource, IBattleSide
|
|||||||
|
|
||||||
scripts.Clear();
|
scripts.Clear();
|
||||||
opponent.GetOwnScripts(scripts);
|
opponent.GetOwnScripts(scripts);
|
||||||
opponent.RunScriptHookInterface<IScriptOnOpponentSwitchIn>(script =>
|
opponent.RunScriptHook<IScriptOnOpponentSwitchIn>(script =>
|
||||||
script.OnOpponentSwitchIn(pokemon, position));
|
script.OnOpponentSwitchIn(pokemon, position));
|
||||||
}
|
}
|
||||||
side.RunScriptHookInterface<IScriptOnOpponentSwitchIn>(script =>
|
side.RunScriptHook<IScriptOnOpponentSwitchIn>(script => script.OnOpponentSwitchIn(pokemon, position));
|
||||||
script.OnOpponentSwitchIn(pokemon, position));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -684,7 +684,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
|||||||
var weight = Form.Weight;
|
var weight = Form.Weight;
|
||||||
if (BattleData is not null)
|
if (BattleData is not null)
|
||||||
// ReSharper disable once AccessToModifiedClosure
|
// ReSharper disable once AccessToModifiedClosure
|
||||||
this.RunScriptHook(script => script.ModifyWeight(ref weight));
|
this.RunScriptHook<IScriptModifyWeight>(script => script.ModifyWeight(ref weight));
|
||||||
if (weight < 0.1f)
|
if (weight < 0.1f)
|
||||||
weight = 0.1f;
|
weight = 0.1f;
|
||||||
return weight;
|
return weight;
|
||||||
@ -793,7 +793,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
|||||||
{
|
{
|
||||||
var previous = HeldItem;
|
var previous = HeldItem;
|
||||||
HeldItem = item;
|
HeldItem = item;
|
||||||
this.RunScriptHook(x => x.OnAfterHeldItemChange(this, previous, item));
|
this.RunScriptHook<IScriptOnAfterHeldItemChange>(x => x.OnAfterHeldItemChange(this, previous, item));
|
||||||
return previous;
|
return previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -809,7 +809,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
|||||||
}
|
}
|
||||||
var previous = HeldItem;
|
var previous = HeldItem;
|
||||||
HeldItem = null;
|
HeldItem = null;
|
||||||
this.RunScriptHook(x => x.OnAfterHeldItemChange(this, previous, null));
|
this.RunScriptHook<IScriptOnAfterHeldItemChange>(x => x.OnAfterHeldItemChange(this, previous, null));
|
||||||
return previous;
|
return previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -833,7 +833,8 @@ public class PokemonImpl : ScriptSource, IPokemon
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var prevent = false;
|
var prevent = false;
|
||||||
this.RunScriptHook(script => script.PreventHeldItemSteal(this, HeldItem, ref prevent));
|
this.RunScriptHook<IScriptPreventHeldItemSteal>(script =>
|
||||||
|
script.PreventHeldItemSteal(this, HeldItem, ref prevent));
|
||||||
if (prevent)
|
if (prevent)
|
||||||
{
|
{
|
||||||
item = null;
|
item = null;
|
||||||
@ -861,7 +862,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
|||||||
if (BattleData != null)
|
if (BattleData != null)
|
||||||
{
|
{
|
||||||
var prevented = false;
|
var prevented = false;
|
||||||
this.RunScriptHookInterface<IScriptPreventHeldItemConsume>(script =>
|
this.RunScriptHook<IScriptPreventHeldItemConsume>(script =>
|
||||||
script.PreventHeldItemConsume(this, HeldItem, ref prevented));
|
script.PreventHeldItemConsume(this, HeldItem, ref prevented));
|
||||||
if (prevented)
|
if (prevented)
|
||||||
return false;
|
return false;
|
||||||
@ -880,7 +881,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
|||||||
{
|
{
|
||||||
// TODO: actually consume the item
|
// TODO: actually consume the item
|
||||||
|
|
||||||
this.RunScriptHookInterface<IScriptOnAfterItemConsume>(x => x.OnAfterItemConsume(this, item));
|
this.RunScriptHook<IScriptOnAfterItemConsume>(x => x.OnAfterItemConsume(this, item));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -890,11 +891,11 @@ public class PokemonImpl : ScriptSource, IPokemon
|
|||||||
if (!force)
|
if (!force)
|
||||||
{
|
{
|
||||||
var prevented = false;
|
var prevented = false;
|
||||||
this.RunScriptHookInterface<IScriptPreventStatBoostChange>(script =>
|
this.RunScriptHook<IScriptPreventStatBoostChange>(script =>
|
||||||
script.PreventStatBoostChange(this, stat, change, selfInflicted, ref prevented));
|
script.PreventStatBoostChange(this, stat, change, selfInflicted, ref prevented));
|
||||||
if (prevented)
|
if (prevented)
|
||||||
return false;
|
return false;
|
||||||
this.RunScriptHookInterface<IScriptChangeStatBoostChange>(script =>
|
this.RunScriptHook<IScriptChangeStatBoostChange>(script =>
|
||||||
script.ChangeStatBoostChange(this, stat, selfInflicted, ref change));
|
script.ChangeStatBoostChange(this, stat, selfInflicted, ref change));
|
||||||
if (change == 0)
|
if (change == 0)
|
||||||
return false;
|
return false;
|
||||||
@ -919,7 +920,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
|||||||
}
|
}
|
||||||
|
|
||||||
RecalculateBoostedStats();
|
RecalculateBoostedStats();
|
||||||
this.RunScriptHookInterface<IScriptOnAfterStatBoostChange>(script =>
|
this.RunScriptHook<IScriptOnAfterStatBoostChange>(script =>
|
||||||
script.OnAfterStatBoostChange(this, stat, selfInflicted, change));
|
script.OnAfterStatBoostChange(this, stat, selfInflicted, change));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1075,7 +1076,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
|||||||
if (BattleData is not null && !forceDamage)
|
if (BattleData is not null && !forceDamage)
|
||||||
{
|
{
|
||||||
var dmg = damage;
|
var dmg = damage;
|
||||||
this.RunScriptHookInterface<IScriptChangeIncomingDamage>(script =>
|
this.RunScriptHook<IScriptChangeIncomingDamage>(script =>
|
||||||
script.ChangeIncomingDamage(this, source, ref dmg));
|
script.ChangeIncomingDamage(this, source, ref dmg));
|
||||||
damage = dmg;
|
damage = dmg;
|
||||||
}
|
}
|
||||||
@ -1096,8 +1097,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
|||||||
BatchId = batchId,
|
BatchId = batchId,
|
||||||
});
|
});
|
||||||
// And allow scripts to execute.
|
// And allow scripts to execute.
|
||||||
this.RunScriptHookInterface<IScriptOnDamage>(script =>
|
this.RunScriptHook<IScriptOnDamage>(script => script.OnDamage(this, source, CurrentHealth, newHealth));
|
||||||
script.OnDamage(this, source, CurrentHealth, newHealth));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentHealth = newHealth;
|
CurrentHealth = newHealth;
|
||||||
@ -1126,14 +1126,14 @@ public class PokemonImpl : ScriptSource, IPokemon
|
|||||||
BattleData.Battle.EventHook.Invoke(new FaintEvent(this));
|
BattleData.Battle.EventHook.Invoke(new FaintEvent(this));
|
||||||
|
|
||||||
// Allow scripts to trigger based on the faint.
|
// Allow scripts to trigger based on the faint.
|
||||||
this.RunScriptHookInterface<IScriptOnFaint>(script => script.OnFaint(this, source));
|
this.RunScriptHook<IScriptOnFaint>(script => script.OnFaint(this, source));
|
||||||
foreach (var ally in BattleData.BattleSide.Pokemon.WhereNotNull().Where(x => x != this))
|
foreach (var ally in BattleData.BattleSide.Pokemon.WhereNotNull().Where(x => x != this))
|
||||||
{
|
{
|
||||||
ally.RunScriptHookInterface<IScriptOnAllyFaint>(script => script.OnAllyFaint(ally, this));
|
ally.RunScriptHook<IScriptOnAllyFaint>(script => script.OnAllyFaint(ally, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the OnRemove script is run.
|
// Make sure the OnRemove script is run.
|
||||||
this.RunScriptHook(script => script.OnRemove());
|
this.RunScriptHook<IScriptOnRemove>(script => script.OnRemove());
|
||||||
|
|
||||||
// Mark the position as unfillable if it can't be filled by any party.
|
// Mark the position as unfillable if it can't be filled by any party.
|
||||||
if (!BattleData.Battle.CanSlotBeFilled(BattleData.SideIndex, BattleData.Position))
|
if (!BattleData.Battle.CanSlotBeFilled(BattleData.SideIndex, BattleData.Position))
|
||||||
@ -1162,7 +1162,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
|||||||
if (!forceHeal)
|
if (!forceHeal)
|
||||||
{
|
{
|
||||||
var prevented = false;
|
var prevented = false;
|
||||||
this.RunScriptHook(x => x.PreventHeal(this, heal, allowRevive, ref prevented));
|
this.RunScriptHook<IScriptPreventHeal>(x => x.PreventHeal(this, heal, allowRevive, ref prevented));
|
||||||
if (prevented)
|
if (prevented)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1226,7 +1226,8 @@ public class PokemonImpl : ScriptSource, IPokemon
|
|||||||
var selfInflicted = originPokemon == this;
|
var selfInflicted = originPokemon == this;
|
||||||
|
|
||||||
var preventStatus = false;
|
var preventStatus = false;
|
||||||
this.RunScriptHook(script => script.PreventStatusChange(this, status, selfInflicted, ref preventStatus));
|
this.RunScriptHook<IScriptPreventStatusChange>(script =>
|
||||||
|
script.PreventStatusChange(this, status, selfInflicted, ref preventStatus));
|
||||||
if (preventStatus)
|
if (preventStatus)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -1236,7 +1237,8 @@ public class PokemonImpl : ScriptSource, IPokemon
|
|||||||
{
|
{
|
||||||
BatchId = batchId,
|
BatchId = batchId,
|
||||||
});
|
});
|
||||||
this.RunScriptHook(script => script.OnAfterStatusChange(this, status, originPokemon));
|
this.RunScriptHook<IScriptOnAfterStatusChange>(script =>
|
||||||
|
script.OnAfterStatusChange(this, status, originPokemon));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1375,7 +1377,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
var isFloating = Types.Any(x => x.Name == "flying");
|
var isFloating = Types.Any(x => x.Name == "flying");
|
||||||
this.RunScriptHook(x => x.IsFloating(this, ref isFloating));
|
this.RunScriptHook<IScriptIsFloating>(x => x.IsFloating(this, ref isFloating));
|
||||||
return isFloating;
|
return isFloating;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ namespace PkmnLib.Dynamic.ScriptHandling;
|
|||||||
/// developer might require.
|
/// developer might require.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Category} - {Name}")]
|
[DebuggerDisplay("{Category} - {Name}")]
|
||||||
public abstract class Script : IDeepCloneable
|
public abstract class Script : IDeepCloneable, IScriptOnRemove
|
||||||
{
|
{
|
||||||
internal event Action<Script>? OnRemoveEvent;
|
internal event Action<Script>? OnRemoveEvent;
|
||||||
|
|
||||||
@ -52,239 +52,17 @@ public abstract class Script : IDeepCloneable
|
|||||||
public virtual void OnAddedToParent(IScriptSource source)
|
public virtual void OnAddedToParent(IScriptSource source)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface is used to allow scripts to run when they are removed from their owner.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptOnRemove
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This function is triggered on a Pokemon and its parents when the given Pokemon gains experience,
|
/// This function is ran when this script stops being in effect, and is removed from its owner.
|
||||||
/// and allows for changing this amount of experience.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void ChangeExperienceGained(IPokemon faintedPokemon, IPokemon winningPokemon, ref uint amount)
|
void OnRemove();
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function is triggered on a Pokemon and its parents when the given Pokemon gains experience,
|
|
||||||
/// and allows for making the experience be shared across multiple Pokemon.
|
|
||||||
/// Amount is the modifier for how much experience is shared, with 1 being the default amount.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void ShareExperience(IPokemon faintedPokemon, IPokemon winningPokemon, ref bool share,
|
|
||||||
ref float amount)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function is triggered on a battle and its parents when something attempts to change the
|
|
||||||
/// weather, and allows for blocking the weather change.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void BlockWeatherChange(IBattle battle, ref bool block)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function is called when a Pokeball is thrown at a Pokemon, and allows modifying the catch
|
|
||||||
/// rate of this attempt. Pokeball modifier effects should be implemented here, as well as for
|
|
||||||
/// example status effects that change capture rates.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void ChangeCatchRateBonus(IPokemon pokemon, IItem pokeball, ref byte modifier)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Custom triggers for scripts. This allows scripts to run custom events that are not part of the
|
|
||||||
/// standard battle flow.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="eventName">
|
|
||||||
/// The name of the event that is triggered. This should be unique for each different event. Overriding scripts
|
|
||||||
/// should validate the event name is one they should handle.
|
|
||||||
/// </param>
|
|
||||||
/// <param name="args">
|
|
||||||
/// The parameters that are passed to the event.
|
|
||||||
/// </param>
|
|
||||||
public virtual void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function allows a script to change the accuracy of a move used. The value for accuracy is in percentage.
|
|
||||||
/// A custom case goes when 255 is returned, in which case the entire accuracy check is skipped, and the move
|
|
||||||
/// will always hit.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="executingMove"></param>
|
|
||||||
/// <param name="target"></param>
|
|
||||||
/// <param name="hitIndex"></param>
|
|
||||||
/// <param name="modifiedAccuracy"></param>
|
|
||||||
public virtual void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
|
||||||
ref int modifiedAccuracy)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function allows a script to change the accuracy of a move that is incoming. The value for accuracy is in percentage.
|
|
||||||
/// A custom case goes when 255 is returned, in which case the entire accuracy check is skipped, and the move
|
|
||||||
/// will always hit.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
|
||||||
ref int modifiedAccuracy)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function allows a script to change the weather duration of a weather effect.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void ChangeWeatherDuration(StringKey weatherName, ref int duration)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function allows a script to prevent a Pokemon from being healed.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void PreventHeal(IPokemon pokemon, uint heal, bool allowRevive, ref bool prevented)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function allows a script to change the types a target has. Multiple types can be set, and will be used
|
|
||||||
/// for the effectiveness calculation.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void ChangeTypesForMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
|
||||||
IList<TypeIdentifier> types)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function allows a script to change the types a Pokemon has for a move that's incoming. Multiple types can
|
|
||||||
/// be set, and will be used for the effectiveness calculation.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
|
||||||
IList<TypeIdentifier> types)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function allows a script to change the handling of the move category. This is used for moves that
|
|
||||||
/// are sometimes a status move, and sometimes a damaging move, such as pollen puff.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void ChangeCategory(IExecutingMove move, IPokemon target, byte hitIndex, ref MoveCategory category)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Triggers first when we're about to hit a target.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function allows a script to prevent a Pokemon from being affected by a status condition.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
|
|
||||||
ref bool preventStatus)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function triggers after a status condition has been applied to a Pokemon.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void OnAfterStatusChange(IPokemon pokemon, StringKey status, IPokemon? originPokemon)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function allows a script to prevent a Pokémon from being affected by a volatile status condition.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function allows a script to make the Pokémon it is attached to float. This is used for moves
|
|
||||||
/// such as levitate, and allows for moves such as earthquake to not hit the Pokémon.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pokemon"></param>
|
|
||||||
/// <param name="isFloating"></param>
|
|
||||||
public virtual void IsFloating(IPokemon pokemon, ref bool isFloating)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function allows a script to prevent the weather from changing. This is used for abilities such as
|
|
||||||
/// Delta Stream, which prevent the weather from changing to anything other than strong winds.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void PreventWeatherChange(StringKey? weatherName, ref bool preventWeatherChange)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function triggers when the weather changes.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void OnWeatherChange(IBattle battle, StringKey? weatherName, StringKey? oldWeatherName)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Modifies the weight of a Pokemon.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="weight">The weight in kilograms</param>
|
|
||||||
public virtual void ModifyWeight(ref float weight)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Modifies whether a move is a contact move or not. This is used for abilities such as Long Reach.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void ModifyIsContact(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
|
||||||
ref bool isContact)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function allows a script to prevent a held item from being stolen by an effect such as Thief or Covet.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void PreventHeldItemSteal(IPokemon pokemon, IItem heldItem, ref bool prevent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function allows a script to run after a held item has changed.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void OnAfterHeldItemChange(IPokemon pokemon, IItem? previous, IItem? item)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function allows a script to modify the PP used by a move.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void ModifyPPUsed(IExecutingMove executingMove, ref byte ppUsed)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function allows a script to modify the PP used by an incoming move. This is used for abilities such as Pressure.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void ModifyPPUsedForIncomingMove(IExecutingMove executingMove, ref byte ppUsed)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function triggers just before a move choice is executed.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void OnBeforeMoveChoice(IMoveChoice moveChoice)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function triggers after a move choice has been executed in its entirety.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void OnAfterMoveChoice(IMoveChoice moveChoice)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This function allows a script to change the turn choice that is made by a Pokemon.
|
|
||||||
/// </summary>
|
|
||||||
public virtual void ChangeTurnChoice(ref ITurnChoice choice)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1103,3 +881,327 @@ public interface IScriptChangeIncomingDamage
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
void ChangeIncomingDamage(IPokemon pokemon, DamageSource source, ref uint damage);
|
void ChangeIncomingDamage(IPokemon pokemon, DamageSource source, ref uint damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to change the weather duration of a weather effect.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptChangeWeatherDuration
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function allows a script to change the weather duration of a weather effect.
|
||||||
|
/// </summary>
|
||||||
|
void ChangeWeatherDuration(StringKey weatherName, ref int duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to prevent a Pokemon from being healed.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptPreventHeal
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function allows a script to prevent a Pokemon from being healed.
|
||||||
|
/// </summary>
|
||||||
|
void PreventHeal(IPokemon pokemon, uint heal, bool allowRevive, ref bool prevented);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to change the types a target has for effectiveness calculation.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptChangeTypesForMove
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function allows a script to change the types a target has. Multiple types can be set, and will be used
|
||||||
|
/// for the effectiveness calculation.
|
||||||
|
/// </summary>
|
||||||
|
void ChangeTypesForMove(IExecutingMove executingMove, IPokemon target, byte hitIndex, IList<TypeIdentifier> types);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to change the types a Pokemon has for incoming moves.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptChangeTypesForIncomingMove
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function allows a script to change the types a Pokemon has for a move that's incoming. Multiple types can
|
||||||
|
/// be set, and will be used for the effectiveness calculation.
|
||||||
|
/// </summary>
|
||||||
|
void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||||
|
IList<TypeIdentifier> types);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to change the handling of the move category.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptChangeCategory
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function allows a script to change the handling of the move category. This is used for moves that
|
||||||
|
/// are sometimes a status move, and sometimes a damaging move, such as pollen puff.
|
||||||
|
/// </summary>
|
||||||
|
void ChangeCategory(IExecutingMove move, IPokemon target, byte hitIndex, ref MoveCategory category);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to trigger when about to hit a target.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptOnBeforeHit
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Triggers first when we're about to hit a target.
|
||||||
|
/// </summary>
|
||||||
|
void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to prevent a Pokemon from being affected by a status condition.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptPreventStatusChange
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function allows a script to prevent a Pokemon from being affected by a status condition.
|
||||||
|
/// </summary>
|
||||||
|
void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to trigger after a status condition has been applied.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptOnAfterStatusChange
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function triggers after a status condition has been applied to a Pokemon.
|
||||||
|
/// </summary>
|
||||||
|
void OnAfterStatusChange(IPokemon pokemon, StringKey status, IPokemon? originPokemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to prevent a Pokemon from being affected by a volatile status condition.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptPreventVolatileAdd
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function allows a script to prevent a Pokémon from being affected by a volatile status condition.
|
||||||
|
/// </summary>
|
||||||
|
void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to make the Pokemon float.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptIsFloating
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function allows a script to make the Pokémon it is attached to float. This is used for moves
|
||||||
|
/// such as levitate, and allows for moves such as earthquake to not hit the Pokémon.
|
||||||
|
/// </summary>
|
||||||
|
void IsFloating(IPokemon pokemon, ref bool isFloating);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to prevent weather from changing.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptPreventWeatherChange
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function allows a script to prevent the weather from changing. This is used for abilities such as
|
||||||
|
/// Delta Stream, which prevent the weather from changing to anything other than strong winds.
|
||||||
|
/// </summary>
|
||||||
|
void PreventWeatherChange(StringKey? weatherName, ref bool preventWeatherChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to trigger when the weather changes.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptOnWeatherChange
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function triggers when the weather changes.
|
||||||
|
/// </summary>
|
||||||
|
void OnWeatherChange(IBattle battle, StringKey? weatherName, StringKey? oldWeatherName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to modify the weight of a Pokemon.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptModifyWeight
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Modifies the weight of a Pokemon.
|
||||||
|
/// </summary>
|
||||||
|
void ModifyWeight(ref float weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to modify whether a move makes contact.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptModifyIsContact
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Modifies whether a move is a contact move or not. This is used for abilities such as Long Reach.
|
||||||
|
/// </summary>
|
||||||
|
void ModifyIsContact(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool isContact);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to prevent held item theft.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptPreventHeldItemSteal
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function allows a script to prevent a held item from being stolen by an effect such as Thief or Covet.
|
||||||
|
/// </summary>
|
||||||
|
void PreventHeldItemSteal(IPokemon pokemon, IItem heldItem, ref bool prevent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to trigger after held item changes.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptOnAfterHeldItemChange
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function allows a script to run after a held item has changed.
|
||||||
|
/// </summary>
|
||||||
|
void OnAfterHeldItemChange(IPokemon pokemon, IItem? previous, IItem? item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to modify the PP used by a move.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptModifyPPUsed
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function allows a script to modify the PP used by a move.
|
||||||
|
/// </summary>
|
||||||
|
void ModifyPPUsed(IExecutingMove executingMove, ref byte ppUsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to modify the PP used by an incoming move.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptModifyPPUsedForIncomingMove
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function allows a script to modify the PP used by an incoming move. This is used for abilities such as Pressure.
|
||||||
|
/// </summary>
|
||||||
|
void ModifyPPUsedForIncomingMove(IExecutingMove executingMove, ref byte ppUsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to trigger just before a move choice is executed.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptOnBeforeMoveChoice
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function triggers just before a move choice is executed.
|
||||||
|
/// </summary>
|
||||||
|
void OnBeforeMoveChoice(IMoveChoice moveChoice);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to trigger after a move choice has been executed.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptOnAfterMoveChoice
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function triggers after a move choice has been executed in its entirety.
|
||||||
|
/// </summary>
|
||||||
|
void OnAfterMoveChoice(IMoveChoice moveChoice);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to change the turn choice that is made by a Pokemon.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptChangeTurnChoice
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function allows a script to change the turn choice that is made by a Pokemon.
|
||||||
|
/// </summary>
|
||||||
|
void ChangeTurnChoice(ref ITurnChoice choice);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to change the experience gained when a Pokemon faints.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptChangeExperienceGained
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function is triggered on a Pokemon and its parents when the given Pokemon gains experience,
|
||||||
|
/// and allows for changing this amount of experience.
|
||||||
|
/// </summary>
|
||||||
|
void ChangeExperienceGained(IPokemon faintedPokemon, IPokemon winningPokemon, ref uint amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to share experience across multiple Pokemon.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptShareExperience
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function is triggered on a Pokemon and its parents when the given Pokemon gains experience,
|
||||||
|
/// and allows for making the experience be shared across multiple Pokemon.
|
||||||
|
/// Amount is the modifier for how much experience is shared, with 1 being the default amount.
|
||||||
|
/// </summary>
|
||||||
|
void ShareExperience(IPokemon faintedPokemon, IPokemon winningPokemon, ref bool share, ref float amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to block weather changes.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptBlockWeatherChange
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function allows a script to block weather changes.
|
||||||
|
/// </summary>
|
||||||
|
void BlockWeatherChange(IBattle battle, ref bool block);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to change the catch rate bonus when a Pokeball is thrown.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptChangeCatchRateBonus
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function is called when a Pokeball is thrown at a Pokemon, and allows modifying the catch
|
||||||
|
/// rate of this attempt. Pokeball modifier effects should be implemented here, as well as for
|
||||||
|
/// example status effects that change capture rates.
|
||||||
|
/// </summary>
|
||||||
|
void ChangeCatchRateBonus(IPokemon pokemon, IItem pokeball, ref byte modifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to handle custom trigger events.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptCustomTrigger
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Custom triggers for scripts. This allows scripts to run custom events that are not part of the
|
||||||
|
/// standard battle flow.
|
||||||
|
/// </summary>
|
||||||
|
void CustomTrigger(StringKey eventName, ICustomTriggerArgs args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to change the accuracy of a move.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptChangeAccuracy
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function allows a script to change the accuracy of a move used. The value for accuracy is in percentage.
|
||||||
|
/// A custom case goes when 255 is returned, in which case the entire accuracy check is skipped, and the move
|
||||||
|
/// will always hit.
|
||||||
|
/// </summary>
|
||||||
|
void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref int modifiedAccuracy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows scripts to change the accuracy of an incoming move.
|
||||||
|
/// </summary>
|
||||||
|
public interface IScriptChangeIncomingAccuracy
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This function allows a script to change the accuracy of a move that is incoming. The value for accuracy is in percentage.
|
||||||
|
/// A custom case goes when 255 is returned, in which case the entire accuracy check is skipped, and the move
|
||||||
|
/// will always hit.
|
||||||
|
/// </summary>
|
||||||
|
void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref int modifiedAccuracy);
|
||||||
|
}
|
@ -13,33 +13,7 @@ public static class ScriptExecution
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Executes a hook on all scripts in a source.
|
/// Executes a hook on all scripts in a source.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void RunScriptHook(this IScriptSource source, Action<Script> hook)
|
public static void RunScriptHook<TScriptHook>(this IScriptSource source, Action<TScriptHook> hook)
|
||||||
{
|
|
||||||
var iterator = source.GetScripts();
|
|
||||||
List<ScriptCategory>? suppressedCategories = null;
|
|
||||||
foreach (var container in iterator)
|
|
||||||
{
|
|
||||||
if (container.IsEmpty)
|
|
||||||
continue;
|
|
||||||
var script = container.Script;
|
|
||||||
if (script is IScriptOnBeforeAnyHookInvoked onBeforeAnyHookInvoked)
|
|
||||||
onBeforeAnyHookInvoked.OnBeforeAnyHookInvoked(ref suppressedCategories);
|
|
||||||
}
|
|
||||||
foreach (var container in iterator)
|
|
||||||
{
|
|
||||||
if (container.IsEmpty)
|
|
||||||
continue;
|
|
||||||
var script = container.Script;
|
|
||||||
if (suppressedCategories != null && suppressedCategories.Contains(script.Category))
|
|
||||||
continue;
|
|
||||||
hook(script);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Executes a hook on all scripts in a source.
|
|
||||||
/// </summary>
|
|
||||||
public static void RunScriptHookInterface<TScriptHook>(this IScriptSource source, Action<TScriptHook> hook)
|
|
||||||
{
|
{
|
||||||
var iterator = source.GetScripts();
|
var iterator = source.GetScripts();
|
||||||
List<ScriptCategory>? suppressedCategories = null;
|
List<ScriptCategory>? suppressedCategories = null;
|
||||||
@ -68,35 +42,7 @@ public static class ScriptExecution
|
|||||||
/// Executes a hook on all scripts in a source.
|
/// Executes a hook on all scripts in a source.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void RunScriptHook(this IEnumerable<IScriptSource> sources, Action<Script> hook)
|
public static void RunScriptHook<TScriptHook>(this IEnumerable<IScriptSource> sources, Action<TScriptHook> hook)
|
||||||
{
|
|
||||||
var iterator = sources.Distinct().SelectMany(x => x.GetScripts()).ToArray();
|
|
||||||
List<ScriptCategory>? suppressedCategories = null;
|
|
||||||
foreach (var container in iterator)
|
|
||||||
{
|
|
||||||
if (container.IsEmpty)
|
|
||||||
continue;
|
|
||||||
var script = container.Script;
|
|
||||||
if (script is IScriptOnBeforeAnyHookInvoked onBeforeAnyHookInvoked)
|
|
||||||
onBeforeAnyHookInvoked.OnBeforeAnyHookInvoked(ref suppressedCategories);
|
|
||||||
}
|
|
||||||
foreach (var container in iterator)
|
|
||||||
{
|
|
||||||
if (container.IsEmpty)
|
|
||||||
continue;
|
|
||||||
var script = container.Script;
|
|
||||||
if (suppressedCategories != null && suppressedCategories.Contains(script.Category))
|
|
||||||
continue;
|
|
||||||
hook(script);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Executes a hook on all scripts in a source.
|
|
||||||
/// </summary>
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public static void RunScriptHookInterface<TScriptHook>(this IEnumerable<IScriptSource> sources,
|
|
||||||
Action<TScriptHook> hook)
|
|
||||||
{
|
{
|
||||||
var iterator = sources.Distinct().SelectMany(x => x.GetScripts()).ToArray();
|
var iterator = sources.Distinct().SelectMany(x => x.GetScripts()).ToArray();
|
||||||
List<ScriptCategory>? suppressedCategories = null;
|
List<ScriptCategory>? suppressedCategories = null;
|
||||||
@ -125,33 +71,7 @@ public static class ScriptExecution
|
|||||||
/// Executes a hook on all scripts in a list of sources. Note that this does not walk through the parents of the
|
/// Executes a hook on all scripts in a list of sources. Note that this does not walk through the parents of the
|
||||||
/// sources, but only the sources themselves.
|
/// sources, but only the sources themselves.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void RunScriptHook(this IReadOnlyList<IEnumerable<ScriptContainer>> source, Action<Script> hook)
|
public static void RunScriptHook<TScriptHook>(this IReadOnlyList<IEnumerable<ScriptContainer>> source,
|
||||||
{
|
|
||||||
List<ScriptCategory>? suppressedCategories = null;
|
|
||||||
foreach (var container in source.SelectMany(x => x))
|
|
||||||
{
|
|
||||||
if (container.IsEmpty)
|
|
||||||
continue;
|
|
||||||
var script = container.Script;
|
|
||||||
if (script is IScriptOnBeforeAnyHookInvoked onBeforeAnyHookInvoked)
|
|
||||||
onBeforeAnyHookInvoked.OnBeforeAnyHookInvoked(ref suppressedCategories);
|
|
||||||
}
|
|
||||||
foreach (var container in source.SelectMany(x => x))
|
|
||||||
{
|
|
||||||
if (container.IsEmpty)
|
|
||||||
continue;
|
|
||||||
var script = container.Script;
|
|
||||||
if (suppressedCategories != null && suppressedCategories.Contains(script.Category))
|
|
||||||
continue;
|
|
||||||
hook(script);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Executes a hook on all scripts in a list of sources. Note that this does not walk through the parents of the
|
|
||||||
/// sources, but only the sources themselves.
|
|
||||||
/// </summary>
|
|
||||||
public static void RunScriptHookInterface<TScriptHook>(this IReadOnlyList<IEnumerable<ScriptContainer>> source,
|
|
||||||
Action<TScriptHook> hook)
|
Action<TScriptHook> hook)
|
||||||
{
|
{
|
||||||
List<ScriptCategory>? suppressedCategories = null;
|
List<ScriptCategory>? suppressedCategories = null;
|
||||||
|
@ -108,7 +108,8 @@ public class ScriptSet : IScriptSet
|
|||||||
if (!forceAdd)
|
if (!forceAdd)
|
||||||
{
|
{
|
||||||
var preventVolatileAdd = false;
|
var preventVolatileAdd = false;
|
||||||
_source.RunScriptHook(x => x.PreventVolatileAdd(_source, script, ref preventVolatileAdd));
|
_source.RunScriptHook<IScriptPreventVolatileAdd>(x =>
|
||||||
|
x.PreventVolatileAdd(_source, script, ref preventVolatileAdd));
|
||||||
if (preventVolatileAdd)
|
if (preventVolatileAdd)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -52,19 +52,21 @@ public class Gen7BattleStatCalculator : IBattleStatCalculator
|
|||||||
byte moveAccuracy)
|
byte moveAccuracy)
|
||||||
{
|
{
|
||||||
var accuracyModifier = 1.0f;
|
var accuracyModifier = 1.0f;
|
||||||
executingMove.RunScriptHookInterface<IScriptChangeAccuracyModifier>(x =>
|
executingMove.RunScriptHook<IScriptChangeAccuracyModifier>(x =>
|
||||||
x.ChangeAccuracyModifier(executingMove, target, hitIndex, ref accuracyModifier));
|
x.ChangeAccuracyModifier(executingMove, target, hitIndex, ref accuracyModifier));
|
||||||
var modifiedAccuracy = (int)(moveAccuracy * accuracyModifier);
|
var modifiedAccuracy = (int)(moveAccuracy * accuracyModifier);
|
||||||
// ReSharper disable once AccessToModifiedClosure
|
// ReSharper disable once AccessToModifiedClosure
|
||||||
executingMove.RunScriptHook(x => x.ChangeAccuracy(executingMove, target, hitIndex, ref modifiedAccuracy));
|
executingMove.RunScriptHook<IScriptChangeAccuracy>(x =>
|
||||||
|
x.ChangeAccuracy(executingMove, target, hitIndex, ref modifiedAccuracy));
|
||||||
if (modifiedAccuracy >= 255)
|
if (modifiedAccuracy >= 255)
|
||||||
return 255;
|
return 255;
|
||||||
target.RunScriptHook(x => x.ChangeIncomingAccuracy(executingMove, target, hitIndex, ref modifiedAccuracy));
|
target.RunScriptHook<IScriptChangeIncomingAccuracy>(x =>
|
||||||
|
x.ChangeIncomingAccuracy(executingMove, target, hitIndex, ref modifiedAccuracy));
|
||||||
if (modifiedAccuracy >= 255)
|
if (modifiedAccuracy >= 255)
|
||||||
return 255;
|
return 255;
|
||||||
var targetEvasion = target.StatBoost.Evasion;
|
var targetEvasion = target.StatBoost.Evasion;
|
||||||
var ignoreEvasion = false;
|
var ignoreEvasion = false;
|
||||||
executingMove.RunScriptHookInterface<IScriptBypassEvasionStatBoosts>(x =>
|
executingMove.RunScriptHook<IScriptBypassEvasionStatBoosts>(x =>
|
||||||
x.BypassEvasionStatBoosts(executingMove, target, hitIndex, ref ignoreEvasion));
|
x.BypassEvasionStatBoosts(executingMove, target, hitIndex, ref ignoreEvasion));
|
||||||
if (ignoreEvasion)
|
if (ignoreEvasion)
|
||||||
targetEvasion = 0;
|
targetEvasion = 0;
|
||||||
|
@ -26,7 +26,8 @@ public class Gen7CaptureLibrary : ICaptureLibrary
|
|||||||
}
|
}
|
||||||
|
|
||||||
byte bonusStatus = 1;
|
byte bonusStatus = 1;
|
||||||
target.RunScriptHook(x => x.ChangeCatchRateBonus(target, captureItem, ref bonusStatus));
|
target.RunScriptHook<IScriptChangeCatchRateBonus>(x =>
|
||||||
|
x.ChangeCatchRateBonus(target, captureItem, ref bonusStatus));
|
||||||
|
|
||||||
var modifiedCatchRate = (3.0f * maxHealth - 2.0f * currentHealth) * catchRate * bonusBall / (3.0f * maxHealth);
|
var modifiedCatchRate = (3.0f * maxHealth - 2.0f * currentHealth) * catchRate * bonusBall / (3.0f * maxHealth);
|
||||||
modifiedCatchRate *= bonusStatus;
|
modifiedCatchRate *= bonusStatus;
|
||||||
|
@ -29,7 +29,7 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
|
|||||||
if (hitData.IsCritical)
|
if (hitData.IsCritical)
|
||||||
{
|
{
|
||||||
var critModifier = 1.5f;
|
var critModifier = 1.5f;
|
||||||
executingMove?.RunScriptHookInterface<IScriptChangeCriticalModifier>(script =>
|
executingMove?.RunScriptHook<IScriptChangeCriticalModifier>(script =>
|
||||||
script.ChangeCriticalModifier(executingMove, target, hitNumber, ref critModifier));
|
script.ChangeCriticalModifier(executingMove, target, hitNumber, ref critModifier));
|
||||||
floatDamage = MathF.Floor(floatDamage * critModifier);
|
floatDamage = MathF.Floor(floatDamage * critModifier);
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
|
|||||||
stabModifier = 1.5f;
|
stabModifier = 1.5f;
|
||||||
isStab = true;
|
isStab = true;
|
||||||
}
|
}
|
||||||
executingMove?.RunScriptHookInterface<IScriptChangeStabModifier>(script =>
|
executingMove?.RunScriptHook<IScriptChangeStabModifier>(script =>
|
||||||
script.ChangeStabModifier(executingMove, target, hitNumber, isStab, ref stabModifier));
|
script.ChangeStabModifier(executingMove, target, hitNumber, isStab, ref stabModifier));
|
||||||
floatDamage = MathF.Floor(floatDamage * stabModifier);
|
floatDamage = MathF.Floor(floatDamage * stabModifier);
|
||||||
|
|
||||||
@ -65,9 +65,9 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
|
|||||||
|
|
||||||
if (executingMove is not null)
|
if (executingMove is not null)
|
||||||
{
|
{
|
||||||
executingMove.RunScriptHookInterface<IScriptChangeMoveDamage>(script =>
|
executingMove.RunScriptHook<IScriptChangeMoveDamage>(script =>
|
||||||
script.ChangeMoveDamage(executingMove, target, hitNumber, ref damage));
|
script.ChangeMoveDamage(executingMove, target, hitNumber, ref damage));
|
||||||
target.RunScriptHookInterface<IScriptChangeIncomingMoveDamage>(script =>
|
target.RunScriptHook<IScriptChangeIncomingMoveDamage>(script =>
|
||||||
script.ChangeIncomingMoveDamage(executingMove, target, hitNumber, ref damage));
|
script.ChangeIncomingMoveDamage(executingMove, target, hitNumber, ref damage));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
|
|||||||
if (executingMove.UseMove.Category == MoveCategory.Status)
|
if (executingMove.UseMove.Category == MoveCategory.Status)
|
||||||
return 0;
|
return 0;
|
||||||
var basePower = (ushort)executingMove.UseMove.BasePower;
|
var basePower = (ushort)executingMove.UseMove.BasePower;
|
||||||
executingMove.RunScriptHookInterface<IScriptChangeBasePower>(script =>
|
executingMove.RunScriptHook<IScriptChangeBasePower>(script =>
|
||||||
script.ChangeBasePower(executingMove, target, hitNumber, ref basePower));
|
script.ChangeBasePower(executingMove, target, hitNumber, ref basePower));
|
||||||
return basePower;
|
return basePower;
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
|
|||||||
if (executingMove.UseMove.Category == MoveCategory.Status)
|
if (executingMove.UseMove.Category == MoveCategory.Status)
|
||||||
return false;
|
return false;
|
||||||
byte critStage = 0;
|
byte critStage = 0;
|
||||||
executingMove.RunScriptHookInterface<IScriptChangeCriticalStage>(script =>
|
executingMove.RunScriptHook<IScriptChangeCriticalStage>(script =>
|
||||||
script.ChangeCriticalStage(executingMove, target, hitNumber, ref critStage));
|
script.ChangeCriticalStage(executingMove, target, hitNumber, ref critStage));
|
||||||
|
|
||||||
var random = battle.Random;
|
var random = battle.Random;
|
||||||
@ -120,14 +120,14 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
|
|||||||
// move is critical, and the target has a defensive stat boost of > 0, but a script is
|
// move is critical, and the target has a defensive stat boost of > 0, but a script is
|
||||||
// allowed to change this.
|
// allowed to change this.
|
||||||
var bypassDefense = hitData.IsCritical && target.StatBoost.GetStatistic(defensive) > 0;
|
var bypassDefense = hitData.IsCritical && target.StatBoost.GetStatistic(defensive) > 0;
|
||||||
executingMove?.RunScriptHookInterface<IScriptBypassDefensiveStatBoosts>(script =>
|
executingMove?.RunScriptHook<IScriptBypassDefensiveStatBoosts>(script =>
|
||||||
script.BypassDefensiveStatBoosts(executingMove, target, hitNumber, ref bypassDefense));
|
script.BypassDefensiveStatBoosts(executingMove, target, hitNumber, ref bypassDefense));
|
||||||
|
|
||||||
// Check if we can bypass the offensive stat boost on the user. We default to this if the
|
// Check if we can bypass the offensive stat boost on the user. We default to this if the
|
||||||
// move is critical, and the user has an offensive stat boost of < 0, but a script is
|
// move is critical, and the user has an offensive stat boost of < 0, but a script is
|
||||||
// allowed to change this.
|
// allowed to change this.
|
||||||
var bypassOffense = hitData.IsCritical && user.StatBoost.GetStatistic(offensive) < 0;
|
var bypassOffense = hitData.IsCritical && user.StatBoost.GetStatistic(offensive) < 0;
|
||||||
executingMove?.RunScriptHookInterface<IScriptBypassOffensiveStatBoosts>(script =>
|
executingMove?.RunScriptHook<IScriptBypassOffensiveStatBoosts>(script =>
|
||||||
script.BypassOffensiveStatBoosts(executingMove, target, hitNumber, ref bypassOffense));
|
script.BypassOffensiveStatBoosts(executingMove, target, hitNumber, ref bypassOffense));
|
||||||
|
|
||||||
var userStats = user.BoostedStats;
|
var userStats = user.BoostedStats;
|
||||||
@ -143,22 +143,22 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
|
|||||||
|
|
||||||
if (executingMove != null)
|
if (executingMove != null)
|
||||||
{
|
{
|
||||||
executingMove.RunScriptHookInterface<IScriptChangeOffensiveStatValue>(script =>
|
executingMove.RunScriptHook<IScriptChangeOffensiveStatValue>(script =>
|
||||||
script.ChangeOffensiveStatValue(executingMove, target, hitNumber, defensiveStat, targetStats, offensive,
|
script.ChangeOffensiveStatValue(executingMove, target, hitNumber, defensiveStat, targetStats, offensive,
|
||||||
ref offensiveStat));
|
ref offensiveStat));
|
||||||
executingMove.RunScriptHookInterface<IScriptChangeDefensiveStatValue>(script =>
|
executingMove.RunScriptHook<IScriptChangeDefensiveStatValue>(script =>
|
||||||
script.ChangeDefensiveStatValue(executingMove, target, hitNumber, origOffensiveStat, targetStats,
|
script.ChangeDefensiveStatValue(executingMove, target, hitNumber, origOffensiveStat, targetStats,
|
||||||
defensive, ref defensiveStat));
|
defensive, ref defensiveStat));
|
||||||
target.RunScriptHookInterface<IScriptChangeIncomingMoveOffensiveStatValue>(script =>
|
target.RunScriptHook<IScriptChangeIncomingMoveOffensiveStatValue>(script =>
|
||||||
script.ChangeIncomingMoveOffensiveStatValue(executingMove, target, hitNumber, defensiveStat,
|
script.ChangeIncomingMoveOffensiveStatValue(executingMove, target, hitNumber, defensiveStat,
|
||||||
targetStats, offensive, ref offensiveStat));
|
targetStats, offensive, ref offensiveStat));
|
||||||
target.RunScriptHookInterface<IScriptChangeIncomingMoveDefensiveStatValue>(script =>
|
target.RunScriptHook<IScriptChangeIncomingMoveDefensiveStatValue>(script =>
|
||||||
script.ChangeIncomingMoveDefensiveStatValue(executingMove, target, hitNumber, origOffensiveStat,
|
script.ChangeIncomingMoveDefensiveStatValue(executingMove, target, hitNumber, origOffensiveStat,
|
||||||
targetStats, defensive, ref defensiveStat));
|
targetStats, defensive, ref defensiveStat));
|
||||||
}
|
}
|
||||||
|
|
||||||
var modifier = (float)offensiveStat / defensiveStat;
|
var modifier = (float)offensiveStat / defensiveStat;
|
||||||
executingMove?.RunScriptHookInterface<IScriptChangeDamageStatModifier>(script =>
|
executingMove?.RunScriptHook<IScriptChangeDamageStatModifier>(script =>
|
||||||
script.ChangeDamageStatModifier(executingMove, target, hitNumber, ref modifier));
|
script.ChangeDamageStatModifier(executingMove, target, hitNumber, ref modifier));
|
||||||
|
|
||||||
return modifier;
|
return modifier;
|
||||||
@ -172,9 +172,9 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
|
|||||||
{
|
{
|
||||||
var modifier = 1.0f;
|
var modifier = 1.0f;
|
||||||
|
|
||||||
executingMove.RunScriptHookInterface<IScriptChangeDamageModifier>(script =>
|
executingMove.RunScriptHook<IScriptChangeDamageModifier>(script =>
|
||||||
script.ChangeDamageModifier(executingMove, target, hitNumber, ref modifier));
|
script.ChangeDamageModifier(executingMove, target, hitNumber, ref modifier));
|
||||||
target.RunScriptHookInterface<IScriptChangeIncomingMoveDamageModifier>(script =>
|
target.RunScriptHook<IScriptChangeIncomingMoveDamageModifier>(script =>
|
||||||
script.ChangeIncomingMoveDamageModifier(executingMove, target, hitNumber, ref modifier));
|
script.ChangeIncomingMoveDamageModifier(executingMove, target, hitNumber, ref modifier));
|
||||||
|
|
||||||
return modifier;
|
return modifier;
|
||||||
|
@ -7,10 +7,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Aura_Break_(Ability)">Bulbapedia - Aura Break</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Aura_Break_(Ability)">Bulbapedia - Aura Break</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "aura_break")]
|
[Script(ScriptCategory.Ability, "aura_break")]
|
||||||
public class AuraBreak : Script
|
public class AuraBreak : Script, IScriptCustomTrigger
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
||||||
{
|
{
|
||||||
if (eventName != CustomTriggers.ModifyAuraEffect || args is not CustomTriggers.ModifyAuraEffectArgs auraArgs)
|
if (eventName != CustomTriggers.ModifyAuraEffect || args is not CustomTriggers.ModifyAuraEffectArgs auraArgs)
|
||||||
return;
|
return;
|
||||||
|
@ -8,11 +8,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Comatose_(Ability)">Bulbapedia - Comatose</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Comatose_(Ability)">Bulbapedia - Comatose</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "comatose")]
|
[Script(ScriptCategory.Ability, "comatose")]
|
||||||
public class Comatose : Script
|
public class Comatose : Script, IScriptPreventStatusChange, IScriptCustomTrigger
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
|
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
|
||||||
ref bool preventStatus)
|
|
||||||
{
|
{
|
||||||
if (status == ScriptUtils.ResolveName<Status.Sleep>())
|
if (status == ScriptUtils.ResolveName<Status.Sleep>())
|
||||||
{
|
{
|
||||||
@ -21,7 +20,7 @@ public class Comatose : Script
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
||||||
{
|
{
|
||||||
if (eventName == CustomTriggers.BypassSleep && args is CustomTriggers.BypassSleepArgs bypassArgs)
|
if (eventName == CustomTriggers.BypassSleep && args is CustomTriggers.BypassSleepArgs bypassArgs)
|
||||||
{
|
{
|
||||||
|
@ -7,10 +7,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Compound_Eyes_(Ability)">Bulbapedia - Compound Eyes</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Compound_Eyes_(Ability)">Bulbapedia - Compound Eyes</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "compound_eyes")]
|
[Script(ScriptCategory.Ability, "compound_eyes")]
|
||||||
public class CompoundEyes : Script
|
public class CompoundEyes : Script, IScriptChangeAccuracy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeAccuracy(IExecutingMove move, IPokemon target, byte hit, ref int modifiedAccuracy)
|
public void ChangeAccuracy(IExecutingMove move, IPokemon target, byte hit, ref int modifiedAccuracy)
|
||||||
{
|
{
|
||||||
move.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User));
|
move.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User));
|
||||||
modifiedAccuracy = (int)(modifiedAccuracy * 1.3f);
|
modifiedAccuracy = (int)(modifiedAccuracy * 1.3f);
|
||||||
|
@ -17,7 +17,7 @@ public class DarkAura : Script, IScriptChangeDamageModifier
|
|||||||
var auraModifier = 5448f / 4096f;
|
var auraModifier = 5448f / 4096f;
|
||||||
var args = new CustomTriggers.ModifyAuraEffectArgs(move, target, hit, auraModifier);
|
var args = new CustomTriggers.ModifyAuraEffectArgs(move, target, hit, auraModifier);
|
||||||
move.Battle.Sides.SelectMany(side => side.Pokemon).WhereNotNull()
|
move.Battle.Sides.SelectMany(side => side.Pokemon).WhereNotNull()
|
||||||
.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ModifyAuraEffect, args));
|
.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyAuraEffect, args));
|
||||||
auraModifier = args.AuraEffect;
|
auraModifier = args.AuraEffect;
|
||||||
modifier *= auraModifier;
|
modifier *= auraModifier;
|
||||||
move.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User));
|
move.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User));
|
||||||
|
@ -8,10 +8,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Early_Bird_(Ability)">Bulbapedia - Early Bird</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Early_Bird_(Ability)">Bulbapedia - Early Bird</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "early_bird")]
|
[Script(ScriptCategory.Ability, "early_bird")]
|
||||||
public class EarlyBird : Script
|
public class EarlyBird : Script, IScriptCustomTrigger
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
||||||
{
|
{
|
||||||
if (eventName != CustomTriggers.ModifySleepTurns)
|
if (eventName != CustomTriggers.ModifySleepTurns)
|
||||||
return;
|
return;
|
||||||
|
@ -18,7 +18,7 @@ public class FairyAura : Script, IScriptChangeDamageModifier
|
|||||||
var auraModifier = 5448f / 4096f;
|
var auraModifier = 5448f / 4096f;
|
||||||
var args = new CustomTriggers.ModifyAuraEffectArgs(move, target, hit, auraModifier);
|
var args = new CustomTriggers.ModifyAuraEffectArgs(move, target, hit, auraModifier);
|
||||||
move.Battle.Sides.SelectMany(side => side.Pokemon).WhereNotNull()
|
move.Battle.Sides.SelectMany(side => side.Pokemon).WhereNotNull()
|
||||||
.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ModifyAuraEffect, args));
|
.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyAuraEffect, args));
|
||||||
auraModifier = args.AuraEffect;
|
auraModifier = args.AuraEffect;
|
||||||
modifier *= auraModifier;
|
modifier *= auraModifier;
|
||||||
move.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User));
|
move.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User));
|
||||||
|
@ -7,7 +7,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Flower_Gift_(Ability)">Bulbapedia - Flower Gift</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Flower_Gift_(Ability)">Bulbapedia - Flower Gift</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "flower_gift")]
|
[Script(ScriptCategory.Ability, "flower_gift")]
|
||||||
public class FlowerGift : Script
|
public class FlowerGift : Script, IScriptOnWeatherChange
|
||||||
{
|
{
|
||||||
private IPokemon? _pokemon;
|
private IPokemon? _pokemon;
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ public class FlowerGift : Script
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnWeatherChange(IBattle battle, StringKey? weatherName, StringKey? oldWeatherName)
|
public void OnWeatherChange(IBattle battle, StringKey? weatherName, StringKey? oldWeatherName)
|
||||||
{
|
{
|
||||||
if (_pokemon is null)
|
if (_pokemon is null)
|
||||||
return;
|
return;
|
||||||
|
@ -7,7 +7,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Forecast_(Ability)">Bulbapedia - Forecast</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Forecast_(Ability)">Bulbapedia - Forecast</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "forecast")]
|
[Script(ScriptCategory.Ability, "forecast")]
|
||||||
public class Forecast : Script, IScriptOnSwitchIn
|
public class Forecast : Script, IScriptOnSwitchIn, IScriptOnWeatherChange
|
||||||
{
|
{
|
||||||
private IPokemon? _pokemon;
|
private IPokemon? _pokemon;
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ public class Forecast : Script, IScriptOnSwitchIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnWeatherChange(IBattle battle, StringKey? weatherName, StringKey? oldWeatherName)
|
public void OnWeatherChange(IBattle battle, StringKey? weatherName, StringKey? oldWeatherName)
|
||||||
{
|
{
|
||||||
if (_pokemon is null)
|
if (_pokemon is null)
|
||||||
return;
|
return;
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Heavy_Metal_(Ability)">Bulbapedia - Heavy Metal</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Heavy_Metal_(Ability)">Bulbapedia - Heavy Metal</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "heavy_metal")]
|
[Script(ScriptCategory.Ability, "heavy_metal")]
|
||||||
public class HeavyMetal : Script
|
public class HeavyMetal : Script, IScriptModifyWeight
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ModifyWeight(ref float weight)
|
public void ModifyWeight(ref float weight)
|
||||||
{
|
{
|
||||||
weight *= 2f;
|
weight *= 2f;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Hustle_(Ability)">Bulbapedia - Hustle</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Hustle_(Ability)">Bulbapedia - Hustle</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "hustle")]
|
[Script(ScriptCategory.Ability, "hustle")]
|
||||||
public class Hustle : Script, IScriptChangeOffensiveStatValue
|
public class Hustle : Script, IScriptChangeOffensiveStatValue, IScriptChangeAccuracy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void ChangeOffensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint defensiveStat,
|
public void ChangeOffensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint defensiveStat,
|
||||||
@ -20,8 +20,7 @@ public class Hustle : Script, IScriptChangeOffensiveStatValue
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
public void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref int modifiedAccuracy)
|
||||||
ref int modifiedAccuracy)
|
|
||||||
{
|
{
|
||||||
if (executingMove.UseMove.Category == MoveCategory.Physical)
|
if (executingMove.UseMove.Category == MoveCategory.Physical)
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Ice_Body_(Ability)">Bulbapedia - Ice Body</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Ice_Body_(Ability)">Bulbapedia - Ice Body</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "ice_body")]
|
[Script(ScriptCategory.Ability, "ice_body")]
|
||||||
public class IceBody : Script, IScriptOnEndTurn
|
public class IceBody : Script, IScriptOnEndTurn, IScriptCustomTrigger
|
||||||
{
|
{
|
||||||
private IPokemon? _pokemon;
|
private IPokemon? _pokemon;
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ public class IceBody : Script, IScriptOnEndTurn
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
||||||
{
|
{
|
||||||
if (eventName != CustomTriggers.IgnoreHail || args is not CustomTriggers.IgnoreHailArgs ignoreHailArgs)
|
if (eventName != CustomTriggers.IgnoreHail || args is not CustomTriggers.IgnoreHailArgs ignoreHailArgs)
|
||||||
return;
|
return;
|
||||||
|
@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Immunity_(Ability)">Bulbapedia - Immunity</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Immunity_(Ability)">Bulbapedia - Immunity</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "immunity")]
|
[Script(ScriptCategory.Ability, "immunity")]
|
||||||
public class Immunity : Script
|
public class Immunity : Script, IScriptPreventStatusChange
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
|
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
|
||||||
ref bool preventStatus)
|
|
||||||
{
|
{
|
||||||
if (status == ScriptUtils.ResolveName<Status.Poisoned>() ||
|
if (status == ScriptUtils.ResolveName<Status.Poisoned>() ||
|
||||||
status == ScriptUtils.ResolveName<Status.BadlyPoisoned>())
|
status == ScriptUtils.ResolveName<Status.BadlyPoisoned>())
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Infiltrator_(Ability)">Bulbapedia - Infiltrator</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Infiltrator_(Ability)">Bulbapedia - Infiltrator</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "infiltrator")]
|
[Script(ScriptCategory.Ability, "infiltrator")]
|
||||||
public class Infiltrator : Script
|
public class Infiltrator : Script, IScriptCustomTrigger
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
||||||
{
|
{
|
||||||
if (eventName == CustomTriggers.BypassSubstitute && args is CustomTriggers.BypassSubstituteArgs bypassArgs)
|
if (eventName == CustomTriggers.BypassSubstitute && args is CustomTriggers.BypassSubstituteArgs bypassArgs)
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Inner_Focus_(Ability)">Bulbapedia - Inner Focus</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Inner_Focus_(Ability)">Bulbapedia - Inner Focus</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "inner_focus")]
|
[Script(ScriptCategory.Ability, "inner_focus")]
|
||||||
public class InnerFocus : Script
|
public class InnerFocus : Script, IScriptPreventVolatileAdd
|
||||||
{
|
{
|
||||||
private IPokemon? _pokemon;
|
private IPokemon? _pokemon;
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ public class InnerFocus : Script
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
|
public void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
|
||||||
{
|
{
|
||||||
if (script is not FlinchEffect)
|
if (script is not FlinchEffect)
|
||||||
return;
|
return;
|
||||||
|
@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Insomnia_(Ability)">Bulbapedia - Insomnia</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Insomnia_(Ability)">Bulbapedia - Insomnia</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "insomnia")]
|
[Script(ScriptCategory.Ability, "insomnia")]
|
||||||
public class Insomnia : Script
|
public class Insomnia : Script, IScriptPreventStatusChange
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
|
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
|
||||||
ref bool preventStatus)
|
|
||||||
{
|
{
|
||||||
if (status != ScriptUtils.ResolveName<Status.Sleep>())
|
if (status != ScriptUtils.ResolveName<Status.Sleep>())
|
||||||
return;
|
return;
|
||||||
|
@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Leaf_Guard_(Ability)">Bulbapedia - Leaf Guard</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Leaf_Guard_(Ability)">Bulbapedia - Leaf Guard</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "leaf_guard")]
|
[Script(ScriptCategory.Ability, "leaf_guard")]
|
||||||
public class LeafGuard : Script
|
public class LeafGuard : Script, IScriptPreventStatusChange
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
|
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
|
||||||
ref bool preventStatus)
|
|
||||||
{
|
{
|
||||||
if (pokemon.BattleData?.Battle.WeatherName != ScriptUtils.ResolveName<Weather.HarshSunlight>())
|
if (pokemon.BattleData?.Battle.WeatherName != ScriptUtils.ResolveName<Weather.HarshSunlight>())
|
||||||
return;
|
return;
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Levitate_(Ability)">Bulbapedia - Levitate</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Levitate_(Ability)">Bulbapedia - Levitate</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "levitate")]
|
[Script(ScriptCategory.Ability, "levitate")]
|
||||||
public class Levitate : Script
|
public class Levitate : Script, IScriptIsFloating
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void IsFloating(IPokemon pokemon, ref bool isFloating)
|
public void IsFloating(IPokemon pokemon, ref bool isFloating)
|
||||||
{
|
{
|
||||||
isFloating = true;
|
isFloating = true;
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Light_Metal_(Ability)">Bulbapedia - Light Metal</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Light_Metal_(Ability)">Bulbapedia - Light Metal</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "light_metal")]
|
[Script(ScriptCategory.Ability, "light_metal")]
|
||||||
public class LightMetal : Script
|
public class LightMetal : Script, IScriptModifyWeight
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ModifyWeight(ref float weight)
|
public void ModifyWeight(ref float weight)
|
||||||
{
|
{
|
||||||
weight *= 0.5f;
|
weight *= 0.5f;
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Limber_(Ability)">Bulbapedia - Limber</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Limber_(Ability)">Bulbapedia - Limber</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "limber")]
|
[Script(ScriptCategory.Ability, "limber")]
|
||||||
public class Limber : Script
|
public class Limber : Script, IScriptPreventStatusChange
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
|
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
|
||||||
ref bool preventStatus)
|
|
||||||
{
|
{
|
||||||
if (status != ScriptUtils.ResolveName<Status.Paralyzed>())
|
if (status != ScriptUtils.ResolveName<Status.Paralyzed>())
|
||||||
return;
|
return;
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Liquid_Ooze_(Ability)">Bulbapedia - Liquid Ooze</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Liquid_Ooze_(Ability)">Bulbapedia - Liquid Ooze</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "liquid_ooze")]
|
[Script(ScriptCategory.Ability, "liquid_ooze")]
|
||||||
public class LiquidOoze : Script
|
public class LiquidOoze : Script, IScriptCustomTrigger
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
||||||
{
|
{
|
||||||
if (eventName != CustomTriggers.ModifyDrain || args is not CustomTriggers.ModifyDrainArgs parameters)
|
if (eventName != CustomTriggers.ModifyDrain || args is not CustomTriggers.ModifyDrainArgs parameters)
|
||||||
return;
|
return;
|
||||||
|
@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Long_Reach_(Ability)">Bulbapedia - Long Reach</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Long_Reach_(Ability)">Bulbapedia - Long Reach</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "long_reach")]
|
[Script(ScriptCategory.Ability, "long_reach")]
|
||||||
public class LongReach : Script
|
public class LongReach : Script, IScriptModifyIsContact
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ModifyIsContact(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
public void ModifyIsContact(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool isContact)
|
||||||
ref bool isContact)
|
|
||||||
{
|
{
|
||||||
isContact = false;
|
isContact = false;
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Magma_Armor_(Ability)">Bulbapedia - Magma Armor</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Magma_Armor_(Ability)">Bulbapedia - Magma Armor</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "magma_armor")]
|
[Script(ScriptCategory.Ability, "magma_armor")]
|
||||||
public class MagmaArmor : Script, IScriptOnSwitchIn
|
public class MagmaArmor : Script, IScriptOnSwitchIn, IScriptPreventStatusChange
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
|
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
|
||||||
ref bool preventStatus)
|
|
||||||
{
|
{
|
||||||
if (status == ScriptUtils.ResolveName<Status.Frozen>())
|
if (status == ScriptUtils.ResolveName<Status.Frozen>())
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Mega_Launcher_(Ability)">Bulbapedia - Mega Launcher</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Mega_Launcher_(Ability)">Bulbapedia - Mega Launcher</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "mega_launcher")]
|
[Script(ScriptCategory.Ability, "mega_launcher")]
|
||||||
public class MegaLauncher : Script, IScriptChangeBasePower
|
public class MegaLauncher : Script, IScriptChangeBasePower, IScriptCustomTrigger
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
|
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
|
||||||
@ -18,7 +18,7 @@ public class MegaLauncher : Script, IScriptChangeBasePower
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
||||||
{
|
{
|
||||||
if (eventName != CustomTriggers.ModifyHealPercent || args is not CustomTriggers.ModifyHealPercentArgs healArgs)
|
if (eventName != CustomTriggers.ModifyHealPercent || args is not CustomTriggers.ModifyHealPercentArgs healArgs)
|
||||||
return;
|
return;
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Multitype_(Ability)">Bulbapedia - Multitype</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Multitype_(Ability)">Bulbapedia - Multitype</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "multitype")]
|
[Script(ScriptCategory.Ability, "multitype")]
|
||||||
public class Multitype : Script
|
public class Multitype : Script, IScriptOnAfterHeldItemChange
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnAfterHeldItemChange(IPokemon pokemon, IItem? previous, IItem? item)
|
public void OnAfterHeldItemChange(IPokemon pokemon, IItem? previous, IItem? item)
|
||||||
{
|
{
|
||||||
if (pokemon.Species.Name != "arceus")
|
if (pokemon.Species.Name != "arceus")
|
||||||
return;
|
return;
|
||||||
|
@ -6,18 +6,17 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/No_Guard_(Ability)">Bulbapedia - No Guard</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/No_Guard_(Ability)">Bulbapedia - No Guard</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "no_guard")]
|
[Script(ScriptCategory.Ability, "no_guard")]
|
||||||
public class NoGuard : Script
|
public class NoGuard : Script, IScriptChangeAccuracy, IScriptChangeIncomingAccuracy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
public void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||||
ref int modifiedAccuracy)
|
ref int modifiedAccuracy)
|
||||||
{
|
{
|
||||||
modifiedAccuracy = 2000;
|
modifiedAccuracy = 2000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
public void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref int modifiedAccuracy)
|
||||||
ref int modifiedAccuracy)
|
|
||||||
{
|
{
|
||||||
modifiedAccuracy = 2000;
|
modifiedAccuracy = 2000;
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Oblivious_(Ability)">Bulbapedia - Oblivious</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Oblivious_(Ability)">Bulbapedia - Oblivious</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "oblivious")]
|
[Script(ScriptCategory.Ability, "oblivious")]
|
||||||
public class Oblivious : Script
|
public class Oblivious : Script, IScriptPreventVolatileAdd
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
|
public void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
|
||||||
{
|
{
|
||||||
preventVolatileAdd = script switch
|
preventVolatileAdd = script switch
|
||||||
{
|
{
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Overcoat_(Ability)">Bulbapedia - Overcoat</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Overcoat_(Ability)">Bulbapedia - Overcoat</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "overcoat")]
|
[Script(ScriptCategory.Ability, "overcoat")]
|
||||||
public class Overcoat : Script, IScriptIsInvulnerableToMove
|
public class Overcoat : Script, IScriptIsInvulnerableToMove, IScriptCustomTrigger
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
||||||
{
|
{
|
||||||
if (eventName == CustomTriggers.IgnoreHail && args is CustomTriggers.IgnoreHailArgs hailArgs)
|
if (eventName == CustomTriggers.IgnoreHail && args is CustomTriggers.IgnoreHailArgs hailArgs)
|
||||||
{
|
{
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Own_Tempo_(Ability)">Bulbapedia - Own Tempo</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Own_Tempo_(Ability)">Bulbapedia - Own Tempo</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "own_tempo")]
|
[Script(ScriptCategory.Ability, "own_tempo")]
|
||||||
public class OwnTempo : Script
|
public class OwnTempo : Script, IScriptPreventVolatileAdd
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
|
public void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
|
||||||
{
|
{
|
||||||
if (script is Pokemon.Confusion)
|
if (script is Pokemon.Confusion)
|
||||||
preventVolatileAdd = true;
|
preventVolatileAdd = true;
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Poison_Heal_(Ability)">Bulbapedia - Poison Heal</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Poison_Heal_(Ability)">Bulbapedia - Poison Heal</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "poison_heal")]
|
[Script(ScriptCategory.Ability, "poison_heal")]
|
||||||
public class PoisonHeal : Script
|
public class PoisonHeal : Script, IScriptCustomTrigger
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
||||||
{
|
{
|
||||||
if (eventName != CustomTriggers.PoisonedDamage)
|
if (eventName != CustomTriggers.PoisonedDamage)
|
||||||
return;
|
return;
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Pressure_(Ability)">Bulbapedia - Pressure</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Pressure_(Ability)">Bulbapedia - Pressure</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "pressure")]
|
[Script(ScriptCategory.Ability, "pressure")]
|
||||||
public class Pressure : Script
|
public class Pressure : Script, IScriptModifyPPUsedForIncomingMove
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ModifyPPUsedForIncomingMove(IExecutingMove executingMove, ref byte ppUsed)
|
public void ModifyPPUsedForIncomingMove(IExecutingMove executingMove, ref byte ppUsed)
|
||||||
{
|
{
|
||||||
if (ppUsed == byte.MaxValue)
|
if (ppUsed == byte.MaxValue)
|
||||||
return;
|
return;
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/RKS_System_(Ability)">Bulbapedia - RKS System</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/RKS_System_(Ability)">Bulbapedia - RKS System</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "rks_system")]
|
[Script(ScriptCategory.Ability, "rks_system")]
|
||||||
public class RKSSystem : Script
|
public class RKSSystem : Script, IScriptOnAfterHeldItemChange
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnAfterHeldItemChange(IPokemon pokemon, IItem? previous, IItem? item)
|
public void OnAfterHeldItemChange(IPokemon pokemon, IItem? previous, IItem? item)
|
||||||
{
|
{
|
||||||
if (pokemon.Species.Name != "silvally")
|
if (pokemon.Species.Name != "silvally")
|
||||||
return;
|
return;
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Rock_Head_(Ability)">Bulbapedia - Rock Head</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Rock_Head_(Ability)">Bulbapedia - Rock Head</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "rock_head")]
|
[Script(ScriptCategory.Ability, "rock_head")]
|
||||||
public class RockHead : Script
|
public class RockHead : Script, IScriptCustomTrigger
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
||||||
{
|
{
|
||||||
if (eventName != CustomTriggers.ModifyRecoil)
|
if (eventName != CustomTriggers.ModifyRecoil)
|
||||||
return;
|
return;
|
||||||
|
@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sand_Force_(Ability)">Bulbapedia - Sand Force</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sand_Force_(Ability)">Bulbapedia - Sand Force</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "sand_force")]
|
[Script(ScriptCategory.Ability, "sand_force")]
|
||||||
public class SandForce : Script, IScriptChangeBasePower
|
public class SandForce : Script, IScriptChangeBasePower, IScriptCustomTrigger
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
|
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
|
||||||
@ -23,7 +23,7 @@ public class SandForce : Script, IScriptChangeBasePower
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
||||||
{
|
{
|
||||||
if (eventName == CustomTriggers.BypassSandstormDamage &&
|
if (eventName == CustomTriggers.BypassSandstormDamage &&
|
||||||
args is CustomTriggers.BypassSandstormDamageArgs bypassArgs)
|
args is CustomTriggers.BypassSandstormDamageArgs bypassArgs)
|
||||||
|
@ -6,7 +6,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sand_Rush_(Ability)">Bulbapedia - Sand Rush</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sand_Rush_(Ability)">Bulbapedia - Sand Rush</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "sand_rush")]
|
[Script(ScriptCategory.Ability, "sand_rush")]
|
||||||
public class SandRush : Script, IScriptChangeSpeed
|
public class SandRush : Script, IScriptChangeSpeed, IScriptCustomTrigger
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void ChangeSpeed(ITurnChoice choice, ref uint speed)
|
public void ChangeSpeed(ITurnChoice choice, ref uint speed)
|
||||||
@ -18,7 +18,7 @@ public class SandRush : Script, IScriptChangeSpeed
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
||||||
{
|
{
|
||||||
if (eventName == CustomTriggers.BypassSandstormDamage &&
|
if (eventName == CustomTriggers.BypassSandstormDamage &&
|
||||||
args is CustomTriggers.BypassSandstormDamageArgs bypassArgs)
|
args is CustomTriggers.BypassSandstormDamageArgs bypassArgs)
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sand_Veil_(Ability)">Bulbapedia - Sand Veil</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sand_Veil_(Ability)">Bulbapedia - Sand Veil</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "sand_veil")]
|
[Script(ScriptCategory.Ability, "sand_veil")]
|
||||||
public class SandVeil : Script
|
public class SandVeil : Script, IScriptCustomTrigger, IScriptChangeIncomingAccuracy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
public void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||||
ref int modifiedAccuracy)
|
ref int modifiedAccuracy)
|
||||||
{
|
{
|
||||||
if (executingMove.Battle.WeatherName != ScriptUtils.ResolveName<Weather.Sandstorm>())
|
if (executingMove.Battle.WeatherName != ScriptUtils.ResolveName<Weather.Sandstorm>())
|
||||||
@ -19,7 +19,7 @@ public class SandVeil : Script
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
||||||
{
|
{
|
||||||
if (eventName == CustomTriggers.BypassSandstormDamage &&
|
if (eventName == CustomTriggers.BypassSandstormDamage &&
|
||||||
args is CustomTriggers.BypassSandstormDamageArgs bypassArgs)
|
args is CustomTriggers.BypassSandstormDamageArgs bypassArgs)
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Scrappy_(Ability)">Bulbapedia - Scrappy</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Scrappy_(Ability)">Bulbapedia - Scrappy</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "scrappy")]
|
[Script(ScriptCategory.Ability, "scrappy")]
|
||||||
public class Scrappy : Script
|
public class Scrappy : Script, IScriptChangeTypesForMove
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeTypesForMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
public void ChangeTypesForMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||||
IList<TypeIdentifier> types)
|
IList<TypeIdentifier> types)
|
||||||
{
|
{
|
||||||
var hitType = executingMove.GetHitData(target, hitIndex).Type;
|
var hitType = executingMove.GetHitData(target, hitIndex).Type;
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Skill_Link_(Ability)">Bulbapedia - Skill Link</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Skill_Link_(Ability)">Bulbapedia - Skill Link</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "skill_link")]
|
[Script(ScriptCategory.Ability, "skill_link")]
|
||||||
public class SkillLink : Script
|
public class SkillLink : Script, IScriptCustomTrigger
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
||||||
{
|
{
|
||||||
if (eventName != CustomTriggers.Modify2_5HitMove)
|
if (eventName != CustomTriggers.Modify2_5HitMove)
|
||||||
return;
|
return;
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Snow_Cloak_(Ability)">Bulbapedia - Snow Cloak</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Snow_Cloak_(Ability)">Bulbapedia - Snow Cloak</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "snow_cloak")]
|
[Script(ScriptCategory.Ability, "snow_cloak")]
|
||||||
public class SnowCloak : Script
|
public class SnowCloak : Script, IScriptCustomTrigger, IScriptChangeIncomingAccuracy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
public void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||||
ref int modifiedAccuracy)
|
ref int modifiedAccuracy)
|
||||||
{
|
{
|
||||||
// If the weather is hail, increase evasion by 20%
|
// If the weather is hail, increase evasion by 20%
|
||||||
@ -19,7 +19,7 @@ public class SnowCloak : Script
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
||||||
{
|
{
|
||||||
if (eventName == CustomTriggers.IgnoreHail && args is CustomTriggers.IgnoreHailArgs hailArgs)
|
if (eventName == CustomTriggers.IgnoreHail && args is CustomTriggers.IgnoreHailArgs hailArgs)
|
||||||
hailArgs.Ignore = true;
|
hailArgs.Ignore = true;
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Steadfast_(Ability)">Bulbapedia - Steadfast</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Steadfast_(Ability)">Bulbapedia - Steadfast</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "steadfast")]
|
[Script(ScriptCategory.Ability, "steadfast")]
|
||||||
public class Steadfast : Script
|
public class Steadfast : Script, IScriptCustomTrigger
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
||||||
{
|
{
|
||||||
if (eventName != CustomTriggers.OnFlinch)
|
if (eventName != CustomTriggers.OnFlinch)
|
||||||
return;
|
return;
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sticky_Hold_(Ability)">Bulbapedia - Sticky Hold</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sticky_Hold_(Ability)">Bulbapedia - Sticky Hold</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "sticky_hold")]
|
[Script(ScriptCategory.Ability, "sticky_hold")]
|
||||||
public class StickyHold : Script
|
public class StickyHold : Script, IScriptPreventHeldItemSteal
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventHeldItemSteal(IPokemon pokemon, IItem heldItem, ref bool prevent)
|
public void PreventHeldItemSteal(IPokemon pokemon, IItem heldItem, ref bool prevent)
|
||||||
{
|
{
|
||||||
prevent = true;
|
prevent = true;
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sweet_Veil_(Ability)">Bulbapedia - Sweet Veil</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Sweet_Veil_(Ability)">Bulbapedia - Sweet Veil</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "sweet_veil")]
|
[Script(ScriptCategory.Ability, "sweet_veil")]
|
||||||
public class SweetVeil : Script
|
public class SweetVeil : Script, IScriptPreventStatusChange
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
|
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
|
||||||
ref bool preventStatus)
|
|
||||||
{
|
{
|
||||||
if (status == ScriptUtils.ResolveName<Status.Sleep>())
|
if (status == ScriptUtils.ResolveName<Status.Sleep>())
|
||||||
{
|
{
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Synchronize_(Ability)">Bulbapedia - Synchronize</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Synchronize_(Ability)">Bulbapedia - Synchronize</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "synchronize")]
|
[Script(ScriptCategory.Ability, "synchronize")]
|
||||||
public class Synchronize : Script
|
public class Synchronize : Script, IScriptOnAfterStatusChange
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnAfterStatusChange(IPokemon pokemon, StringKey status, IPokemon? originPokemon)
|
public void OnAfterStatusChange(IPokemon pokemon, StringKey status, IPokemon? originPokemon)
|
||||||
{
|
{
|
||||||
if (originPokemon == null || pokemon == originPokemon)
|
if (originPokemon == null || pokemon == originPokemon)
|
||||||
return;
|
return;
|
||||||
|
@ -6,10 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Tangled_Feet_(Ability)">Bulbapedia - Tangled Feet</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Tangled_Feet_(Ability)">Bulbapedia - Tangled Feet</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "tangled_feet")]
|
[Script(ScriptCategory.Ability, "tangled_feet")]
|
||||||
public class TangledFeet : Script
|
public class TangledFeet : Script, IScriptChangeIncomingAccuracy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
public void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||||
ref int modifiedAccuracy)
|
ref int modifiedAccuracy)
|
||||||
{
|
{
|
||||||
if (modifiedAccuracy != 255 && target.Volatile.Contains<Pokemon.Confusion>())
|
if (modifiedAccuracy != 255 && target.Volatile.Contains<Pokemon.Confusion>())
|
||||||
|
@ -8,10 +8,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Teravolt_(Ability)">Bulbapedia - Teravolt</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Teravolt_(Ability)">Bulbapedia - Teravolt</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "teravolt")]
|
[Script(ScriptCategory.Ability, "teravolt")]
|
||||||
public class Teravolt : Script
|
public class Teravolt : Script, IScriptOnBeforeMoveChoice, IScriptOnAfterMoveChoice
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnBeforeMoveChoice(IMoveChoice moveChoice)
|
public void OnBeforeMoveChoice(IMoveChoice moveChoice)
|
||||||
{
|
{
|
||||||
var battleData = moveChoice.User.BattleData;
|
var battleData = moveChoice.User.BattleData;
|
||||||
if (battleData is null)
|
if (battleData is null)
|
||||||
@ -25,7 +25,7 @@ public class Teravolt : Script
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnAfterMoveChoice(IMoveChoice move)
|
public void OnAfterMoveChoice(IMoveChoice move)
|
||||||
{
|
{
|
||||||
var battleData = move.User.BattleData;
|
var battleData = move.User.BattleData;
|
||||||
if (battleData is null)
|
if (battleData is null)
|
||||||
|
@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Victory_Star_(Ability)">Bulbapedia - Victory Star</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Victory_Star_(Ability)">Bulbapedia - Victory Star</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "victory_star")]
|
[Script(ScriptCategory.Ability, "victory_star")]
|
||||||
public class VictoryStar : Script
|
public class VictoryStar : Script, IScriptChangeAccuracy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
public void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref int modifiedAccuracy)
|
||||||
ref int modifiedAccuracy)
|
|
||||||
{
|
{
|
||||||
modifiedAccuracy = modifiedAccuracy.MultiplyOrMax(1.1f);
|
modifiedAccuracy = modifiedAccuracy.MultiplyOrMax(1.1f);
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Vital_Spirit_(Ability)">Bulbapedia - Vital Spirit</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Vital_Spirit_(Ability)">Bulbapedia - Vital Spirit</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "vital_spirit")]
|
[Script(ScriptCategory.Ability, "vital_spirit")]
|
||||||
public class VitalSpirit : Script
|
public class VitalSpirit : Script, IScriptPreventStatusChange
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
|
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
|
||||||
ref bool preventStatus)
|
|
||||||
{
|
{
|
||||||
if (status == ScriptUtils.ResolveName<Status.Sleep>() && !selfInflicted)
|
if (status == ScriptUtils.ResolveName<Status.Sleep>() && !selfInflicted)
|
||||||
{
|
{
|
||||||
|
@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Water_Bubble_(Ability)">Bulbapedia - Water Bubble</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Water_Bubble_(Ability)">Bulbapedia - Water Bubble</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "water_bubble")]
|
[Script(ScriptCategory.Ability, "water_bubble")]
|
||||||
public class WaterBubble : Script, IScriptChangeIncomingMoveDamage, IScriptChangeMoveDamage
|
public class WaterBubble : Script, IScriptChangeIncomingMoveDamage, IScriptChangeMoveDamage, IScriptPreventStatusChange
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
|
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
|
||||||
ref bool preventStatus)
|
|
||||||
{
|
{
|
||||||
if (status == ScriptUtils.ResolveName<Status.Burned>())
|
if (status == ScriptUtils.ResolveName<Status.Burned>())
|
||||||
preventStatus = true;
|
preventStatus = true;
|
||||||
|
@ -6,11 +6,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Water_Veil_(Ability)">Bulbapedia - Water Veil</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Water_Veil_(Ability)">Bulbapedia - Water Veil</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "water_veil")]
|
[Script(ScriptCategory.Ability, "water_veil")]
|
||||||
public class WaterVeil : Script
|
public class WaterVeil : Script, IScriptPreventStatusChange
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
|
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
|
||||||
ref bool preventStatus)
|
|
||||||
{
|
{
|
||||||
if (status == ScriptUtils.ResolveName<Status.Burned>())
|
if (status == ScriptUtils.ResolveName<Status.Burned>())
|
||||||
preventStatus = true;
|
preventStatus = true;
|
||||||
|
@ -8,10 +8,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Wonder_Skin_(Ability)">Bulbapedia - Wonder Skin</see>
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Wonder_Skin_(Ability)">Bulbapedia - Wonder Skin</see>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Script(ScriptCategory.Ability, "wonder_skin")]
|
[Script(ScriptCategory.Ability, "wonder_skin")]
|
||||||
public class WonderSkin : Script
|
public class WonderSkin : Script, IScriptChangeIncomingAccuracy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
public void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||||
ref int modifiedAccuracy)
|
ref int modifiedAccuracy)
|
||||||
{
|
{
|
||||||
if (executingMove.UseMove.Category == MoveCategory.Status && executingMove.UseMove.Accuracy != 255)
|
if (executingMove.UseMove.Category == MoveCategory.Status && executingMove.UseMove.Accuracy != 255)
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Battle;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Battle;
|
||||||
|
|
||||||
[Script(ScriptCategory.Battle, "gravity")]
|
[Script(ScriptCategory.Battle, "gravity")]
|
||||||
public class Gravity : Script, IScriptFailIncomingMove, IScriptOnEndTurn
|
public class Gravity : Script, IScriptFailIncomingMove, IScriptOnEndTurn, IScriptChangeTypesForIncomingMove,
|
||||||
|
IScriptIsFloating
|
||||||
{
|
{
|
||||||
private int _turns = 5;
|
private int _turns = 5;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||||
IList<TypeIdentifier> types)
|
IList<TypeIdentifier> types)
|
||||||
{
|
{
|
||||||
var typeLibrary = target.Library.StaticLibrary.Types;
|
var typeLibrary = target.Library.StaticLibrary.Types;
|
||||||
@ -25,7 +26,7 @@ public class Gravity : Script, IScriptFailIncomingMove, IScriptOnEndTurn
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void IsFloating(IPokemon pokemon, ref bool isFloating)
|
public void IsFloating(IPokemon pokemon, ref bool isFloating)
|
||||||
{
|
{
|
||||||
// Gravity makes all Pokémon susceptible to Ground-type moves
|
// Gravity makes all Pokémon susceptible to Ground-type moves
|
||||||
isFloating = false;
|
isFloating = false;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Battle;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Battle;
|
||||||
|
|
||||||
[Script(ScriptCategory.Battle, "uproar_effect")]
|
[Script(ScriptCategory.Battle, "uproar_effect")]
|
||||||
public class UproarEffect : Script, IScriptOnBeforeTurnStart, IScriptOnSecondaryEffect, IScriptOnEndTurn
|
public class UproarEffect : Script, IScriptOnBeforeTurnStart, IScriptOnSecondaryEffect, IScriptOnEndTurn,
|
||||||
|
IScriptPreventStatusChange
|
||||||
{
|
{
|
||||||
private IPokemon? _placer;
|
private IPokemon? _placer;
|
||||||
private bool _hasUsedUproar;
|
private bool _hasUsedUproar;
|
||||||
@ -14,8 +15,7 @@ public class UproarEffect : Script, IScriptOnBeforeTurnStart, IScriptOnSecondary
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
|
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
|
||||||
ref bool preventStatus)
|
|
||||||
{
|
{
|
||||||
if (status == ScriptUtils.ResolveName<Status.Sleep>())
|
if (status == ScriptUtils.ResolveName<Status.Sleep>())
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.MoveVolatile;
|
namespace PkmnLib.Plugin.Gen7.Scripts.MoveVolatile;
|
||||||
|
|
||||||
[Script(ScriptCategory.MoveVolatile, "bypass_sleep")]
|
[Script(ScriptCategory.MoveVolatile, "bypass_sleep")]
|
||||||
public class BypassSleepVolatile : Script
|
public class BypassSleepVolatile : Script, IScriptCustomTrigger
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
||||||
{
|
{
|
||||||
if (eventName == CustomTriggers.BypassSleep && args is CustomTriggers.BypassSleepArgs bypassArgs)
|
if (eventName == CustomTriggers.BypassSleep && args is CustomTriggers.BypassSleepArgs bypassArgs)
|
||||||
bypassArgs.Bypass = true;
|
bypassArgs.Bypass = true;
|
||||||
|
@ -40,7 +40,7 @@ public class AuroraVeil : Script, IScriptOnSecondaryEffect
|
|||||||
var side = battle.Sides[move.User.BattleData!.SideIndex];
|
var side = battle.Sides[move.User.BattleData!.SideIndex];
|
||||||
|
|
||||||
var args = new CustomTriggers.AuroraVeilDurationArgs(move, 5);
|
var args = new CustomTriggers.AuroraVeilDurationArgs(move, 5);
|
||||||
move.User.RunScriptHook(x => x.CustomTrigger(CustomTriggers.AuroraVeilDuration, args));
|
move.User.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.AuroraVeilDuration, args));
|
||||||
var numberOfTurns = args.Duration;
|
var numberOfTurns = args.Duration;
|
||||||
|
|
||||||
var script = side.VolatileScripts.StackOrAdd(ScriptUtils.ResolveName<AuroraVeilEffect>(), () =>
|
var script = side.VolatileScripts.StackOrAdd(ScriptUtils.ResolveName<AuroraVeilEffect>(), () =>
|
||||||
|
@ -9,7 +9,7 @@ public class Bind : Script, IScriptOnSecondaryEffect
|
|||||||
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||||
{
|
{
|
||||||
var args = new CustomTriggers.ModifyBindArgs(move);
|
var args = new CustomTriggers.ModifyBindArgs(move);
|
||||||
move.User.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ModifyBind, args));
|
move.User.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyBind, args));
|
||||||
|
|
||||||
var bindTurns = args.Duration;
|
var bindTurns = args.Duration;
|
||||||
var bindDamage = args.DamagePercent;
|
var bindDamage = args.DamagePercent;
|
||||||
|
@ -8,7 +8,7 @@ public class ChargeMove : Script, IScriptPreventMove
|
|||||||
public void PreventMove(IExecutingMove move, ref bool prevent)
|
public void PreventMove(IExecutingMove move, ref bool prevent)
|
||||||
{
|
{
|
||||||
var args = new CustomTriggers.BypassChargeMoveArgs(move, false);
|
var args = new CustomTriggers.BypassChargeMoveArgs(move, false);
|
||||||
move.RunScriptHook(script => script.CustomTrigger(CustomTriggers.BypassChargeMove, args));
|
move.RunScriptHook<IScriptCustomTrigger>(script => script.CustomTrigger(CustomTriggers.BypassChargeMove, args));
|
||||||
if (args.Bypass)
|
if (args.Bypass)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ public class Drain : Script, IScriptOnInitialize, IScriptOnSecondaryEffect
|
|||||||
var invert = false;
|
var invert = false;
|
||||||
|
|
||||||
var args = new CustomTriggers.ModifyDrainArgs(move, target, hit, damage, healed, invert);
|
var args = new CustomTriggers.ModifyDrainArgs(move, target, hit, damage, healed, invert);
|
||||||
target.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ModifyDrain, args));
|
target.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyDrain, args));
|
||||||
invert = args.Invert;
|
invert = args.Invert;
|
||||||
healed = args.Healed;
|
healed = args.Healed;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class DreamEater : Script, IScriptOnSecondaryEffect, IScriptBlockOutgoing
|
|||||||
healed = (uint)(healed * 1.3f);
|
healed = (uint)(healed * 1.3f);
|
||||||
|
|
||||||
var args = new CustomTriggers.ModifyDrainArgs(move, target, hit, damage, healed, false);
|
var args = new CustomTriggers.ModifyDrainArgs(move, target, hit, damage, healed, false);
|
||||||
target.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ModifyDrain, args));
|
target.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyDrain, args));
|
||||||
var invert = args.Invert;
|
var invert = args.Invert;
|
||||||
healed = args.Healed;
|
healed = args.Healed;
|
||||||
|
|
||||||
|
@ -3,10 +3,10 @@ using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||||
|
|
||||||
[Script(ScriptCategory.Move, "feint")]
|
[Script(ScriptCategory.Move, "feint")]
|
||||||
public class Feint : Script
|
public class Feint : Script, IScriptOnBeforeHit
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
|
public void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
|
||||||
{
|
{
|
||||||
if (target.Volatile.Contains<ProtectionEffectScript>())
|
if (target.Volatile.Contains<ProtectionEffectScript>())
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ public class FlareBlitz : Script, IScriptOnSecondaryEffect
|
|||||||
var recoilDamage = hitData.Damage * (1 / 3);
|
var recoilDamage = hitData.Damage * (1 / 3);
|
||||||
|
|
||||||
var triggerArgs = new CustomTriggers.ModifyRecoilArgs(move, target, hit, hitData.Damage, recoilDamage);
|
var triggerArgs = new CustomTriggers.ModifyRecoilArgs(move, target, hit, hitData.Damage, recoilDamage);
|
||||||
move.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ModifyRecoil, triggerArgs));
|
move.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyRecoil, triggerArgs));
|
||||||
if (triggerArgs.Prevent)
|
if (triggerArgs.Prevent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||||
|
|
||||||
[Script(ScriptCategory.Move, "flying_press")]
|
[Script(ScriptCategory.Move, "flying_press")]
|
||||||
public class FlyingPress : Script
|
public class FlyingPress : Script, IScriptChangeTypesForMove
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeTypesForMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
public void ChangeTypesForMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||||
IList<TypeIdentifier> types)
|
IList<TypeIdentifier> types)
|
||||||
{
|
{
|
||||||
var typeLibrary = executingMove.User.Library.StaticLibrary.Types;
|
var typeLibrary = executingMove.User.Library.StaticLibrary.Types;
|
||||||
|
@ -18,7 +18,7 @@ public class HealPercent : Script, IScriptOnInitialize, IScriptOnSecondaryEffect
|
|||||||
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||||
{
|
{
|
||||||
var args = new CustomTriggers.ModifyHealPercentArgs(move, target, hit, _healPercent);
|
var args = new CustomTriggers.ModifyHealPercentArgs(move, target, hit, _healPercent);
|
||||||
move.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ModifyHealPercent, args));
|
move.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyHealPercent, args));
|
||||||
var healPercent = args.HealPercent;
|
var healPercent = args.HealPercent;
|
||||||
|
|
||||||
target.Heal(target.BoostedStats.Hp.MultiplyOrMax(healPercent));
|
target.Heal(target.BoostedStats.Hp.MultiplyOrMax(healPercent));
|
||||||
|
@ -13,7 +13,7 @@ public class LightScreen : Script, IScriptOnSecondaryEffect
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var args = new CustomTriggers.LightScreenNumberOfTurnsArgs(move, 5);
|
var args = new CustomTriggers.LightScreenNumberOfTurnsArgs(move, 5);
|
||||||
move.RunScriptHook(x => x.CustomTrigger(CustomTriggers.LightScreenNumberOfTurns, args));
|
move.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.LightScreenNumberOfTurns, args));
|
||||||
var turns = args.Duration;
|
var turns = args.Duration;
|
||||||
|
|
||||||
battleData.BattleSide.VolatileScripts.StackOrAdd(ScriptUtils.ResolveName<LightScreenEffect>(),
|
battleData.BattleSide.VolatileScripts.StackOrAdd(ScriptUtils.ResolveName<LightScreenEffect>(),
|
||||||
|
@ -20,7 +20,7 @@ public class MultiHitMove : Script, IScriptChangeNumberOfHits
|
|||||||
_ => 5,
|
_ => 5,
|
||||||
};
|
};
|
||||||
var triggerArgs = new CustomTriggers.Modify2_5HitMoveArgs(choice, (byte)newHits);
|
var triggerArgs = new CustomTriggers.Modify2_5HitMoveArgs(choice, (byte)newHits);
|
||||||
choice.RunScriptHook(x => x.CustomTrigger(CustomTriggers.Modify2_5HitMove, triggerArgs));
|
choice.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.Modify2_5HitMove, triggerArgs));
|
||||||
newHits = triggerArgs.NumberOfHits;
|
newHits = triggerArgs.NumberOfHits;
|
||||||
|
|
||||||
numberOfHits = (byte)newHits;
|
numberOfHits = (byte)newHits;
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||||
|
|
||||||
[Script(ScriptCategory.Move, "one_hit_ko")]
|
[Script(ScriptCategory.Move, "one_hit_ko")]
|
||||||
public class OneHitKo : Script, IScriptChangeMoveDamage
|
public class OneHitKo : Script, IScriptChangeMoveDamage, IScriptChangeAccuracy
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
public void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref int modifiedAccuracy)
|
||||||
ref int modifiedAccuracy)
|
|
||||||
{
|
{
|
||||||
var levelDifference = executingMove.User.Level - target.Level;
|
var levelDifference = executingMove.User.Level - target.Level;
|
||||||
if (levelDifference < 0)
|
if (levelDifference < 0)
|
||||||
|
@ -3,11 +3,11 @@ using PkmnLib.Static.Moves;
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||||
|
|
||||||
[Script(ScriptCategory.Move, "pollen_puff")]
|
[Script(ScriptCategory.Move, "pollen_puff")]
|
||||||
public class PollenPuff : Script, IScriptOnSecondaryEffect
|
public class PollenPuff : Script, IScriptOnSecondaryEffect, IScriptChangeCategory
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeCategory(IExecutingMove move, IPokemon target, byte hitIndex, ref MoveCategory category)
|
public void ChangeCategory(IExecutingMove move, IPokemon target, byte hitIndex, ref MoveCategory category)
|
||||||
{
|
{
|
||||||
var battleData = move.User.BattleData;
|
var battleData = move.User.BattleData;
|
||||||
var targetBattleData = target.BattleData;
|
var targetBattleData = target.BattleData;
|
||||||
|
@ -3,13 +3,14 @@ using PkmnLib.Static.Moves;
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||||
|
|
||||||
[Script(ScriptCategory.Move, "present")]
|
[Script(ScriptCategory.Move, "present")]
|
||||||
public class Present : Script, IScriptOnSecondaryEffect, IScriptChangeBasePower
|
public class Present : Script, IScriptOnSecondaryEffect, IScriptChangeBasePower, IScriptChangeCategory,
|
||||||
|
IScriptOnBeforeHit
|
||||||
{
|
{
|
||||||
private bool _isHealing;
|
private bool _isHealing;
|
||||||
private byte _basePower;
|
private byte _basePower;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
|
public void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
|
||||||
{
|
{
|
||||||
var battleRandom = move.User.BattleData?.Battle.Random;
|
var battleRandom = move.User.BattleData?.Battle.Random;
|
||||||
if (battleRandom == null)
|
if (battleRandom == null)
|
||||||
@ -33,7 +34,7 @@ public class Present : Script, IScriptOnSecondaryEffect, IScriptChangeBasePower
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeCategory(IExecutingMove move, IPokemon target, byte hitIndex, ref MoveCategory category)
|
public void ChangeCategory(IExecutingMove move, IPokemon target, byte hitIndex, ref MoveCategory category)
|
||||||
{
|
{
|
||||||
if (_isHealing)
|
if (_isHealing)
|
||||||
category = MoveCategory.Status;
|
category = MoveCategory.Status;
|
||||||
|
@ -23,7 +23,7 @@ public class Recoil : Script, IScriptOnInitialize, IScriptOnSecondaryEffect
|
|||||||
var recoilDamage = (uint)(hitData.Damage * _recoilPercentage);
|
var recoilDamage = (uint)(hitData.Damage * _recoilPercentage);
|
||||||
|
|
||||||
var triggerArgs = new CustomTriggers.ModifyRecoilArgs(move, target, hit, hitData.Damage, recoilDamage);
|
var triggerArgs = new CustomTriggers.ModifyRecoilArgs(move, target, hit, hitData.Damage, recoilDamage);
|
||||||
move.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ModifyRecoil, triggerArgs));
|
move.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ModifyRecoil, triggerArgs));
|
||||||
if (triggerArgs.Prevent)
|
if (triggerArgs.Prevent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ public class Reflect : Script, IScriptOnSecondaryEffect
|
|||||||
var numberOfTurns = 5;
|
var numberOfTurns = 5;
|
||||||
|
|
||||||
var args = new CustomTriggers.ReflectNumberOfTurnsArgs(move, numberOfTurns);
|
var args = new CustomTriggers.ReflectNumberOfTurnsArgs(move, numberOfTurns);
|
||||||
move.User.RunScriptHook(x => x.CustomTrigger(CustomTriggers.ReflectNumberOfTurns, args));
|
move.User.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.ReflectNumberOfTurns, args));
|
||||||
numberOfTurns = args.Duration;
|
numberOfTurns = args.Duration;
|
||||||
|
|
||||||
battleData.BattleSide.VolatileScripts.Add(new Side.ReflectEffect(numberOfTurns));
|
battleData.BattleSide.VolatileScripts.Add(new Side.ReflectEffect(numberOfTurns));
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||||
|
|
||||||
[Script(ScriptCategory.Move, "spectral_thief")]
|
[Script(ScriptCategory.Move, "spectral_thief")]
|
||||||
public class SpectralThief : Script
|
public class SpectralThief : Script, IScriptOnBeforeHit
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
|
public void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
|
||||||
{
|
{
|
||||||
var positiveStats = target.StatBoost.Where(x => x.value > 0).ToArray();
|
var positiveStats = target.StatBoost.Where(x => x.value > 0).ToArray();
|
||||||
if (positiveStats.Length > 0)
|
if (positiveStats.Length > 0)
|
||||||
|
@ -3,10 +3,10 @@ using PkmnLib.Static.Moves;
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||||
|
|
||||||
[Script(ScriptCategory.Move, "sucker_punch")]
|
[Script(ScriptCategory.Move, "sucker_punch")]
|
||||||
public class SuckerPunch : Script
|
public class SuckerPunch : Script, IScriptOnBeforeHit
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
|
public void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
|
||||||
{
|
{
|
||||||
var targetChoice = move.Battle.ChoiceQueue?.Where(x => x.User == target).FirstOrDefault();
|
var targetChoice = move.Battle.ChoiceQueue?.Where(x => x.User == target).FirstOrDefault();
|
||||||
if (targetChoice is not IMoveChoice moveChoice ||
|
if (targetChoice is not IMoveChoice moveChoice ||
|
||||||
|
@ -14,7 +14,7 @@ public class Whirlpool : Script, IScriptOnSecondaryEffect
|
|||||||
var turns = move.Battle.Random.GetInt(4, 6);
|
var turns = move.Battle.Random.GetInt(4, 6);
|
||||||
var damagePercent = 0.125f;
|
var damagePercent = 0.125f;
|
||||||
var args = new CustomTriggers.WhirlpoolArgs(move, target, hit, turns, damagePercent);
|
var args = new CustomTriggers.WhirlpoolArgs(move, target, hit, turns, damagePercent);
|
||||||
move.RunScriptHook(x => x.CustomTrigger(CustomTriggers.Whirlpool, args));
|
move.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.Whirlpool, args));
|
||||||
turns = args.Turns;
|
turns = args.Turns;
|
||||||
damagePercent = args.DamagePercent;
|
damagePercent = args.DamagePercent;
|
||||||
whirlpoolEffect.AddTargetedPokemon(target, turns, damagePercent);
|
whirlpoolEffect.AddTargetedPokemon(target, turns, damagePercent);
|
||||||
|
@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||||
|
|
||||||
[Script(ScriptCategory.Pokemon, "autotomize")]
|
[Script(ScriptCategory.Pokemon, "autotomize")]
|
||||||
public class AutotomizeEffect : Script, IBatonPassException, IScriptStack
|
public class AutotomizeEffect : Script, IBatonPassException, IScriptStack, IScriptModifyWeight
|
||||||
{
|
{
|
||||||
public int Stacks { get; private set; } = 1;
|
public int Stacks { get; private set; } = 1;
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ public class AutotomizeEffect : Script, IBatonPassException, IScriptStack
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ModifyWeight(ref float weight)
|
public void ModifyWeight(ref float weight)
|
||||||
{
|
{
|
||||||
weight -= 100f * Stacks;
|
weight -= 100f * Stacks;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
|||||||
|
|
||||||
[Script(ScriptCategory.Pokemon, "charge_bounce")]
|
[Script(ScriptCategory.Pokemon, "charge_bounce")]
|
||||||
public class ChargeBounceEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage,
|
public class ChargeBounceEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage,
|
||||||
IScriptBlockIncomingHit
|
IScriptBlockIncomingHit, IScriptOnAfterMoveChoice
|
||||||
{
|
{
|
||||||
private readonly IPokemon _owner;
|
private readonly IPokemon _owner;
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public class ChargeBounceEffect : Script, IScriptForceTurnSelection, IScriptChan
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnAfterMoveChoice(IMoveChoice moveChoice)
|
public void OnAfterMoveChoice(IMoveChoice moveChoice)
|
||||||
{
|
{
|
||||||
if (moveChoice.AdditionalData?.ContainsKey("bounce_charge") != true)
|
if (moveChoice.AdditionalData?.ContainsKey("bounce_charge") != true)
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
|||||||
|
|
||||||
[Script(ScriptCategory.Pokemon, "charge_fly")]
|
[Script(ScriptCategory.Pokemon, "charge_fly")]
|
||||||
public class ChargeFlyEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage,
|
public class ChargeFlyEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage,
|
||||||
IScriptBlockIncomingHit
|
IScriptBlockIncomingHit, IScriptOnAfterMoveChoice
|
||||||
{
|
{
|
||||||
private readonly IPokemon _owner;
|
private readonly IPokemon _owner;
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public class ChargeFlyEffect : Script, IScriptForceTurnSelection, IScriptChangeI
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnAfterMoveChoice(IMoveChoice moveChoice)
|
public void OnAfterMoveChoice(IMoveChoice moveChoice)
|
||||||
{
|
{
|
||||||
if (moveChoice.AdditionalData?.ContainsKey("fly_charge") != true)
|
if (moveChoice.AdditionalData?.ContainsKey("fly_charge") != true)
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
|||||||
|
|
||||||
[Script(ScriptCategory.Pokemon, "charge_sky_drop")]
|
[Script(ScriptCategory.Pokemon, "charge_sky_drop")]
|
||||||
public class ChargeSkyDropEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage,
|
public class ChargeSkyDropEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage,
|
||||||
IScriptBlockIncomingHit
|
IScriptBlockIncomingHit, IScriptOnAfterMoveChoice
|
||||||
{
|
{
|
||||||
private readonly IPokemon _owner;
|
private readonly IPokemon _owner;
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public class ChargeSkyDropEffect : Script, IScriptForceTurnSelection, IScriptCha
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnAfterMoveChoice(IMoveChoice moveChoice)
|
public void OnAfterMoveChoice(IMoveChoice moveChoice)
|
||||||
{
|
{
|
||||||
if (moveChoice.AdditionalData?.ContainsKey("sky_drop_charge") != true)
|
if (moveChoice.AdditionalData?.ContainsKey("sky_drop_charge") != true)
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,8 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||||
|
|
||||||
[Script(ScriptCategory.Pokemon, "dig")]
|
[Script(ScriptCategory.Pokemon, "dig")]
|
||||||
public class DigEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage, IScriptBlockIncomingHit
|
public class DigEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage, IScriptBlockIncomingHit,
|
||||||
|
IScriptOnAfterMoveChoice
|
||||||
{
|
{
|
||||||
private readonly IPokemon _owner;
|
private readonly IPokemon _owner;
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ public class DigEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomin
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnAfterMoveChoice(IMoveChoice moveChoice)
|
public void OnAfterMoveChoice(IMoveChoice moveChoice)
|
||||||
{
|
{
|
||||||
if (moveChoice.AdditionalData?.ContainsKey("dig_charge") != true)
|
if (moveChoice.AdditionalData?.ContainsKey("dig_charge") != true)
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,8 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||||
|
|
||||||
[Script(ScriptCategory.Pokemon, "dive")]
|
[Script(ScriptCategory.Pokemon, "dive")]
|
||||||
public class DiveEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage, IScriptBlockIncomingHit
|
public class DiveEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomingMoveDamage, IScriptBlockIncomingHit,
|
||||||
|
IScriptOnAfterMoveChoice
|
||||||
{
|
{
|
||||||
private readonly IPokemon _owner;
|
private readonly IPokemon _owner;
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ public class DiveEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomi
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnAfterMoveChoice(IMoveChoice moveChoice)
|
public void OnAfterMoveChoice(IMoveChoice moveChoice)
|
||||||
{
|
{
|
||||||
if (moveChoice.AdditionalData?.ContainsKey("dive_charge") != true)
|
if (moveChoice.AdditionalData?.ContainsKey("dive_charge") != true)
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@ public class FlinchEffect : Script, IScriptPreventMove
|
|||||||
{
|
{
|
||||||
prevent = true;
|
prevent = true;
|
||||||
var args = new CustomTriggers.OnFlinchArgs(move);
|
var args = new CustomTriggers.OnFlinchArgs(move);
|
||||||
move.RunScriptHook(x => x.CustomTrigger(CustomTriggers.OnFlinch, args));
|
move.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.OnFlinch, args));
|
||||||
if (args.Prevent)
|
if (args.Prevent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ using PkmnLib.Static.Libraries;
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||||
|
|
||||||
[Script(ScriptCategory.Pokemon, "foresight")]
|
[Script(ScriptCategory.Pokemon, "foresight")]
|
||||||
public class ForesightEffect : Script, IScriptPreventStatBoostChange
|
public class ForesightEffect : Script, IScriptPreventStatBoostChange, IScriptChangeTypesForIncomingMove
|
||||||
{
|
{
|
||||||
private readonly TypeIdentifier _normalType;
|
private readonly TypeIdentifier _normalType;
|
||||||
private readonly TypeIdentifier _fightingType;
|
private readonly TypeIdentifier _fightingType;
|
||||||
@ -25,7 +25,7 @@ public class ForesightEffect : Script, IScriptPreventStatBoostChange
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||||
IList<TypeIdentifier> types)
|
IList<TypeIdentifier> types)
|
||||||
{
|
{
|
||||||
if (executingMove.UseMove.MoveType == _normalType || executingMove.UseMove.MoveType == _fightingType)
|
if (executingMove.UseMove.MoveType == _normalType || executingMove.UseMove.MoveType == _fightingType)
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||||
|
|
||||||
[Script(ScriptCategory.Pokemon, "heal_block")]
|
[Script(ScriptCategory.Pokemon, "heal_block")]
|
||||||
public class HealBlockEffect : Script, IScriptPreventMoveSelection, IScriptPreventMove, IScriptOnEndTurn
|
public class HealBlockEffect : Script, IScriptPreventMoveSelection, IScriptPreventMove, IScriptOnEndTurn,
|
||||||
|
IScriptPreventHeal
|
||||||
{
|
{
|
||||||
private int _duration;
|
private int _duration;
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ public class HealBlockEffect : Script, IScriptPreventMoveSelection, IScriptPreve
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventHeal(IPokemon pokemon, uint heal, bool allowRevive, ref bool prevented)
|
public void PreventHeal(IPokemon pokemon, uint heal, bool allowRevive, ref bool prevented)
|
||||||
{
|
{
|
||||||
prevented = true;
|
prevented = true;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
|||||||
|
|
||||||
[Script(ScriptCategory.Pokemon, "ingrain")]
|
[Script(ScriptCategory.Pokemon, "ingrain")]
|
||||||
public class IngrainEffect : Script, IScriptFailIncomingMove, IScriptOnEndTurn, IScriptPreventSelfSwitch,
|
public class IngrainEffect : Script, IScriptFailIncomingMove, IScriptOnEndTurn, IScriptPreventSelfSwitch,
|
||||||
IScriptPreventSelfRunAway
|
IScriptPreventSelfRunAway, IScriptChangeTypesForIncomingMove
|
||||||
{
|
{
|
||||||
private readonly IPokemon _owner;
|
private readonly IPokemon _owner;
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ public class IngrainEffect : Script, IScriptFailIncomingMove, IScriptOnEndTurn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||||
IList<TypeIdentifier> types)
|
IList<TypeIdentifier> types)
|
||||||
{
|
{
|
||||||
if (executingMove.UseMove.MoveType.Name == "ground")
|
if (executingMove.UseMove.MoveType.Name == "ground")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||||
|
|
||||||
[Script(ScriptCategory.Pokemon, "lock_on")]
|
[Script(ScriptCategory.Pokemon, "lock_on")]
|
||||||
public class LockOnEffect : Script, IScriptOnEndTurn
|
public class LockOnEffect : Script, IScriptOnEndTurn, IScriptChangeAccuracy
|
||||||
{
|
{
|
||||||
private readonly IPokemon _placer;
|
private readonly IPokemon _placer;
|
||||||
|
|
||||||
@ -11,8 +11,7 @@ public class LockOnEffect : Script, IScriptOnEndTurn
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
public void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref int modifiedAccuracy)
|
||||||
ref int modifiedAccuracy)
|
|
||||||
{
|
{
|
||||||
if (_placer != target)
|
if (_placer != target)
|
||||||
return;
|
return;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||||
|
|
||||||
[Script(ScriptCategory.Pokemon, "miracle_eye")]
|
[Script(ScriptCategory.Pokemon, "miracle_eye")]
|
||||||
public class MiracleEyeEffect : Script, IScriptPreventStatBoostChange
|
public class MiracleEyeEffect : Script, IScriptPreventStatBoostChange, IScriptChangeTypesForIncomingMove
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void PreventStatBoostChange(IPokemon target, Statistic stat, sbyte amount, bool selfInflicted,
|
public void PreventStatBoostChange(IPokemon target, Statistic stat, sbyte amount, bool selfInflicted,
|
||||||
@ -12,7 +12,7 @@ public class MiracleEyeEffect : Script, IScriptPreventStatBoostChange
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||||
IList<TypeIdentifier> types)
|
IList<TypeIdentifier> types)
|
||||||
{
|
{
|
||||||
if (executingMove.UseMove.MoveType.Name != "psychic")
|
if (executingMove.UseMove.MoveType.Name != "psychic")
|
||||||
|
@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||||
|
|
||||||
[Script(ScriptCategory.Pokemon, "phantom_force")]
|
[Script(ScriptCategory.Pokemon, "phantom_force")]
|
||||||
public class PhantomForceCharge : Script, IScriptForceTurnSelection, IScriptBlockIncomingHit
|
public class PhantomForceCharge : Script, IScriptForceTurnSelection, IScriptBlockIncomingHit, IScriptOnAfterMoveChoice
|
||||||
{
|
{
|
||||||
private readonly IPokemon _owner;
|
private readonly IPokemon _owner;
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ public class PhantomForceCharge : Script, IScriptForceTurnSelection, IScriptBloc
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnAfterMoveChoice(IMoveChoice moveChoice)
|
public void OnAfterMoveChoice(IMoveChoice moveChoice)
|
||||||
{
|
{
|
||||||
if (moveChoice.AdditionalData?.ContainsKey("phantom_force_charge") != true)
|
if (moveChoice.AdditionalData?.ContainsKey("phantom_force_charge") != true)
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,8 @@ public class ProtectionEffectScript : Script, IScriptBlockIncomingHit
|
|||||||
if (!executingMove.UseMove.HasFlag("protect"))
|
if (!executingMove.UseMove.HasFlag("protect"))
|
||||||
return;
|
return;
|
||||||
var args = new CustomTriggers.BypassProtectionArgs(executingMove, target, hitIndex, false);
|
var args = new CustomTriggers.BypassProtectionArgs(executingMove, target, hitIndex, false);
|
||||||
executingMove.User.RunScriptHook(x => x.CustomTrigger(CustomTriggers.BypassProtection, args));
|
executingMove.User.RunScriptHook<IScriptCustomTrigger>(x =>
|
||||||
|
x.CustomTrigger(CustomTriggers.BypassProtection, args));
|
||||||
if (args.Bypass)
|
if (args.Bypass)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||||
|
|
||||||
[Script(ScriptCategory.Pokemon, "roost_effect")]
|
[Script(ScriptCategory.Pokemon, "roost_effect")]
|
||||||
public class RoostEffect : Script, IScriptOnEndTurn
|
public class RoostEffect : Script, IScriptOnEndTurn, IScriptChangeTypesForIncomingMove
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
public void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||||
IList<TypeIdentifier> types)
|
IList<TypeIdentifier> types)
|
||||||
{
|
{
|
||||||
types.RemoveAll(x => x.Name == "flying");
|
types.RemoveAll(x => x.Name == "flying");
|
||||||
|
@ -3,7 +3,7 @@ using PkmnLib.Plugin.Gen7.Scripts.Utils;
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||||
|
|
||||||
[Script(ScriptCategory.Pokemon, "shadow_force")]
|
[Script(ScriptCategory.Pokemon, "shadow_force")]
|
||||||
public class ShadowForceCharge : Script, IScriptForceTurnSelection, IScriptBlockIncomingHit
|
public class ShadowForceCharge : Script, IScriptForceTurnSelection, IScriptBlockIncomingHit, IScriptOnAfterMoveChoice
|
||||||
{
|
{
|
||||||
private readonly IPokemon _owner;
|
private readonly IPokemon _owner;
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ public class ShadowForceCharge : Script, IScriptForceTurnSelection, IScriptBlock
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnAfterMoveChoice(IMoveChoice moveChoice)
|
public void OnAfterMoveChoice(IMoveChoice moveChoice)
|
||||||
{
|
{
|
||||||
if (moveChoice.AdditionalData?.ContainsKey("shadow_force_charge") != true)
|
if (moveChoice.AdditionalData?.ContainsKey("shadow_force_charge") != true)
|
||||||
{
|
{
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user