Implements 11 more moves

This commit is contained in:
2025-03-07 11:50:59 +01:00
parent 61a69eecb8
commit a3a9f1800a
17 changed files with 311 additions and 13 deletions

View File

@@ -0,0 +1,27 @@
using System.Collections.Generic;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public abstract class BaseChargeMove<TVolatile> : Script where TVolatile : Script
{
public abstract TVolatile CreateVolatile(IPokemon user);
public override void PreventMove(IExecutingMove move, ref bool prevent)
{
if (move.User.Volatile.Contains<TVolatile>())
return;
move.User.Volatile.Add(CreateVolatile(move.User));
move.User.BattleData?.Battle.EventHook.Invoke(new DialogEvent("began_charging", new Dictionary<string, object>()
{
{ "user", move.User },
}));
prevent = true;
}
/// <inheritdoc />
public override void OnBeforeMove(IExecutingMove move)
{
move.User.Volatile.Remove(ScriptUtils.ResolveName<TVolatile>());
}
}

View File

@@ -0,0 +1,11 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "force_critical")]
public class ForceCritical : Script
{
/// <inheritdoc />
public override void ChangeCriticalStage(IExecutingMove move, IPokemon target, byte hit, ref byte stage)
{
stage = 100;
}
}

View File

@@ -0,0 +1,23 @@
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "freeze_shock")]
public class FreezeShock : BaseChargeMove<FreezeShockEffect>
{
/// <inheritdoc />
public override FreezeShockEffect CreateVolatile(IPokemon user) => new(user);
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var battleData = target.BattleData;
if (battleData == null)
return;
if (battleData.Battle.Random.EffectChance(30, move, target, hit))
{
target.SetStatus("paralyzed");
}
}
}

View File

@@ -0,0 +1,14 @@
using System;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "frustration")]
public class Frustration : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
{
var friendship = move.User.Happiness;
basePower = Math.Min((byte)1, (byte)((255 - friendship) * 2 / 5));
}
}

View File

@@ -0,0 +1,18 @@
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "fury_cutter")]
public class FuryCutter : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
{
var userEffect = move.User.Volatile.Get<FuryCutterEffect>();
if (userEffect == null)
return;
userEffect.TurnCount++;
basePower = (byte)(basePower * (userEffect.TurnCount + 1));
}
}

View File

@@ -0,0 +1,26 @@
using System.Linq;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "fusion_bolt")]
public class FusionBolt : Script
{
/// <inheritdoc />
public override void ChangeDamageModifier(IExecutingMove move, IPokemon target, byte hit, ref float modifier)
{
var battleData = target.BattleData;
if (battleData == null)
return;
// Grab the choices for the current turn, that have been executed before this move.
var choice = battleData.Battle.PreviousTurnChoices.Last().TakeWhile(x => x != move.MoveChoice)
// Of these, find the move choice that used Fusion Flare.
.OfType<MoveChoice>().FirstOrDefault(x => x.ChosenMove.MoveData.Name == "fusion_flare");
// If Fusion Flare was used, Fusion Bolt's power is doubled.
if (choice != null)
{
modifier *= 2;
}
}
}

View File

@@ -0,0 +1,26 @@
using System.Linq;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "fusion_flare")]
public class FusionFlare : Script
{
/// <inheritdoc />
public override void ChangeDamageModifier(IExecutingMove move, IPokemon target, byte hit, ref float modifier)
{
var battleData = target.BattleData;
if (battleData == null)
return;
// Grab the choices for the current turn, that have been executed before this move.
var choice = battleData.Battle.PreviousTurnChoices.Last().TakeWhile(x => x != move.MoveChoice)
// Of these, find the move choice that used Fusion Bolt.
.OfType<MoveChoice>().FirstOrDefault(x => x.ChosenMove.MoveData.Name == "fusion_bolt");
// If Fusion Bolt was used, Fusion Flare's power is doubled.
if (choice != null)
{
modifier *= 2;
}
}
}

View File

@@ -0,0 +1,20 @@
using System;
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "future_sight")]
public class FutureSight : Script
{
/// <inheritdoc />
public override void StopBeforeMove(IExecutingMove move, ref bool prevent)
{
var battleData = move.User.BattleData;
if (battleData == null)
return;
battleData.Battle.Volatile.Add(new FutureSightEffect(move.MoveChoice));
prevent = true;
}
}

View File

@@ -0,0 +1,11 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "gastro_acid")]
public class GastroAcid : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
target.SuppressAbility();
}
}

View File

@@ -0,0 +1,22 @@
using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
public abstract class BaseChargeEffect : Script
{
private readonly IPokemon _owner;
private readonly string _moveName;
public BaseChargeEffect(IPokemon owner, string moveName)
{
_owner = owner;
_moveName = moveName;
}
/// <inheritdoc />
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
{
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
choice = TurnChoiceHelper.CreateMoveChoice(_owner, _moveName, opposingSideIndex, position);
}
}

View File

@@ -0,0 +1,4 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "freeze_shock")]
public class FreezeShockEffect(IPokemon owner) : BaseChargeEffect(owner, "freeze_shock");

View File

@@ -0,0 +1,14 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "fury_cutter")]
public class FuryCutterEffect : Script
{
public int TurnCount { get; set; }
/// <inheritdoc />
public override void OnBeforeMove(IExecutingMove move)
{
if (move.UseMove.Name != "fury_cutter")
RemoveSelf();
}
}

View File

@@ -0,0 +1,35 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "future_sight")]
public class FutureSightEffect : Script
{
private int _turnsLeft = 3;
private readonly IMoveChoice _moveChoice;
public FutureSightEffect(IMoveChoice moveChoice)
{
_moveChoice = moveChoice;
}
/// <inheritdoc />
public override void OnEndTurn(IBattle battle)
{
_turnsLeft -= 1;
if (_turnsLeft <= 0)
{
var target = battle.GetPokemon(_moveChoice.TargetSide, _moveChoice.TargetPosition);
if (target is not { IsUsable: true })
{
battle.EventHook.Invoke(new DialogEvent("move_failed"));
return;
}
var damageCalculator = battle.Library.DamageCalculator;
var executingMove = new ExecutingMoveImpl([target], 1, _moveChoice.ChosenMove,
_moveChoice.ChosenMove.MoveData, _moveChoice);
var hitData = executingMove.GetHitData(target, 0);
var damage = damageCalculator.GetDamage(executingMove, target, 1, hitData);
target.Damage(damage, DamageSource.Misc);
}
}
}