This commit is contained in:
@@ -40,7 +40,7 @@ public static class CustomTriggers
|
|||||||
|
|
||||||
public static readonly StringKey BypassSleep = "bypass_sleep";
|
public static readonly StringKey BypassSleep = "bypass_sleep";
|
||||||
|
|
||||||
public record BypassSleepArgs(IExecutingMove Move, bool Bypass) : ICustomTriggerArgs
|
public record BypassSleepArgs(IMoveChoice Choice, bool Bypass) : ICustomTriggerArgs
|
||||||
{
|
{
|
||||||
public bool Bypass { get; set; } = Bypass;
|
public bool Bypass { get; set; } = Bypass;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
namespace PkmnLib.Plugin.Gen7.Scripts.Status;
|
namespace PkmnLib.Plugin.Gen7.Scripts.Status;
|
||||||
|
|
||||||
[Script(ScriptCategory.Status, "sleep")]
|
[Script(ScriptCategory.Status, "sleep")]
|
||||||
public class Sleep : Script, IScriptPreventMove, IAIInfoScriptNumberTurnsLeft
|
public class Sleep : Script, IScriptChangeNumberOfHits, IAIInfoScriptNumberTurnsLeft
|
||||||
{
|
{
|
||||||
private IPokemon? _pokemon;
|
private IPokemon? _pokemon;
|
||||||
public int Turns { get; set; }
|
public int Turns { get; set; }
|
||||||
@@ -27,23 +27,27 @@ public class Sleep : Script, IScriptPreventMove, IAIInfoScriptNumberTurnsLeft
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void PreventMove(IExecutingMove move, ref bool prevent)
|
/// <remarks>
|
||||||
|
/// This is slightly hacky, but setting number of hits to 0 stops the move *before* the MoveUseEvent is triggered,
|
||||||
|
/// so this is cleaner for UI.
|
||||||
|
/// </remarks>
|
||||||
|
public void ChangeNumberOfHits(IMoveChoice choice, ref byte numberOfHits)
|
||||||
{
|
{
|
||||||
Turns--;
|
Turns--;
|
||||||
if (Turns <= 0)
|
if (Turns < 0)
|
||||||
{
|
{
|
||||||
move.User.ClearStatus();
|
choice.User.ClearStatus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (move.UseMove.HasFlag(MoveFlags.UsableWhileAsleep))
|
if (choice.ChosenMove.MoveData.HasFlag(MoveFlags.UsableWhileAsleep))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var args = new CustomTriggers.BypassSleepArgs(move, false);
|
var args = new CustomTriggers.BypassSleepArgs(choice, false);
|
||||||
move.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.BypassSleep, args));
|
choice.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.BypassSleep, args));
|
||||||
if (args.Bypass)
|
if (args.Bypass)
|
||||||
return;
|
return;
|
||||||
prevent = true;
|
numberOfHits = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
Reference in New Issue
Block a user