More move effects
This commit is contained in:
41
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/FreezeDry.cs
Normal file
41
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/FreezeDry.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "freeze_dry")]
|
||||
public class FreezeDry : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeEffectiveness(IExecutingMove move, IPokemon target, byte hit, ref float effectiveness)
|
||||
{
|
||||
var battleData = target.BattleData;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
var typeLibrary = battleData.Battle.Library.StaticLibrary.Types;
|
||||
if (!typeLibrary.TryGetTypeIdentifier("water", out var waterType))
|
||||
return;
|
||||
|
||||
if (target.Types.Contains(waterType))
|
||||
{
|
||||
var effectivenessWithoutWater = target.Types
|
||||
.Where(x => x != waterType)
|
||||
.Select(x => typeLibrary.GetEffectiveness(x, target.Types))
|
||||
.Aggregate(1f, (a, b) => a * b);
|
||||
effectiveness = effectivenessWithoutWater * 2;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
var battleData = target.BattleData;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
if (battleData.Battle.Random.EffectChance(10, move, target, hit))
|
||||
{
|
||||
target.SetStatus("frozen");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user