More moves
This commit is contained in:
@@ -85,6 +85,7 @@ internal static class MoveTurnExecutor
|
||||
{
|
||||
ExecuteMoveChoiceForTarget(battle, executingMove, target);
|
||||
}
|
||||
executingMove.RunScriptHook(x => x.OnAfterMove(executingMove));
|
||||
}
|
||||
|
||||
private static void ExecuteMoveChoiceForTarget(IBattle battle, IExecutingMove executingMove, IPokemon target)
|
||||
|
||||
@@ -139,6 +139,8 @@ public interface IExecutingMove : IScriptSource
|
||||
/// The underlying move choice.
|
||||
/// </summary>
|
||||
IMoveChoice MoveChoice { get; }
|
||||
|
||||
IReadOnlyList<IHitData> Hits { get; }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IExecutingMove"/>
|
||||
@@ -225,6 +227,9 @@ public class ExecutingMoveImpl : ScriptSource, IExecutingMove
|
||||
/// <inheritdoc />
|
||||
public IMoveChoice MoveChoice { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyList<IHitData> Hits => _hits;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int ScriptCount => 2 + User.ScriptCount;
|
||||
|
||||
|
||||
@@ -315,7 +315,7 @@ public interface IPokemon : IScriptSource, IDeepCloneable
|
||||
/// <summary>
|
||||
/// Damages the Pokemon by a certain amount of damage, from a damage source.
|
||||
/// </summary>
|
||||
void Damage(uint damage, DamageSource source, EventBatchId batchId = default);
|
||||
void Damage(uint damage, DamageSource source, EventBatchId batchId = default, bool forceDamage = false);
|
||||
|
||||
/// <summary>
|
||||
/// Forces the Pokémon to faint.
|
||||
@@ -326,7 +326,7 @@ public interface IPokemon : IScriptSource, IDeepCloneable
|
||||
/// Heals the Pokemon by a specific amount. Unless allow_revive is set to true, this will not
|
||||
/// heal if the Pokemon has 0 health. If the amount healed is 0, this will return false.
|
||||
/// </summary>
|
||||
bool Heal(uint heal, bool allowRevive = false);
|
||||
bool Heal(uint heal, bool allowRevive = false, EventBatchId batchId = default, bool forceHeal = false);
|
||||
|
||||
/// <summary>
|
||||
/// Restores all PP of the Pokemon.
|
||||
@@ -943,12 +943,12 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
public bool IsFainted => CurrentHealth == 0;
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Damage(uint damage, DamageSource source, EventBatchId batchId)
|
||||
public void Damage(uint damage, DamageSource source, EventBatchId batchId, bool forceDamage = false)
|
||||
{
|
||||
// If the Pokémon is already fainted, we don't need to do anything.
|
||||
if (IsFainted)
|
||||
return;
|
||||
if (BattleData is not null)
|
||||
if (BattleData is not null && !forceDamage)
|
||||
{
|
||||
var dmg = damage;
|
||||
this.RunScriptHook(script => script.ChangeIncomingDamage(this, source, ref dmg));
|
||||
@@ -1013,7 +1013,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Heal(uint heal, bool allowRevive)
|
||||
public bool Heal(uint heal, bool allowRevive, EventBatchId batchId = default, bool forceHeal = false)
|
||||
{
|
||||
if (IsFainted && !allowRevive)
|
||||
return false;
|
||||
@@ -1023,13 +1023,19 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
heal = maxAmount;
|
||||
if (heal == 0)
|
||||
return false;
|
||||
var prevented = false;
|
||||
this.RunScriptHook(x => x.PreventHeal(this, heal, allowRevive, ref prevented));
|
||||
if (prevented)
|
||||
return false;
|
||||
if (!forceHeal)
|
||||
{
|
||||
var prevented = false;
|
||||
this.RunScriptHook(x => x.PreventHeal(this, heal, allowRevive, ref prevented));
|
||||
if (prevented)
|
||||
return false;
|
||||
}
|
||||
|
||||
var newHealth = CurrentHealth + heal;
|
||||
BattleData?.Battle.EventHook.Invoke(new HealEvent(this, CurrentHealth, newHealth));
|
||||
BattleData?.Battle.EventHook.Invoke(new HealEvent(this, CurrentHealth, newHealth)
|
||||
{
|
||||
BatchId = batchId,
|
||||
});
|
||||
CurrentHealth = newHealth;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user