More moves implemented
This commit is contained in:
17
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/ChargeMove.cs
Normal file
17
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/ChargeMove.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "charge_move")]
|
||||
public class ChargeMove : Script
|
||||
{
|
||||
public override void PreventMove(IExecutingMove move, ref bool prevent)
|
||||
{
|
||||
var chargeMoveEffect = move.User.Volatile.Get<ChargeMoveEffect>();
|
||||
if (chargeMoveEffect != null && chargeMoveEffect.MoveName == move.UseMove.Name)
|
||||
return;
|
||||
prevent = true;
|
||||
move.User.Volatile.Add(new ChargeMoveEffect(move.UseMove.Name, move.User, move.MoveChoice.TargetSide,
|
||||
move.MoveChoice.TargetPosition));
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "dragon_rage")]
|
||||
public class DragonRage : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
|
||||
{
|
||||
damage = 40;
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,9 @@ public class Gravity : Script
|
||||
var flyEffect = ScriptUtils.ResolveName<ChargeFlyEffect>();
|
||||
if (pokemon.Volatile.Contains(flyEffect))
|
||||
pokemon.Volatile.Remove(flyEffect);
|
||||
// TODO: Sky Drop
|
||||
var skyDropEffect = ScriptUtils.ResolveName<ChargeSkyDropEffect>();
|
||||
if (pokemon.Volatile.Contains(skyDropEffect))
|
||||
pokemon.Volatile.Remove(skyDropEffect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public class GuardSplit : Script
|
||||
userStats.SetStatistic(Statistic.SpecialDefense, newSpecialDefense);
|
||||
targetStats.SetStatistic(Statistic.Defense, newDefense);
|
||||
targetStats.SetStatistic(Statistic.SpecialDefense, newSpecialDefense);
|
||||
user.RecalculateFlatStats();
|
||||
target.RecalculateFlatStats();
|
||||
user.RecalculateBoostedStats();
|
||||
target.RecalculateBoostedStats();
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public class PowerSplit : Script
|
||||
userStats.SetStatistic(Statistic.SpecialAttack, newSpecialAttack);
|
||||
targetStats.SetStatistic(Statistic.Attack, newAttack);
|
||||
targetStats.SetStatistic(Statistic.SpecialAttack, newSpecialAttack);
|
||||
user.RecalculateFlatStats();
|
||||
target.RecalculateFlatStats();
|
||||
user.RecalculateBoostedStats();
|
||||
target.RecalculateBoostedStats();
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class Rest : Script
|
||||
move.GetHitData(target, hit).Fail();
|
||||
return;
|
||||
}
|
||||
move.User.SetStatus(ScriptUtils.ResolveName<Sleep>());
|
||||
((Sleep)move.User.StatusScript.Script!).Turns = 2;
|
||||
if (move.User.SetStatus(ScriptUtils.ResolveName<Sleep>()) && move.User.StatusScript.Script is Sleep sleep)
|
||||
sleep.Turns = 2;
|
||||
}
|
||||
}
|
||||
24
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SkullBash.cs
Normal file
24
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SkullBash.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
using PkmnLib.Static;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "skull_bash")]
|
||||
public class SkullBash : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void PreventMove(IExecutingMove move, ref bool prevent)
|
||||
{
|
||||
if (move.User.Volatile.Contains<SkullBashEffect>())
|
||||
return;
|
||||
move.User.ChangeStatBoost(Statistic.Defense, 1, true);
|
||||
move.User.Volatile.Add(new SkullBashEffect(move.User));
|
||||
prevent = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
move.User.Volatile.Remove<SkullBashEffect>();
|
||||
}
|
||||
}
|
||||
27
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SkyAttack.cs
Normal file
27
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SkyAttack.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
using PkmnLib.Static;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "sky_attack")]
|
||||
public class SkyAttack : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void PreventMove(IExecutingMove move, ref bool prevent)
|
||||
{
|
||||
if (move.User.Volatile.Contains<SkyAttackEffect>())
|
||||
return;
|
||||
move.User.Volatile.Add(new SkyAttackEffect(move.User));
|
||||
prevent = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
move.User.Volatile.Remove<SkyAttackEffect>();
|
||||
if (move.Battle.Random.EffectChance(30, move, target, hit))
|
||||
{
|
||||
target.Volatile.Add(new FlinchEffect());
|
||||
}
|
||||
}
|
||||
}
|
||||
28
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SkyDrop.cs
Normal file
28
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SkyDrop.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "sky_drop")]
|
||||
public class SkyDrop : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void PreventMove(IExecutingMove move, ref bool prevent)
|
||||
{
|
||||
if (move.User.Volatile.Contains<ChargeSkyDropEffect>())
|
||||
return;
|
||||
|
||||
move.User.Volatile.Add(new ChargeSkyDropEffect(move.User));
|
||||
move.User.BattleData?.Battle.EventHook.Invoke(new DialogEvent("sky_drop_charge", new Dictionary<string, object>
|
||||
{
|
||||
{ "user", move.User },
|
||||
}));
|
||||
prevent = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnBeforeMove(IExecutingMove move)
|
||||
{
|
||||
move.User.Volatile.Remove(ScriptUtils.ResolveName<ChargeSkyDropEffect>());
|
||||
}
|
||||
}
|
||||
34
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SleepTalk.cs
Normal file
34
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SleepTalk.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.MoveVolatile;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Utils;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "sleep_talk")]
|
||||
public class SleepTalk : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeMove(IMoveChoice choice, ref StringKey moveName)
|
||||
{
|
||||
if (!choice.User.HasStatus(ScriptUtils.ResolveName<Status.Sleep>()))
|
||||
{
|
||||
choice.Fail();
|
||||
return;
|
||||
}
|
||||
var battleData = choice.User.BattleData;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
var moves = choice.User.Moves.WhereNotNull().Where(x => x.MoveData.CanCopyMove())
|
||||
.Where(x => x != choice.ChosenMove).OrderBy(_ => battleData.Battle.Random.GetInt()).FirstOrDefault();
|
||||
if (moves == null)
|
||||
{
|
||||
choice.Fail();
|
||||
return;
|
||||
}
|
||||
moveName = moves.MoveData.Name;
|
||||
choice.Volatile.Add(new BypassSleepVolatile());
|
||||
}
|
||||
}
|
||||
30
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SmackDown.cs
Normal file
30
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SmackDown.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
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, "smack_down")]
|
||||
public class SmackDown : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
var battleData = target.BattleData;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
target.Volatile.Add(new SmackDownEffect());
|
||||
|
||||
var chargeBounceEffect = ScriptUtils.ResolveName<ChargeBounceEffect>();
|
||||
if (target.Volatile.Contains(chargeBounceEffect))
|
||||
target.Volatile.Remove(chargeBounceEffect);
|
||||
var flyEffect = ScriptUtils.ResolveName<ChargeFlyEffect>();
|
||||
if (target.Volatile.Contains(flyEffect))
|
||||
target.Volatile.Remove(flyEffect);
|
||||
var skyDropEffect = ScriptUtils.ResolveName<ChargeSkyDropEffect>();
|
||||
if (target.Volatile.Contains(skyDropEffect))
|
||||
target.Volatile.Remove(skyDropEffect);
|
||||
}
|
||||
}
|
||||
25
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SmellingSalts.cs
Normal file
25
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SmellingSalts.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "smelling_salts")]
|
||||
public class SmellingSalts : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
|
||||
{
|
||||
// If the target is paralyzed, double the damage
|
||||
if (target.HasStatus(ScriptUtils.ResolveName<Status.Paralyzed>()))
|
||||
{
|
||||
damage *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
// If the target is paralyzed, remove the paralysis
|
||||
if (target.HasStatus(ScriptUtils.ResolveName<Status.Paralyzed>()))
|
||||
{
|
||||
target.ClearStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Snatch.cs
Normal file
15
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Snatch.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Battle;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "snatch")]
|
||||
public class Snatch : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
move.Battle.Volatile.Add(new SnatchEffect());
|
||||
var snatchEffect = move.Battle.Volatile.Get<SnatchEffect>();
|
||||
snatchEffect?.AddSnatcher(target);
|
||||
}
|
||||
}
|
||||
20
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Snore.cs
Normal file
20
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Snore.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "snore")]
|
||||
public class Snore : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void FailMove(IExecutingMove move, ref bool fail)
|
||||
{
|
||||
if (!move.User.HasStatus(ScriptUtils.ResolveName<Status.Sleep>()))
|
||||
fail = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
target.Volatile.Add(new FlinchEffect());
|
||||
}
|
||||
}
|
||||
22
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Soak.cs
Normal file
22
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Soak.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "soak")]
|
||||
public class Soak : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
if (target.ActiveAbility?.Name == "multitype")
|
||||
{
|
||||
move.GetHitData(target, hit).Fail();
|
||||
return;
|
||||
}
|
||||
|
||||
var typeLibrary = move.Battle.Library.StaticLibrary.Types;
|
||||
// If water type is not found, we can't do anything.
|
||||
if (!typeLibrary.TryGetTypeIdentifier("water", out var waterType))
|
||||
return;
|
||||
|
||||
target.SetTypes([waterType]);
|
||||
}
|
||||
}
|
||||
12
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SparklingAria.cs
Normal file
12
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SparklingAria.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "sparkling_aria")]
|
||||
public class SparklingAria : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
if (target.HasStatus(ScriptUtils.ResolveName<Status.Burned>()))
|
||||
target.ClearStatus();
|
||||
}
|
||||
}
|
||||
22
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SpectralThief.cs
Normal file
22
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SpectralThief.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "spectral_thief")]
|
||||
public class SpectralThief : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
|
||||
{
|
||||
var positiveStats = target.StatBoost.Where(x => x.value > 0).ToArray();
|
||||
if (positiveStats.Length > 0)
|
||||
{
|
||||
EventBatchId batchId = new();
|
||||
foreach (var positiveStat in positiveStats)
|
||||
{
|
||||
move.User.ChangeStatBoost(positiveStat.statistic, positiveStat.value, true, batchId);
|
||||
target.ChangeStatBoost(positiveStat.statistic, (sbyte)-positiveStat.value, true, batchId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SpeedSwap.cs
Normal file
19
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SpeedSwap.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using PkmnLib.Static;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "speed_swap")]
|
||||
public class SpeedSwap : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
var userSpeed = move.User.FlatStats.Speed;
|
||||
var targetSpeed = target.FlatStats.Speed;
|
||||
|
||||
move.User.FlatStats.SetStatistic(Statistic.Speed, targetSpeed);
|
||||
target.FlatStats.SetStatistic(Statistic.Speed, userSpeed);
|
||||
move.User.RecalculateBoostedStats();
|
||||
target.RecalculateBoostedStats();
|
||||
}
|
||||
}
|
||||
15
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SpiderWeb.cs
Normal file
15
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SpiderWeb.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "spider_web")]
|
||||
public class SpiderWeb : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
move.User.Volatile.Add(new SpiderWebEffect());
|
||||
var effect = move.User.Volatile.Get<SpiderWebEffect>();
|
||||
effect?.AddTarget(target);
|
||||
}
|
||||
}
|
||||
35
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/StaticDamage.cs
Normal file
35
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/StaticDamage.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "static_damage")]
|
||||
public class StaticDamage : Script
|
||||
{
|
||||
private uint Damage { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnInitialize(IReadOnlyDictionary<StringKey, object?>? parameters)
|
||||
{
|
||||
if (parameters == null)
|
||||
throw new Exception("Parameters cannot be null for StaticDamage script.");
|
||||
if (parameters.TryGetValue("damage", out var damage))
|
||||
{
|
||||
if (damage is int d)
|
||||
Damage = (uint)d;
|
||||
else
|
||||
throw new Exception($"Invalid damage value: {damage}");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Missing required parameter: damage");
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
|
||||
{
|
||||
damage = Damage;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user