Further work on the script interface rework
This commit is contained in:
@@ -39,14 +39,6 @@ public abstract class Script : IDeepCloneable
|
||||
/// </summary>
|
||||
public virtual ScriptCategory Category => this.ResolveCategory();
|
||||
|
||||
/// <summary>
|
||||
/// This function is ran when a volatile effect is added while that volatile effect already is
|
||||
/// in place. Instead of adding the volatile effect twice, it will execute this function instead.
|
||||
/// </summary>
|
||||
public virtual void Stack()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is ran when this script stops being in effect, and is removed from its owner.
|
||||
/// </summary>
|
||||
@@ -61,101 +53,6 @@ public abstract class Script : IDeepCloneable
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function prevents the Pokemon it is attached to from being able to switch out.
|
||||
/// </summary>
|
||||
public virtual void PreventSelfSwitch(ISwitchChoice choice, ref bool prevent)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function allows the prevention of switching for any opponent.
|
||||
/// </summary>
|
||||
public virtual void PreventOpponentSwitch(ISwitchChoice choice, ref bool prevent)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called on a move and its parents when the move fails.
|
||||
/// </summary>
|
||||
public virtual void OnFail(IPokemon pokemon)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called on a script when an opponent fails.
|
||||
/// </summary>
|
||||
/// <param name="pokemon"></param>
|
||||
public virtual void OnOpponentFail(IPokemon pokemon)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function allows preventing the running away of the Pokemon its attached to
|
||||
/// </summary>
|
||||
public virtual void PreventSelfRunAway(IFleeChoice choice, ref bool prevent)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function prevents a Pokemon on another side than where its attached to from running away.
|
||||
/// </summary>
|
||||
public virtual void PreventOpponentRunAway(IFleeChoice choice, ref bool prevent)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is triggered on a Pokemon and its parents when the given Pokemon takes damage.
|
||||
/// </summary>
|
||||
public virtual void OnDamage(IPokemon pokemon, DamageSource source, uint oldHealth, uint newHealth)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is triggered on a Pokemon and its parents when the given Pokemon faints.
|
||||
/// </summary>
|
||||
public virtual void OnFaint(IPokemon pokemon, DamageSource source)
|
||||
{
|
||||
}
|
||||
|
||||
/// <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.
|
||||
/// </summary>
|
||||
public virtual void OnSwitchOut(IPokemon oldPokemon, byte position)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is triggered on a Pokemon and its parents when the given Pokemon is switched into
|
||||
/// the battlefield.
|
||||
/// </summary>
|
||||
public virtual void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is triggered on a Pokemon and its parents when an opponent switches in.
|
||||
/// </summary>
|
||||
public virtual void OnOpponentSwitchIn(IPokemon pokemon, byte position)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is triggered on a Pokemon and its parents when the given Pokemon consumes the
|
||||
/// held item it had.
|
||||
/// </summary>
|
||||
public virtual void OnAfterItemConsume(IPokemon pokemon, IItem item)
|
||||
{
|
||||
}
|
||||
|
||||
/// <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.
|
||||
@@ -191,20 +88,6 @@ public abstract class Script : IDeepCloneable
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function allows a script to block an incoming hit.
|
||||
/// </summary>
|
||||
public virtual void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function allows a script to block an outgoing hit.
|
||||
/// </summary>
|
||||
public virtual void BlockOutgoingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom triggers for scripts. This allows scripts to run custom events that are not part of the
|
||||
/// standard battle flow.
|
||||
@@ -220,20 +103,6 @@ public abstract class Script : IDeepCloneable
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function allows a script to prevent a held item from being consumed.
|
||||
/// </summary>
|
||||
public virtual void PreventHeldItemConsume(IPokemon pokemon, IItem heldItem, ref bool prevented)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function allows a script to change any kind of damage that is incoming.
|
||||
/// </summary>
|
||||
public virtual void ChangeIncomingDamage(IPokemon pokemon, DamageSource source, ref uint damage)
|
||||
{
|
||||
}
|
||||
|
||||
/// <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
|
||||
@@ -1053,4 +922,184 @@ public interface IScriptOnEndTurn
|
||||
/// function.
|
||||
/// </summary>
|
||||
void OnEndTurn(IScriptSource owner, IBattle battle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface allows scripts to prevent the Pokemon it is attached to from being able to switch out.
|
||||
/// </summary>
|
||||
public interface IScriptPreventSelfSwitch
|
||||
{
|
||||
/// <summary>
|
||||
/// This function prevents the Pokemon it is attached to from being able to switch out.
|
||||
/// </summary>
|
||||
void PreventSelfSwitch(ISwitchChoice choice, ref bool prevent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface allows scripts to prevent switching for any opponent.
|
||||
/// </summary>
|
||||
public interface IScriptPreventOpponentSwitch
|
||||
{
|
||||
/// <summary>
|
||||
/// This function allows the prevention of switching for any opponent.
|
||||
/// </summary>
|
||||
void PreventOpponentSwitch(ISwitchChoice choice, ref bool prevent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface allows scripts to prevent the Pokemon its attached to from running away.
|
||||
/// </summary>
|
||||
public interface IScriptPreventSelfRunAway
|
||||
{
|
||||
/// <summary>
|
||||
/// This function allows preventing the running away of the Pokemon its attached to
|
||||
/// </summary>
|
||||
void PreventSelfRunAway(IFleeChoice choice, ref bool prevent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface allows scripts to prevent a Pokemon on another side from running away.
|
||||
/// </summary>
|
||||
public interface IScriptPreventOpponentRunAway
|
||||
{
|
||||
/// <summary>
|
||||
/// This function prevents a Pokemon on another side than where its attached to from running away.
|
||||
/// </summary>
|
||||
void PreventOpponentRunAway(IFleeChoice choice, ref bool prevent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface allows scripts to trigger when a Pokemon takes damage.
|
||||
/// </summary>
|
||||
public interface IScriptOnDamage
|
||||
{
|
||||
/// <summary>
|
||||
/// This function is triggered on a Pokemon and its parents when the given Pokemon takes damage.
|
||||
/// </summary>
|
||||
void OnDamage(IPokemon pokemon, DamageSource source, uint oldHealth, uint newHealth);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface allows scripts to trigger when a Pokemon faints.
|
||||
/// </summary>
|
||||
public interface IScriptOnFaint
|
||||
{
|
||||
/// <summary>
|
||||
/// This function is triggered on a Pokemon and its parents when the given Pokemon faints.
|
||||
/// </summary>
|
||||
void OnFaint(IPokemon pokemon, DamageSource source);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface allows scripts to trigger when an ally Pokemon faints.
|
||||
/// </summary>
|
||||
public interface IScriptOnAllyFaint
|
||||
{
|
||||
/// <summary>
|
||||
/// This function is triggered on a Pokemon when an ally Pokemon faints.
|
||||
/// </summary>
|
||||
void OnAllyFaint(IPokemon ally, IPokemon faintedPokemon);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface allows scripts to trigger when a Pokemon switches out of the battlefield.
|
||||
/// </summary>
|
||||
public interface IScriptOnSwitchOut
|
||||
{
|
||||
/// <summary>
|
||||
/// This function is triggered on a Pokemon and its parents when the given Pokemon switches out
|
||||
/// of the battlefield.
|
||||
/// </summary>
|
||||
void OnSwitchOut(IPokemon oldPokemon, byte position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface allows scripts to trigger when a Pokemon is switched into the battlefield.
|
||||
/// </summary>
|
||||
public interface IScriptOnSwitchIn
|
||||
{
|
||||
/// <summary>
|
||||
/// This function is triggered on a Pokemon and its parents when the given Pokemon is switched into
|
||||
/// the battlefield.
|
||||
/// </summary>
|
||||
void OnSwitchIn(IPokemon pokemon, byte position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface allows scripts to trigger when an opponent Pokemon switches in.
|
||||
/// </summary>
|
||||
public interface IScriptOnOpponentSwitchIn
|
||||
{
|
||||
/// <summary>
|
||||
/// This function is triggered on a Pokemon and its parents when an opponent switches in.
|
||||
/// </summary>
|
||||
void OnOpponentSwitchIn(IPokemon pokemon, byte position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface allows scripts to stack when a volatile effect is added while already in place.
|
||||
/// </summary>
|
||||
public interface IScriptStack
|
||||
{
|
||||
/// <summary>
|
||||
/// This function is ran when a volatile effect is added while that volatile effect already is
|
||||
/// in place. Instead of adding the volatile effect twice, it will execute this function instead.
|
||||
/// </summary>
|
||||
void Stack();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface allows scripts to trigger after a Pokemon consumes an item.
|
||||
/// </summary>
|
||||
public interface IScriptOnAfterItemConsume
|
||||
{
|
||||
/// <summary>
|
||||
/// This function is triggered on a Pokemon and its parents when the given Pokemon consumes the
|
||||
/// held item it had.
|
||||
/// </summary>
|
||||
void OnAfterItemConsume(IPokemon pokemon, IItem item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface allows scripts to block incoming hits on a target.
|
||||
/// </summary>
|
||||
public interface IScriptBlockIncomingHit
|
||||
{
|
||||
/// <summary>
|
||||
/// This function allows a script to block an incoming hit.
|
||||
/// </summary>
|
||||
void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface allows scripts to block outgoing hits from a move.
|
||||
/// </summary>
|
||||
public interface IScriptBlockOutgoingHit
|
||||
{
|
||||
/// <summary>
|
||||
/// This function allows a script to block an outgoing hit.
|
||||
/// </summary>
|
||||
void BlockOutgoingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface allows scripts to prevent held item consumption.
|
||||
/// </summary>
|
||||
public interface IScriptPreventHeldItemConsume
|
||||
{
|
||||
/// <summary>
|
||||
/// This function allows a script to prevent a held item from being consumed.
|
||||
/// </summary>
|
||||
void PreventHeldItemConsume(IPokemon pokemon, IItem heldItem, ref bool prevented);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This interface allows scripts to change incoming damage to a Pokemon.
|
||||
/// </summary>
|
||||
public interface IScriptChangeIncomingDamage
|
||||
{
|
||||
/// <summary>
|
||||
/// This function allows a script to change any kind of damage that is incoming.
|
||||
/// </summary>
|
||||
void ChangeIncomingDamage(IPokemon pokemon, DamageSource source, ref uint damage);
|
||||
}
|
||||
@@ -116,7 +116,8 @@ public class ScriptSet : IScriptSet
|
||||
var existing = _scripts.FirstOrDefault(s => s.Script?.Name == script.Name);
|
||||
if (existing != null)
|
||||
{
|
||||
existing.Script!.Stack();
|
||||
if (existing.Script is IScriptStack stackable)
|
||||
stackable.Stack();
|
||||
return existing;
|
||||
}
|
||||
|
||||
@@ -133,7 +134,8 @@ public class ScriptSet : IScriptSet
|
||||
var existing = _scripts.FirstOrDefault(s => s.Script?.Name == scriptKey);
|
||||
if (existing != null)
|
||||
{
|
||||
existing.Script!.Stack();
|
||||
if (existing.Script is IScriptStack stackable)
|
||||
stackable.Stack();
|
||||
return existing;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user