Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
DerpleMQ2 committed Feb 19, 2024
2 parents ab22767 + 00e8080 commit 3ec5184
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 22 deletions.
2 changes: 1 addition & 1 deletion modules/class.lua
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ function Module:RunCureRotation()
local effectId = DanNet.observe(peer, data.check, 1000) or "null"
RGMercsLogger.log_verbose("\ay[Cures] %s :: %s [%s] => %s", peer, data.check, data.type, effectId)

if effectId:lower() ~= "null" then
if effectId:lower() ~= "null" and effectId ~= "0" then
local cureTarget = mq.TLO.Spawn(string.format("pc =%s", peer))
if cureTarget and cureTarget() then
-- Cure it!
Expand Down
2 changes: 2 additions & 0 deletions modules/movement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ function Module:CampOn()
self.TempSettings.AutoCampZ = mq.TLO.Me.Z()
self.TempSettings.CampZoneId = mq.TLO.Zone.ID()
RGMercUtils.DoCmd("/mapfilter campradius %d", RGMercUtils.GetSetting('AutoCampRadius'))
RGMercUtils.DoCmd("/mapfilter pullradius %d", RGMercUtils.GetSetting('PullRadius'))
RGMercsLogger.log_info("\ayCamping On: (X: \at%d\ay ; Y: \at%d\ay)", self.TempSettings.AutoCampX, self.TempSettings.AutoCampY)
end

Expand All @@ -175,6 +176,7 @@ function Module:CampOff()
self.settings.ReturnToCamp = false
self:SaveSettings(false)
RGMercUtils.DoCmd("/mapfilter campradius off")
RGMercUtils.DoCmd("/mapfilter pullradius off")
end

function Module:DestoryCampfire()
Expand Down
24 changes: 17 additions & 7 deletions modules/pull.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Module.Constants.PullAbilities = {
Type = "Special",
AbilityRange = 100,
DisplayName = "Pet Pull",
LOS = false,
cond = function(self)
return RGMercConfig.Constants.RGPetClass:contains(RGMercConfig.Globals.CurLoadedClass)
end,
Expand Down Expand Up @@ -753,10 +754,18 @@ function Module:CheckGroupForPull(classes, resourceStartPct, resourceStopPct, ca
end

--if (member.Distance() or 0) > math.max(RGMercConfig.SubModuleSettings.Movement.settings.AutoCampRadius, 80) then
if RGMercUtils.GetDistance(member.X(), member.Y(), campData.AutoCampX, campData.AutoCampY) > math.max(RGMercConfig.SubModuleSettings.Movement.settings.AutoCampRadius, 50) then
RGMercUtils.PrintGroupMessage("%s is too far away - Holding pulls!", member.CleanName())
return false,
string.format("%s Too Far (%d)", member.CleanName(), RGMercUtils.GetDistance(member.X(), member.Y(), campData.AutoCampX, campData.AutoCampY))
if returnToCamp then
if RGMercUtils.GetDistance(member.X(), member.Y(), campData.AutoCampX, campData.AutoCampY) > math.max(RGMercConfig.SubModuleSettings.Movement.settings.AutoCampRadius, 50) then
RGMercUtils.PrintGroupMessage("%s is too far away - Holding pulls!", member.CleanName())
return false,
string.format("%s Too Far (%d)", member.CleanName(), RGMercUtils.GetDistance(member.X(), member.Y(), campData.AutoCampX, campData.AutoCampY))
end
else
if (member.Distance() or 0) > math.max(RGMercConfig.SubModuleSettings.Movement.settings.AutoCampRadius, 80) then
RGMercUtils.PrintGroupMessage("%s is too far away - Holding pulls!", member.CleanName())
return false,
string.format("%s Too Far (%d)", member.CleanName(), RGMercUtils.GetDistance(member.X(), member.Y(), campData.AutoCampX, campData.AutoCampY))
end
end

if self.Constants.PullModes[self.settings.PullMode] == "Chain" then
Expand Down Expand Up @@ -827,7 +836,7 @@ function Module:FindTarget()
local spawn = mq.TLO.NearestSpawn(i, pullSearchString)
local skipSpawn = false

if spawn and (spawn.ID() or 0) > 0 then
if spawn and (spawn.ID() or 0) > 0 and spawn.Targetable() then
if self:IsPullMode("Chain") then
if RGMercUtils.IsSpawnXHater(spawn.ID()) then
RGMercsLogger.log_debug("\awSpawn \am%s\aw (\at%d\aw) Already on XTarget -- Skipping", spawn.CleanName(), spawn.ID())
Expand Down Expand Up @@ -1120,7 +1129,7 @@ function Module:GiveTime(combat_state)

if self.TempSettings.TargetSpawnID > 0 then
local targetSpawn = mq.TLO.Spawn(self.TempSettings.TargetSpawnID)
if not targetSpawn() or targetSpawn.Dead() or targetSpawn.PctHPs() == 0 then
if not targetSpawn() or targetSpawn.Dead() then
RGMercsLogger.log_debug("\arDropping Manual target id %d - it is dead.", self.TempSettings.TargetSpawnID)
self.TempSettings.TargetSpawnID = 0
end
Expand Down Expand Up @@ -1190,8 +1199,9 @@ function Module:GiveTime(combat_state)

local pullAbility = self.TempSettings.ValidPullAbilities[self.settings.PullAbility]
local startingXTargs = RGMercUtils.GetXTHaterIDs()
local requireLOS = pullAbility.LOS == nil and true or pullAbility.LOS

RGMercUtils.DoCmd("/nav id %d distance=%d lineofsight=%s log=off", self.TempSettings.PullID, self:GetPullAbilityRange(), "on")
RGMercUtils.DoCmd("/nav id %d distance=%d lineofsight=%s log=off", self.TempSettings.PullID, self:GetPullAbilityRange(), requireLOS)

mq.delay(1000)

Expand Down
37 changes: 32 additions & 5 deletions utils/rgmercs_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ Config.DefaultConfig = {
['ModRodManaPct'] = { DisplayName = "Mod Rod Mana %", Category = "Utilities", Tooltip = "What Mana % to hit before using a rod.", Default = 30, Min = 1, Max = 99, ConfigType = "Advanced", },
['ClarityPotion'] = { DisplayName = "Clarity Potion", Category = "Utilities", Tooltip = "Name of your Clarity Pot", Default = "Distillate of Clarity", ConfigType = "Advanced", },
['RunMovePaused'] = { DisplayName = "Run Movement on Pause", Category = "Utilities", Tooltip = "Runs the Movement/Chase module even if the Main loop is paused", Default = false, ConfigType = "Advanced", },
['StandFailedFD'] = { DisplayName = "Stand on Failed FD", Category = "Utilities", Tooltip = "Auto stands you up if you fall to the ground.", Default = true, ConfigType = "Normal", },

-- [ CLICKIES ] --
['UseClickies'] = { DisplayName = "Use Clickies", Category = "Clickies", Tooltip = "Use Clicky Items", Default = true, ConfigType = "Normal", },
Expand Down Expand Up @@ -171,6 +172,7 @@ Config.DefaultConfig = {
['DoMelee'] = { DisplayName = "Enable Melee Combat", Category = "Combat", Tooltip = "Melee targets.", Default = Config.Constants.RGMelee:contains(Config.Globals.CurLoadedClass), ConfigType = "Normal", },
['ManaToNuke'] = { DisplayName = "Mana to Nuke", Category = "Combat", Tooltip = "Minimum % Mana in order to continue to cast nukes.", Default = 30, Min = 1, Max = 100, ConfigType = "Advanced", },
['MovebackWhenTank'] = { DisplayName = "Moveback as Tank", Category = "Combat", Tooltip = "Adds 'moveback' to stick command when tanking. Helpful to keep mobs from getting behind you.", Default = false, ConfigType = "Advanced", },
['AutoStandFD'] = { DisplayName = "Stand from FD in Combat", Category = "Combat", Tooltip = "Auto stands you up from FD if combat starts.", Default = true, ConfigType = "Normal", },

-- [ Wards ] --
['WardsPlease'] = { DisplayName = "Enable Wards", Category = "Wards", Tooltip = "Enable Ward Type Spells", Default = true, ConfigType = "Normal", },
Expand Down Expand Up @@ -300,6 +302,7 @@ function Config:UpdateCommandHandlers()
name = config,
usage = usageString,
subModule = moduleName,
category = configData.Category,
about = configData.Tooltip,
handler = function(self, value)
value = tonumber(value)
Expand Down Expand Up @@ -327,6 +330,7 @@ function Config:UpdateCommandHandlers()
name = config,
usage = usageString,
subModule = moduleName,
category = configData.Category,
about = configData.Tooltip,
handler = function(self, value)
local boolValue = false
Expand All @@ -352,6 +356,7 @@ function Config:UpdateCommandHandlers()
name = config,
usage = usageString,
subModule = moduleName,
category = configData.Category,
about = configData.Tooltip,
handler = function(self, value)
local _, update = self:GetUsageText(config, false, moduleData.defaults)
Expand Down Expand Up @@ -455,12 +460,34 @@ function Config:HandleBind(config, value)
end
table.sort(sortedKeys)

local sortedCategories = {}
for c, d in pairs(self.CommandHandlers or {}) do
sortedCategories[d.subModule] = sortedCategories[d.subModule] or {}
if not RGMercUtils.TableContains(sortedCategories[d.subModule], d.category) then
table.insert(sortedCategories[d.subModule], d.category)
end
end
for _, subModuleTable in pairs(sortedCategories) do
table.sort(subModuleTable)
end

for _, subModuleName in ipairs(allModules) do
printf("\n\ag%s\aw Settings\n------------\n", subModuleName)
for _, c in pairs(sortedKeys) do
local d = self.CommandHandlers[c]
if d.subModule == subModuleName then
printf("\am%-20s\aw - \atUsage: \ay%s\aw | %s", d.name, RGMercUtils.PadString(d.usage, 100, false), d.about)
local printHeader = true
for _, c in ipairs(sortedCategories[subModuleName] or {}) do
local printCategory = true
for _, k in ipairs(sortedKeys) do
local d = self.CommandHandlers[k]
if d.subModule == subModuleName and d.category == c then
if printHeader then
printf("\n\ag%s\aw Settings\n------------", subModuleName)
printHeader = false
end
if printCategory then
printf("\n\aoCategory: %s\aw", c)
printCategory = false
end
printf("\am%-20s\aw - \atUsage: \ay%s\aw | %s", d.name, RGMercUtils.PadString(d.usage, 100, false), d.about)
end
end
end
end
Expand Down
12 changes: 11 additions & 1 deletion utils/rgmercs_events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,18 @@ end)

-- [ GAME EVENT HANDLERS ] --

mq.event('Camping', "It will take you about #1# seconds to prepare your camp.", function(seconds)
mq.event('Camping', "It will take you about #1# seconds to prepare your camp.", function(_, seconds)
RGMercConfig.Globals.PauseMain = true
end)

-- [ END GAME EVENT HANDLERS ] --

-- [ FD EVENT HANDLERS ] --

mq.event('FallToGround', "#1# has fallen to the ground#*#", function(_, who)
if who == mq.TLO.Me.DisplayName() and RGMercUtils.GetSetting('StandFailedFD') then
mq.cmd("/stand")
end
end)

-- [ END FD EVENT HANDLERS ] --
48 changes: 40 additions & 8 deletions utils/rgmercs_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ function Utils.GetTableSize(t)
return i
end

---@param t table
---@param value string
---@return boolean
function Utils.TableContains(t, value)
for _, v in pairs(t) do
if v == value then
return true
end
end
return false
end

---@param time integer # in seconds
---@return string
function Utils.FormatTime(time)
Expand Down Expand Up @@ -1443,7 +1455,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)
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 @@ -1977,17 +2003,19 @@ function Utils.EngageTarget(autoTargetId, preEngageRoutine)

local target = mq.TLO.Target

if mq.TLO.Me.State():lower() == "feign" and not Utils.MyClassIs("mnk") then
if mq.TLO.Me.State():lower() == "feign" and not Utils.MyClassIs("mnk") and Utils.GetSetting('AutoStandFD') then
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 Utils.GetTargetPctHPs() > 0 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 @@ -2005,19 +2033,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 Expand Up @@ -2524,7 +2556,7 @@ function Utils.OkToEngagePreValidateId(targetId)
local target = mq.TLO.Spawn(targetId)
local assistId = Utils.GetMainAssistId()

if not target() or target.Dead() or target.PctHPs() == 0 then return false end
if not target() or target.Dead() then return false end

local pcCheck = (target.Type() or "none"):lower() == "pc" or
((target.Type() or "none"):lower() == "pet" and (target.Master.Type() or "none"):lower() == "pc")
Expand Down Expand Up @@ -2575,7 +2607,7 @@ function Utils.OkToEngage(autoTargetId)
local target = mq.TLO.Target
local assistId = Utils.GetMainAssistId()

if not target() or target.Dead() or target.PctHPs() == 0 then return false end
if not target() or target.Dead() then return false end

local pcCheck = (target.Type() or "none"):lower() == "pc" or
((target.Type() or "none"):lower() == "pet" and (target.Master.Type() or "none"):lower() == "pc")
Expand Down

0 comments on commit 3ec5184

Please sign in to comment.