More moves implemented
This commit is contained in:
56
Plugins/PkmnLib.Plugin.Gen7/Scripts/Pokemon/IngrainEffect.cs
Normal file
56
Plugins/PkmnLib.Plugin.Gen7/Scripts/Pokemon/IngrainEffect.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "ingrain")]
|
||||
public class IngrainEffect : Script
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
|
||||
public IngrainEffect(IPokemon owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void PreventSelfSwitch(ISwitchChoice choice, ref bool prevent) => prevent = true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void PreventSelfRunAway(IFleeChoice choice, ref bool prevent) => prevent = true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
var heal = _owner.BoostedStats.Hp / 16;
|
||||
_owner.Heal(heal);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void FailIncomingMove(IExecutingMove move, IPokemon target, ref bool fail)
|
||||
{
|
||||
if (move.UseMove.Name == "roar" || move.UseMove.Name == "whirlwind")
|
||||
{
|
||||
fail = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeEffectiveness(IExecutingMove move, IPokemon target, byte hit, ref float effectiveness)
|
||||
{
|
||||
var battleData = target.BattleData;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
if (move.UseMove.MoveType.Name != "ground")
|
||||
return;
|
||||
var targetTypes = target.Types;
|
||||
var typeLibrary = battleData.Battle.Library.StaticLibrary.Types;
|
||||
effectiveness =
|
||||
// Get the effectiveness of the move against each target type
|
||||
targetTypes.Select(x => typeLibrary.GetSingleEffectiveness(move.UseMove.MoveType, x))
|
||||
// Ignore all types that are immune to ground moves
|
||||
.Where(x => x > 0)
|
||||
// Multiply all effectiveness values together
|
||||
.Aggregate(1.0f, (current, x) => current * x);
|
||||
}
|
||||
}
|
||||
18
Plugins/PkmnLib.Plugin.Gen7/Scripts/Pokemon/KingsShield.cs
Normal file
18
Plugins/PkmnLib.Plugin.Gen7/Scripts/Pokemon/KingsShield.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using PkmnLib.Static;
|
||||
using PkmnLib.Static.Moves;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "kings_shield")]
|
||||
public class KingsShield : ProtectionEffectScript
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
|
||||
{
|
||||
base.BlockIncomingHit(executingMove, target, hitIndex, ref block);
|
||||
if (executingMove.UseMove.Category != MoveCategory.Status && executingMove.UseMove.HasFlag("contact"))
|
||||
{
|
||||
executingMove.User.ChangeStatBoost(Statistic.Accuracy, -2, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "laser_focus")]
|
||||
public class LaserFocusEffect : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeCriticalStage(IExecutingMove move, IPokemon target, byte hit, ref byte stage)
|
||||
{
|
||||
stage = 100;
|
||||
RemoveSelf();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user