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();
}
}