38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
namespace PkmnLib.Plugin.Gen7.Scripts.Terrain;
|
|
|
|
[Script(ScriptCategory.Terrain, "electric_terrain")]
|
|
public class ElectricTerrain : Script, IScriptChangeBasePower
|
|
{
|
|
private static bool IsAffectedByTerrain(IPokemon pokemon) =>
|
|
!pokemon.IsFloating;
|
|
|
|
/// <inheritdoc />
|
|
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
|
|
{
|
|
if (!IsAffectedByTerrain(move.User))
|
|
return;
|
|
var type = move.GetHitData(target, hit).Type;
|
|
if (type?.Name == "electric")
|
|
basePower = basePower.MultiplyOrMax(1.5f);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
|
|
ref bool preventStatus)
|
|
{
|
|
if (!IsAffectedByTerrain(pokemon))
|
|
return;
|
|
if (status == ScriptUtils.ResolveName<Status.Sleep>())
|
|
preventStatus = true;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
|
|
{
|
|
if (parent is IPokemon pokemon && !IsAffectedByTerrain(pokemon))
|
|
return;
|
|
|
|
if (script is Pokemon.YawnEffect)
|
|
preventVolatileAdd = true;
|
|
}
|
|
} |