From cf61a74fa87511d2a6576fa8ea3742068a2853cc Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Mon, 13 Jan 2025 16:25:07 +0100 Subject: [PATCH] Don't tag minimap if we aren't in the same zone --- Heimdall.toc | 2 +- Heimdall.zip | 4 +-- Modules/MinimapTagger.lua | 53 ++++++++++++++++++++++++++++++--------- 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/Heimdall.toc b/Heimdall.toc index b983725..4ec38cc 100644 --- a/Heimdall.toc +++ b/Heimdall.toc @@ -1,6 +1,6 @@ ## Interface: 70300 ## Title: Heimdall -## Version: 3.4.3 +## Version: 3.4.4 ## Notes: Watches over areas and alerts when hostiles spotted ## Author: Cyka ## SavedVariables: Heimdall_Data diff --git a/Heimdall.zip b/Heimdall.zip index 139d872..7942448 100644 --- a/Heimdall.zip +++ b/Heimdall.zip @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:16e952627492a8927c58dcd7e308ec2ec5f8da10b92d29c6ec4bc3d65e71cd67 -size 986032 +oid sha256:9d357f1c14acc51e9f4363b14da1303abe29c67c3e717ce33b23e968314a75f0 +size 985991 diff --git a/Modules/MinimapTagger.lua b/Modules/MinimapTagger.lua index ab61d9f..1beb9cb 100644 --- a/Modules/MinimapTagger.lua +++ b/Modules/MinimapTagger.lua @@ -92,7 +92,9 @@ function shared.MinimapTagger.Init() ---@param x number ---@param y number ---@param scale number? - local function PlantAlert(x, y, scale) + ---@param doTag boolean? + local function PlantAlert(x, y, scale, doTag) + if doTag == nil then doTag = true end local frame = nil for _, alertFrame in ipairs(alertFramePool) do if not alertFrame.custom.busy then @@ -124,7 +126,9 @@ function shared.MinimapTagger.Init() end end end - PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.alertTTL) + if doTag then + PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.alertTTL) + end end --endregion @@ -144,7 +148,9 @@ function shared.MinimapTagger.Init() ---@param x number ---@param y number ---@param scale number? - local function PlantTag(x, y, scale) + ---@param doTag boolean? + local function PlantTag(x, y, scale, doTag) + if doTag == nil then doTag = true end local frame = nil for _, tagFrame in ipairs(tagFramePool) do if not tagFrame.custom.busy then @@ -176,7 +182,9 @@ function shared.MinimapTagger.Init() end end end - PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.tagTTL) + if doTag then + PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.tagTTL) + end end --endregion @@ -196,7 +204,9 @@ function shared.MinimapTagger.Init() ---@param x number ---@param y number ---@param scale number? - local function PlantCombat(x, y, scale) + ---@param doTag boolean? + local function PlantCombat(x, y, scale, doTag) + if doTag == nil then doTag = true end local frame = nil for _, combatFrame in ipairs(combatFramePool) do if not combatFrame.custom.busy then @@ -228,7 +238,9 @@ function shared.MinimapTagger.Init() end end end - PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.combatTTL) + if doTag then + PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.combatTTL) + end end --endregion @@ -248,7 +260,9 @@ function shared.MinimapTagger.Init() ---@param x number ---@param y number ---@param scale number? - local function PlantHelp(x, y, scale) + ---@param doTag boolean? + local function PlantHelp(x, y, scale, doTag) + if doTag == nil then doTag = true end local frame = nil for _, helpFrame in ipairs(helpFramePool) do if not helpFrame.custom.busy then @@ -280,7 +294,9 @@ function shared.MinimapTagger.Init() end end end - PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.helpTTL) + if doTag then + PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.helpTTL) + end end --endregion @@ -360,6 +376,19 @@ function shared.MinimapTagger.Init() shared.dumpTable(Heimdall_Data.config.minimapTagger) end + local doTag = true + local messageMapId = string.match(msg, "%[(%d+)%]") or 0 + if messageMapId then messageMapId = tonumber(messageMapId) end + + local currentMapId = GetCurrentMapAreaID() + if currentMapId ~= messageMapId then + if Heimdall_Data.config.minimapTagger.debug then + print(string.format("[%s] Current map ID (%d) does not match message map ID (%d), ignoring message", + ModuleName, currentMapId, messageMapId)) + end + doTag = false + end + --region Tag if string.find(msg, "^I see") then if Heimdall_Data.config.minimapTagger.tagTTL == 0 then @@ -373,7 +402,7 @@ function shared.MinimapTagger.Init() print(string.format("[%s] Found alert position: %s, %s", ModuleName, tostring(x), tostring(y))) end if x and y then - PlantTag(tonumber(x), tonumber(y), 2) + PlantTag(tonumber(x), tonumber(y), 2, doTag) end end --endregion @@ -393,7 +422,7 @@ function shared.MinimapTagger.Init() print(string.format("[%s] Found combat position: %s, %s", ModuleName, tostring(x), tostring(y))) end if x and y then - PlantCombat(tonumber(x), tonumber(y), 2) + PlantCombat(tonumber(x), tonumber(y), 2, doTag) end end --endregion @@ -413,7 +442,7 @@ function shared.MinimapTagger.Init() print(string.format("[%s] Found death position: %s, %s", ModuleName, tostring(x), tostring(y))) end if x and y then - PlantAlert(tonumber(x), tonumber(y), 2) + PlantAlert(tonumber(x), tonumber(y), 2, doTag) end end --endregion @@ -434,7 +463,7 @@ function shared.MinimapTagger.Init() end if x and y then x, y = tonumber(x), tonumber(y) - PlantHelp(x, y, 1) + PlantHelp(x, y, 1, doTag) if TomTom then if Heimdall_Data.config.minimapTagger.debug then print(string.format("[%s] Adding help waypoint to TomTom", ModuleName))