More move scripts
This commit is contained in:
parent
4584185a42
commit
85ea31f7cd
|
@ -299,7 +299,7 @@ public interface IPokemon : IScriptSource, IDeepCloneable
|
|||
/// Heals the Pokemon by a specific amount. Unless allow_revive is set to true, this will not
|
||||
/// heal if the Pokemon has 0 health. If the amount healed is 0, this will return false.
|
||||
/// </summary>
|
||||
bool Heal(uint heal, bool allowRevive);
|
||||
bool Heal(uint heal, bool allowRevive = false);
|
||||
|
||||
/// <summary>
|
||||
/// Restores all PP of the Pokemon.
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
using System.Collections.Generic;
|
||||
using PkmnLib.Dynamic.Libraries;
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "heal_each_end_of_turn")]
|
||||
public class HealEachEndOfTurn : Script
|
||||
{
|
||||
private float _healPercentage;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnInitialize(IDynamicLibrary library, IReadOnlyDictionary<StringKey, object?>? parameters)
|
||||
{
|
||||
base.OnInitialize(library, parameters);
|
||||
if (parameters == null || !parameters.TryGetValue("percent", out var healPercentageObj) ||
|
||||
healPercentageObj is not float healPercentage)
|
||||
{
|
||||
_healPercentage = 6.25f;
|
||||
}
|
||||
else
|
||||
{
|
||||
_healPercentage = healPercentage!;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
var effectName = ScriptUtils.ResolveName<HealEachEndOfTurnEffect>();
|
||||
if (target.Volatile.Contains(effectName))
|
||||
{
|
||||
move.GetHitData(target, hit).Fail();
|
||||
return;
|
||||
}
|
||||
target.Volatile.Add(new HealEachEndOfTurnEffect(_healPercentage, target));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "increased_critical_stage")]
|
||||
public class IncreasedCriticalStage : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeCriticalStage(IExecutingMove move, IPokemon target, byte hit, ref byte stage)
|
||||
{
|
||||
// Extreme edge case, should never happen
|
||||
if (stage == byte.MaxValue)
|
||||
{
|
||||
move.GetHitData(target, hit).Fail();
|
||||
return;
|
||||
}
|
||||
stage += 1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
using PkmnLib.Dynamic.Models.Choices;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "2_5_hit_move")]
|
||||
public class MultiHitMove : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeNumberOfHits(IMoveChoice choice, ref byte numberOfHits)
|
||||
{
|
||||
var random = choice.User.BattleData?.Battle.Random;
|
||||
if (random == null)
|
||||
return;
|
||||
var roll = random.GetInt(100);
|
||||
// 35% chance that it will hit 2 times, a 35% chance it will hit 3 times, a 15% chance it
|
||||
// will hit 4 times, and a 15% chance it will hit 5 times.
|
||||
var newHits = roll switch
|
||||
{
|
||||
< 35 => 2,
|
||||
< 70 => 3,
|
||||
< 85 => 4,
|
||||
_ => 5
|
||||
};
|
||||
numberOfHits = (byte)newHits;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "prevent_foes_exit")]
|
||||
public class PreventFoesExit : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
move.User.Volatile.Add(new PreventFoesExitEffect());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "heal_each_end_of_turn_effect")]
|
||||
public class HealEachEndOfTurnEffect : Script
|
||||
{
|
||||
private readonly float _healPercentage;
|
||||
private readonly IPokemon? _pokemon;
|
||||
|
||||
private HealEachEndOfTurnEffect()
|
||||
{
|
||||
}
|
||||
|
||||
public HealEachEndOfTurnEffect(float healPercentage, IPokemon pokemon)
|
||||
{
|
||||
_healPercentage = healPercentage;
|
||||
_pokemon = pokemon;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn()
|
||||
{
|
||||
if (_pokemon is null)
|
||||
return;
|
||||
if (_pokemon.BattleData?.IsOnBattlefield != true)
|
||||
return;
|
||||
|
||||
var amount = _pokemon.BoostedStats.Hp * _healPercentage;
|
||||
if (_pokemon.HasHeldItem("big_root"))
|
||||
amount *= 1.3f;
|
||||
_pokemon.Heal((uint)amount);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
using PkmnLib.Dynamic.Models.Choices;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "prevent_foes_exit_effect")]
|
||||
public class PreventFoesExitEffect : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void PreventOpponentSwitch(ISwitchChoice choice, ref bool prevent)
|
||||
{
|
||||
prevent = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void PreventOpponentRunAway(IFleeChoice choice, ref bool prevent)
|
||||
{
|
||||
prevent = true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue