Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: change the delay.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jan 20, 2023
1 parent 7610fd8 commit 98ceec3
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions RotationSolver/Updaters/ActionUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ private static void UPdateMPTimer()
_lastMP = player.CurrentMp;
}

static readonly Stopwatch _weaponDelayStopwatch = new Stopwatch();
static long _weaponRandomDelay = 0;
static DateTime _lastWeaponGo = DateTime.MinValue;
static float _weaponRandomDelay = -1;
internal static float _lastCastingTotal = 0;
internal unsafe static void DoAction()
{
Expand All @@ -173,22 +173,17 @@ internal unsafe static void DoAction()
//GCD
if (WeaponRemain <= Service.Configuration.WeaponFaster)
{
if (!_weaponDelayStopwatch.IsRunning)
if(_weaponRandomDelay < 0)
{
_weaponDelayStopwatch.Start();
return;
Random ran = new Random(DateTime.Now.Millisecond);
_weaponRandomDelay = (float)ran.NextDouble() * Service.Configuration.WeaponDelay;

_lastWeaponGo = DateTime.Now;
}
else if (_weaponDelayStopwatch.ElapsedMilliseconds > _weaponRandomDelay)
else if ((DateTime.Now - _lastWeaponGo).TotalSeconds >= _weaponRandomDelay)
{
_weaponDelayStopwatch.Stop();
_weaponDelayStopwatch.Reset();

_weaponRandomDelay = -1;
RSCommands.DoAnAction(true);

Random ran = new Random(DateTime.Now.Millisecond);
_weaponRandomDelay = (long)(ran.NextDouble() * Service.Configuration.WeaponDelay * 1000);

return;
}
return;
}
Expand Down Expand Up @@ -216,9 +211,4 @@ internal unsafe static void DoAction()
RSCommands.DoAnAction(false);
}
}

public static void Dispose()
{
_weaponDelayStopwatch?.Stop();
}
}

0 comments on commit 98ceec3

Please sign in to comment.