Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Monster Reader] HP display on "Target" widget does not become zero when target is killed sometimes #87

Open
eleriaqueen opened this issue Nov 10, 2024 · 5 comments

Comments

@eleriaqueen
Copy link

eleriaqueen commented Nov 10, 2024

Hi, often when I kill a mob the following happen : mob is removed from Monster Reader list which is expected but then "Target" widget still displays for a while the last HP the mob had and it is slightly confusing.

@eleriaqueen eleriaqueen changed the title HP display on "Target" widget does always become zero when target is killed [Monster Reader] HP display on "Target" widget does always become zero when target is killed Nov 10, 2024
@eleriaqueen eleriaqueen changed the title [Monster Reader] HP display on "Target" widget does always become zero when target is killed [Monster Reader] HP display on "Target" widget does not become zero when target is killed Nov 10, 2024
@eleriaqueen
Copy link
Author

eleriaqueen commented Nov 10, 2024

I have almost zero LUA programming knowledge, Ideally when a target is killed the HP the reader display should be set to zero.

@eleriaqueen eleriaqueen changed the title [Monster Reader] HP display on "Target" widget does not become zero when target is killed [Monster Reader] HP display on "Target" widget does not become zero when target is killed sometimes Nov 10, 2024
@Solybum
Copy link
Owner

Solybum commented Nov 10, 2024

Could look into making the dialog disappear faster when the monster hp is 0... the thing with the dialog sticking, is to mimic the original dialog behavior.

I suppose a good fix would be to have a flag that stores if the last targetted monster died, if so, set the timeout to a smaller value.

I might be able to look at this later during the week, but if you want to try to do that, feel free.

@eleriaqueen
Copy link
Author

eleriaqueen commented Nov 10, 2024

One of the problems also is that the Target display doesn't reflect you killed the mob... sometimes..., as in it doesn't display 0, you wittle the mob's health down and then when giving the final blow it just stays at the last value it was before you killed the mob and that for the duration it then "sticks".

@Solybum
Copy link
Owner

Solybum commented Nov 10, 2024

Fair, the monster should be marked dead some other way though... I guess it would need a bit more of an investigation to see whats up.

@eleriaqueen
Copy link
Author

eleriaqueen commented Nov 10, 2024

I'm poking around.
Idk why but it seems that when killing with spells the target HP display is much less likely to have an erroneous lingering HP value than with physical attacks...

Global monsterlist seems to be pretty much always right, it only displays an entry when mob when alive. Hmmm....

Edit 1:
Adding a new function getMonsterFromMonsterList() and modifying PresentTargetMonsterWindow() like so seem to improve things because we get monster data directly from MonsterList so we don't cache possibly outdated value (?).

function getMonsterFromMonsterList(monsterID)
    monsterlist = GetMonsterList()

    for _, mon in pairs(monsterlist) do
        if mon.id == monsterID then
            return mon
        end
    end
    return nil
end

-- Need to use this so I can hide the window when nothing is targetted for a while
local targetIDCache = 0
local targetWindowTimeOut = 0
local function PresentTargetMonsterWindow()
    local monster = GetTargetMonster()

    if monster == nil then
        if targetWindowTimeOut > 0 then
            targetWindowTimeOut = targetWindowTimeOut - 1
        end

        monster = getMonsterFromMonsterList(targetIDCache)

        if targetWindowTimeOut <= 0 then
            return
        end
    else
        targetWindowTimeOut = 90

        targetIDCache = monster.id
    end

    if options.targetEnableWindow and monster ~= nil and monster.unitxtID ~= 0 then
        if firstPresent or options.targetChanged then
            options.targetChanged = false
            local ps = lib_helpers.GetPosBySizeAndAnchor(options.targetX, options.targetY, options.targetW,
                options.targetH, options.targetAnchor)
            imgui.SetNextWindowPos(ps[1], ps[2], "Always");
            imgui.SetNextWindowSize(options.targetW, options.targetH, "Always");
        end

        if options.targetTransparentWindow == true then
            imgui.PushStyleColor("WindowBg", 0.0, 0.0, 0.0, 0.0)
        end

        if imgui.Begin("Monster Reader - Target", nil, { options.targetNoTitleBar, options.targetNoResize, options.targetNoMove, options.targetNoScrollbar }) then
            PresentTargetMonster(monster)
        end
        imgui.End()

        if options.targetTransparentWindow == true then
            imgui.PopStyleColor()
        end
    end
end

Edit 2: Yeah I tested this solution and, while it's not pretty, it seems to work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants