39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
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");
|
|
}
|
|
}
|
|
} |