Factory health/buildtime modification

Factory health/buildtime modification

Requests for features in the spring code.

Moderator: Moderators

Post Reply
User avatar
LathanStanley
Posts: 1429
Joined: 20 Jun 2005, 05:16

Factory health/buildtime modification

Post 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.) :wink:

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.. :P

whadda you think?
Last edited by LathanStanley on 19 Apr 2007, 20:34, edited 1 time in total.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post 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.
User avatar
LathanStanley
Posts: 1429
Joined: 20 Jun 2005, 05:16

Post 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.... :P

maybe we can make it "sputter" in lua, toggle on and off fast.. :roll:
manored
Posts: 3179
Joined: 15 Nov 2006, 00:37

Post 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.
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post 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.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post 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.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Post 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?
User avatar
LathanStanley
Posts: 1429
Joined: 20 Jun 2005, 05:16

Post 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 :wink:
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post 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
User avatar
LathanStanley
Posts: 1429
Joined: 20 Jun 2005, 05:16

Post 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.. :P

someday...
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post 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).
User avatar
LathanStanley
Posts: 1429
Joined: 20 Jun 2005, 05:16

Post 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..
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post 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 ...)
Post Reply

Return to “Feature Requests”