More abilities
All checks were successful
Build / Build (push) Successful in 48s

This commit is contained in:
2025-06-13 15:39:08 +02:00
parent 4385f0afaa
commit 24712fbb0d
16 changed files with 238 additions and 16 deletions

View File

@@ -76,7 +76,8 @@ public static class MoveTurnExecutor
return;
byte ppUsed = 1;
// TODO: Modify the PP used by the move.
executingMove.RunScriptHook(x => x.ModifyPPUsed(executingMove, ref ppUsed));
targets.WhereNotNull().RunScriptHook(x => x.ModifyPPUsedForIncomingMove(executingMove, ref ppUsed));
if (!executingMove.ChosenMove.TryUse(ppUsed))
return;

View File

@@ -311,7 +311,6 @@ public class BattleImpl : ScriptSource, IBattle
if (choice is IMoveChoice moveChoice)
{
// TODO: Hook to change number of PP needed.
if (moveChoice.ChosenMove.CurrentPp < 1)
return false;
if (!TargetResolver.IsValidTarget(moveChoice.TargetSide, moveChoice.TargetPosition,

View File

@@ -1072,6 +1072,11 @@ public class PokemonImpl : ScriptSource, IPokemon
// Allow scripts to trigger based on the faint.
this.RunScriptHook(script => script.OnFaint(this, source));
foreach (var ally in BattleData.BattleSide.Pokemon.WhereNotNull().Where(x => x != this))
{
ally.RunScriptHook(script => script.OnAllyFaint(ally, this));
}
// Make sure the OnRemove script is run.
this.RunScriptHook(script => script.OnRemove());

View File

@@ -562,6 +562,13 @@ public abstract class Script : IDeepCloneable
{
}
/// <summary>
/// This function is triggered on a Pokemon when an ally Pokemon faints.
/// </summary>
public virtual void OnAllyFaint(IPokemon ally, IPokemon faintedPokemon)
{
}
/// <summary>
/// This function is triggered on a Pokemon and its parents when the given Pokemon switches out
/// of the battlefield.
@@ -801,4 +808,18 @@ public abstract class Script : IDeepCloneable
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)
{
}
}