Skip to content

Commit

Permalink
- Fixed an issue with auto attack turning on and added more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
DerpleMQ2 committed Feb 19, 2024
1 parent f52508f commit c5119ff
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions utils/rgmercs_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1443,13 +1443,21 @@ end
---@param target MQTarget|nil
---@return number
function Utils.GetTargetPctHPs(target)
return (target and target.PctHPs() or (mq.TLO.Target.PctHPs() or 0))
local useTarget = target
if not useTarget then useTarget = mq.TLO.Target end
if not useTarget or not useTarget() then return 0 end

return useTarget.PctHPs()
end

---@param target MQTarget|nil
---@return boolean
function Utils.GetTargetDead(target)
return (target and target.Dead() or (mq.TLO.Target.Dead() or true))
local useTarget = target
if not useTarget then useTarget = mq.TLO.Target end
if not useTarget or not useTarget() then return true end

return useTarget.Dead()
end

---@param target MQTarget|nil
Expand Down Expand Up @@ -1987,13 +1995,15 @@ function Utils.EngageTarget(autoTargetId, preEngageRoutine)
mq.TLO.Me.Stand()
end

RGMercsLogger.log_verbose("\awNOTICE:\ax EngageTarget(%s) Checking for valid Target.", Utils.GetTargetCleanName())

if target() and (target.ID() or 0) == autoTargetId and (mq.TLO.Target.Distance() or 0) <= config.AssistRange then
if config.DoMelee then
if mq.TLO.Me.Sitting() then
mq.TLO.Me.Stand()
end

if (Utils.GetTargetPctHPs() <= config.AutoAssistAt or Utils.IAmMA()) and not Utils.GetTargetDead() then
if (Utils.GetTargetPctHPs() <= config.AutoAssistAt or Utils.IAmMA()) and not Utils.GetTargetDead(target) then
if target.Distance() > Utils.GetTargetMaxRangeTo(target) then
RGMercsLogger.log_debug("Target is too far! %d>%d attempting to nav to it.", target.Distance(),
target.MaxRangeTo())
Expand All @@ -2011,19 +2021,23 @@ function Utils.EngageTarget(autoTargetId, preEngageRoutine)
end

if not mq.TLO.Me.Combat() then
RGMercsLogger.log_info("\awNOTICE:\ax Engaging %s in mortal combat.", target.CleanName())
Utils.DoCmd("/keypress AUTOPRIM")
RGMercsLogger.log_info("\awNOTICE:\ax Engaging %s in mortal combat.", Utils.GetTargetCleanName())
Utils.DoCmd("/attack on")
end
end
else
RGMercsLogger.log_verbose("\awNOTICE:\ax EngageTarget(%s) Target is above Assist HP or Dead.", Utils.GetTargetCleanName())
end
else
RGMercsLogger.log_verbose("\awNOTICE:\ax EngageTarget(%s) DoMelee is false.", Utils.GetTargetCleanName())
end
else
if not config.DoMelee and RGMercConfig.Constants.RGCasters:contains(mq.TLO.Me.Class.ShortName()) and target.Named() and target.Body.Name() == "Dragon" then
Utils.DoCmd("/stick pin 40")
end

-- TODO: why are we doing this after turning stick on just now?
if mq.TLO.Stick.Status():lower() == "on" then Utils.DoCmd("/stick off") end
--if mq.TLO.Stick.Status():lower() == "on" then Utils.DoCmd("/stick off") end
end
end

Expand Down

0 comments on commit c5119ff

Please sign in to comment.