Bunch more moves, changes in how additional information for items works.

This commit is contained in:
2025-04-14 15:29:26 +02:00
parent 2adbb12367
commit 7c2845502d
60 changed files with 4275 additions and 963 deletions

View File

@@ -1,4 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using PkmnLib.Static;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Battle;
@@ -6,24 +9,15 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Battle;
public class Gravity : Script
{
/// <inheritdoc />
public override void ChangeEffectiveness(IExecutingMove move, IPokemon target, byte hit, ref float effectiveness)
public override void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
IList<TypeIdentifier> types)
{
var battleData = target.BattleData;
if (battleData == null)
return;
var typeLibrary = target.Library.StaticLibrary.Types;
if (move.UseMove.MoveType.Name == "ground")
{
var targetTypes = target.Types;
var typeLibrary = battleData.Battle.Library.StaticLibrary.Types;
effectiveness =
// Get the effectiveness of the move against each target type
targetTypes.Select(x => typeLibrary.GetSingleEffectiveness(move.UseMove.MoveType, x))
// Ignore all types that are immune to ground moves
.Where(x => x > 0)
// Multiply all effectiveness values together
.Aggregate(1.0f, (current, x) => current * x);
}
if (executingMove.UseMove.MoveType.Name != "ground")
return;
// Remove all types that are immune to ground moves
types.RemoveAll(x => typeLibrary.GetSingleEffectiveness(executingMove.UseMove.MoveType, x) == 0);
}
/// <inheritdoc />