Implements a bunch more moves
This commit is contained in:
@@ -10,14 +10,15 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Moq" Version="4.20.70" />
|
||||
<PackageReference Include="Moq" Version="4.20.70"/>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0"/>
|
||||
<PackageReference Include="TUnit" Version="0.5.18" />
|
||||
<PackageReference Include="TUnit" Version="0.5.18"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\PkmnLib.Dynamic\PkmnLib.Dynamic.csproj" />
|
||||
<ProjectReference Include="..\PkmnLib.Plugin.Gen7\PkmnLib.Plugin.Gen7.csproj" />
|
||||
<ProjectReference Include="..\..\PkmnLib.Dataloader\PkmnLib.Dataloader.csproj"/>
|
||||
<ProjectReference Include="..\..\PkmnLib.Dynamic\PkmnLib.Dynamic.csproj"/>
|
||||
<ProjectReference Include="..\PkmnLib.Plugin.Gen7\PkmnLib.Plugin.Gen7.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
using PkmnLib.Dynamic.Libraries;
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
using PkmnLib.Static;
|
||||
using PkmnLib.Static.Libraries;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
|
||||
|
||||
public class HiddenPowerTests
|
||||
{
|
||||
public record TestCaseData(IndividualValueStatisticSet Ivs, StringKey ExpectedType, byte ExpectedPower)
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string ToString() =>
|
||||
$"Hidden Power type is {ExpectedType}, base power is {ExpectedPower} " +
|
||||
$"with IVs: HP {Ivs.Hp}, Atk {Ivs.Attack}, Def {Ivs.Defense}, SpA {Ivs.SpecialAttack}, SpD {Ivs.SpecialDefense}, Spe {Ivs.Speed}";
|
||||
}
|
||||
|
||||
public static IEnumerable<Func<TestCaseData>> HiddenPowerTestData()
|
||||
{
|
||||
yield return () => new TestCaseData(new IndividualValueStatisticSet(31, 31, 31, 31, 31, 31), "dark", 70);
|
||||
yield return () => new TestCaseData(new IndividualValueStatisticSet(25, 2, 12, 5, 8, 17), "bug", 31);
|
||||
yield return () => new TestCaseData(new IndividualValueStatisticSet(29, 19, 18, 22, 15, 28), "fire", 64);
|
||||
}
|
||||
|
||||
[Test, MethodDataSource(nameof(HiddenPowerTestData))]
|
||||
public async Task HiddenPower_ChangesType(TestCaseData test)
|
||||
{
|
||||
var typeLibrary = new TypeLibrary();
|
||||
typeLibrary.RegisterType("normal");
|
||||
typeLibrary.RegisterType("fighting");
|
||||
typeLibrary.RegisterType("flying");
|
||||
typeLibrary.RegisterType("poison");
|
||||
typeLibrary.RegisterType("ground");
|
||||
typeLibrary.RegisterType("rock");
|
||||
typeLibrary.RegisterType("bug");
|
||||
typeLibrary.RegisterType("ghost");
|
||||
typeLibrary.RegisterType("steel");
|
||||
typeLibrary.RegisterType("fire");
|
||||
typeLibrary.RegisterType("water");
|
||||
typeLibrary.RegisterType("grass");
|
||||
typeLibrary.RegisterType("electric");
|
||||
typeLibrary.RegisterType("psychic");
|
||||
typeLibrary.RegisterType("ice");
|
||||
typeLibrary.RegisterType("dragon");
|
||||
typeLibrary.RegisterType("dark");
|
||||
typeLibrary.RegisterType("fairy");
|
||||
|
||||
var executingMove = new Mock<IExecutingMove>(MockBehavior.Strict);
|
||||
var user = new Mock<IPokemon>(MockBehavior.Strict);
|
||||
var target = new Mock<IPokemon>(MockBehavior.Strict);
|
||||
var dynamicLibrary = new Mock<IDynamicLibrary>(MockBehavior.Strict);
|
||||
var staticLibrary = new Mock<IStaticLibrary>(MockBehavior.Strict);
|
||||
|
||||
executingMove.SetupGet(x => x.User).Returns(user.Object);
|
||||
user.SetupGet(x => x.IndividualValues).Returns(test.Ivs);
|
||||
user.SetupGet(x => x.Library).Returns(dynamicLibrary.Object);
|
||||
staticLibrary.Setup(x => x.Types).Returns(typeLibrary);
|
||||
dynamicLibrary.Setup(x => x.StaticLibrary).Returns(staticLibrary.Object);
|
||||
|
||||
var moveType = new TypeIdentifier(1, "normal");
|
||||
|
||||
var hiddenPower = new HiddenPower();
|
||||
hiddenPower.ChangeMoveType(executingMove.Object, target.Object, 0, ref moveType);
|
||||
|
||||
await Assert.That(moveType.Name).IsEqualTo(test.ExpectedType);
|
||||
}
|
||||
|
||||
[Test, MethodDataSource(nameof(HiddenPowerTestData))]
|
||||
public async Task HiddenPower_ChangesBasePower(TestCaseData test)
|
||||
{
|
||||
var executingMove = new Mock<IExecutingMove>(MockBehavior.Strict);
|
||||
var user = new Mock<IPokemon>(MockBehavior.Strict);
|
||||
var target = new Mock<IPokemon>(MockBehavior.Strict);
|
||||
var dynamicLibrary = new Mock<IDynamicLibrary>(MockBehavior.Strict);
|
||||
var staticLibrary = new Mock<IStaticLibrary>(MockBehavior.Strict);
|
||||
|
||||
executingMove.SetupGet(x => x.User).Returns(user.Object);
|
||||
user.SetupGet(x => x.IndividualValues).Returns(test.Ivs);
|
||||
user.SetupGet(x => x.Library).Returns(dynamicLibrary.Object);
|
||||
dynamicLibrary.Setup(x => x.StaticLibrary).Returns(staticLibrary.Object);
|
||||
|
||||
var hiddenPower = new HiddenPower();
|
||||
byte power = 0;
|
||||
hiddenPower.ChangeBasePower(executingMove.Object, target.Object, 0, ref power);
|
||||
|
||||
await Assert.That(power).IsEqualTo(test.ExpectedPower);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
@@ -12,7 +14,8 @@ public class FuryCutter : Script
|
||||
if (userEffect == null)
|
||||
return;
|
||||
|
||||
userEffect.TurnCount++;
|
||||
basePower = (byte)(basePower * (userEffect.TurnCount + 1));
|
||||
if (userEffect.TurnCount < 5)
|
||||
userEffect.TurnCount++;
|
||||
basePower = basePower.MultiplyOrMax((byte)Math.Pow(2, userEffect.TurnCount));
|
||||
}
|
||||
}
|
||||
25
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HealBell.cs
Normal file
25
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HealBell.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Linq;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "heal_bell")]
|
||||
public class HealBell : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
var party = move.User.BattleData?.Battle.Parties.FirstOrDefault(p => p.Party.Contains(target));
|
||||
if (party == null)
|
||||
return;
|
||||
|
||||
foreach (var pokemon in party.Party.WhereNotNull())
|
||||
{
|
||||
pokemon.ClearStatus();
|
||||
var confusion = ScriptUtils.ResolveName<Confusion>();
|
||||
if (pokemon.Volatile.Contains(confusion))
|
||||
pokemon.Volatile.Remove(confusion);
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HealBlock.cs
Normal file
13
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HealBlock.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "heal_block")]
|
||||
public class HealBlock : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
target.Volatile.Add(new HealBlockEffect());
|
||||
}
|
||||
}
|
||||
25
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HealPercent.cs
Normal file
25
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HealPercent.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "heal_percent")]
|
||||
public class HealPercent : Script
|
||||
{
|
||||
private float _healPercent = 0.5f;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnInitialize(IReadOnlyDictionary<StringKey, object?>? parameters)
|
||||
{
|
||||
if (parameters?.TryGetValue("healPercent", out var variable) == true && variable is float healPercent)
|
||||
{
|
||||
_healPercent = healPercent;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
target.Heal((uint)(move.User.BoostedStats.Hp * _healPercent));
|
||||
}
|
||||
}
|
||||
20
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HealingWish.cs
Normal file
20
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HealingWish.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Side;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "healing_wish")]
|
||||
public class HealingWish : 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];
|
||||
side.VolatileScripts.Add(new HealingWishEffect(battleData.Position));
|
||||
|
||||
move.User.Faint(DamageSource.Misc);
|
||||
}
|
||||
}
|
||||
26
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HeartSwap.cs
Normal file
26
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HeartSwap.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using PkmnLib.Static;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "heart_swap")]
|
||||
public class HeartSwap : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
EventBatchId eventBatchId = new();
|
||||
var userStats = move.User.StatBoost;
|
||||
var targetStats = target.StatBoost;
|
||||
|
||||
foreach (Statistic stat in Enum.GetValues(typeof(Statistic)))
|
||||
{
|
||||
var userStat = userStats.GetStatistic(stat);
|
||||
var targetStat = targetStats.GetStatistic(stat);
|
||||
if (userStat == targetStat)
|
||||
continue;
|
||||
move.User.ChangeStatBoost(stat, (sbyte)(userStat - targetStat), true, eventBatchId);
|
||||
target.ChangeStatBoost(stat, (sbyte)(targetStat - userStat), false, eventBatchId);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HeatCrash.cs
Normal file
19
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HeatCrash.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "heat_crash")]
|
||||
public class HeatCrash : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
|
||||
{
|
||||
var weightMultiplier = move.User.WeightInKg / target.WeightInKg;
|
||||
basePower = weightMultiplier switch
|
||||
{
|
||||
> 5 => 120,
|
||||
> 4 => 100,
|
||||
> 3 => 80,
|
||||
> 2 => 60,
|
||||
_ => 40,
|
||||
};
|
||||
}
|
||||
}
|
||||
11
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HelpingHand.cs
Normal file
11
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HelpingHand.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "helping_hand")]
|
||||
public class HelpingHand : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit) =>
|
||||
target.Volatile.Add(new HelpingHandEffect());
|
||||
}
|
||||
16
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Hex.cs
Normal file
16
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Hex.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "hex")]
|
||||
public class Hex : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
|
||||
{
|
||||
if (!target.StatusScript.IsEmpty)
|
||||
{
|
||||
basePower = basePower.MultiplyOrMax(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
39
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HiddenPower.cs
Normal file
39
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HiddenPower.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using PkmnLib.Static;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "hidden_power")]
|
||||
public class HiddenPower : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeMoveType(IExecutingMove move, IPokemon target, byte hit, ref TypeIdentifier moveType)
|
||||
{
|
||||
var ivs = move.User.IndividualValues;
|
||||
|
||||
var type = GetHiddenPowerValue(ivs, 0x00000001) * 15 / 63;
|
||||
|
||||
move.User.Library.StaticLibrary.Types.TryGetTypeIdentifierFromIndex((byte)(type + 2), out moveType);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
|
||||
{
|
||||
var ivs = move.User.IndividualValues;
|
||||
|
||||
var power = GetHiddenPowerValue(ivs, 0x00000002) * 40 / 63 + 30;
|
||||
// cast to byte with overflow check
|
||||
basePower = (byte)Math.Min(power, byte.MaxValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to calculate the hidden power value from the IVs.
|
||||
/// This is used to determine the type and power of the move.
|
||||
/// </summary>
|
||||
private static int GetHiddenPowerValue(IndividualValueStatisticSet ivs, int significance) =>
|
||||
((ivs.Hp & significance) >> (significance - 1)) + (((ivs.Attack & significance) >> (significance - 1)) << 1) +
|
||||
(((ivs.Defense & significance) >> (significance - 1)) << 2) +
|
||||
(((ivs.Speed & significance) >> (significance - 1)) << 3) +
|
||||
(((ivs.SpecialAttack & significance) >> (significance - 1)) << 4) +
|
||||
(((ivs.SpecialDefense & significance) >> (significance - 1)) << 5);
|
||||
}
|
||||
18
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HighJumpKick.cs
Normal file
18
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HighJumpKick.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "high_jump_kick")]
|
||||
public class HighJumpKick : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnMoveMiss(IExecutingMove move, IPokemon target)
|
||||
{
|
||||
var damage = move.GetHitData(target, 0).Damage;
|
||||
var recoil = damage / 2;
|
||||
// This recoil damage will not exceed half the user's max HP
|
||||
var maxHp = move.User.BoostedStats.Hp;
|
||||
recoil = Math.Min(recoil, maxHp / 2);
|
||||
move.User.Damage(recoil, DamageSource.Misc);
|
||||
}
|
||||
}
|
||||
18
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HyperspaceFury.cs
Normal file
18
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/HyperspaceFury.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Linq;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "hyperspace_fury")]
|
||||
public class HyperspaceFury : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
var protectionScripts = target.Volatile.Select(x => x.Script).OfType<ProtectionEffectScript>();
|
||||
foreach (var protectionScript in protectionScripts.ToList())
|
||||
{
|
||||
target.Volatile.Remove(protectionScript.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
34
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/IceBall.cs
Normal file
34
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/IceBall.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "ice_ball")]
|
||||
public class IceBall : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
|
||||
{
|
||||
var userEffect = move.User.Volatile.Get<IceBallEffect>();
|
||||
if (userEffect == null)
|
||||
return;
|
||||
|
||||
basePower = basePower.MultiplyOrMax((byte)Math.Pow(2, userEffect.TurnCount));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
var userEffect = move.User.Volatile.Get<IceBallEffect>();
|
||||
if (userEffect == null)
|
||||
{
|
||||
userEffect = new IceBallEffect(move.User, move.UseMove.Name);
|
||||
move.User.Volatile.Add(userEffect);
|
||||
}
|
||||
else
|
||||
{
|
||||
userEffect.TurnCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
24
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/IceBurn.cs
Normal file
24
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/IceBurn.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "ice_burn")]
|
||||
public class IceBurn : BaseChargeMove<RequireChargeEffect>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override RequireChargeEffect CreateVolatile(IPokemon user) => new(user, "ice_burn");
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
var battleData = move.User.BattleData;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
if (battleData.Battle.Random.EffectChance(30, move, target, hit))
|
||||
{
|
||||
target.SetStatus("burned");
|
||||
}
|
||||
}
|
||||
}
|
||||
24
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/IceFang.cs
Normal file
24
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/IceFang.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "ice_fang")]
|
||||
public class IceFang : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
var battleData = move.User.BattleData;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
if (battleData.Battle.Random.EffectChance(10, move, target, hit))
|
||||
{
|
||||
target.SetStatus("frozen");
|
||||
}
|
||||
if (battleData.Battle.Random.EffectChance(10, move, target, hit))
|
||||
{
|
||||
target.Volatile.Add(new FlinchEffect());
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Imprison.cs
Normal file
13
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Imprison.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "imprison")]
|
||||
public class Imprison : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
target.Volatile.Add(new ImprisonEffect(move.User));
|
||||
}
|
||||
}
|
||||
16
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Incinerate.cs
Normal file
16
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Incinerate.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using PkmnLib.Static;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "incinerate")]
|
||||
public class Incinerate : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
if (target.HeldItem is { Category: ItemCategory.Berry })
|
||||
{
|
||||
target.RemoveHeldItemForBattle();
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Infestation.cs
Normal file
29
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Infestation.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "infestation")]
|
||||
public class Infestation : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
var infestationEffect = ScriptUtils.ResolveName<InfestationEffect>();
|
||||
if (target.Volatile.Contains(infestationEffect))
|
||||
{
|
||||
move.GetHitData(target, hit).Fail();
|
||||
return;
|
||||
}
|
||||
|
||||
var battleData = move.User.BattleData;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
var turns = 4;
|
||||
if (battleData.Battle.Random.GetBool())
|
||||
{
|
||||
turns = 5;
|
||||
}
|
||||
target.Volatile.Add(new InfestationEffect(target, turns));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "heal_block")]
|
||||
public class HealBlockEffect : Script
|
||||
{
|
||||
private int _duration;
|
||||
|
||||
public HealBlockEffect(int duration = 5)
|
||||
{
|
||||
_duration = duration;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
_duration--;
|
||||
if (_duration <= 0)
|
||||
RemoveSelf();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
|
||||
{
|
||||
if (choice.ChosenMove.MoveData.HasFlag("heal"))
|
||||
prevent = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void PreventMove(IExecutingMove move, ref bool prevent)
|
||||
{
|
||||
if (move.ChosenMove.MoveData.HasFlag("heal"))
|
||||
prevent = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void PreventHeal(IPokemon pokemon, uint heal, bool allowRevive, ref bool prevented)
|
||||
{
|
||||
prevented = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
public class HelpingHandEffect : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower) =>
|
||||
basePower = basePower.MultiplyOrMax(1.5f);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn(IBattle battle) => RemoveSelf();
|
||||
}
|
||||
41
Plugins/PkmnLib.Plugin.Gen7/Scripts/Pokemon/IceBallEffect.cs
Normal file
41
Plugins/PkmnLib.Plugin.Gen7/Scripts/Pokemon/IceBallEffect.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Utils;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "ice_ball")]
|
||||
public class IceBallEffect : Script
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private readonly StringKey _moveName;
|
||||
public int TurnCount { get; set; }
|
||||
|
||||
public IceBallEffect(IPokemon owner, StringKey moveName)
|
||||
{
|
||||
_owner = owner;
|
||||
_moveName = moveName;
|
||||
TurnCount = 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, _moveName, opposingSideIndex, position);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnMoveMiss(IExecutingMove move, IPokemon target)
|
||||
{
|
||||
RemoveSelf();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
if (TurnCount < 5)
|
||||
TurnCount++;
|
||||
else
|
||||
RemoveSelf();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Linq;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "imprison")]
|
||||
public class ImprisonEffect : Script
|
||||
{
|
||||
private readonly IPokemon _user;
|
||||
|
||||
public ImprisonEffect(IPokemon user)
|
||||
{
|
||||
_user = user;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
|
||||
{
|
||||
if (_user.Moves.WhereNotNull().Any(x => x.MoveData.Name == choice.ChosenMove.MoveData.Name))
|
||||
prevent = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "infestation")]
|
||||
public class InfestationEffect : Script
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
private int _turns;
|
||||
|
||||
public InfestationEffect(IPokemon owner, int turns)
|
||||
{
|
||||
_owner = owner;
|
||||
_turns = turns;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void PreventSelfSwitch(ISwitchChoice choice, ref bool prevent) => prevent = true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void PreventSelfRunAway(IFleeChoice choice, ref bool prevent) => prevent = true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
var damage = _owner.BoostedStats.Hp / 8;
|
||||
_owner.Damage(damage, DamageSource.Misc);
|
||||
|
||||
_turns--;
|
||||
if (_turns <= 0)
|
||||
{
|
||||
RemoveSelf();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Side;
|
||||
|
||||
[Script(ScriptCategory.Side, "healing_wish")]
|
||||
public class HealingWishEffect : Script
|
||||
{
|
||||
private readonly byte _position;
|
||||
|
||||
public HealingWishEffect(byte position)
|
||||
{
|
||||
_position = position;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
{
|
||||
if (position == _position)
|
||||
{
|
||||
pokemon.Heal(pokemon.BoostedStats.Hp);
|
||||
pokemon.ClearStatus();
|
||||
RemoveSelf();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user