Skip to content

Commit

Permalink
Spell wait timeouts.
Browse files Browse the repository at this point in the history
  • Loading branch information
DerpleMQ2 committed Jan 5, 2024
1 parent 21317a3 commit 58e3c1f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions utils/rgmercs_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -301,23 +301,26 @@ function Utils.CastReady(spell)
end

---@param spell string
function Utils.WaitCastReady(spell)
while not mq.TLO.Me.SpellReady(spell)() do
---@param maxWait number # how many ms to wait before giving up
function Utils.WaitCastReady(spell, maxWait)
while not mq.TLO.Me.SpellReady(spell)() and maxWait > 0 do
mq.delay(100)
mq.doevents()
if Utils.GetXTHaterCount() > 0 then
RGMercsLogger.log_debug("I was interruped by combat while waiting to cast %s.", spell)
return
end
--RGMercsLogger.log_debug("Waiting for spell '%s' to be ready...", spell)

maxWait = maxWait - 100
RGMercsLogger.log_verbose("Waiting for spell '%s' to be ready...", spell)
end
end

function Utils.WaitGlobalCoolDown()
while mq.TLO.Me.SpellInCooldown() do
mq.delay(100)
mq.doevents()
--RGMercsLogger.log_debug("Waiting for spell '%s' to be ready...", spell)
RGMercsLogger.log_verbose("Waiting for Global Cooldown to be ready...")
end
end

Expand Down Expand Up @@ -552,7 +555,7 @@ function Utils.UseSpell(spellName, targetId, bAllowMem)
return false
end

Utils.WaitCastReady(spellName)
Utils.WaitCastReady(spellName, 5000)

Utils.ActionPrep()

Expand Down
2 changes: 1 addition & 1 deletion version.lua
Original file line number Diff line number Diff line change
@@ -1 +1 @@
return { commitId = '9c65bc5 2024-01-05' }
return { commitId = '21317a3 2024-01-05' }

0 comments on commit 58e3c1f

Please sign in to comment.