83 lines
2.7 KiB
C#
83 lines
2.7 KiB
C#
namespace PkmnLib.Plugin.Gen7.Scripts.Weather;
|
|
|
|
/// <summary>
|
|
/// HarshSunlight is a weather condition that intensifies the effects of sunlight.
|
|
///
|
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Harsh_sunlight">Bulbapedia - Harsh Sunlight</see>
|
|
/// </summary>
|
|
[Script(ScriptCategory.Weather, "harsh_sunlight")]
|
|
public class HarshSunlight : Script, ILimitedTurnsScript, IScriptChangeBasePower, IScriptOnEndTurn,
|
|
IScriptPreventStatusChange, IScriptCustomTrigger, IScriptChangeAccuracy
|
|
{
|
|
private int? _duration;
|
|
|
|
/// <inheritdoc />
|
|
public int TurnsRemaining => _duration ?? 0;
|
|
|
|
/// <inheritdoc />
|
|
public void SetTurns(int turns)
|
|
{
|
|
_duration = turns;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public virtual void OnEndTurn(IScriptSource owner, IBattle battle)
|
|
{
|
|
_duration--;
|
|
if (_duration <= 0)
|
|
{
|
|
battle.SetWeather(null, 0);
|
|
}
|
|
}
|
|
|
|
// Hydro Steam is not part of the gen 7 data files, so no generated constant exists for it.
|
|
private static readonly StringKey HydroSteamName = "hydro_steam";
|
|
|
|
/// <inheritdoc />
|
|
public void ChangeBasePower(IExecutingMove move, IBattlePokemon target, byte hit, ref ushort basePower)
|
|
{
|
|
var hitType = move.GetHitData(target, hit).Type;
|
|
if (hitType?.Name == TypeNames.Fire || move.UseMove.Name == HydroSteamName)
|
|
{
|
|
// Increase Fire-type move power by 50% in harsh sunlight
|
|
basePower = (ushort)(basePower * 1.5);
|
|
}
|
|
else if (hitType?.Name == TypeNames.Water)
|
|
{
|
|
basePower = (ushort)(basePower * 0.5);
|
|
}
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void CustomTrigger(StringKey eventName, ICustomTriggerArgs args)
|
|
{
|
|
if (eventName != CustomTriggers.BypassChargeMove)
|
|
return;
|
|
if (args is not CustomTriggers.BypassChargeMoveArgs bypassArgs)
|
|
return;
|
|
if (bypassArgs.Move.UseMove.Name == MoveNames.SolarBeam || bypassArgs.Move.UseMove.Name == MoveNames.SolarBlade)
|
|
{
|
|
bypassArgs.Bypass = true;
|
|
}
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void PreventStatusChange(IBattlePokemon pokemon, StringKey status, bool selfInflicted,
|
|
ref bool preventStatus)
|
|
{
|
|
if (status == ScriptUtils.ResolveName<Status.Frozen>())
|
|
{
|
|
preventStatus = true;
|
|
}
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void ChangeAccuracy(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
|
ref int modifiedAccuracy)
|
|
{
|
|
if (executingMove.UseMove.Name == MoveNames.Thunder || executingMove.UseMove.Name == MoveNames.Hurricane)
|
|
{
|
|
modifiedAccuracy = (int)(modifiedAccuracy * 0.5);
|
|
}
|
|
}
|
|
} |