Deukhoofd 1579d46671
All checks were successful
Build / Build (push) Successful in 49s
More abilities
2025-06-09 15:24:37 +02:00

40 lines
1.8 KiB
C#

using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
/// <summary>
/// The user sheds part of its body to make itself lighter and sharply raise its Speed stat.
/// </summary>
/// <remarks>
/// Autotomize raises the user's Speed stat by two stages and (if the user successfully changes its Speed) decreases its
/// weight by 220 lbs. (100 kg). If the user successfully changes its weight, the message "Pokémon became nimble!"
/// is displayed.
/// <br />
/// Autotomize cannot decrease the user's weight below the minimum 0.2 lbs (0.1 kg); if the user's weight would drop
/// below the minimum, it becomes the minimum instead. Weight loss from Autotomize stacks, so using it multiple times
/// will continue to decrease the user's weight accordingly until it reaches the minimum weight. Autotomize's weight
/// reduction cannot be transferred by Baton Pass or removed by Haze. A Pokémon's weight is reset if it changes form
/// (from Generation VI onward), switches out or faints, or the battle ends.
/// </remarks>
[Script(ScriptCategory.Move, "autotomize")]
public class Autotomize : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var user = move.User;
var existingEffect = user.Volatile.Get<AutotomizeEffect>();
var stacks = existingEffect?.Stacks ?? 0;
if (!user.ChangeStatBoost(Statistic.Speed, 2, true, false) || !(user.WeightInKg - 100f * stacks >= 0.1f))
return;
user.Volatile.StackOrAdd(ScriptUtils.ResolveName<AutotomizeEffect>(), () => new AutotomizeEffect());
var battle = user.BattleData?.Battle;
battle?.EventHook.Invoke(new DialogEvent("pokemon_became_nimble", new Dictionary<string, object>
{
{ "pokemon", user },
}));
}
}