Adds more move scripts

This commit is contained in:
Deukhoofd 2025-03-07 12:07:57 +01:00
parent a3a9f1800a
commit 3571b2130e
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
16 changed files with 193 additions and 21 deletions

View File

@ -46,4 +46,17 @@ public readonly record struct StringKey
/// <inheritdoc cref="Equals(StringKey)"/>
public static bool operator !=(StringKey left, string right) => !(left == right);
/// <inheritdoc cref="Equals(StringKey)"/>
public static bool operator ==(StringKey? left, string? right) =>
(left is null && right is null) || (right != null && (left?.Equals(right) ?? false));
/// <inheritdoc cref="Equals(StringKey)"/>
public static bool operator !=(StringKey? left, string? right) => !(left == right);
/// <inheritdoc cref="Equals(StringKey)"/>
public static bool operator ==(StringKey? left, StringKey right) => left?.Equals(right) ?? false;
/// <inheritdoc cref="Equals(StringKey)"/>
public static bool operator !=(StringKey? left, StringKey right) => !(left == right);
}

View File

@ -4346,7 +4346,10 @@
"flags": [
"snatch",
"ignore-substitute"
]
],
"effect": {
"name": "gear_up"
}
},
{
"name": "genesis_supernova",
@ -4357,7 +4360,10 @@
"priority": 0,
"target": "Any",
"category": "special",
"flags": []
"flags": [],
"effect": {
"name": "genesis_supernova"
}
},
{
"name": "geomancy",
@ -4371,7 +4377,10 @@
"flags": [
"charge",
"nonskybattle"
]
],
"effect": {
"name": "geomancy"
}
},
{
"name": "giga_drain",
@ -4386,7 +4395,13 @@
"protect",
"mirror",
"heal"
]
],
"effect": {
"name": "drain",
"parameters": {
"drain_modifier": 0.5
}
}
},
{
"name": "giga_impact",
@ -4402,7 +4417,10 @@
"recharge",
"protect",
"mirror"
]
],
"effect": {
"name": "requires_recharge"
}
},
{
"name": "gigavolt_havoc__physical",
@ -4438,7 +4456,13 @@
"flags": [
"protect",
"mirror"
]
],
"effect": {
"name": "change_target_speed",
"parameters": {
"amount": -1
}
}
},
{
"name": "glare",
@ -4453,7 +4477,13 @@
"protect",
"reflectable",
"mirror"
]
],
"effect": {
"name": "set_status",
"parameters": {
"status": "paralyzed"
}
}
},
{
"name": "grass_knot",
@ -4469,7 +4499,10 @@
"protect",
"mirror",
"nonskybattle"
]
],
"effect": {
"name": "grass_knot"
}
},
{
"name": "grass_pledge",
@ -4484,7 +4517,10 @@
"protect",
"mirror",
"nonskybattle"
]
],
"effect": {
"name": "grass_pledge"
}
},
{
"name": "grass_whistle",
@ -4501,7 +4537,13 @@
"mirror",
"sound",
"ignore-substitute"
]
],
"effect": {
"name": "set_status",
"parameters": {
"status": "sleep"
}
}
},
{
"name": "grassy_terrain",
@ -4514,7 +4556,10 @@
"category": "status",
"flags": [
"nonskybattle"
]
],
"effect": {
"name": "grassy_terrain"
}
},
{
"name": "gravity",

View File

@ -1,8 +1,9 @@
using System.Collections.Generic;
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public abstract class BaseChargeMove<TVolatile> : Script where TVolatile : Script
public abstract class BaseChargeMove<TVolatile> : Script where TVolatile : RequireChargeEffect
{
public abstract TVolatile CreateVolatile(IPokemon user);

View File

@ -7,6 +7,6 @@ public class ElectricTerrain : Script
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var battleData = move.User.BattleData;
battleData?.Battle.SetTerrain(ScriptUtils.ResolveName<ElectricTerrain>());
battleData?.Battle.SetTerrain(ScriptUtils.ResolveName<Terrain.ElectricTerrain>());
}
}

View File

@ -3,10 +3,10 @@ using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "freeze_shock")]
public class FreezeShock : BaseChargeMove<FreezeShockEffect>
public class FreezeShock : BaseChargeMove<RequireChargeEffect>
{
/// <inheritdoc />
public override FreezeShockEffect CreateVolatile(IPokemon user) => new(user);
public override RequireChargeEffect CreateVolatile(IPokemon user) => new(user, "freeze_shock");
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)

View File

@ -0,0 +1,27 @@
using PkmnLib.Static;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "gear_up")]
public class GearUp : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var battleData = move.User.BattleData;
if (battleData == null)
return;
var side = battleData.Battle.Sides[battleData.SideIndex];
EventBatchId evtBatchId = new();
foreach (var pokemon in side.Pokemon.WhereNotNull())
{
var ability = pokemon.ActiveAbility?.Name;
if (ability != "plus" && ability != "minus")
continue;
pokemon.ChangeStatBoost(Statistic.Attack, 1, pokemon == move.User, evtBatchId);
pokemon.ChangeStatBoost(Statistic.SpecialAttack, 1, pokemon == move.User, evtBatchId);
}
}
}

View File

@ -0,0 +1,17 @@
using PkmnLib.Plugin.Gen7.Scripts.Terrain;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "genesis_supernova")]
public class GenesisSupernova : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var battleData = move.User.BattleData;
if (battleData == null)
return;
battleData.Battle.SetTerrain(ScriptUtils.ResolveName<PsychicTerrain>());
}
}

View File

@ -0,0 +1,19 @@
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
public class Geomancy : BaseChargeMove<RequireChargeEffect>
{
/// <inheritdoc />
public override RequireChargeEffect CreateVolatile(IPokemon user) => new(user, "geomancy");
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
EventBatchId eventBatchId = new();
move.User.ChangeStatBoost(Statistic.SpecialAttack, 2, true, eventBatchId);
move.User.ChangeStatBoost(Statistic.SpecialDefense, 2, true, eventBatchId);
move.User.ChangeStatBoost(Statistic.Speed, 2, true, eventBatchId);
}
}

View File

@ -0,0 +1,20 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "grass_knot")]
public class GrassKnot : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
{
var targetWeight = target.WeightInKg;
basePower = targetWeight switch
{
< 10 => 20,
< 25 => 40,
< 50 => 60,
< 100 => 80,
< 200 => 100,
_ => 120,
};
}
}

View File

@ -0,0 +1,7 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "grass_pledge")]
public class GrassPledge : Script
{
// TODO: pledge moves
}

View File

@ -0,0 +1,14 @@
using PkmnLib.Plugin.Gen7.Scripts.Terrain;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "grassy_terrain")]
public class GrassyTerrain : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var battleData = move.User.BattleData;
battleData?.Battle.SetTerrain(ScriptUtils.ResolveName<Terrain.GrassyTerrain>());
}
}

View File

@ -1,13 +1,14 @@
using PkmnLib.Plugin.Gen7.Scripts.Utils;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
public abstract class BaseChargeEffect : Script
{
private readonly IPokemon _owner;
private readonly string _moveName;
private readonly StringKey _moveName;
public BaseChargeEffect(IPokemon owner, string moveName)
public BaseChargeEffect(IPokemon owner, StringKey moveName)
{
_owner = owner;
_moveName = moveName;

View File

@ -1,4 +1,5 @@
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "freeze_shock")]
public class FreezeShockEffect(IPokemon owner) : BaseChargeEffect(owner, "freeze_shock");
public class RequireChargeEffect(IPokemon owner, StringKey moveName) : BaseChargeEffect(owner, moveName);

View File

@ -3,5 +3,5 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Terrain;
[Script(ScriptCategory.Terrain, "electric_terrain")]
public class ElectricTerrain : Script
{
// TODO: Implement Electric Terrain
// TODO: Implement Terrain
}

View File

@ -3,5 +3,5 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Terrain;
[Script(ScriptCategory.Terrain, "grassy_terrain")]
public class GrassyTerrain : Script
{
// TODO: Implement Electric Terrain
// TODO: Implement Terrain
}

View File

@ -0,0 +1,7 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Terrain;
[Script(ScriptCategory.Terrain, "psychic_terrain")]
public class PsychicTerrain : Script
{
// TODO: Implement Terrain
}