Finishes the last few moves
All checks were successful
Build / Build (push) Successful in 49s

This commit is contained in:
2025-05-18 12:20:21 +02:00
parent 3a9123b5ba
commit 9ff4745c0a
19 changed files with 585 additions and 27 deletions

View File

@@ -0,0 +1,18 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "volt_tackle")]
public class VoltTackle : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var hitData = move.GetHitData(target, hit);
var recoilDamage = (uint)(hitData.Damage * (1f / 3f));
move.User.Damage(recoilDamage, DamageSource.Misc);
if (move.Battle.Random.EffectChance(10, move, target, hit))
{
target.SetStatus(ScriptUtils.ResolveName<Status.Paralyzed>());
}
}
}

View File

@@ -0,0 +1,26 @@
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "wake_up_slap")]
public class WakeUpSlap : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
if (target.HasStatus(ScriptUtils.ResolveName<Status.Sleep>()))
{
basePower = basePower.MultiplyOrMax(2);
}
}
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
// Wake up the target if it is asleep
if (target.HasStatus(ScriptUtils.ResolveName<Status.Sleep>()))
{
target.ClearStatus();
}
}
}

View File

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

View File

@@ -0,0 +1,17 @@
using PkmnLib.Plugin.Gen7.Scripts.Battle;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "water_sport")]
public class WaterSport : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var effect = move.Battle.Volatile.Add(new WaterSportEffect());
if (effect?.Script is WaterSportEffect waterSportEffect)
{
waterSportEffect.Placers.Add(move.User);
}
}
}

View File

@@ -0,0 +1,39 @@
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "weather_ball")]
public class WeatherBall : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
if (move.Battle.WeatherName is not null)
{
basePower = basePower.MultiplyOrMax(2);
}
}
/// <inheritdoc />
public override void ChangeMoveType(IExecutingMove move, IPokemon target, byte hit,
ref TypeIdentifier? typeIdentifier)
{
var weather = move.Battle.WeatherName;
var typeLibrary = move.Battle.Library.StaticLibrary.Types;
if (weather is null)
return;
if (weather == ScriptUtils.ResolveName<Weather.Sunny>() &&
typeLibrary.TryGetTypeIdentifier("fire", out var fireType))
typeIdentifier = fireType;
else if (weather == ScriptUtils.ResolveName<Weather.Rain>() &&
typeLibrary.TryGetTypeIdentifier("water", out var waterType))
typeIdentifier = waterType;
else if (weather == ScriptUtils.ResolveName<Weather.Hail>() &&
typeLibrary.TryGetTypeIdentifier("ice", out var iceType))
typeIdentifier = iceType;
else if (weather == ScriptUtils.ResolveName<Weather.Sandstorm>() &&
typeLibrary.TryGetTypeIdentifier("rock", out var rockType))
typeIdentifier = rockType;
}
}

View File

@@ -0,0 +1,28 @@
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "whirlpool")]
public class Whirlpool : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var userVolatile = move.User.Volatile.Add(new WhirlpoolEffect());
if (userVolatile?.Script is WhirlpoolEffect whirlpoolEffect)
{
var turns = move.Battle.Random.GetInt(4, 6);
var damagePercent = 0.125f;
var parameters = new Dictionary<StringKey, object?>
{
{ "number_of_turns", turns },
{ "damage_percent", damagePercent },
};
move.RunScriptHook(x => x.CustomTrigger(CustomTriggers.Whirlpool, parameters));
turns = parameters.GetValueOrDefault("number_of_turns", turns) as int? ?? turns;
damagePercent = parameters.GetValueOrDefault("damage_percent", damagePercent) as float? ?? damagePercent;
whirlpoolEffect.AddTargetedPokemon(target, turns, damagePercent);
}
}
}

View File

@@ -0,0 +1,18 @@
using PkmnLib.Plugin.Gen7.Scripts.Side;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "wide_guard")]
public class WideGuard : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
if (move.Battle.ChoiceQueue?.HasNext() != true)
{
move.GetHitData(target, hit).Fail();
return;
}
move.User.BattleData?.BattleSide.VolatileScripts.Add(new WideGuardEffect());
}
}

View File

@@ -0,0 +1,11 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "wish")]
public class Wish : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
move.User.Volatile.Add(new Pokemon.WishEffect());
}
}

View File

@@ -0,0 +1,13 @@
using PkmnLib.Plugin.Gen7.Scripts.Battle;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "wonder_room")]
public class WonderRoom : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
move.Battle.Volatile.Add(new WonderRoomEffect());
}
}

View File

@@ -0,0 +1,17 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "worry_seed")]
public class WorrySeed : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var abilityLibrary = move.Battle.Library.StaticLibrary.Abilities;
if (!abilityLibrary.TryGet("insomnia", out var ability))
{
// Edge case: if the ability is not found, we should not change the ability.
return;
}
target.ChangeAbility(ability);
}
}

View File

@@ -0,0 +1,13 @@
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "yawn")]
public class Yawn : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
target.Volatile.Add(new YawnEffect());
}
}