More abilities
This commit is contained in:
parent
1579d46671
commit
e68491e72a
@ -1256,6 +1256,8 @@ public class PokemonImpl : ScriptSource, IPokemon
|
|||||||
{
|
{
|
||||||
ChangeForm(battleData.OriginalSpecies == Species ? battleData.OriginalForm : Species.GetDefaultForm());
|
ChangeForm(battleData.OriginalSpecies == Species ? battleData.OriginalForm : Species.GetDefaultForm());
|
||||||
}
|
}
|
||||||
|
DisplaySpecies = null;
|
||||||
|
DisplayForm = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
@ -288,15 +288,33 @@
|
|||||||
"infiltrator": {
|
"infiltrator": {
|
||||||
"effect": "infiltrator"
|
"effect": "infiltrator"
|
||||||
},
|
},
|
||||||
"innards_out": {},
|
"innards_out": {
|
||||||
"inner_focus": {},
|
"effect": "innards_out"
|
||||||
"insomnia": {},
|
},
|
||||||
"intimidate": {},
|
"inner_focus": {
|
||||||
"iron_barbs": {},
|
"effect": "inner_focus"
|
||||||
"iron_fist": {},
|
},
|
||||||
"justified": {},
|
"insomnia": {
|
||||||
"keen_eye": {},
|
"effect": "insomnia"
|
||||||
"klutz": {},
|
},
|
||||||
|
"intimidate": {
|
||||||
|
"effect": "intimidate"
|
||||||
|
},
|
||||||
|
"iron_barbs": {
|
||||||
|
"effect": "iron_barbs"
|
||||||
|
},
|
||||||
|
"iron_fist": {
|
||||||
|
"effect": "iron_fist"
|
||||||
|
},
|
||||||
|
"justified": {
|
||||||
|
"effect": "justified"
|
||||||
|
},
|
||||||
|
"keen_eye": {
|
||||||
|
"effect": "keen_eye"
|
||||||
|
},
|
||||||
|
"klutz": {
|
||||||
|
"effect": "klutz"
|
||||||
|
},
|
||||||
"leaf_guard": {},
|
"leaf_guard": {},
|
||||||
"levitate": {},
|
"levitate": {},
|
||||||
"light_metal": {},
|
"light_metal": {},
|
||||||
|
35
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/InnardsOut.cs
Normal file
35
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/InnardsOut.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Innards Out is an ability that deals damage to the attacker equal to the amount of HP lost when the Pokémon with this ability faints.
|
||||||
|
///
|
||||||
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Innards_Out_(Ability)">Bulbapedia - Innards Out</see>
|
||||||
|
/// </summary>
|
||||||
|
[Script(ScriptCategory.Ability, "innards_out")]
|
||||||
|
public class InnardsOut : Script
|
||||||
|
{
|
||||||
|
private IPokemon? _lastPokemonToHit;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||||
|
{
|
||||||
|
_lastPokemonToHit = move.User;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void OnDamage(IPokemon pokemon, DamageSource source, uint oldHealth, uint newHealth)
|
||||||
|
{
|
||||||
|
if (newHealth != 0 || source is not DamageSource.MoveDamage)
|
||||||
|
return;
|
||||||
|
if (_lastPokemonToHit is null || !_lastPokemonToHit.IsUsable)
|
||||||
|
return;
|
||||||
|
|
||||||
|
EventBatchId batchId = new();
|
||||||
|
|
||||||
|
pokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon)
|
||||||
|
{
|
||||||
|
BatchId = batchId,
|
||||||
|
});
|
||||||
|
_lastPokemonToHit.Damage(oldHealth, DamageSource.Misc, batchId);
|
||||||
|
}
|
||||||
|
}
|
31
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/InnerFocus.cs
Normal file
31
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/InnerFocus.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||||
|
|
||||||
|
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inner Focus is an ability that prevents the Pokémon from flinching.
|
||||||
|
///
|
||||||
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Inner_Focus_(Ability)">Bulbapedia - Inner Focus</see>
|
||||||
|
/// </summary>
|
||||||
|
[Script(ScriptCategory.Ability, "inner_focus")]
|
||||||
|
public class InnerFocus : 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 PreventVolatileAdd(Script script, ref bool preventVolatileAdd)
|
||||||
|
{
|
||||||
|
if (script is not FlinchEffect)
|
||||||
|
return;
|
||||||
|
_pokemon?.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(_pokemon));
|
||||||
|
preventVolatileAdd = true;
|
||||||
|
}
|
||||||
|
}
|
20
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Insomnia.cs
Normal file
20
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Insomnia.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Insomnia is an ability that prevents the Pokémon from falling asleep.
|
||||||
|
///
|
||||||
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Insomnia_(Ability)">Bulbapedia - Insomnia</see>
|
||||||
|
/// </summary>
|
||||||
|
[Script(ScriptCategory.Ability, "insomnia")]
|
||||||
|
public class Insomnia : Script
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
|
||||||
|
ref bool preventStatus)
|
||||||
|
{
|
||||||
|
if (status != ScriptUtils.ResolveName<Status.Sleep>())
|
||||||
|
return;
|
||||||
|
pokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
|
||||||
|
preventStatus = true;
|
||||||
|
}
|
||||||
|
}
|
28
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Intimidate.cs
Normal file
28
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Intimidate.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Intimidate is an ability that lowers the opposing Pokémon's Attack stat when the Pokémon enters battle.
|
||||||
|
///
|
||||||
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Intimidate_(Ability)">Bulbapedia - Intimidate</see>
|
||||||
|
/// </summary>
|
||||||
|
[Script(ScriptCategory.Ability, "intimidate")]
|
||||||
|
public class Intimidate : Script
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void OnSwitchIn(IPokemon pokemon, byte position)
|
||||||
|
{
|
||||||
|
var battle = pokemon.BattleData?.Battle;
|
||||||
|
if (battle is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var opponents = battle.Sides.Where(side => side != pokemon.BattleData?.BattleSide)
|
||||||
|
.SelectMany(side => side.Pokemon).WhereNotNull().Where(opponent => opponent.IsUsable);
|
||||||
|
EventBatchId batchId = new();
|
||||||
|
|
||||||
|
battle.EventHook.Invoke(new AbilityTriggerEvent(pokemon));
|
||||||
|
foreach (var opponent in opponents)
|
||||||
|
{
|
||||||
|
opponent.ChangeStatBoost(Statistic.Attack, -1, true, true, batchId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
19
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/IronBarbs.cs
Normal file
19
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/IronBarbs.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Iron Barbs is an ability that damages attackers making contact with the Pokémon.
|
||||||
|
///
|
||||||
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Iron_Barbs_(Ability)">Bulbapedia - Iron Barbs</see>
|
||||||
|
/// </summary>
|
||||||
|
[Script(ScriptCategory.Ability, "iron_barbs")]
|
||||||
|
public class IronBarbs : Script
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||||
|
{
|
||||||
|
if (move.UseMove.HasFlag("contact"))
|
||||||
|
{
|
||||||
|
move.User.Damage(move.User.MaxHealth / 8, DamageSource.Misc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/IronFist.cs
Normal file
17
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/IronFist.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Iron Fist is an ability that increases the power of punching moves.
|
||||||
|
///
|
||||||
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Iron_Fist_(Ability)">Bulbapedia - Iron Fist</see>
|
||||||
|
/// </summary>
|
||||||
|
[Script(ScriptCategory.Ability, "iron_fist")]
|
||||||
|
public class IronFist : Script
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
|
||||||
|
{
|
||||||
|
if (move.UseMove.HasFlag("punch"))
|
||||||
|
basePower = basePower.MultiplyOrMax(1.2f);
|
||||||
|
}
|
||||||
|
}
|
25
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Justified.cs
Normal file
25
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Justified.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Justified is an ability that raises the Pokémon's Attack stat when hit by a Dark-type move.
|
||||||
|
///
|
||||||
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Justified_(Ability)">Bulbapedia - Justified</see>
|
||||||
|
/// </summary>
|
||||||
|
[Script(ScriptCategory.Ability, "justified")]
|
||||||
|
public class Justified : Script
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||||
|
{
|
||||||
|
if (move.GetHitData(target, hit).Type?.Name != "dark")
|
||||||
|
return;
|
||||||
|
|
||||||
|
EventBatchId batchId = new();
|
||||||
|
|
||||||
|
move.Battle.EventHook.Invoke(new AbilityTriggerEvent(target)
|
||||||
|
{
|
||||||
|
BatchId = batchId,
|
||||||
|
});
|
||||||
|
target.ChangeStatBoost(Statistic.Attack, 1, true, false, batchId);
|
||||||
|
}
|
||||||
|
}
|
18
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/KeenEye.cs
Normal file
18
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/KeenEye.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Keen Eye is an ability that prevents the Pokémon's accuracy from being lowered.
|
||||||
|
///
|
||||||
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Keen_Eye_(Ability)">Bulbapedia - Keen Eye</see>
|
||||||
|
/// </summary>
|
||||||
|
[Script(ScriptCategory.Ability, "keen_eye")]
|
||||||
|
public class KeenEye : Script
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void PreventStatBoostChange(IPokemon target, Statistic stat, sbyte amount, bool selfInflicted,
|
||||||
|
ref bool prevent)
|
||||||
|
{
|
||||||
|
if (stat == Statistic.Accuracy && amount < 0)
|
||||||
|
prevent = true;
|
||||||
|
}
|
||||||
|
}
|
23
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Klutz.cs
Normal file
23
Plugins/PkmnLib.Plugin.Gen7/Scripts/Abilities/Klutz.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Klutz is an ability that prevents the Pokémon from using its held item in battle.
|
||||||
|
///
|
||||||
|
/// <see href="https://bulbapedia.bulbagarden.net/wiki/Klutz_(Ability)">Bulbapedia - Klutz</see>
|
||||||
|
/// </summary>
|
||||||
|
[Script(ScriptCategory.Ability, "klutz")]
|
||||||
|
public class Klutz : Script
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void OnBeforeAnyHookInvoked(ref List<ScriptCategory>? suppressedCategories)
|
||||||
|
{
|
||||||
|
suppressedCategories ??= new List<ScriptCategory>();
|
||||||
|
suppressedCategories.Add(ScriptCategory.ItemBattleTrigger);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void PreventHeldItemConsume(IPokemon pokemon, IItem heldItem, ref bool prevented)
|
||||||
|
{
|
||||||
|
prevented = true;
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,12 @@ public class Rest : Script
|
|||||||
move.GetHitData(target, hit).Fail();
|
move.GetHitData(target, hit).Fail();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (move.User.ActiveAbility?.Effect == ScriptUtils.ResolveName<Abilities.InnerFocus>())
|
||||||
|
{
|
||||||
|
move.GetHitData(target, hit).Fail();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (move.User.SetStatus(ScriptUtils.ResolveName<Sleep>(), true) && move.User.StatusScript.Script is Sleep sleep)
|
if (move.User.SetStatus(ScriptUtils.ResolveName<Sleep>(), true) && move.User.StatusScript.Script is Sleep sleep)
|
||||||
sleep.Turns = 2;
|
sleep.Turns = 2;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user