EC: health bars stop updating (part 1)

ForeverFunForeverFun Posts: 920
In EC, healthbars of pets and other mobiles (not in your party) stop updating after extended gameplay.  Champ spawns are a common case where this happens.

There may be more than one change for this, hence the "part 1".  With the below changes, I didn't see the problem where healthbars stop updating.

There are 3 parts to this change:
  1. Free various table entries (leaks).  (I confirmed certain tables contain many hundreds of elements added per champ spawn round).
  2. Avoid un-necessary data dependency for updating the healthbar (mobileData can be non nil, while data can be nil).
  3. Reduce un-necessary calls inside the commonly called MobileHealthBar.UpdateStatus(), as this can be called dozens of times a second.

All changes to mobilehealthbar.lua


MobileHealthBar.UnregisterHealthBar()
	MobileHealthBar.windowDisabled[mobileId] = nil

-- added free for these
MobileHealthBar.Handled[mobileId] = nil
MobileHealthBar.CheckStatus[mobileId] = nil
MobileHealthBar.RegisterTime[mobileId] = nil
-- overheadtext.lua can create these. (low counts over time).
MobileHealthBar.Changelings[mobileId] = nil
MobileHealthBar.Irks[mobileId] = nil
MobileHealthBar.Guiles[mobileId] = nil
MobileHealthBar.Spites[mobileId] = nil
MobileHealthBar.Travestys[mobileId] = nil


MobileHealthBar.UpdateStatus(mobileId)


	local mobileData = Interface.GetMobileData(mobileId, true)	-- uses WindowData.MobileStatus[mobileId]
-- local data = WindowData.MobileName[mobileId] -- no longer needed.




-- if(MobileHealthBar.hasWindow[mobileId] == true and data and mobileData) then
if(MobileHealthBar.hasWindow[mobileId] == true and mobileData) then



if(mobileData.Notoriety+1 == NameColor.Notoriety.INVULNERABLE) then -- notoriety check, since most of this is not applicable to other mobiles.
local bodDealer = IsBodDealer( mobileId )
if bodDealer and not DoesWindowNameExist(windowName.."Bod") then
CreateWindowFromTemplate( windowName.."Bod", "BodIconTemplate", windowName)
WindowClearAnchors(windowName.."Bod")
WindowAddAnchor(windowName.."Bod", "topright", windowName .. "Name", "topleft", -7, 20)
WindowSetShowing(windowName.."Bod", true)
elseif(DoesWindowNameExist(windowName.."Bod") and not bodDealer) then
DestroyWindow(windowName.."Bod")
end

-- move this above, where CreateWindowFromTemplate is called?
if(DoesWindowNameExist(windowName.."Bod")) then
WindowSetScale(windowName.."Bod", WindowGetScale(windowName))
end
end



--WindowSetShowing(windowName .. "GreenButton", data.Notoriety+1 ~= NameColor.Notoriety.INVULNERABLE)
--WindowSetShowing(windowName .. "RedButton", data.Notoriety+1 ~= NameColor.Notoriety.INVULNERABLE)
--WindowSetShowing(windowName .. "BlueButton", data.Notoriety+1 ~= NameColor.Notoriety.INVULNERABLE)
-- all windows started with the green, red, blue buttons showing by default, so no reason to set those.
-- note: these buttons should be disabled on monsters...
if(mobileData.Notoriety+1 == NameColor.Notoriety.INVULNERABLE) then -- only invulnerable targets have these buttons removed, currently.
-- avoid repeated calls to SetShowing.
if(WindowGetShowing(windowName .. "GreenButton") == true) then
WindowSetShowing(windowName .. "GreenButton", false)
WindowSetShowing(windowName .. "RedButton", false)
WindowSetShowing(windowName .. "BlueButton", false)
end
end




-- elseif ((data == nil or tostring(perc) == "-1.#IND") and not MobileHealthBar.Handled[mobileId] and mobileId ~= WindowData.PlayerStatus.PlayerId ) then
elseif ((tostring(perc) == "-1.#IND") and not MobileHealthBar.Handled[mobileId] and mobileId ~= WindowData.PlayerStatus.PlayerId ) then -- data could never be nil in prior code.
MobileHealthBar.CheckStatus[mobileId] = true



Comments

  • GrimbeardGrimbeard Posts: 2,407
    I'm gonna go ahead and name forever the new lead developer based on work done and community communication
  • ForeverFunForeverFun Posts: 920
    Sorry, the last paste above didn't include the spellweaving update  (use mobileData, instead of data). 

    MobileHealthBar.UpdateStatus(mobileId)

    			LabelSetText(windowName .. "HealthBarPerc", perc .. L"%")
    if (Interface.HealthBarWod and (mobileData.Notoriety+1 ~= NameColor.Notoriety.FRIEND) and (mobileData.Notoriety+1 ~= NameColor.Notoriety.INVULNERABLE) and WindowData.SkillsCSV) then -- checks moved from below.
    local serverId = WindowData.SkillsCSV[Interface.SpellweavingID].ServerId
    local skillLevel = WindowData.SkillDynamicData[serverId].TempSkillValue / 10

    if (skillLevel >= 83 and not MobilesOnScreen.IsPet(mobileId) ) then
    local circleLimit = (Interface.ArcaneFocusLevel + 1) * 5
    if (circleLimit <= 0) then
    circleLimit = 0
    end

    if (perc < circleLimit) then
    WindowSetShowing(windowName .. "Wod", true)
    else
    WindowSetShowing(windowName .. "Wod", false)
    end

    end
    end
    -- elseif ((data == nil or tostring(perc) == "-1.#IND") and not MobileHealthBar.Handled[mobileId] and mobileId ~= WindowData.PlayerStatus.PlayerId ) then
    elseif ((tostring(perc) == "-1.#IND") and not MobileHealthBar.Handled[mobileId] and mobileId ~= WindowData.PlayerStatus.PlayerId ) then -- data could never be nil in prior code.


  • YoshiYoshi Posts: 3,322
    edited May 2023
    "lol players gotta program their own code bug fixes in EC or download third party stuff for fixes for CC
    this is pay to play every month too"
    Posts on this account have been pre filtered from personal comment or opinion in an effort to suppress conservative views in order to protect the reader.
  • YoshiYoshi Posts: 3,322
    “You’re actually wasting your time fixing things in EC because 
    https://forum.uo.com/discussion/872/enhance-client-character-sheet

    dev still haven’t yet figured out how to copy paste the fixes into default UI after 2 years

    This one I linked to is still broken in default UI even though fix is posted here

    i think there have been half a dozen player made fixes over the years. “
    Posts on this account have been pre filtered from personal comment or opinion in an effort to suppress conservative views in order to protect the reader.
  • Can you explain what i'm supposed to do with this code? Do I add it in at a certain spot in the file? Or am I replacing existing code?
  • Arroth_ThaielArroth_Thaiel Posts: 1,075
    edited January 2
    SkuLover said:
    Can you explain what i'm supposed to do with this code? Do I add it in at a certain spot in the file? Or am I replacing existing code?
    I don't know how much modding you've done, but you want to have a copy of MobileHealthBar.lua in the source folder of your custom UI.

    Within MobileHealthBar.lua, look for the function MobileHealthBar.UnregisterHealthBar(windowName)

    This function will begin on line 288 of an unmodified file.


    --
    The first line in the first code chunk of the original post 
    MobileHealthBar.windowDisabled[mobileId] = nil
    begins on line 304 of an unmodified file.

    Insert the remainder of the code just below that line.


    The final function MobileHealthBar.UnregisterHealthBar(windowName) should now read
    function MobileHealthBar.UnregisterHealthBar(windowName)
    	local mobileId = WindowGetId(windowName)
    		
    	WindowUnregisterEventHandler(windowName, WindowData.MobileStatus.Event)
    	WindowUnregisterEventHandler(windowName, WindowData.MobileName.Event)
    	WindowUnregisterEventHandler(windowName, WindowData.HealthBarColor.Event)
    	WindowUnregisterEventHandler(windowName, SystemData.Events.ENABLE_HEALTHBAR_WINDOW)
    	WindowUnregisterEventHandler(windowName, SystemData.Events.DISABLE_HEALTHBAR_WINDOW)
    
    	if WindowData.PlayerStatus.PlayerId ~= mobileId and TargetWindow.TargetId ~= mobileId then
    		UnregisterWindowData(WindowData.MobileStatus.Type, mobileId)
    		UnregisterWindowData(WindowData.MobileName.Type, mobileId)
    		UnregisterWindowData(WindowData.HealthBarColor.Type, mobileId)
    	end
    
    	MobileHealthBar.hasWindow[mobileId] = nil
    	MobileHealthBar.windowDisabled[mobileId] = nil
    
    
            -- added free for these
    MobileHealthBar.Handled[mobileId] = nil
    MobileHealthBar.CheckStatus[mobileId] = nil
    MobileHealthBar.RegisterTime[mobileId] = nil
    -- overheadtext.lua can create these. (low counts over time).
    MobileHealthBar.Changelings[mobileId] = nil
    MobileHealthBar.Irks[mobileId] = nil
    MobileHealthBar.Guiles[mobileId] = nil
    MobileHealthBar.Spites[mobileId] = nil
    MobileHealthBar.Travestys[mobileId] = nil SnapUtils.SnappableWindows[windowName] = nil if (MobileHealthBar.mouseOverId == mobileId) then MobileHealthBar.OnMouseOverEnd() end end


    --
    The second code chunk in the original post goes into the function MobileHealthBar.UpdateStatus(mobileId)

    which begins on line 325 of an unmodified file.


    The first line in the second code chunk of the original post
    local mobileData = Interface.GetMobileData(mobileId, true)	-- uses WindowData.MobileStatus[mobileId]
    begins on line 332 of an unmodified file.

    Insert the remainder of the code just below that line.


    The function MobileHealthBar.UpdateStatus(mobileId) is long, so I won't post the final chunk here, but the instructions above should be enough to get you started.


    --
    Good luck!
    -Arroth
Sign In or Register to comment.