Page 1 of 1
Factory health/buildtime modification
Posted: 19 Apr 2007, 19:14
by LathanStanley
I think a trigger that you can define to alter the speed a factory, or a worker, or ANYTHING that nanolathes to a slower buildtime dependant on health would be quite interesting...
think about it,
Factory or Conbot:
100% health -> 100% buildspeed
80% health -> ~95% buildspeed
60% health -> ~65% buildspeed
40% health -> ~35% buildspeed
20% health -> ~5% buildspeed
0% health -> duh...
anyways... you get the point... consider it as a polynomial graph of the third power.. (for you eggheads like me) anyways I think it would add a neat aspect to raiding, you go though and just damage something.. and, OH NOES!!! ITS BUILDING SLOW!!! I GOTTA FIX IT!!!....
and to make it less, or more, close to a linear scale, just change the multiplier on the formula:
Y = (X-50)^(3*#)+50
(edit: ok I threw that formula out in my head on the fly, its waaay f'ed up, I'll see if I can fix it)
Where:
Y = Buildspeed
X = health amount
# = multiplier from (.3334 - 1.0)
using .3334 will be a linear graph, and 1.0 a full third power graph, put it in excell or your graphing calculator and look with a zoom from 0 - 100 on both axis.
(going less than 1/3 will cause, well, issues in the graph, and going over 1, will cause dips and more rises and stuff, so yes, 1/3 - 1 are the limitations of the function.)
it'll add a bit more "incentitive" to micro, but at the same time.. players too worried about "only damaging everything" might get hurt in the long run a- because they never kill anything, and b- spend too much time on micro and lose their base..
whadda you think?
Posted: 19 Apr 2007, 19:41
by KDR_11k
I think being able to change the workertime would be nice for mods. Let the script do it though, not some hardcoded function. Not sure if Lua can't already do it but I don't think so, you can only handle the building completely in Lua.
Posted: 19 Apr 2007, 19:53
by LathanStanley
KDR_11k wrote:I think being able to change the workertime would be nice for mods. Let the script do it though, not some hardcoded function. Not sure if Lua can't already do it but I don't think so, you can only handle the building completely in Lua.
well... lua lua lua, I don't know lua....
maybe we can make it "sputter" in lua, toggle on and off fast..

Posted: 20 Apr 2007, 00:12
by manored
I think it would be nice to have something to allow the player hinself to control the nanolathing speed, so incase of necessity he would be able to send resources to the stuff that really matters while not completly stoping building the others.
Posted: 20 Apr 2007, 11:34
by imbaczek
KDR_11k wrote:I think being able to change the workertime would be nice for mods. Let the script do it though, not some hardcoded function. Not sure if Lua can't already do it but I don't think so, you can only handle the building completely in Lua.
You have UnitDamaged call-in; there will be a slight problem with restoring buildspeed when restoring health. You could always use LuaCOB to periodically call a Lua function from a COB thread.
What I'm not sure is wheter it is (currently) possible to change only one unit's build speed.
Posted: 20 Apr 2007, 13:25
by KDR_11k
I can very well monitor the health myself, even if it takes a per-frame loop (it's a factory, those aren't going to be that common). I think it would be pretty easy to implement a slider for the user. The only question is whether we can modify the factory's workertime, preferrably without handling the build process completely in Lua.
Posted: 20 Apr 2007, 14:47
by zwzsg
Is there any mod that's longing to use that feature, or is it just new features for the sake of requesting new features?
Posted: 22 Apr 2007, 01:45
by LathanStanley
zwzsg wrote:Is there any mod that's longing to use that feature, or is it just new features for the sake of requesting new features?
not that I know of, I just thought it might add a new feel to parts of the game, and as a mild request for someone to include it

Posted: 22 Apr 2007, 02:30
by trepan
Now that lua access has been made available to buildSpeed,
a LuaRules script could be used to implement this feature
(very easily).
In UnitDamaged():
Code: Select all
local ud = UnitDefs[unitDefID]
if (ud.builder) then
local health, maxHealth = Spring.GetUnitHealth(unitID)
local scale = 0.5 + (0.5 * (health / maxHealth))
Spring.SetUnitBuildSpeed(unitID, ud.buildSpeed * scale)
end
Posted: 22 Apr 2007, 22:03
by LathanStanley
trepan wrote:Now that lua access has been made available to buildSpeed,
a LuaRules script could be used to implement this feature
(very easily).
In UnitDamaged():
Code: Select all
local ud = UnitDefs[unitDefID]
if (ud.builder) then
local health, maxHealth = Spring.GetUnitHealth(unitID)
local scale = 0.5 + (0.5 * (health / maxHealth))
Spring.SetUnitBuildSpeed(unitID, ud.buildSpeed * scale)
end
how cool!
now if I can only get off my rear and learn some more bout lua to script my features..
someday...
Posted: 22 Apr 2007, 22:09
by trepan
Actually, you'll also want to make sure they get
updated when they're healed. For efficienty reasons,
it might be best to keep a list of the current factories
and update them every N frames (staggered updates
would be even better).
Posted: 22 Apr 2007, 22:13
by LathanStanley
trepan wrote:Actually, you'll also want to make sure they get
updated when they're healed. For efficienty reasons,
it might be best to keep a list of the current factories
and update them every N frames (staggered updates
would be even better).
point taken.. same kinda staggered update I'm planning on the tiberium...
I've got the idea on paper, the line and bubble drawing of how the code will react upon itself and units, buildings, edge of the map, etc... I just gotta write it..
Posted: 22 Apr 2007, 22:18
by trepan
If I find the motivation, I'll also port the LuaUI widgets.lua (widgetHandler)
code to the LuaCob/LuaGaia/LuaRules scripts. It'll make it easier to support
modular simulation scripts. Then you could have a directory with sim widgets
that get loaded, ex:
LuaRules/Widgets/health_based_building.lua
LuaRules/Widgets/share_allies_only.lua
LuaRules/Widgets/unit_teleporter.lua
The one big catch is that it'll have to be tweaked to make it work with the
split synced/unsynced code. Shouldn't be too hard to get around (could
even put both in the same file with mode guards, ex: if (SYNCED) then ...)