36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
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;
|
|
|
|
/// <inheritdoc />
|
|
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;
|
|
}
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
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<Confusion>())
|
|
preventVolatileAdd = true;
|
|
}
|
|
} |