36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
|
using PkmnLib.Static.Utils;
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
|
|
|
[Script(ScriptCategory.Move, "gravity")]
|
|
public class Gravity : Script
|
|
{
|
|
/// <inheritdoc />
|
|
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
|
{
|
|
var battleData = target.BattleData;
|
|
if (battleData == null)
|
|
return;
|
|
|
|
battleData.Battle.Volatile.StackOrAdd("gravity", () =>
|
|
{
|
|
battleData.Battle.Library.ScriptResolver.TryResolve(ScriptCategory.Battle, "gravity",
|
|
new Dictionary<StringKey, object?>(), out var script);
|
|
return script;
|
|
});
|
|
|
|
foreach (var pokemon in battleData.Battle.Sides.SelectMany(x => x.Pokemon).WhereNotNull())
|
|
{
|
|
var chargeBounceEffect = ScriptUtils.ResolveName<ChargeBounceEffect>();
|
|
if (pokemon.Volatile.Contains(chargeBounceEffect))
|
|
pokemon.Volatile.Remove(chargeBounceEffect);
|
|
var flyEffect = ScriptUtils.ResolveName<ChargeFlyEffect>();
|
|
if (pokemon.Volatile.Contains(flyEffect))
|
|
pokemon.Volatile.Remove(flyEffect);
|
|
// TODO: Sky Drop
|
|
}
|
|
}
|
|
} |