Zombie api gadget - #5784
Conversation
groundwork for splitting off some the zombies into a gadget to be used by nanoplague
|
I'm a bit on the fence on some things, specifically handling the zombies arrays and such. I could unify/port/standerdise the countdown to revive aswell I suppose, though then it would not be possible to differentiate between zombie or nanoplague zombies. |
|
What does each of the gadgets do? The descriptions of each should be updated to make this clear, because api_ and unit_ don't mean a whole lot. |
|
aaaaaye. Ideally I want to put as much into the helper gadget to avoid duplication, but I'm unsure if I can put more there without it becoming inflexible. |
| GG.Zombies = { | ||
| TurnFeatureIntoUnit = TurnFeatureIntoUnit, | ||
| SetZombieSpeedMult = SetZombieSpeedMult, | ||
| SetZombieBehavior = SetZombieBehavior, |
There was a problem hiding this comment.
I'd get rid of the "set behaviour" and just let gadgets ask for the wander directly. Units are essentially "controlled by luaAI" by default.
| SetZombieBehavior = SetZombieBehavior, | |
| SetZombieWander = GiveZombiesRandomOrders, |
sprunk
left a comment
There was a problem hiding this comment.
looks ok overall, i'll see if i can find some time to test during the week
|
aye thanks, I'll change it around! Thoughts on if theres sense in trying to put the to be rezed arrays in the api gadget? And is LuaAi different from amove behavior? since thats essentially what wander applies, and I'd be curious if more complex behavior can be coaxed out for nanoplague zombies. |
IMO slowing is ok as-is, rezzed arrays may be ok to eventually put in the api but I'll have to think of how to do it cleanly.
LuaAI can make units do anything, it's just a matter of writing an implementation. This includes arbitrarily powerful "legit" behaviour (e.g. pyros use jump; glaives perfectly dodge projectiles and avoid LLTs; units congregate into hivemind armies and strategically raid mexes...) but also beyond that (e.g. radars call down orbital tacnukes; detriment roars, whistles, and even plays music). |
|
For rezzed arrays I think the issue would be referencing back to the gadgets that put the features "in queue", so that you can differentiate between different zombie types. And :O Detriment with all the bells and whistles. Is there a good example for LuaAI floating about? Wandering works generally for whats intended, but cons building structures and units being smarter or 'biased' toward the team that made them could be interesting to give Nanoplagued zombies a smarter feel over normal ones, being a less degraded/feral version of the same tech essentially. |
Yea I'm thinking there could just be a callback like so
Not really, what I listed is mostly just what's possible. In theory CAI is a LuaAI and tries to be smart but it may be hard to make a "detached" instance that won't try to control the rest of non-zombies owned by Gaia. |
|
poke |
|
Sounds fine either way. I was/am sort of busy but I'll try to prioritize looking at this deeper soon. |
|
Aye, just wanted to get some confirmation. No rush! |
sprunk
left a comment
There was a problem hiding this comment.
I left a bunch of comments, but couldn't resist immediately addressing them all myself. I pushed the resulting commit to https://github.com/ZeroK-RTS/Zero-K/tree/zombie-api-cleaned-up.
Your choice on whether you want to have your share of fun and learning and do them on your own, or if you want me to just merge that cleaned up commit so you can move on to nanoplague etc.
| if reclaimPercentHealth then | ||
| local currentMetal, maxMetal = Spring.GetFeatureResources(featureID) | ||
| if currentMetal and maxMetal and (maxMetal > 0) then | ||
| partialReclaim = currentMetal/maxMetal |
There was a problem hiding this comment.
When the code does not enter these ifs then the partialReclaim var (which is a global btw) will be nil,
| if partialReclaim ~= 1 then | ||
| local health = Spring.GetUnitHealth(unitID) | ||
| if health then | ||
| Spring.SetUnitHealth(unitID, health*partialReclaim) |
There was a problem hiding this comment.
and since nil ~= 1 it will enter there and crash on health * partialReclaim due to multiplication by nil.
|
|
||
| -- Works on non zombie units too. | ||
| local function SetZombieSpeedMult(unitID,speedMult) | ||
| Spring.SetUnitRulesParam(unitID, "zombieSpeedMult", speedMult, LOS_ACCESS) |
There was a problem hiding this comment.
Now that it's an API it needs a bit more care around argument correctness, perhaps add something like
| Spring.SetUnitRulesParam(unitID, "zombieSpeedMult", speedMult, LOS_ACCESS) | |
| if type(speedMult) ~= 'number' or speedMult < 0 then | |
| error("SetZombieSpeedMult: mult must be number >= 0") | |
| end | |
| Spring.SetUnitRulesParam(unitID, "zombieSpeedMult", speedMult, LOS_ACCESS) |
| -------------------------------------------------------------------------------- | ||
|
|
There was a problem hiding this comment.
needs a synced code check, same as zombies
| author = "Stiofan", | ||
| date = "June 2026", |
There was a problem hiding this comment.
largely just shuffling of existing code
| author = "Stiofan", | |
| date = "June 2026", | |
| author = "TomFyuri, Stiofan", | |
| date = "Mar 2014", |
| if (#orders > 0) then | ||
| if not Spring.GetUnitIsDead(unitID) then |
There was a problem hiding this comment.
death checks could be done at the top, before rolling dice 30 times. the orders check is redundant since there's always at least 10 orders.
| end | ||
| if (#orders > 0) then | ||
| if not Spring.GetUnitIsDead(unitID) then | ||
| Spring.GiveOrderArrayToUnitArray({unitID}, orders) |
There was a problem hiding this comment.
the array always has just 1 unit, so could be just Spring.GiveOrderArrayToUnit
| local function disSQ(x1, y1, x2, y2) | ||
| return (x1 - x2)^2 + (y1 - y2)^2 | ||
| end |
| Spring.DestroyFeature(featureID) | ||
| local unitID = Spring.CreateUnit(featureDefName, x, y, z, facing, teamID) |
There was a problem hiding this comment.
these could be swapped, would keep a brief window where they exist together to allow transferring some traits from the feature to the unit in the future, if needed
| --unused, may be used depending on how things shake out | ||
| local ZOMBIE_SOUNDS = { | ||
| "sounds/misc/zombie_1.wav", | ||
| "sounds/misc/zombie_2.wav", |
There was a problem hiding this comment.
sounds easy to copypaste if/when that happens
Splitting off some the zombies code into a gadget to later be used by nanoplague