Implements several more moves

This commit is contained in:
2025-01-10 13:45:29 +01:00
parent 0ad692a921
commit ecdc9c7654
12 changed files with 206 additions and 16 deletions

View File

@@ -0,0 +1,32 @@
using System.Collections.Generic;
using PkmnLib.Dynamic.Events;
using PkmnLib.Dynamic.Models;
using PkmnLib.Dynamic.Models.Choices;
using PkmnLib.Dynamic.ScriptHandling;
using PkmnLib.Dynamic.ScriptHandling.Registry;
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "beak_blast")]
public class BeakBlast : Script
{
/// <inheritdoc />
public override void OnBeforeTurnStart(ITurnChoice choice)
{
var battleData = choice.User.BattleData;
if (battleData == null)
return;
choice.User.Volatile.Add(new BeakBlastEffect());
battleData.Battle.EventHook.Invoke(new DialogEvent("beak_blast_charge", new Dictionary<string, object>()
{
{ "user", choice.User }
}));
}
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
move.User.Volatile.Remove(ScriptUtils.ResolveName<BeakBlastEffect>());
}
}

View File

@@ -0,0 +1,45 @@
using System.Collections.Generic;
using System.Linq;
using PkmnLib.Dynamic.Models;
using PkmnLib.Dynamic.Models.Choices;
using PkmnLib.Dynamic.ScriptHandling;
using PkmnLib.Dynamic.ScriptHandling.Registry;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "beat_up")]
public class BeatUp : Script
{
private IPokemon[]? _relevantPartyMembers;
private static IEnumerable<IPokemon> GetRelevantPartyMembers(IPokemon user)
{
var battleData = user.BattleData;
if (battleData == null)
return [];
var party = battleData.Battle.Parties.FirstOrDefault(x => x.Party.Contains(user));
return party?.Party.WhereNotNull().Where(x => x.IsUsable && x.StatusScript.IsEmpty) ?? [];
}
/// <inheritdoc />
public override void ChangeNumberOfHits(IMoveChoice choice, ref byte numberOfHits)
{
var relevantPartyMembers = _relevantPartyMembers ??= GetRelevantPartyMembers(choice.User).ToArray();
numberOfHits = (byte)relevantPartyMembers.Count();
if (numberOfHits == 0)
numberOfHits = 1;
}
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
{
var relevantPartyMembers = _relevantPartyMembers ??= GetRelevantPartyMembers(move.User).ToArray();
var hittingPokemon = relevantPartyMembers.ElementAtOrDefault(hit);
if (hittingPokemon == null)
return;
basePower = (byte)(hittingPokemon.Form.BaseStats.Attack / 10 + 5);
}
}

View File

@@ -0,0 +1,20 @@
using System.Linq;
using PkmnLib.Dynamic.Models.Choices;
using PkmnLib.Dynamic.ScriptHandling;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Belch : Script
{
/// <inheritdoc />
public override void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
{
var battleData = choice.User.BattleData;
if (battleData == null)
return;
if (battleData.ConsumedItems.All(x => x.Category != ItemCategory.Berry))
prevent = true;
}
}

View File

@@ -0,0 +1,26 @@
using PkmnLib.Dynamic.Events;
using PkmnLib.Dynamic.Models;
using PkmnLib.Dynamic.ScriptHandling;
using PkmnLib.Dynamic.ScriptHandling.Registry;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "belly_drum")]
public class BellyDrum : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var maxHealthHalved = target.BoostedStats.Hp / 2;
if (target.CurrentHealth <= maxHealthHalved)
{
move.GetHitData(target, hit).Fail();
return;
}
target.Damage(maxHealthHalved, DamageSource.Misc);
// Raising the user's Attack by 12 stages should always set it to +6.
target.ChangeStatBoost(Statistic.Attack, 12, true);
}
}

View File

@@ -0,0 +1,18 @@
using PkmnLib.Dynamic.Models;
using PkmnLib.Dynamic.ScriptHandling;
using PkmnLib.Dynamic.ScriptHandling.Registry;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "beak_blast_effect")]
public class BeakBlastEffect : Script
{
/// <inheritdoc />
public override void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
{
if (move.UseMove.HasFlag("contact"))
{
move.User.SetStatus("burned");
}
}
}

View File

@@ -12,15 +12,7 @@ public abstract class ProtectionEffectScript : Script
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)
if (!executingMove.UseMove.HasFlag("protect"))
return;
block = true;

View File

@@ -0,0 +1,10 @@
using PkmnLib.Dynamic.ScriptHandling;
using PkmnLib.Dynamic.ScriptHandling.Registry;
namespace PkmnLib.Plugin.Gen7.Scripts.Status;
[Script(ScriptCategory.Status, "burned")]
public class Burned : Script
{
// TODO: Implement the Burned status effect.
}