Skip to content

Commit

Permalink
new RGMercUtils cmd handler that can log.
Browse files Browse the repository at this point in the history
  • Loading branch information
DerpleMQ2 committed Jan 8, 2024
1 parent bf6914b commit 8d46830
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 112 deletions.
8 changes: 4 additions & 4 deletions class_configs/nec_class_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ local _ClassConfig = {
return mq.TLO.Me.State():lower() == "feign" and (mq.TLO.Me.PctAggro() < 90 or mq.TLO.Me.TargetOfTarget.ID() ~= mq.TLO.Me.ID())
end,
cmd = function()
mq.cmdf("/stand")
RGMercUtils.DoCmd("/stand")
return true
end,
},
Expand Down Expand Up @@ -906,7 +906,7 @@ local _ClassConfig = {
return mq.TLO.Me.State():lower() == "feign" and (mq.TLO.Me.PctAggro() < 90 or mq.TLO.Me.TargetOfTarget.ID() ~= mq.TLO.Me.ID())
end,
cmd = function()
mq.cmdf("/stand")
RGMercUtils.DoCmd("/stand")
return true
end,
},
Expand Down Expand Up @@ -964,7 +964,7 @@ local _ClassConfig = {
active_cond = function(self, _) return mq.TLO.Me.Pet.ID() ~= 0 and mq.TLO.Me.Pet.Class.ShortName():lower() == "war" end,
pre_activate = function(self, spell)
if mq.TLO.Me.Pet.ID() > 0 then
mq.cmdf("/pet leave")
RGMercUtils.DoCmd("/pet leave")
end
end,
cond = function(self, spell) return self.settings.PetType == 1 and (mq.TLO.Me.Pet.ID() == 0 or mq.TLO.Me.Pet.Class.ShortName():lower() ~= "war") end,
Expand All @@ -981,7 +981,7 @@ local _ClassConfig = {
active_cond = function(self, _) return mq.TLO.Me.Pet.ID() ~= 0 and mq.TLO.Me.Pet.Class.ShortName():lower() == "rog" end,
pre_activate = function(self, spell)
if mq.TLO.Me.Pet.ID() > 0 then
mq.cmdf("/pet leave")
RGMercUtils.DoCmd("/pet leave")
end
end,
cond = function(self, _) return self.settings.PetType == 2 and (mq.TLO.Me.Pet.ID() == 0 or mq.TLO.Me.Pet.Class.ShortName():lower() ~= "rog") end,
Expand Down
4 changes: 2 additions & 2 deletions class_configs/rog_class_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,8 @@ return {
return self.settings.DoHideSneak
end,
cmd = function()
if mq.TLO.Me.AbilityReady("hide") then mq.cmdf("/doability hide") end
if mq.TLO.Me.AbilityReady("sneak") then mq.cmdf("/doability sneak") end
if mq.TLO.Me.AbilityReady("hide") then RGMercUtils.DoCmd("/doability hide") end
if mq.TLO.Me.AbilityReady("sneak") then RGMercUtils.DoCmd("/doability sneak") end
return true
end,
},
Expand Down
4 changes: 2 additions & 2 deletions class_configs/shd_class_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ local _ClassConfig = {
mq.TLO.Me.Bandolier("Shield").Index() and RGMercUtils.IsTanking()
end,
cmd = function()
mq.cmdf("/bandolier activate Shield")
RGMercUtils.DoCmd("/bandolier activate Shield")
return true
end,

Expand All @@ -818,7 +818,7 @@ local _ClassConfig = {
mq.TLO.Me.Bandolier("2HS").Index() and not RGMercUtils.IsTanking()
end,
cmd = function()
mq.cmdf("/bandolier activate 2HS")
RGMercUtils.DoCmd("/bandolier activate 2HS")
return true
end,
},
Expand Down
2 changes: 1 addition & 1 deletion extras/version.lua
Original file line number Diff line number Diff line change
@@ -1 +1 @@
return { commitId = '7d94a54 2024-01-08' }
return { commitId = 'bf6914b 2024-01-08' }
57 changes: 20 additions & 37 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local mq = require('mq')
local ImGui = require('ImGui')
local GitCommit = require('extras.version')

RGMercsBinds = require('utils.rgmercs_binds')
RGMercConfig = require('utils.rgmercs_config')
RGMercConfig:LoadSettings()

Expand Down Expand Up @@ -323,29 +324,29 @@ local function RGInit(...)
mainAssist = mq.TLO.Me.CleanName()
end

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

if mq.TLO.Plugin("MQ2DanNet")() then
mq.cmdf("/squelch /dnet commandecho off")
RGMercUtils.DoCmd("/squelch /dnet commandecho off")
end

mq.cmdf("/stick set breakontarget on")
RGMercUtils.DoCmd("/stick set breakontarget on")

-- TODO: Chat Begs

RGMercUtils.PrintGroupMessage("Pausing the CWTN Plugin on this host If it exists! (/%s pause on)", mq.TLO.Me.Class.ShortName())
mq.cmdf("/squelch /docommand /%s pause on", mq.TLO.Me.Class.ShortName())
RGMercUtils.DoCmd("/squelch /docommand /%s pause on", mq.TLO.Me.Class.ShortName())

if RGMercUtils.CanUseAA("Companion's Discipline") then
mq.cmdf("/pet ghold on")
RGMercUtils.DoCmd("/pet ghold on")
else
mq.cmdf("/pet hold on")
RGMercUtils.DoCmd("/pet hold on")
end

if mq.TLO.Cursor() and mq.TLO.Cursor.ID() > 0 then
RGMercsLogger.log_info("Sending Item(%s) on Cursor to Bag", mq.TLO.Cursor())
mq.cmdf("/autoinventory")
RGMercUtils.DoCmd("/autoinventory")
end

RGMercUtils.WelcomeMsg()
Expand Down Expand Up @@ -382,7 +383,7 @@ local function Main()
curState = "Combat"
if os.clock() - RGMercConfig.Globals.LastFaceTime > 6 then
RGMercConfig.Globals.LastFaceTime = os.clock()
mq.cmdf("/squelch /face")
RGMercUtils.DoCmd("/squelch /face")
end
else
curState = "Downtime"
Expand Down Expand Up @@ -450,17 +451,17 @@ local function Main()
if merc() and merc.ID() then
if RGMercUtils.MercEngage() then
if merc.Class.ShortName():lower() == "war" and merc.Stance():lower() ~= "aggressive" then
mq.cmdf("/squelch /stance aggressive")
RGMercUtils.DoCmd("/squelch /stance aggressive")
end

if merc.Class.ShortName():lower() ~= "war" and merc.Stance():lower() ~= "balanced" then
mq.cmdf("/squelch /stance balanced")
RGMercUtils.DoCmd("/squelch /stance balanced")
end

RGMercUtils.MercAssist()
else
if merc.Class.ShortName():lower() ~= "clr" and merc.Stance():lower() ~= "passive" then
mq.cmdf("/squelch /stance passive")
RGMercUtils.DoCmd("/squelch /stance passive")
end
end
end
Expand All @@ -469,7 +470,7 @@ local function Main()

if RGMercUtils.DoCamp() then
if RGMercConfig:GetSettings().DoMercenary and mq.TLO.Me.Mercenary.ID() and (mq.TLO.Me.Mercenary.Class.ShortName() or "none"):lower() ~= "clr" and mq.TLO.Me.Mercenary.Stance():lower() ~= "passive" then
mq.cmdf("/squelch /stance passive")
RGMercUtils.DoCmd("/squelch /stance passive")
end
end

Expand All @@ -496,7 +497,7 @@ local function Main()
if mq.TLO.Me.Combat() and (not mq.TLO.Target() or pcCheck or mercCheck) then
RGMercsLogger.log_debug("\ay[1] Target type check failed \aw[\atinCombat(%s) pcCheckFailed(%s) mercCheckFailed(%s)\aw]\ay - turning attack off!",
RGMercUtils.BoolToString(mq.TLO.Me.Combat()), RGMercUtils.BoolToString(pcCheck), RGMercUtils.BoolToString(mercCheck))
mq.cmdf("/attack off")
RGMercUtils.DoCmd("/attack off")
end

-- TODO: Fix Curing
Expand Down Expand Up @@ -541,26 +542,8 @@ end)

-- Binds
local function bindHandler(cmd, ...)
if cmd == "pause" then
RGMercConfig.Globals.PauseMain = true
return
end

if cmd == "unpause" then
RGMercConfig.Globals.PauseMain = false
return
end

if cmd == "yes" then
mq.cmdf("/dggaexecute /notify LargeDialogWindow LDW_YesButton leftmouseup")
mq.cmdf("/dggaexecute /notify LargeDialogWindow LDW_OkButton leftmouseup")
mq.cmdf("/dggaexecute /notify ConfirmationDialogBox CD_Yes_Button leftmouseup")
mq.cmdf("/dggaexecute /notify ConfirmationDialogBox CD_OK_Button leftmouseup")
mq.cmdf("/dggaexecute /notify TradeWND TRDW_Trade_Button leftmouseup")
mq.cmdf("/dggaexecute /notify GiveWnd GVW_Give_Button leftmouseup ")
mq.cmdf("/dggaexecute /notify ProgressionSelectionWnd ProgressionTemplateSelectAcceptButton leftmouseup ; /notify TaskSelectWnd TSEL_AcceptButton leftmouseup")
mq.cmdf("/dggaexecute /notify RaidWindow RAID_AcceptButton leftmouseup")
return
if RGMercsBinds.Handlers[cmd] then
return RGMercsBinds.Handlers[cmd].handler(...)
end

local results = RGMercModules:ExecAll("HandleBind", cmd, ...)
Expand All @@ -581,12 +564,12 @@ mq.event("CantSee", "You cannot see your target.", function()
if RGMercConfig.Globals.BackOffFlag then return end

if mq.TLO.Stick.Active() then
mq.cmdf("/stick off")
RGMercUtils.DoCmd("/stick off")
end

if RGMercModules:ExecModule("Pull", "IsPullState", "PULL_PULLING") then
RGMercsLogger.log_info("\ayWe are in Pull_State PULLING and Cannot see our target!")
mq.cmdf("/nav id %d distance=%d lineofsight=on log=off", mq.TLO.Target.ID() or 0, (mq.TLO.Target.Distance() or 0) * 0.5)
RGMercUtils.DoCmd("/nav id %d distance=%d lineofsight=on log=off", mq.TLO.Target.ID() or 0, (mq.TLO.Target.Distance() or 0) * 0.5)
mq.delay("2s", function() return mq.TLO.Navigation.Active() end)

-- TODO: Do we need this?
Expand All @@ -599,7 +582,7 @@ mq.event("CantSee", "You cannot see your target.", function()
RGMercsLogger.log_info("\ayWe are in COMBAT and Cannot see our target!")
if RGMercConfig:GetSettings().DoAutoEngage then
if RGMercUtils.OkToEngage(mq.TLO.Target.ID() or 0) then
mq.cmdf("/squelch /face fast")
RGMercUtils.DoCmd("/squelch /face fast")
if RGMercConfig:GetSettings().DoMelee then
RGMercsLogger.log_debug("Can't See target (%s [%d]). Naving to %d away.", mq.TLO.Target.CleanName() or "", mq.TLO.Target.ID() or 0,
(mq.TLO.Target.MaxRangeTo() or 0) * 0.9)
Expand Down
2 changes: 1 addition & 1 deletion modules/movement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function Module:RunCmd(cmd, ...)
end

self.TempSettings.LastCmd = formattedCmd
mq.cmdf(formattedCmd)
RGMercUtils.DoCmd(formattedCmd)
end

function Module:ChaseOff()
Expand Down
30 changes: 15 additions & 15 deletions modules/pull.lua
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ function Module:FarmFullInvActions()

RGMercsLogger.log_error("\arStopping Pulls - Bags are full!")
self.settings.DoPull = 0
mq.cmdf("/beep")
RGMercUtils.DoCmd("/beep")
end

---comment
Expand Down Expand Up @@ -756,21 +756,21 @@ function Module:NavToWaypoint(loc, ignoreAggro)

mq.TLO.Me.Stand()

mq.cmdf("/nav locyxz %s, log=off", loc)
RGMercUtils.DoCmd("/nav locyxz %s, log=off", loc)
mq.delay("2s")

while mq.TLO.Navigation.Active() do
RGMercsLogger.log_verbose("NavToWaypoint Aggro Count: %d", RGMercUtils.GetXTHaterCount())

if RGMercUtils.GetXTHaterCount() > 0 and not ignoreAggro then
mq.cmdf("/nav stop log=off")
RGMercUtils.DoCmd("/nav stop log=off")
return false
end

if mq.TLO.Navigation.Velocity() == 0 then
RGMercsLogger.log_warning("NavToWaypoint Velocity is 0 - Are we stuck?")
if mq.TLO.Navigation.Paused() then
mq.cmdf("/nav pause log=off")
RGMercUtils.DoCmd("/nav pause log=off")
end
end

Expand Down Expand Up @@ -939,7 +939,7 @@ function Module:GiveTime(combat_stateModule)
local pullAbility = self.Constants.PullAbilities[self.settings.PullAbility]
local startingXTargs = RGMercUtils.GetXTHaterIDs()

mq.cmdf("/nav id %d distance=%d lineofsight=%s log=off", pullID, pullAbility.AbilityRange, "off")
RGMercUtils.DoCmd("/nav id %d distance=%d lineofsight=%s log=off", pullID, pullAbility.AbilityRange, "off")

mq.delay(1000)

Expand Down Expand Up @@ -1018,22 +1018,22 @@ function Module:GiveTime(combat_stateModule)
end

if RGMercUtils.CanUseAA("Companion's Discipline") then
mq.cmdf("/squelch /pet ghold on")
RGMercUtils.DoCmd("/squelch /pet ghold on")
end
mq.cmdf("/squelch /pet back off")
RGMercUtils.DoCmd("/squelch /pet back off")
mq.delay("1s", function() return (mq.TLO.Pet.PlayerState() or 0) == 0 end)
mq.cmdf("/squelch /pet follow")
RGMercUtils.DoCmd("/squelch /pet follow")
elseif self.settings.PullAbility == PullAbilityIDToName.Ranged then -- Ranged pull
-- Make sure we're looking straight ahead at our mob and delay
-- until we're facing them.
mq.cmdf("/look 0")
RGMercUtils.DoCmd("/look 0")

mq.delay("3s", function() return mq.TLO.Me.Heading.ShortName() == target.HeadingTo.ShortName() end)

-- We will continue to fire arrows until we aggro our target
while not successFn(self) do
startingXTargs = RGMercUtils.GetXTHaterIDs()
mq.cmdf("/ranged %d", pullID)
RGMercUtils.DoCmd("/ranged %d", pullID)
mq.doevents()
if self:IsPullMode("Chain") and RGMercUtils.DiffXTHaterIDs(startingXTargs) then
break
Expand All @@ -1048,7 +1048,7 @@ function Module:GiveTime(combat_stateModule)
mq.delay(5)
while not successFn(self) do
startingXTargs = RGMercUtils.GetXTHaterIDs()
mq.cmdf("/target ID %d", pullID)
RGMercUtils.DoCmd("/target ID %d", pullID)
mq.doevents()

if pullAbility.Type:lower() == "ability" then
Expand All @@ -1072,30 +1072,30 @@ function Module:GiveTime(combat_stateModule)
end
else
RGMercsLogger.log_debug("\arNOTICE:\ax Pull Aborted!")
mq.cmdf("/nav stop log=off")
RGMercUtils.DoCmd("/nav stop log=off")
mq.delay("2s", function() return not mq.TLO.Navigation.Active() end)
end

if self:IsPullMode("Normal") or self:IsPullMode("Chain") then
-- Nav back to camp.
self.TempSettings.PullState = PullStates.PULL_RETURN_TO_CAMP

mq.cmdf("/nav locyxz %0.2f %0.2f %0.2f log=off", start_y, start_x, start_z)
RGMercUtils.DoCmd("/nav locyxz %0.2f %0.2f %0.2f log=off", start_y, start_x, start_z)
mq.delay("5s", function() return mq.TLO.Navigation.Active() end)

while mq.TLO.Navigation.Active() do
if mq.TLO.Me.State():lower() == "feign" or mq.TLO.Me.Sitting() then
RGMercsLogger.log_debug("Standing up to Engage Target")
mq.TLO.Me.Stand()
mq.cmdf("/nav locyxz %0.2f %0.2f %0.2f log=off", start_y, start_x, start_z)
RGMercUtils.DoCmd("/nav locyxz %0.2f %0.2f %0.2f log=off", start_y, start_x, start_z)
mq.delay("5s", function() return mq.TLO.Navigation.Active() end)
end

mq.doevents()
mq.delay(10)
end

mq.cmdf("/face id %d", pullID)
RGMercUtils.DoCmd("/face id %d", pullID)

-- TODO PostPullCampFunc()
end
Expand Down
6 changes: 3 additions & 3 deletions modules/travel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ function Module:Render()
ImGui.PushStyleColor(ImGuiCol.Button, self:GetColorForType(sv.Type))
if ImGui.Button(sv.Name, self.ButtonWidth, self.ButtonHeight) then
if sv.Type == "Single" then
mq.cmdf(string.format("/dex %s /casting \"%s\" -maxtries|10 -targetid|%d gem%d", selectedPorter, sv.Name, RGMercUtils.GetTargetID(),
RGMercUtils.DoCmd(string.format("/dex %s /casting \"%s\" -maxtries|10 -targetid|%d gem%d", selectedPorter, sv.Name, RGMercUtils.GetTargetID(),
mq.TLO.Me.NumGems()))
else
mq.cmdf("/dex " .. selectedPorter .. " /casting \"" .. sv.Name .. "\" -maxtries|10")
mq.cmdf(string.format("/dex %s /casting \"%s\" -maxtries|10 gem%d", selectedPorter, sv.Name, mq.TLO.Me.NumGems()))
RGMercUtils.DoCmd("/dex " .. selectedPorter .. " /casting \"" .. sv.Name .. "\" -maxtries|10")
RGMercUtils.DoCmd(string.format("/dex %s /casting \"%s\" -maxtries|10 gem%d", selectedPorter, sv.Name, mq.TLO.Me.NumGems()))
end
end
ImGui.PopStyleColor(2)
Expand Down

0 comments on commit 8d46830

Please sign in to comment.