Imlements baneful bunker, data fixes

This commit is contained in:
2025-01-10 12:55:25 +01:00
parent 6434f9925c
commit 92ab67ddf8
12 changed files with 209 additions and 17 deletions

View File

@@ -0,0 +1,17 @@
using PkmnLib.Dynamic.Models;
using PkmnLib.Static.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
public class BanefulBunkerEffect : ProtectionEffectScript
{
/// <inheritdoc />
public override void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{
base.BlockIncomingHit(executingMove, target, hitIndex, ref block);
if (executingMove.UseMove.Category != MoveCategory.Status && executingMove.UseMove.HasFlag("contact"))
{
executingMove.User.SetStatus("poisoned");
}
}
}

View File

@@ -0,0 +1,28 @@
using PkmnLib.Dynamic.Models;
using PkmnLib.Dynamic.ScriptHandling;
using PkmnLib.Static.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
public abstract class ProtectionEffectScript : Script
{
/// <inheritdoc />
public override void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{
if (target.BattleData == null)
return;
var originalTarget = executingMove.MoveChoice.TargetPosition;
var targetPosition = target.BattleData.Position;
// We only want to block the hit if it's explicitly targeting the Pokemon.
if (targetPosition != originalTarget)
return;
if (executingMove.UseMove.Target is MoveTarget.All or MoveTarget.SelfUse or MoveTarget.AllAlly
or MoveTarget.AllAdjacent)
return;
block = true;
}
}

View File

@@ -0,0 +1,32 @@
using PkmnLib.Dynamic.Models;
using PkmnLib.Dynamic.Models.Choices;
using PkmnLib.Dynamic.ScriptHandling;
using PkmnLib.Dynamic.ScriptHandling.Registry;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
/// <summary>
/// Attached script for <see cref="ProtectionEffectScript"/> to keep track of the consecutive turns of using Protect,
/// or protect-like moves.
/// </summary>
[Script(ScriptCategory.Pokemon, "protection_failure")]
public class ProtectionFailureScript : Script
{
public int ProtectTurns { get; set; }
public bool UsedProtect { get; set; }
/// <inheritdoc />
public override void OnBeforeTurnStart(ITurnChoice choice)
{
UsedProtect = false;
}
/// <inheritdoc />
public override void OnEndTurn(IBattle battle)
{
if (!UsedProtect)
{
RemoveSelf();
}
}
}