More move scripts
This commit is contained in:
@@ -172,6 +172,7 @@ public class BattleImpl : ScriptSource, IBattle
|
||||
CanFlee = canFlee;
|
||||
NumberOfSides = numberOfSides;
|
||||
PositionsPerSide = positionsPerSide;
|
||||
Volatile = new ScriptSet(this);
|
||||
var sides = new IBattleSide[numberOfSides];
|
||||
for (byte i = 0; i < numberOfSides; i++)
|
||||
sides[i] = new BattleSideImpl(i, positionsPerSide, this);
|
||||
@@ -399,7 +400,7 @@ public class BattleImpl : ScriptSource, IBattle
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IScriptSet Volatile { get; } = new ScriptSet();
|
||||
public IScriptSet Volatile { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public StringKey? WeatherName => WeatherScript.Script?.Name;
|
||||
|
||||
@@ -132,6 +132,9 @@ public class BattleChoiceQueue : IDeepCloneable
|
||||
public ITurnChoice? FirstOrDefault(Func<ITurnChoice, bool> predicate) =>
|
||||
_choices.Skip(_currentIndex).WhereNotNull().FirstOrDefault(predicate);
|
||||
|
||||
public IEnumerable<ITurnChoice> Where(Func<ITurnChoice, bool> predicate) =>
|
||||
_choices.Skip(_currentIndex).WhereNotNull().Where(predicate);
|
||||
|
||||
/// <summary>
|
||||
/// Removes a choice from the queue.
|
||||
/// </summary>
|
||||
|
||||
@@ -174,7 +174,7 @@ public class BattleSideImpl : ScriptSource, IBattleSide
|
||||
_fillablePositions[i] = true;
|
||||
}
|
||||
Battle = battle;
|
||||
VolatileScripts = new ScriptSet();
|
||||
VolatileScripts = new ScriptSet(this);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -55,6 +55,7 @@ public class MoveChoice : TurnChoice, IMoveChoice
|
||||
ChosenMove = usedMove;
|
||||
TargetSide = targetSide;
|
||||
TargetPosition = targetPosition;
|
||||
Volatile = new ScriptSet(this);
|
||||
|
||||
var secondaryEffect = usedMove.MoveData.SecondaryEffect;
|
||||
if (secondaryEffect != null)
|
||||
@@ -86,7 +87,7 @@ public class MoveChoice : TurnChoice, IMoveChoice
|
||||
public Dictionary<StringKey, object?>? AdditionalData { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IScriptSet Volatile { get; } = new ScriptSet();
|
||||
public IScriptSet Volatile { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int ScriptCount => 2 + User.ScriptCount;
|
||||
|
||||
@@ -37,6 +37,11 @@ public enum MoveLearnMethod
|
||||
/// The move is learned when the Pokémon changes form.
|
||||
/// </summary>
|
||||
FormChange,
|
||||
|
||||
/// <summary>
|
||||
/// The move is learned by using a move sketch.
|
||||
/// </summary>
|
||||
Sketch,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -487,6 +487,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
WeightInKg = form.Weight;
|
||||
HeightInMeters = form.Height;
|
||||
Happiness = species.BaseHappiness;
|
||||
Volatile = new ScriptSet(this);
|
||||
if (!library.StaticLibrary.Natures.TryGet(natureName, out var nature))
|
||||
throw new KeyNotFoundException($"Nature {natureName} not found.");
|
||||
Nature = nature;
|
||||
@@ -532,6 +533,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
AbilityIndex = form.FindAbilityIndex(ability) ??
|
||||
throw new KeyNotFoundException(
|
||||
$"Ability {ability.Name} not found on species {species.Name} form {form.Name}.");
|
||||
Volatile = new ScriptSet(this);
|
||||
_learnedMoves = serializedPokemon.Moves.Select(move =>
|
||||
{
|
||||
if (move == null)
|
||||
@@ -736,7 +738,7 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
public ScriptContainer StatusScript { get; } = new();
|
||||
|
||||
/// <inheritdoc />
|
||||
public IScriptSet Volatile { get; } = new ScriptSet();
|
||||
public IScriptSet Volatile { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool HasHeldItem(StringKey itemName) => HeldItem?.Name == itemName;
|
||||
@@ -1097,6 +1099,11 @@ public class PokemonImpl : ScriptSource, IPokemon
|
||||
{
|
||||
if (!Library.ScriptResolver.TryResolve(ScriptCategory.Status, status, null, out var statusScript))
|
||||
throw new KeyNotFoundException($"Status script {status} not found");
|
||||
var preventStatus = false;
|
||||
this.RunScriptHook(script => script.PreventStatusChange(this, status, ref preventStatus));
|
||||
if (preventStatus)
|
||||
return false;
|
||||
|
||||
StatusScript.Set(statusScript);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user