Imlements baneful bunker, data fixes
This commit is contained in:
@@ -325,6 +325,7 @@ public class BattleImpl : ScriptSource, IBattle
|
||||
{
|
||||
_weatherScript.Clear();
|
||||
}
|
||||
// TODO: Trigger weather change script hooks
|
||||
}
|
||||
|
||||
private IScriptSet Volatile { get; } = new ScriptSet();
|
||||
|
||||
@@ -44,8 +44,7 @@ internal static class MoveTurnExecutor
|
||||
return;
|
||||
}
|
||||
|
||||
var executingMove = new ExecutingMoveImpl(targets, numberOfHits, moveChoice.User, chosenMove, moveData,
|
||||
moveChoice.Script);
|
||||
var executingMove = new ExecutingMoveImpl(targets, numberOfHits, chosenMove, moveData, moveChoice);
|
||||
|
||||
var prevented = false;
|
||||
executingMove.RunScriptHook(x => x.PreventMove(executingMove, ref prevented));
|
||||
@@ -150,7 +149,11 @@ internal static class MoveTurnExecutor
|
||||
battle.EventHook.Invoke(new MoveMissEvent(executingMove));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
var blockIncomingHit = false;
|
||||
target.RunScriptHook(x => x.BlockIncomingHit(executingMove, target, hitIndex, ref blockIncomingHit));
|
||||
if (blockIncomingHit)
|
||||
break;
|
||||
if (useMove.Category == MoveCategory.Status)
|
||||
{
|
||||
var secondaryEffect = useMove.SecondaryEffect;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using PkmnLib.Dynamic.Models.Choices;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Static;
|
||||
using PkmnLib.Static.Moves;
|
||||
@@ -133,6 +134,11 @@ public interface IExecutingMove : IScriptSource
|
||||
/// Gets the targets of this move.
|
||||
/// </summary>
|
||||
IReadOnlyList<IPokemon?> Targets { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The underlying move choice.
|
||||
/// </summary>
|
||||
IMoveChoice MoveChoice { get; }
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IExecutingMove"/>
|
||||
@@ -142,15 +148,14 @@ public class ExecutingMoveImpl : ScriptSource, IExecutingMove
|
||||
private readonly IHitData[] _hits;
|
||||
|
||||
/// <inheritdoc cref="ExecutingMoveImpl"/>
|
||||
public ExecutingMoveImpl(IReadOnlyList<IPokemon?> targets, byte numberOfHits, IPokemon user, ILearnedMove chosenMove,
|
||||
IMoveData useMove, ScriptContainer script)
|
||||
public ExecutingMoveImpl(IReadOnlyList<IPokemon?> targets, byte numberOfHits, ILearnedMove chosenMove,
|
||||
IMoveData useMove, IMoveChoice moveChoice)
|
||||
{
|
||||
_targets = targets;
|
||||
NumberOfHits = numberOfHits;
|
||||
User = user;
|
||||
ChosenMove = chosenMove;
|
||||
UseMove = useMove;
|
||||
Script = script;
|
||||
MoveChoice = moveChoice;
|
||||
|
||||
var totalHits = targets.Count * numberOfHits;
|
||||
_hits = new IHitData[totalHits];
|
||||
@@ -167,7 +172,7 @@ public class ExecutingMoveImpl : ScriptSource, IExecutingMove
|
||||
public byte NumberOfHits { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IPokemon User { get; }
|
||||
public IPokemon User => MoveChoice.User;
|
||||
|
||||
/// <inheritdoc />
|
||||
public ILearnedMove ChosenMove { get; }
|
||||
@@ -176,7 +181,7 @@ public class ExecutingMoveImpl : ScriptSource, IExecutingMove
|
||||
public IMoveData UseMove { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public ScriptContainer Script { get; }
|
||||
public ScriptContainer Script => MoveChoice.Script;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IHitData GetHitData(IPokemon target, byte hit)
|
||||
@@ -215,6 +220,9 @@ public class ExecutingMoveImpl : ScriptSource, IExecutingMove
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyList<IPokemon?> Targets => _targets.ToList();
|
||||
|
||||
/// <inheritdoc />
|
||||
public IMoveChoice MoveChoice { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int ScriptCount => 1 + User.ScriptCount;
|
||||
|
||||
|
||||
@@ -313,6 +313,10 @@ public interface IPokemon : IScriptSource, IDeepCloneable
|
||||
/// </summary>
|
||||
void LearnMove(StringKey moveName, MoveLearnMethod method, byte index);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a non-volatile status to the Pokemon.
|
||||
/// </summary>
|
||||
void SetStatus(StringKey status);
|
||||
/// <summary>
|
||||
/// Removes the current non-volatile status from the Pokemon.
|
||||
/// </summary>
|
||||
@@ -926,6 +930,14 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
_learnedMoves[index] = new LearnedMoveImpl(move, method);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SetStatus(StringKey status)
|
||||
{
|
||||
if (!Library.ScriptResolver.TryResolve(ScriptCategory.Status, status, null, out var statusScript))
|
||||
throw new KeyNotFoundException($"Status script {status} not found");
|
||||
StatusScript.Set(statusScript);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ClearStatus() => StatusScript.Clear();
|
||||
|
||||
|
||||
@@ -497,4 +497,8 @@ public abstract class Script : IDeepCloneable
|
||||
public virtual void ChangeCatchRateBonus(IPokemon pokemon, IItem pokeball, ref byte modifier)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user