Implements Hail
This commit is contained in:
parent
42e3273483
commit
6434f9925c
|
@ -57,15 +57,15 @@ public static class TurnRunner
|
|||
{
|
||||
scripts.Clear();
|
||||
pokemon.GetOwnScripts(scripts);
|
||||
scripts.RunScriptHook(x => x.OnEndTurn());
|
||||
scripts.RunScriptHook(x => x.OnEndTurn(battle));
|
||||
}
|
||||
scripts.Clear();
|
||||
side.GetOwnScripts(scripts);
|
||||
scripts.RunScriptHook(x => x.OnEndTurn());
|
||||
scripts.RunScriptHook(x => x.OnEndTurn(battle));
|
||||
}
|
||||
scripts.Clear();
|
||||
battle.GetOwnScripts(scripts);
|
||||
scripts.RunScriptHook(x => x.OnEndTurn());
|
||||
scripts.RunScriptHook(x => x.OnEndTurn(battle));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,4 +25,9 @@ public enum DamageSource
|
|||
/// This happens when the form of a Pokemon changes, and it has less max HP than it had before.
|
||||
/// </summary>
|
||||
FormChange = 3,
|
||||
|
||||
/// <summary>
|
||||
/// The damage is done because of the weather.
|
||||
/// </summary>
|
||||
Weather = 4,
|
||||
}
|
|
@ -428,7 +428,8 @@ public abstract class Script : IDeepCloneable
|
|||
/// running. Note that choices are not active anymore here, so their scripts do not call this
|
||||
/// function.
|
||||
/// </summary>
|
||||
public virtual void OnEndTurn()
|
||||
/// <param name="battle"></param>
|
||||
public virtual void OnEndTurn(IBattle battle)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,9 @@ public class HealEachEndOfTurnEffect : Script
|
|||
_pokemon = pokemon;
|
||||
}
|
||||
|
||||
/// <param name="battle"></param>
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn()
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
if (_pokemon is null)
|
||||
return;
|
||||
|
|
|
@ -35,8 +35,9 @@ public class AuroraVeilEffect : Script
|
|||
NumberOfTurns = numberOfTurns;
|
||||
}
|
||||
|
||||
/// <param name="battle"></param>
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn()
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
if (NumberOfTurns > 0)
|
||||
NumberOfTurns--;
|
||||
|
|
|
@ -9,9 +9,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Side;
|
|||
public class DoublePowerIfTargetDamagedInTurnData : Script
|
||||
{
|
||||
public HashSet<IPokemon> _hitPokemon = new();
|
||||
|
||||
|
||||
/// <param name="battle"></param>
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn()
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
RemoveSelf();
|
||||
}
|
||||
|
|
|
@ -1,10 +1,53 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using PkmnLib.Dynamic.Events;
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
using PkmnLib.Static;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Weather;
|
||||
|
||||
[Script(ScriptCategory.Weather, "hail")]
|
||||
public class Hail : Script
|
||||
{
|
||||
// TODO: Implement Hail weather effect
|
||||
public static void RegisterHailIgnoreAbility(StringKey abilityName)
|
||||
{
|
||||
_hailIgnoreAbilities.Add(abilityName);
|
||||
}
|
||||
|
||||
private static readonly HashSet<StringKey> _hailIgnoreAbilities =
|
||||
[
|
||||
"ice_body",
|
||||
"magic_guard",
|
||||
"overcoat",
|
||||
"snow_cloak"
|
||||
];
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
if (!battle.Library.StaticLibrary.Types.TryGetTypeIdentifier("ice", out var iceType))
|
||||
{
|
||||
iceType = new TypeIdentifier(255);
|
||||
}
|
||||
foreach (var side in battle.Sides)
|
||||
{
|
||||
foreach (var pokemon in side.Pokemon.WhereNotNull())
|
||||
{
|
||||
if (!pokemon.IsUsable)
|
||||
continue;
|
||||
if (pokemon.Types.Contains(iceType))
|
||||
continue;
|
||||
if (_hailIgnoreAbilities.Contains(pokemon.ActiveAbility.Name))
|
||||
continue;
|
||||
|
||||
var maxHealth = pokemon.BoostedStats.Hp;
|
||||
var damage = maxHealth / 16;
|
||||
// TODO: Consider Safety Goggles. Handle it inside the Damage method?
|
||||
pokemon.Damage(damage, DamageSource.Weather, new EventBatchId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue