Skip to content

Zombie api gadget expanded - #5835

Open
Stiofan-K wants to merge 5 commits into
ZeroK-RTS:masterfrom
Stiofan-K:zombie_revive_for_all
Open

Stiofan-K wants to merge 5 commits into
ZeroK-RTS:masterfrom
Stiofan-K:zombie_revive_for_all

Conversation

@Stiofan-K

Copy link
Copy Markdown
Contributor

Moves the rez queue functionality of zombies to the api and makes accessible for other things.

Moves the rez queue functionality to the api and makes accessible for other things via a callback function.
Except I havent figured out how to get the callback funciton to work correctly.
Comment thread LuaRules/Gadgets/unit_global_zombie_resurrect.lua Outdated
Comment thread LuaRules/Gadgets/api_zombie_helper.lua
Comment thread LuaRules/Gadgets/api_zombie_helper.lua Outdated
Comment thread LuaRules/Gadgets/api_zombie_helper.lua
Comment thread LuaRules/Gadgets/api_zombie_helper.lua Outdated
Thx Steelblue
who knew functions accept only as many arguments as they request!

new zombies also do their thing on rez correctly
thxthx anyhow. needs to be fixed at some point eh?
Seems to be working as intended
@Stiofan-K
Stiofan-K marked this pull request as ready for review September 15, 2026 19:22
if (resurrectingFeatures[featureID].rezFrameCallback) then
resurrectingFeatures[featureID].rezFrameCallback(featureID)
else
local unitID = TurnFeatureIntoUnit(featureID,GaiaTeamID,true,nil)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure if this sort of default behavior is good practice.
Can't be slowed because unslowing isn't handled here but in the global rez gadget.

local unitID = units[i]
local unitTeam = spGetUnitTeam(unitID)
if (unitTeam == GaiaTeamID) then
zombies[unitID] = true

@Stiofan-K Stiofan-K Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, you reach this via unpause and I assume also "loading" a game as a campaign map start would.

I've attempted to differentiate between zombies and other forms of neutral units via the zombies table here, though a pause would just add all neutrals to the zombie team regardless. I assume its necessary or good when all neutrals units are intended to be zombies.

I suppose the gadget removes itself anyways if global zombies are disabled. So if this is reached all neutrals would/should be considered zombies anyways in that case and it doesnt matter?

Comment on lines +231 to +244
-- Reclaiming the wreck can stretch the revive time up to 2x the base time.
function gadget:AllowFeatureBuildStep(builderID, builderTeam, featureID, featureDefID, part)
if (resurrectingFeatures[featureID]) then
local rezInitFrame = resurrectingFeatures[featureID].rezInitFrame
local rezBaseTime = resurrectingFeatures[featureID].rezBaseTime
local reclaimPercent = resurrectingFeatures[featureID].reclaimPercent

reclaimPercent = reclaimPercent + part
local rezTime = rezBaseTime + rezBaseTime * (1 - reclaimPercent)
resurrectingFeatures[featureID].rezFrame = rezInitFrame + rezTime * 32

resurrectingFeatures[featureID].reclaimPercent = reclaimPercent
end
return true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was a bit scary to touch, but I think is functionally identical.
We count the reclaim % remaining down from 100 instead of reclaim taken up from 0.

Comment on lines +205 to +208
local _,_,_,_,reclaimPercent,_ = Spring.GetFeatureResources(featureID)

rezTime = rezBaseTime + rezBaseTime * (1 - reclaimPercent)

@Stiofan-K Stiofan-K Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting revive time is also based on reclaim % left in the wreck instead of assuming it is at 100%

This is new, but shouldnt change anything for base zombies as they revive on Feature creation at 100% reclaim. Seem logical and inline for how it would work for a delayed revival application however.

rezWarningTime = WARNING_TIME, -- warning time in seconds for base particles and sfx, set 0 to hide.
reclaimPercent = reclaimPercent, -- reclaim left in feature in % to compare and adjust reztime
}
return resurrectingFeatures[featureID]

@Stiofan-K Stiofan-K Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should allow anyone to modify the base values to their liking afterwards

Unsure if there would be a better way to do things for this function outside of me assuming some base functionality/behavior as a wanted standard and then exposing the output for tweaks.

@Stiofan-K

Copy link
Copy Markdown
Contributor Author

Also could add proper getter/setters to modify things with if requested

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

Successfully merging this pull request may close these issues.

2 participants