Implements a bunch more moves
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2025-05-17 17:44:15 +02:00
parent ecabe2fd10
commit a17cb92c5a
62 changed files with 1180 additions and 81 deletions

View File

@@ -1,4 +1,4 @@
using PkmnLib.Dynamic.Models.BattleFlow;
using PkmnLib.Dynamic.BattleFlow;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;

View File

@@ -3,14 +3,45 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "stockpile_effect")]
public class StockpileEffect : Script
{
private IPokemon? _pokemon;
public int StockpileCount { get; set; } = 1;
/// <inheritdoc />
public override void OnAddedToParent(IScriptSource source)
{
if (source is not IPokemon pokemon)
{
throw new InvalidOperationException("StockpileEffect can only be added to a Pokemon.");
}
_pokemon = pokemon;
EventBatchId batchId = new();
pokemon.ChangeStatBoost(Statistic.Defense, 1, true, batchId);
pokemon.ChangeStatBoost(Statistic.SpecialDefense, 1, true, batchId);
StockpileCount = 1;
}
/// <inheritdoc />
public override void Stack()
{
if (StockpileCount < 3)
{
EventBatchId batchId = new();
_pokemon?.ChangeStatBoost(Statistic.Defense, 1, true, batchId);
_pokemon?.ChangeStatBoost(Statistic.SpecialDefense, 1, true, batchId);
StockpileCount++;
}
}
/// <inheritdoc />
public override void OnRemove()
{
if (_pokemon == null)
{
return;
}
EventBatchId batchId = new();
_pokemon.ChangeStatBoost(Statistic.Defense, (sbyte)-StockpileCount, true, batchId);
_pokemon.ChangeStatBoost(Statistic.SpecialDefense, (sbyte)-StockpileCount, true, batchId);
StockpileCount = 0;
}
}

View File

@@ -0,0 +1,24 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "substitute")]
public class SubstituteEffect(uint health) : Script
{
private uint _health = health;
/// <inheritdoc />
public override void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{
if (executingMove.UseMove.HasFlag("ignore-substitute"))
return;
block = true;
var damage = executingMove.GetHitData(target, hitIndex).Damage;
if (damage >= _health)
{
executingMove.Battle.EventHook.Invoke(new DialogEvent("substitute_broken"));
RemoveSelf();
return;
}
_health -= damage;
}
}

View File

@@ -0,0 +1,34 @@
using PkmnLib.Static.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "taunt")]
public class TauntEffect(int turns) : Script
{
private int _turns = turns;
/// <inheritdoc />
public override void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
{
if (choice.ChosenMove.MoveData.Category == MoveCategory.Status)
{
prevent = true;
}
}
/// <inheritdoc />
public override void FailMove(IExecutingMove move, ref bool fail)
{
if (move.ChosenMove.MoveData.Category == MoveCategory.Status)
{
fail = true;
}
}
public override void OnEndTurn(IBattle battle)
{
_turns--;
if (_turns <= 0)
RemoveSelf();
}
}

View File

@@ -0,0 +1,26 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "telekinesis")]
public class TelekinesisEffect : Script
{
/// <inheritdoc />
public override void ChangeIncomingAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
ref int modifiedAccuracy)
{
modifiedAccuracy = 255;
}
/// <inheritdoc />
public override void IsFloating(IPokemon pokemon, ref bool isFloating)
{
isFloating = true;
}
/// <inheritdoc />
public override void ChangeIncomingEffectiveness(IExecutingMove executingMove, IPokemon target, byte hitIndex,
ref float effectiveness)
{
if (executingMove.UseMove.MoveType.Name == "ground")
effectiveness = 0;
}
}

View File

@@ -0,0 +1,23 @@
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Move, "thousand_arrows")]
public class ThousandArrowsEffect : Script
{
/// <inheritdoc />
public override void IsFloating(IPokemon pokemon, ref bool isFloating)
{
isFloating = false;
}
/// <inheritdoc />
public override void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
IList<TypeIdentifier> types)
{
if (executingMove.UseMove.MoveType.Name == "ground")
{
types.RemoveAll(x => x.Name == "flying");
}
}
}

View File

@@ -0,0 +1,11 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "thousand_waves")]
public class ThousandWavesEffect : Script
{
/// <inheritdoc />
public override void PreventSelfSwitch(ISwitchChoice choice, ref bool prevent) => prevent = true;
/// <inheritdoc />
public override void PreventSelfRunAway(IFleeChoice choice, ref bool prevent) => prevent = true;
}

View File

@@ -0,0 +1,29 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "throat_chop")]
public class ThroatChopEffect : Script
{
private int _turns = 3;
/// <inheritdoc />
public override void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
{
if (choice.ChosenMove.MoveData.HasFlag("sound"))
prevent = true;
}
/// <inheritdoc />
public override void FailMove(IExecutingMove move, ref bool fail)
{
if (move.UseMove.HasFlag("sound"))
fail = true;
}
/// <inheritdoc />
public override void OnEndTurn(IBattle battle)
{
_turns--;
if (_turns <= 0)
RemoveSelf();
}
}

View File

@@ -0,0 +1,25 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "torment")]
public class TormentEffect(IMoveChoice? moveChoice) : Script
{
private IMoveChoice? _moveChoice = moveChoice;
/// <inheritdoc />
public override void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
{
if (_moveChoice == null)
return;
if (choice.ChosenMove.MoveData == _moveChoice.ChosenMove.MoveData)
{
prevent = true;
}
}
/// <inheritdoc />
public override void OnBeforeTurnStart(ITurnChoice choice)
{
if (choice is IMoveChoice moveChoice)
_moveChoice = moveChoice;
}
}