Support for changing turn choice when executing
All checks were successful
Build / Build (push) Successful in 50s
All checks were successful
Build / Build (push) Successful in 50s
This commit is contained in:
parent
b11203cb3a
commit
e305cfaef6
@ -77,6 +77,7 @@ public static class TurnRunner
|
||||
/// </summary>
|
||||
public static void ExecuteChoice(IBattle battle, ITurnChoice choice)
|
||||
{
|
||||
choice.RunScriptHook(x => x.ChangeTurnChoice(ref choice));
|
||||
if (choice is IPassChoice)
|
||||
return;
|
||||
if (battle.HasEnded)
|
||||
|
@ -296,7 +296,7 @@ public class BattleImpl : ScriptSource, IBattle
|
||||
|
||||
ITurnChoice? forcedChoice = null;
|
||||
pokemon.RunScriptHook(script =>
|
||||
script.ForceTurnSelection(battleData.SideIndex, battleData.Position, ref forcedChoice));
|
||||
script.ForceTurnSelection(this, battleData.SideIndex, battleData.Position, ref forcedChoice));
|
||||
choice = forcedChoice;
|
||||
return choice != null;
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ public abstract class Script : IDeepCloneable
|
||||
/// Force a certain move choice to be selected. If the choice is set, the Pokemon will be forced
|
||||
/// to use it, and will not be able to select any other choice.
|
||||
/// </summary>
|
||||
public virtual void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
public virtual void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
}
|
||||
|
||||
@ -302,7 +302,7 @@ public abstract class Script : IDeepCloneable
|
||||
/// This function allows a script to change the damage modifier of a Same Type Attack Bonus, which
|
||||
/// occurs when the user has the move type as one of its own types.
|
||||
/// </summary>
|
||||
public virtual void ChangeStabModifier(IExecutingMove executingMove, IPokemon target, byte hitNumber,
|
||||
public virtual void ChangeStabModifier(IExecutingMove executingMove, IPokemon target, byte hitNumber, bool isStab,
|
||||
ref float modifier)
|
||||
{
|
||||
}
|
||||
@ -851,4 +851,8 @@ public abstract class Script : IDeepCloneable
|
||||
public virtual void OnAfterMoveChoice(IMoveChoice moveChoice)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void ChangeTurnChoice(ref ITurnChoice choice)
|
||||
{
|
||||
}
|
||||
}
|
@ -44,13 +44,16 @@ public class Gen7DamageCalculator(Gen7PluginConfiguration configuration) : IDama
|
||||
floatDamage = MathF.Floor(floatDamage * randomFactor);
|
||||
}
|
||||
|
||||
var stabModifier = 1.0f;
|
||||
var isStab = false;
|
||||
if (hitData.Type != null && executingMove.User.Types.Contains(hitData.Type.Value))
|
||||
{
|
||||
var stabModifier = 1.5f;
|
||||
executingMove.RunScriptHook(script =>
|
||||
script.ChangeStabModifier(executingMove, target, hitNumber, ref stabModifier));
|
||||
floatDamage = MathF.Floor(floatDamage * stabModifier);
|
||||
stabModifier = 1.5f;
|
||||
isStab = true;
|
||||
}
|
||||
executingMove.RunScriptHook(script =>
|
||||
script.ChangeStabModifier(executingMove, target, hitNumber, isStab, ref stabModifier));
|
||||
floatDamage = MathF.Floor(floatDamage * stabModifier);
|
||||
|
||||
floatDamage = MathF.Floor(floatDamage * hitData.Effectiveness);
|
||||
uint damage = floatDamage switch
|
||||
|
@ -10,10 +10,10 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
public class IncreasedStab : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeStabModifier(IExecutingMove executingMove, IPokemon target, byte hitNumber,
|
||||
public override void ChangeStabModifier(IExecutingMove executingMove, IPokemon target, byte hitNumber, bool isStab,
|
||||
ref float modifier)
|
||||
{
|
||||
if (!modifier.IsApproximatelyEqualTo(1.5f))
|
||||
if (!isStab || !modifier.IsApproximatelyEqualTo(1.5f))
|
||||
return;
|
||||
executingMove.Battle.EventHook.Invoke(new AbilityTriggerEvent(executingMove.User));
|
||||
modifier = 2.0f;
|
||||
|
@ -15,7 +15,7 @@ public abstract class BaseChargeEffect : Script
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, _moveName, opposingSideIndex, position);
|
||||
|
@ -34,7 +34,7 @@ public class BideEffect : Script
|
||||
private ITurnChoice? _choice;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
if (_owner == null)
|
||||
return;
|
||||
|
@ -13,7 +13,7 @@ public class ChargeBounceEffect : Script
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "bounce", opposingSideIndex, position);
|
||||
|
@ -13,7 +13,7 @@ public class ChargeFlyEffect : Script
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "fly", opposingSideIndex, position);
|
||||
|
@ -20,7 +20,7 @@ public class ChargeMoveEffect : Script
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_user, MoveName, _targetSide, _targetPosition);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class ChargeSkyDropEffect : Script
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "sky_drop", opposingSideIndex, position);
|
||||
|
@ -13,7 +13,7 @@ public class DigEffect : Script
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "dig", opposingSideIndex, position);
|
||||
|
@ -13,7 +13,7 @@ public class DiveEffect : Script
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "dive", opposingSideIndex, position);
|
||||
|
@ -18,7 +18,7 @@ public class EncoreEffect : Script
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, _move, opposingSideIndex, position);
|
||||
|
@ -18,7 +18,7 @@ public class IceBallEffect : Script
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, _moveName, opposingSideIndex, position);
|
||||
|
@ -21,7 +21,7 @@ public abstract class OutrageLikeEffect : Script
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, _move, _targetSide, _targetPosition);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class PhantomForceCharge : Script
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "phantom_force", opposingSideIndex, position);
|
||||
|
@ -11,7 +11,7 @@ public class RequiresRechargeEffect : Script
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
choice = new PassChoice(_owner);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class ShadowForceCharge : Script
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "shadow_force", opposingSideIndex, position);
|
||||
|
@ -13,7 +13,7 @@ public class SkullBashEffect : Script
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "skull_bash", sideIndex, position);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class SkyAttackEffect : Script
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
choice = TurnChoiceHelper.CreateMoveChoice(_owner, "sky_attack", sideIndex, position);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
|
||||
public class TruantEffect(IPokemon owner) : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ForceTurnSelection(byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
public override void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
|
||||
{
|
||||
choice = new PassChoice(owner);
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Utils;
|
||||
|
||||
public static class TurnChoiceHelper
|
||||
|
Loading…
x
Reference in New Issue
Block a user