using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
namespace PkmnLib.Plugin.Gen7.Scripts.Terrain;
[Script(ScriptCategory.Terrain, "misty_terrain")]
public class MistyTerrain : Script, IScriptChangeBasePower, IScriptPreventStatusChange, IScriptPreventVolatileAdd
{
private static bool IsAffectedByTerrain(IBattlePokemon pokemon) =>
!pokemon.IsFloating;
///
public void ChangeBasePower(IExecutingMove move, IBattlePokemon target, byte hit, ref ushort basePower)
{
if (!IsAffectedByTerrain(target))
return;
if (move.GetHitData(target, hit).Type?.Name == TypeNames.Dragon)
{
basePower /= 2;
}
}
///
public void PreventStatusChange(IBattlePokemon pokemon, StringKey status, bool selfInflicted,
ref bool preventStatus)
{
if (!IsAffectedByTerrain(pokemon))
return;
preventStatus = true;
}
public void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
{
if (script.Name == ScriptUtils.ResolveName())
preventVolatileAdd = true;
}
}