Surprisingly, more moves

This commit is contained in:
2025-04-17 17:51:42 +02:00
parent d02c05874b
commit c22ad1a793
17 changed files with 298 additions and 43 deletions

View File

@@ -136,9 +136,10 @@ public class Gen7DamageCalculator(bool hasRandomness) : IDamageCalculator
var origOffensiveStat = offensiveStat;
executingMove.RunScriptHook(script =>
script.ChangeOffensiveStatValue(executingMove, target, hitNumber, defensiveStat, ref offensiveStat));
executingMove.RunScriptHook(script =>
script.ChangeDefensiveStatValue(executingMove, target, hitNumber, origOffensiveStat, ref defensiveStat));
script.ChangeOffensiveStatValue(executingMove, target, hitNumber, defensiveStat, targetStats,
ref offensiveStat));
executingMove.RunScriptHook(script => script.ChangeDefensiveStatValue(executingMove, target, hitNumber,
origOffensiveStat, targetStats, ref defensiveStat));
var modifier = (float)offensiveStat / defensiveStat;
executingMove.RunScriptHook(script =>

View File

@@ -18,7 +18,7 @@ public class Acupressure : Script
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
// If the target has no stats to raise, the move fails
if (target.StatBoost.All(s => s == 6))
if (target.StatBoost.All(s => s.value == 6))
{
move.GetHitData(target, hit).Fail();
return;

View File

@@ -1,3 +1,4 @@
using PkmnLib.Static;
using PkmnLib.Static.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
@@ -7,7 +8,7 @@ public class FoulPlay : Script
{
/// <inheritdoc />
public override void ChangeOffensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint _,
ref uint value)
ImmutableStatisticSet<uint> targetStats, ref uint value)
{
value = move.UseMove.Category == MoveCategory.Physical
? target.BoostedStats.Attack

View File

@@ -0,0 +1,57 @@
using PkmnLib.Static.Moves;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "present")]
public class Present : Script
{
private bool _isHealing;
private byte _basePower;
/// <inheritdoc />
public override void OnBeforeHit(IExecutingMove move, IPokemon target, byte hitIndex)
{
var battleRandom = move.User.BattleData?.Battle.Random;
if (battleRandom == null)
return;
var percentRoll = battleRandom.GetFloat() * 100.0;
if (percentRoll < 20.0)
{
_isHealing = true;
_basePower = 0;
}
else
{
_isHealing = false;
_basePower = percentRoll switch
{
< 30 => 120,
< 60 => 80,
_ => 40,
};
}
}
/// <inheritdoc />
public override void ChangeCategory(IExecutingMove move, IPokemon target, byte hitIndex, ref MoveCategory category)
{
if (_isHealing)
category = MoveCategory.Status;
}
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
{
basePower = _basePower;
}
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
if (!_isHealing)
return;
var healAmount = (ushort)(target.MaxHealth / 4);
target.Heal(healAmount);
}
}

View File

@@ -0,0 +1,25 @@
using System;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "psych_up")]
public class PsychUp : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var targetStats = target.StatBoost;
var userStats = move.User.StatBoost;
foreach (Statistic stat in Enum.GetValues(typeof(Statistic)))
{
var targetStat = targetStats.GetStatistic(stat);
var userStat = userStats.GetStatistic(stat);
if (targetStat != userStat)
{
userStats.SetStatistic(stat, targetStat);
}
}
move.User.RecalculateBoostedStats();
}
}

View File

@@ -0,0 +1,12 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "psychic_terrain")]
public class PsychicTerrain : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var battleData = move.User.BattleData;
battleData?.Battle.SetTerrain(ScriptUtils.ResolveName<Terrain.PsychicTerrain>());
}
}

View File

@@ -0,0 +1,19 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "psycho_shift")]
public class PsychoShift : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
var statusScript = move.User.StatusScript;
var targetStatusScript = target.StatusScript;
if (statusScript.IsEmpty || !targetStatusScript.IsEmpty)
{
move.GetHitData(target, hit).Fail();
return;
}
var script = statusScript.Clear();
targetStatusScript.Set(script!);
}
}

View File

@@ -0,0 +1,14 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "psyshock")]
public class Psyshock : Script
{
/// <inheritdoc />
public override void ChangeDefensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint offensiveStat,
ImmutableStatisticSet<uint> targetStats, ref uint value)
{
value = targetStats.Defense;
}
}

View File

@@ -0,0 +1,19 @@
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "psywave")]
public class Psywave : Script
{
/// <inheritdoc />
public override void ChangeMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
{
if (move.User.BattleData == null)
return;
var random = move.User.BattleData.Battle.Random.GetInt(0, 10);
var level = (uint)move.User.Level;
var power = level.MultiplyOrMax(0.5f + 0.1f * random);
damage = power;
}
}

View File

@@ -0,0 +1,21 @@
using System.Linq;
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "punishment")]
public class Punishment : Script
{
/// <inheritdoc />
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref byte basePower)
{
if (move.User.BattleData == null)
return;
var totalPower = 60 + 20 * target.StatBoost.Count(x =>
x.statistic is not Statistic.Accuracy and Statistic.Evasion && x.value > 0);
if (totalPower > 200)
totalPower = 200;
basePower = (byte)totalPower;
}
}

View File

@@ -0,0 +1,18 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "purify")]
public class Purify : Script
{
/// <inheritdoc />
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
{
if (target.StatusScript.IsEmpty)
{
move.GetHitData(target, hit).Fail();
return;
}
target.ClearStatus();
target.Heal(target.MaxHealth / 2);
}
}

View File

@@ -1,3 +1,5 @@
using PkmnLib.Static;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "power_trick")]
@@ -5,14 +7,14 @@ public class PowerTrickEffect : Script
{
/// <inheritdoc />
public override void ChangeOffensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint defensiveStat,
ref uint value)
ImmutableStatisticSet<uint> targetStats, ref uint value)
{
value = defensiveStat;
}
/// <inheritdoc />
public override void ChangeDefensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint offensiveStat,
ref uint value)
ImmutableStatisticSet<uint> targetStats, ref uint value)
{
value = offensiveStat;
}