Flat-Badger-1971 / ArchiveHelper

0 stars 1 forks source link

Bug: minor bug with target unmarking (via keybind) on yourself #31

Open Stemuweb opened 3 months ago

Stemuweb commented 3 months ago

You can mark yourself (when nothing is under the reticle) using the "mark" keybind. This behaviour is acceptable. If you scroll through all icons, you unmark yourself. That is also okay.

But the "unmark" keybind does not work on yourself. You can remove mark when a target is under the reticle but the key has no effect otherwise, when you expect to be able to remove the target on yourself.

Either marking yourself should not be allowed (but why not) or unmarking yourself should function.

Flat-Badger-1971 commented 3 months ago

I came across this too, but not sure at this stage if that's an in-game bug

Stemuweb commented 3 months ago

I've just noticed that it's possible to remove the mark on the player since it's removed if you repeat the mark command enough times to cycle through all the marker types.

By saving the marker placed on the player (when marking), it is possible to remove it by applying it again (when unmarking).

I tried this (poorly written) solution, and it works in practice, solo. But perhaps it will create more problems in group if other players reassign the marker.

local markerOnPlayer = nil

-- for keybinds
function AH.MarkCurrentTarget()
    if (GetUnitTargetMarkerType("reticleover") == _G.TARGET_MARKER_TYPE_NONE) then
        AssignTargetMarkerToReticleTarget(marker)
        AH.MARKERS[key].manual = true
        AH.ShareData(AH.SHARE.MARK, key)

        if (GetUnitName("reticleover") == "") then
            -- player: save marker
            markerOnPlayer = marker;
        end
    end
end

function AH.UnmarkCurrentTarget()
    if ((GetUnitName("reticleover") == "") and (markerOnPlayer ~= nil)) then
        -- player: reapply marker
        marker = markerOnPlayer;
        markerOnPlayer = nil
    end

    if (marker ~= _G.TARGET_MARKER_TYPE_NONE) then
        AssignTargetMarkerToReticleTarget(marker)
        makeMarkerAvailable(marker)
        AH.ShareData(AH.SHARE.UNMARK, getMarkerIndex(marker))
    end
end

Maybe it's easier to check if GetUnitName("reticleover") is not empty in MarkCurrentTarget() rather than trying to make it work on the player.

function AH.MarkCurrentTarget()
    if (GetUnitName("reticleover") ~= "" and GetUnitTargetMarkerType("reticleover") == _G.TARGET_MARKER_TYPE_NONE) then

After all, the keybind is "mark the current target" and there isn't one. So it makes sense not to mark anything.