Implements more move effects
This commit is contained in:
35
Plugins/PkmnLib.Plugin.Gen7/Scripts/Battle/Gravity.cs
Normal file
35
Plugins/PkmnLib.Plugin.Gen7/Scripts/Battle/Gravity.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Battle;
|
||||
|
||||
[Script(ScriptCategory.Battle, "gravity")]
|
||||
public class Gravity : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeEffectiveness(IExecutingMove move, IPokemon target, byte hit, ref float effectiveness)
|
||||
{
|
||||
var battleData = target.BattleData;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void FailIncomingMove(IExecutingMove move, IPokemon target, ref bool fail)
|
||||
{
|
||||
if (move.UseMove.HasFlag("gravity"))
|
||||
fail = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user