Skip to content

Commit

Permalink
Startup fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DerpleMQ2 committed Jan 1, 2024
1 parent 8112441 commit d510183
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
17 changes: 14 additions & 3 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ local function RGInit(...)
"MQ2AdvPath",
"MQ2MoveUtils",
"MQ2Nav",
"MQ2DanNet",
"MQ2SpawnMaster" })
"MQ2DanNet" })

unloadedPlugins = RGMercUtils.UnCheckPlugins({ "MQ2Melee" })

Expand All @@ -170,13 +169,25 @@ local function RGInit(...)
if #unloaded == 1 then table.insert(unloadedPlugins, unloaded[1]) end
end

local mainAssist = mq.TLO.Me.Name()
local mainAssist = RGMercUtils.GetTargetName()

if mainAssist:len() == 0 and mq.TLO.Group() then
mainAssist = mq.TLO.Group.MainAssist() or ""
end

for k, v in ipairs(RGMercConfig.ExpansionIDToName) do
RGMercsLogger.log_debug("\ayExpanions \at%s\ao[\am%d\ao]: %s", v, k, RGMercUtils.HaveExpansion(v) and "\agEnabled" or "\arDisabled")
end

-- TODO: Can turn this into an options parser later.
if ... then
mainAssist = ...
end

if not mainAssist or mainAssist == "" then
mainAssist = mq.TLO.Me.CleanName()
end

mq.cmdf("/squelch /rez accept on")
mq.cmdf("/squelch /rez pct 90")

Expand Down
5 changes: 4 additions & 1 deletion utils/rgmercs_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ Config.ExpansionNameToID = {
['EXPANSION_LEVEL_LS'] = 30, -- Laurion's Song
}

Config.ExpansionIDToName = {}
for k, v in pairs(Config.ExpansionNameToID) do Config.ExpansionIDToName[v] = k end

-- Defaults
Config.DefaultConfig = {
Config.DefaultConfig = {
['DoAutoTarget'] = { DisplayName = "Auto Target", Tooltip = "Automatically change targets.", Default = true },
['DoMercenary'] = { DisplayName = "Use Mercenary", Tooltip = "Use Merc during combat.", Default = true },
['PriorityHealing'] = { DisplayName = "Priority Healing", Tooltip = "Prioritize Healing over Combat", Default = false },
Expand Down
8 changes: 6 additions & 2 deletions utils/rgmercs_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,10 @@ function Utils.GetTargetPctHPs()
return (mq.TLO.Target.PctHPs() or 0)
end

function Utils.GetTargetName()
return (mq.TLO.Target.Name() or "")
end

function Utils.GetTargetID()
return (mq.TLO.Target.ID() or 0)
end
Expand Down Expand Up @@ -1223,7 +1227,7 @@ function Utils.OkToEngage(autoTargetId)

if not target() then return false end

if target.ID() ~= autoTargetId then
if Utils.GetTargetID() ~= autoTargetId then
RGMercsLogger.log_debug("%d != %d --> Not Engageing", target.ID() or 0, autoTargetId)
return false
end
Expand All @@ -1234,7 +1238,7 @@ function Utils.OkToEngage(autoTargetId)
end

if Utils.GetXTHaterCount() > 0 then -- TODO: or AutoTargetID and !BackOffFlag
if target.Distance() < config.AssistRange and (Utils.GetTargetPctHPs() < config.AutoAssistAt or RGMercConfig.Globals.IsTanking or assistId == mq.TLO.Me.ID()) then
if Utils.GetTargetDistance() < config.AssistRange and (Utils.GetTargetPctHPs() < config.AutoAssistAt or RGMercConfig.Globals.IsTanking or assistId == mq.TLO.Me.ID()) then
if not mq.TLO.Me.Combat() then
RGMercsLogger.log_debug("\ay%d < %d and %d < %d or Tanking or %d == %d --> \agOK To Engage!",
target.Distance(), config.AssistRange, Utils.GetTargetPctHPs(), config.AutoAssistAt, assistId, mq.TLO.Me.ID())
Expand Down

0 comments on commit d510183

Please sign in to comment.