Bunch more moves, changes in how additional information for items works.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using PkmnLib.Static;
|
||||
using PkmnLib.Static.Libraries;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
@@ -29,12 +31,12 @@ public class ForesightEffect : Script
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeEffectiveness(IExecutingMove move, IPokemon target, byte hit, ref float effectiveness)
|
||||
public override void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||
IList<TypeIdentifier> types)
|
||||
{
|
||||
var hitData = move.GetHitData(target, hit);
|
||||
if (hitData.Type == _normalType && target.Types.Contains(_fightingType))
|
||||
effectiveness = _typeLibrary.GetEffectiveness(_normalType, target.Types.Where(x => x != _ghostType));
|
||||
else if (hitData.Type == _fightingType && target.Types.Contains(_ghostType))
|
||||
effectiveness = _typeLibrary.GetEffectiveness(_fightingType, target.Types.Where(x => x != _ghostType));
|
||||
if (executingMove.UseMove.MoveType == _normalType || executingMove.UseMove.MoveType == _fightingType)
|
||||
{
|
||||
types.RemoveAll(x => x == _ghostType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using PkmnLib.Static;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
@@ -35,22 +38,14 @@ public class IngrainEffect : Script
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeEffectiveness(IExecutingMove move, IPokemon target, byte hit, ref float effectiveness)
|
||||
public override void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||
IList<TypeIdentifier> types)
|
||||
{
|
||||
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);
|
||||
if (executingMove.UseMove.MoveType.Name == "ground")
|
||||
{
|
||||
var typeLibrary = target.Library.StaticLibrary.Types;
|
||||
// Remove all types that are immune to ground moves
|
||||
types.RemoveAll(x => typeLibrary.GetSingleEffectiveness(executingMove.UseMove.MoveType, x) == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "magma_storm")]
|
||||
public class MagmaStormEffect : Script
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
|
||||
public MagmaStormEffect(IPokemon owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
_owner.Damage(_owner.BoostedStats.Hp / 16, DamageSource.Misc);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void PreventSelfRunAway(IFleeChoice choice, ref bool prevent) => prevent = true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void PreventSelfSwitch(ISwitchChoice choice, ref bool prevent) => prevent = true;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "magnet_rise")]
|
||||
public class MagnetRiseEffect : Script
|
||||
{
|
||||
private int _turnsRemaining = 5;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeEffectiveness(IExecutingMove move, IPokemon target, byte hit, ref float effectiveness)
|
||||
{
|
||||
if (move.UseMove.MoveType.Name == "ground")
|
||||
{
|
||||
effectiveness = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
if (_turnsRemaining > 0)
|
||||
_turnsRemaining--;
|
||||
else
|
||||
RemoveSelf();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "mean_look_user")]
|
||||
public class MeanLookEffectUser : Script
|
||||
{
|
||||
private readonly ScriptContainer _targetScriptEffect;
|
||||
|
||||
public MeanLookEffectUser(ScriptContainer targetScriptEffect)
|
||||
{
|
||||
_targetScriptEffect = targetScriptEffect;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnRemove()
|
||||
{
|
||||
// Remove the effect from the target
|
||||
_targetScriptEffect.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "mean_look_target")]
|
||||
public class MeanLookEffectTarget : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void PreventSelfSwitch(ISwitchChoice choice, ref bool prevent) => prevent = true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void PreventSelfRunAway(IFleeChoice choice, ref bool prevent) => prevent = true;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using PkmnLib.Static;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "miracle_eye")]
|
||||
public class MiracleEyeEffect : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void PreventStatBoostChange(IPokemon target, Statistic stat, sbyte amount, bool selfInflicted,
|
||||
ref bool prevent)
|
||||
{
|
||||
if (stat == Statistic.Evasion && amount > 0)
|
||||
prevent = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeTypesForIncomingMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||
IList<TypeIdentifier> types)
|
||||
{
|
||||
if (executingMove.UseMove.MoveType.Name != "psychic")
|
||||
return;
|
||||
var darkType = types.FirstOrDefault(x => x.Name == "dark");
|
||||
if (darkType == null)
|
||||
return;
|
||||
types.Remove(darkType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Status;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
|
||||
[Script(ScriptCategory.Pokemon, "nightmare")]
|
||||
public class NightmareEffect : Script
|
||||
{
|
||||
private readonly IPokemon _owner;
|
||||
|
||||
public NightmareEffect(IPokemon owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
if (!_owner.HasStatus(ScriptUtils.ResolveName<Sleep>()))
|
||||
{
|
||||
RemoveSelf();
|
||||
return;
|
||||
}
|
||||
var maxHp = _owner.MaxHealth;
|
||||
_owner.Damage(maxHp / 4, DamageSource.Misc);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user