Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
3dd0c0e
add bar healthbars.
amnykon Dec 15, 2024
557b1f9
add MIT licence to BAR healthbar shaders.
amnykon Dec 16, 2024
5c90398
add bar healthbar gadget.
amnykon Dec 18, 2024
136f529
add Zero-k health bars to bar health bars WIP.
amnykon Dec 20, 2024
9241589
Add the nonsense placeholder license
GoogleFrog Dec 20, 2024
6ce27e0
Add the nonsense placeholder license
GoogleFrog Dec 20, 2024
998c134
Add the nonsense placeholder license
GoogleFrog Dec 20, 2024
1dcac82
connect more bars.
amnykon Dec 20, 2024
5fe1aea
Merge branch 'BarHealthbars' of https://github.com/amnykon/Zero-K int…
amnykon Dec 20, 2024
10dd3aa
connect more healthbars.
amnykon Dec 30, 2024
b8c5f88
move game frame calulation to shader.
amnykon Dec 31, 2024
1400b75
update artwork.
amnykon Jan 7, 2025
96c0eea
add numbers.
amnykon Jan 8, 2025
5ae1b7c
hide bars.
amnykon Jan 11, 2025
f0b1f85
remove unitBars
amnykon Jan 18, 2025
c6063dc
add range to feature healthbars.
amnykon Jan 18, 2025
c56b593
cleanup and fix shader bug.
amnykon Jan 22, 2025
c08e21d
add unit_status_values.
amnykon Jan 22, 2025
2ed5dbd
add drawFeatureHealth option and fix unit_status_value update bug.
amnykon Jan 23, 2025
b972c03
Merge branch 'master' into BarHealthbars
amnykon Jan 25, 2025
10e5d43
remove development Spring.Echos and fix partial update.
amnykon Jan 27, 2025
0b2544d
rename unit_status_values widget to unit_gl_uniform_updater.
amnykon Jan 29, 2025
5b2d1ee
start bringing over update units to unit_gl_uniform_updater.
amnykon Feb 1, 2025
352e870
move channel constants to an Include file and move more updates to un…
amnykon Feb 2, 2025
2407f39
WIP
amnykon Feb 10, 2025
a2a633c
WIP
amnykon Jun 14, 2026
7549a8d
Merge branch 'master' into BarHealthbars
amnykon Jun 14, 2026
0fb081d
complete channel migration to unit_gl_uniform_updater
amnykon Jun 15, 2026
40e58de
extend morph callbacks to support multiple listeners via WG tables
amnykon Jun 15, 2026
5754208
Overlay: weapon-def `icon` customParam drives reload-badge icons
amnykon Jun 25, 2026
5cec16d
Fix weapon reload icons: Stardust → heavy machine gun, Faraday → ligh…
claude Jun 25, 2026
9e84819
Overlay: always render on top of buildings by hardcoding overlayDepth…
claude Jun 25, 2026
ef0829b
Overlay: implement items 1-5 (selected icon, distance fades, burst ga…
claude Jun 25, 2026
13abc3b
Merge pull request #1 from amnykon/claude/unit-overlays-health-bar-l1…
amnykon Jun 26, 2026
6fa140e
Fix stale radar icon appearing on newly-spawned units
claude Jun 26, 2026
6834834
Merge pull request #2 from amnykon/claude/clone-barhealthbar-repo-m47qkn
amnykon Jun 26, 2026
441431b
Unit overlay: tint the center icon when slowed
claude Jun 26, 2026
698b2f2
Unit overlay: tint the center icon when disarmed
claude Jun 26, 2026
0f00385
Unit overlay: tint the center icon when paralyzed
claude Jun 26, 2026
b5dc628
Unit overlay: keep the icon legible under status tints
claude Jun 26, 2026
f6a05c9
Unit overlay: fade the center icon when cloaked (own/allied only)
claude Jun 26, 2026
19e3b1f
Unit overlay: show construction progress on the center icon
claude Jun 26, 2026
a62933b
Unit overlay: status bars show 100% instead of a flashing seconds cou…
claude Jun 26, 2026
403224e
Unit overlay: only tint the icon for paralyze/disarm once locked at 100%
claude Jun 26, 2026
bf44558
Merge pull request #3 from amnykon/claude/barhealthbar-branch-8fizcf
amnykon Jun 26, 2026
2bd115f
healthbars: suppress paralyze bar on spent silo missiles
claude Jun 27, 2026
353e5be
healthbars: suppress paralyze bar on spent silo missiles (GL4 updater)
claude Jun 27, 2026
d4086ce
Merge pull request #4 from amnykon/claude/barhealthbar-branch-ef73y5
amnykon Jun 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LuaRules/Gadgets/cus_gl4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,7 @@ function gadget:UnitCreated(unitID, unitDefID)
unitDefModelMaxY[unitDefID] = (ud.customParams.build_effect_sweep_height and tonumber(ud.customParams.build_effect_sweep_height) or ud.model.maxy or 10)
end
uniformCache[1] = unitDefModelMaxY[unitDefID]
gl.SetUnitBufferUniforms(unitID, uniformCache, 11) -- set unit height
gl.SetUnitBufferUniforms(unitID, uniformCache, 15) -- set unit height (moved off slot 11 -> ability slot; 15 is outside the updater block write 1-11, so not clobbered)
uniformCache[1] = 0
gl.SetUnitBufferUniforms(unitID, uniformCache, 12) -- clear cloak effect
gl.SetUnitBufferUniforms(unitID, uniformCache, 6) -- clear selectedness effect
Expand Down
193 changes: 193 additions & 0 deletions LuaRules/Gadgets/unit_healthbars_widget_forwarding.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
function gadget:GetInfo()
return {
name = "Healthbars Widget Forwarding",
desc = "Notifies widgets that a feature reclaim or resurrect action has begun, updates GL Uniforms, and also notifies on capture start, emp damage, reload",
author = "Beherith", -- ty Sprung
date = "2021.11.25",
license = "GNU GPL, v2 or later",
layer = -1,
enabled = true
}
end


if gadgetHandler:IsSyncedCode() then

local forwardedFeatureIDs = {} -- so we only forward the start event once
local forwardedCaptureUnitIDs = {}
local weapondefsreload = {}
local unitreloadframe = {} -- maps unitID to next frame it can shoot its primary weapon, cause lasers retrigger projetileCreated every frame
local minReloadTime = 5 -- in concerto with healthbars widget

function gadget:AllowFeatureBuildStep(builderID, builderTeam, featureID, featureDefID, step)
-- VERY IMPORTANT: This also gets called on resurrect!, but its very hard to tell if its a reclaim, but we can make the mother of all assumptions:
-- features die at 100% metal value
-- step is negative if 'reclaiming'
-- step is large positive if refilling
-- step is small positive if rezzing

local gf = Spring.GetGameFrame()
--Spring.Echo("AllowFeatureBuildStep",gf,builderID, builderTeam, featureID, featureDefID, step)
if forwardedFeatureIDs[featureID] == nil or forwardedFeatureIDs[featureID] < gf then
forwardedFeatureIDs[featureID] = gf
SendToUnsynced("featureReclaimFrame", featureID, step)
end
return true
end

function gadget:AllowUnitCaptureStep(builderID, builderTeam, unitID, unitDefID, part)
if forwardedCaptureUnitIDs[unitID] == nil then
forwardedCaptureUnitIDs[unitID] = true
SendToUnsynced("unitCaptureFrame", unitID, part)
end
return true
end

function gadget:FeatureDestroyed(featureID, allyTeamID)
forwardedFeatureIDs[featureID] = nil
end

function gadget:UnitDestroyed(unitID)
forwardedCaptureUnitIDs[unitID] = nil
unitreloadframe[unitID] = nil
end

function gadget:UnitTaken(unitID)
forwardedCaptureUnitIDs[unitID] = nil
end

function gadget:Initialize()
for udefID, unitDef in pairs(UnitDefs) do
local weapons = unitDef.weapons
local watchweaponID = nil
local longestreloadtime = -1
local longestreloadindex
for i = 1, #weapons do
local WeaponDefID = weapons[i].weaponDef
local WeaponDef = WeaponDefs[WeaponDefID]
if WeaponDef.reload and WeaponDef.reload >0 and WeaponDef.reload >= longestreloadtime then
longestreloadtime = WeaponDef.reload
watchweaponID = WeaponDefID
longestreloadindex = i
end
end
if watchweaponID and longestreloadtime > minReloadTime then
--Spring.Echo("Unit with watched reload time:", unitDef.name, longestreloadtime, watchweaponID, udefID)
weapondefsreload[watchweaponID] = longestreloadindex
Script.SetWatchProjectile(watchweaponID, true)
end
end
end

function gadget:ProjectileCreated(projectileID, ownerID, weaponID) -- needs: Script.SetWatchProjectile(weaponDefID, true)
--local unitDef = Spring.GetUnitDefID(ownerID)
--Spring.Echo("gadget:ProjectileCreated(",projectileID, ownerID, weaponID,weapondefsreload[weaponID],unitreloadframe[ownerID], ")")
local weaponIndex = weapondefsreload[weaponID]

if weaponIndex then
local gf = Spring.GetGameFrame()
local reloadFrame = Spring.GetUnitWeaponState(ownerID, weaponIndex, 'reloadFrame')

if unitreloadframe[ownerID] == nil or unitreloadframe[ownerID] <= gf then
SendToUnsynced("projetileCreatedReload", projectileID, ownerID, weaponID)
unitreloadframe[ownerID] = reloadFrame
end
end
end

else

local glSetFeatureBufferUniforms = gl.SetFeatureBufferUniforms
local GetFeatureResources = Spring.GetFeatureResources
local rezreclaim = {0.0, 1.0} -- this is just a small table cache, so we dont allocate a new table for every update
local forwardedFeatureIDsResurrect = {} -- so we only forward the start event once
local forwardedFeatureIDsReclaim = {} -- so we only forward the start event once
local myTeamID = Spring.GetMyTeamID()
local myAllyTeamID = Spring.GetMyAllyTeamID()
local _, fullview = Spring.GetSpectatingState()
local IsUnitInLos = Spring.IsUnitInLos
local GetFeatureHealth = Spring.GetFeatureHealth
local headless = false

function gadget:PlayerChanged(playerID)
myTeamID = Spring.GetMyTeamID()
myAllyTeamID = Spring.GetMyAllyTeamID()
_, fullview = Spring.GetSpectatingState()
end

function featureReclaimFrame(cmd, featureID, step)
--Spring.Echo("HandleFeatureReclaimStarted", featureID)
rezreclaim[1] = select(3, GetFeatureHealth( featureID )) -- resurrect progress
rezreclaim[2] = select(5, GetFeatureResources(featureID)) -- reclaim percent

--Spring.Echo('rezreclaim', rezreclaim[1], rezreclaim[2])

--if not headless then glSetFeatureBufferUniforms(featureID, rezreclaim, 1) end -- update GL, at offset of 1

if step > 0 and forwardedFeatureIDsResurrect[featureID] == nil and Script.LuaUI("FeatureReclaimStartedHealthbars") then
forwardedFeatureIDsResurrect[featureID] = true
--Spring.Echo("HandleFeatureReclaimStartedHealthbars", featureID, step)
Script.LuaUI.FeatureReclaimStartedHealthbars(featureID, step)
end

if step < 0 and forwardedFeatureIDsReclaim[featureID] == nil and Script.LuaUI("FeatureReclaimStartedHealthbars") then
forwardedFeatureIDsReclaim[featureID] = true
--Spring.Echo("HandleFeatureReclaimStartedHealthbars", featureID, step)
Script.LuaUI.FeatureReclaimStartedHealthbars(featureID, step)
end
end

function unitCaptureFrame(cmd, unitID, step)
if not fullview and not IsUnitInLos(unitID, myAllyTeamID) then return end
if Script.LuaUI("UnitCaptureStartedHealthbars") then
--Spring.Echo("UnitCaptureStartedHealthbars", unitID, step)
Script.LuaUI.UnitCaptureStartedHealthbars(unitID, step)
end
end

function projetileCreatedReload(cmd, projectileID, ownerID, weaponID)
--Spring.Echo("unsynced projetileCreatedReload", projectileID, ownerID, weaponID, fullview, Spring.GetUnitTeam(ownerID))
if fullview or Spring.GetUnitTeam(ownerID) == myTeamID then
if Script.LuaUI("ProjectileCreatedReloadHB") then
--Spring.Echo("G:ProjectileCreatedReloadHB", projectileID, ownerID, weaponID)
Script.LuaUI.ProjectileCreatedReloadHB(projectileID, ownerID, weaponID)
end
end
end

function gadget:FeatureDestroyed(featureID, allyTeamID)
forwardedFeatureIDsResurrect[featureID] = nil
forwardedFeatureIDsReclaim[featureID] = nil
end

function gadget:UnitDamaged(unitID, unitDefID, unitTeam, damage, paralyzer)
--Spring.Echo("gadget:UnitDamaged",unitID, unitDefID, unitTeam, damage, paralyzer)
if paralyzer then
if not fullview and not IsUnitInLos(unitID, myAllyTeamID) then return end

if damage > 0 then
if Script.LuaUI("UnitParalyzeDamageHealthbars") then
--Spring.Echo("UnitParalyzeDamageHealthbars", unitID, step)
Script.LuaUI.UnitParalyzeDamageHealthbars(unitID, unitDefID, damage)
end
if Script.LuaUI("UnitParalyzeDamageEffect") then
--Spring.Echo("UnitParalyzeDamageHealthbars", unitID, step)
Script.LuaUI.UnitParalyzeDamageEffect(unitID, unitDefID, damage)
end
end
end
end

function gadget:Initialize()
headless = Spring.GetConfigInt("Headless", 0) > 0
gadgetHandler:AddSyncAction("featureReclaimFrame", featureReclaimFrame)
gadgetHandler:AddSyncAction("unitCaptureFrame", unitCaptureFrame)
gadgetHandler:AddSyncAction("projetileCreatedReload", projetileCreatedReload)
end

function gadget:ShutDown()
gadgetHandler:RemoveSyncAction("featureReclaimFrame")
gadgetHandler:RemoveSyncAction("unitCaptureFrame")
gadgetHandler:RemoveSyncAction("projetileCreatedReload")
end
end
Binary file added LuaUI/Images/bars/build.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LuaUI/Images/bars/capture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LuaUI/Images/bars/disable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LuaUI/Images/bars/disarm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LuaUI/Images/bars/health.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LuaUI/Images/bars/reclaim.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LuaUI/Images/bars/resurrect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LuaUI/Images/bars/shield.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LuaUI/Images/bars/slow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LuaUI/Images/commands/Bold/captureReload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LuaUI/Images/commands/Bold/disable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LuaUI/Images/commands/Bold/disarm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LuaUI/Images/commands/Bold/slow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added LuaUI/Images/numbers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading