This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using PkmnLib.Dynamic.Models.BattleFlow;
|
||||
using PkmnLib.Dynamic.BattleFlow;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
34
Plugins/PkmnLib.Plugin.Gen7/Scripts/Pokemon/TauntEffect.cs
Normal file
34
Plugins/PkmnLib.Plugin.Gen7/Scripts/Pokemon/TauntEffect.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
25
Plugins/PkmnLib.Plugin.Gen7/Scripts/Pokemon/TormentEffect.cs
Normal file
25
Plugins/PkmnLib.Plugin.Gen7/Scripts/Pokemon/TormentEffect.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user