This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Status;
|
||||
|
||||
[Script(ScriptCategory.Status, "sleep")]
|
||||
public class Sleep : Script, IScriptPreventMove, IAIInfoScriptNumberTurnsLeft
|
||||
public class Sleep : Script, IScriptChangeNumberOfHits, IAIInfoScriptNumberTurnsLeft
|
||||
{
|
||||
private IPokemon? _pokemon;
|
||||
public int Turns { get; set; }
|
||||
@@ -27,23 +27,27 @@ public class Sleep : Script, IScriptPreventMove, IAIInfoScriptNumberTurnsLeft
|
||||
}
|
||||
|
||||
/// <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--;
|
||||
if (Turns <= 0)
|
||||
if (Turns < 0)
|
||||
{
|
||||
move.User.ClearStatus();
|
||||
choice.User.ClearStatus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (move.UseMove.HasFlag(MoveFlags.UsableWhileAsleep))
|
||||
if (choice.ChosenMove.MoveData.HasFlag(MoveFlags.UsableWhileAsleep))
|
||||
return;
|
||||
|
||||
var args = new CustomTriggers.BypassSleepArgs(move, false);
|
||||
move.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.BypassSleep, args));
|
||||
var args = new CustomTriggers.BypassSleepArgs(choice, false);
|
||||
choice.RunScriptHook<IScriptCustomTrigger>(x => x.CustomTrigger(CustomTriggers.BypassSleep, args));
|
||||
if (args.Bypass)
|
||||
return;
|
||||
prevent = true;
|
||||
numberOfHits = 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Reference in New Issue
Block a user