This commit is contained in:
16
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/HeavyMetal.cs
Normal file
16
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/HeavyMetal.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
|
||||
/// <summary>
|
||||
/// Heavy Metal is an ability that doubles the Pokémon's weight.
|
||||
///
|
||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Heavy_Metal_(Ability)">Bulbapedia - Heavy Metal</see>
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Ability, "heavy_metal")]
|
||||
public class HeavyMetal : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ModifyWeight(ref float weight)
|
||||
{
|
||||
weight *= 2f;
|
||||
}
|
||||
}
|
||||
12
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/HoneyGather.cs
Normal file
12
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/HoneyGather.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
|
||||
/// <summary>
|
||||
/// Honey Gather is an ability that may allow the Pokémon to collect Honey after battle.
|
||||
///
|
||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Honey_Gather_(Ability)">Bulbapedia - Honey Gather</see>
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Ability, "honey_gather")]
|
||||
public class HoneyGather : Script
|
||||
{
|
||||
// No Effect in battle
|
||||
}
|
||||
20
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/HugePower.cs
Normal file
20
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/HugePower.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
|
||||
/// <summary>
|
||||
/// Huge Power is an ability that doubles the Pokémon's Attack stat.
|
||||
///
|
||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Huge_Power_(Ability)">Bulbapedia - Huge Power</see>
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Ability, "huge_power")]
|
||||
public class HugePower : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeOffensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint defensiveStat,
|
||||
ImmutableStatisticSet<uint> targetStats, Statistic stat, ref uint value)
|
||||
{
|
||||
if (stat == Statistic.Attack)
|
||||
{
|
||||
value = value.MultiplyOrMax(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
31
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Hustle.cs
Normal file
31
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Hustle.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using PkmnLib.Static.Moves;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
|
||||
/// <summary>
|
||||
/// Hustle is an ability that increases the Pokémon's Attack by 50% but lowers the accuracy of its physical moves.
|
||||
///
|
||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Hustle_(Ability)">Bulbapedia - Hustle</see>
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Ability, "hustle")]
|
||||
public class Hustle : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeOffensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint defensiveStat,
|
||||
ImmutableStatisticSet<uint> targetStats, Statistic stat, ref uint value)
|
||||
{
|
||||
if (stat != Statistic.Attack)
|
||||
return;
|
||||
value = value.MultiplyOrMax(1.5f);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||
ref int modifiedAccuracy)
|
||||
{
|
||||
if (executingMove.UseMove.Category == MoveCategory.Physical)
|
||||
{
|
||||
modifiedAccuracy = (int)(modifiedAccuracy * 0.8f);
|
||||
}
|
||||
}
|
||||
}
|
||||
40
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Hydration.cs
Normal file
40
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Hydration.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
|
||||
/// <summary>
|
||||
/// Hydration is an ability that heals status conditions if it is raining at the end of the turn.
|
||||
///
|
||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Hydration_(Ability)">Bulbapedia - Hydration</see>
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Ability, "hydration")]
|
||||
public class Hydration : Script
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
throw new InvalidOperationException("Hydration can only be added to a Pokemon script source.");
|
||||
_pokemon = pokemon;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
if (_pokemon is null)
|
||||
return;
|
||||
|
||||
if (battle.WeatherName != ScriptUtils.ResolveName<Weather.Rain>())
|
||||
return;
|
||||
if (_pokemon.StatusScript.IsEmpty)
|
||||
return;
|
||||
|
||||
EventBatchId batchId = new();
|
||||
|
||||
battle.EventHook.Invoke(new AbilityTriggerEvent(_pokemon)
|
||||
{
|
||||
BatchId = batchId,
|
||||
});
|
||||
_pokemon.ClearStatus(batchId);
|
||||
}
|
||||
}
|
||||
22
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/HyperCutter.cs
Normal file
22
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/HyperCutter.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
|
||||
/// <summary>
|
||||
/// Hyper Cutter is an ability that prevents the Pokémon's Attack stat from being lowered by other Pokémon.
|
||||
///
|
||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Hyper_Cutter_(Ability)">Bulbapedia - Hyper Cutter</see>
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Ability, "hyper_cutter")]
|
||||
public class HyperCutter : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void PreventStatBoostChange(IPokemon target, Statistic stat, sbyte amount, bool selfInflicted,
|
||||
ref bool prevent)
|
||||
{
|
||||
if (stat != Statistic.Attack)
|
||||
return;
|
||||
|
||||
// Prevent the Attack stat from being lowered by any means
|
||||
if (amount < 0 && !selfInflicted)
|
||||
prevent = true;
|
||||
}
|
||||
}
|
||||
51
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/IceBody.cs
Normal file
51
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/IceBody.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
|
||||
/// <summary>
|
||||
/// Ice Body is an ability that heals the Pokémon for 1/16 of its maximum HP each turn during hail.
|
||||
///
|
||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Ice_Body_(Ability)">Bulbapedia - Ice Body</see>
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Ability, "ice_body")]
|
||||
public class IceBody : Script
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
throw new InvalidOperationException("Ice Body can only be added to a Pokemon script source.");
|
||||
_pokemon = pokemon;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
if (_pokemon is null)
|
||||
return;
|
||||
|
||||
// Check if the weather is hail
|
||||
if (battle.WeatherName != ScriptUtils.ResolveName<Weather.Hail>())
|
||||
return;
|
||||
|
||||
// Heal the Pokémon for 1/16 of its maximum HP
|
||||
EventBatchId batchId = new();
|
||||
var healAmount = _pokemon.MaxHealth / 16;
|
||||
_pokemon.Heal(healAmount, true, batchId);
|
||||
|
||||
// Trigger the ability event
|
||||
battle.EventHook.Invoke(new AbilityTriggerEvent(_pokemon)
|
||||
{
|
||||
BatchId = batchId,
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void CustomTrigger(StringKey eventName, IDictionary<StringKey, object?>? parameters)
|
||||
{
|
||||
if (eventName != CustomTriggers.IgnoreHail || parameters is null)
|
||||
return;
|
||||
|
||||
parameters["ignoresHail"] = true;
|
||||
}
|
||||
}
|
||||
12
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Illuminate.cs
Normal file
12
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Illuminate.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
|
||||
/// <summary>
|
||||
/// Illuminate is an ability that increases the wild encounter rate when the Pokémon is leading the party.
|
||||
///
|
||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Illuminate_(Ability)">Bulbapedia - Illuminate</see>
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Ability, "illuminate")]
|
||||
public class Illuminate : Script
|
||||
{
|
||||
// No effect in battle.
|
||||
}
|
||||
55
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Illusion.cs
Normal file
55
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Illusion.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
|
||||
/// <summary>
|
||||
/// Illusion is an ability that disguises the Pokémon as the last non-fainted Pokémon in the party until it takes damage.
|
||||
///
|
||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Illusion_(Ability)">Bulbapedia - Illusion</see>
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Ability, "illusion")]
|
||||
public class Illusion : Script
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
throw new InvalidOperationException("Illusion can only be added to a Pokemon script source.");
|
||||
_pokemon = pokemon;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
{
|
||||
var battleData = pokemon.BattleData;
|
||||
if (battleData is null)
|
||||
return;
|
||||
var lastNonFaintedPokemon = battleData.Battle.Parties.FirstOrDefault(p => p.Party.Any(pkmn => pkmn == pokemon))
|
||||
?.Party.WhereNotNull().FirstOrDefault(x => x.IsUsable);
|
||||
if (lastNonFaintedPokemon is null || lastNonFaintedPokemon == pokemon)
|
||||
return;
|
||||
|
||||
pokemon.SetDisplaySpecies(lastNonFaintedPokemon.Species, lastNonFaintedPokemon.Form);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnRemove()
|
||||
{
|
||||
if (_pokemon is null)
|
||||
return;
|
||||
|
||||
_pokemon.SetDisplaySpecies(null, null);
|
||||
_pokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(_pokemon));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
if (_pokemon?.BattleData?.Battle is null)
|
||||
return;
|
||||
|
||||
// Remove the illusion when the Pokémon takes damage
|
||||
_pokemon.SetDisplaySpecies(null, null);
|
||||
_pokemon.BattleData.Battle.EventHook.Invoke(new AbilityTriggerEvent(_pokemon));
|
||||
}
|
||||
}
|
||||
21
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Immunity.cs
Normal file
21
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Immunity.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
|
||||
/// <summary>
|
||||
/// Immunity is an ability that prevents the Pokémon from being poisoned.
|
||||
///
|
||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Immunity_(Ability)">Bulbapedia - Immunity</see>
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Ability, "immunity")]
|
||||
public class Immunity : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
|
||||
ref bool preventStatus)
|
||||
{
|
||||
if (status == ScriptUtils.ResolveName<Status.Poisoned>() ||
|
||||
status == ScriptUtils.ResolveName<Status.BadlyPoisoned>())
|
||||
{
|
||||
preventStatus = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Imposter.cs
Normal file
12
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Imposter.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
|
||||
/// <summary>
|
||||
/// Imposter is an ability that transforms the Pokémon into its opponent upon entering battle.
|
||||
///
|
||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Imposter_(Ability)">Bulbapedia - Imposter</see>
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Ability, "imposter")]
|
||||
public class Imposter : Script
|
||||
{
|
||||
// TODO: Implement Imposter effect.
|
||||
}
|
||||
20
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Infiltrator.cs
Normal file
20
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Infiltrator.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
|
||||
/// <summary>
|
||||
/// Infiltrator is an ability that allows the Pokémon's moves to ignore the opposing side's barriers and substitutes.
|
||||
///
|
||||
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Infiltrator_(Ability)">Bulbapedia - Infiltrator</see>
|
||||
/// </summary>
|
||||
[Script(ScriptCategory.Ability, "infiltrator")]
|
||||
public class Infiltrator : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void CustomTrigger(StringKey eventName, IDictionary<StringKey, object?>? parameters)
|
||||
{
|
||||
if ((eventName != CustomTriggers.BypassProtection && eventName != CustomTriggers.BypassSubstitute) ||
|
||||
parameters is null)
|
||||
return;
|
||||
|
||||
parameters["bypass"] = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user