He's trying to say that you could generate supply-use values for your units based on an amalgam of their previously existing stats and some contrived neon-math.
He pulled the "wreckages" thing from the fact that ZK seems to automatically assign metal values to wreckages based on unit cost.
Population Cap Gadget
Moderator: Moderators
Re: Population Cap Gadget
There are two ways to add a new property to a hundred items (Here, supply cost to all Evo units):
- The dumb way is to add a new tag to each one of your unit stat spreadsheet.
- The smart way is to add a couple lines of code in some gadget or gamedata/*.lua to calculate a value for each unit from a generic formula.
But I don't agree that the "smart" way is always better: NeonStorm might be of the opinion that it is easier to maintain a few lines of code than a hundred value spread in a hundred files, except that he forgets that if the code is too smart, it becomes impossible to understand (at a later stage or by another person), and thus impossible to maintain, while many values in many files, while laborious to edit, are at least understandable and editable by anybody, and with a much lower risk of breaking the Lua.
NeonStorm then propose a formula to derive Supply Cost from Metal Cost (which indeed isn't very clear).
- The dumb way is to add a new tag to each one of your unit stat spreadsheet.
- The smart way is to add a couple lines of code in some gadget or gamedata/*.lua to calculate a value for each unit from a generic formula.
But I don't agree that the "smart" way is always better: NeonStorm might be of the opinion that it is easier to maintain a few lines of code than a hundred value spread in a hundred files, except that he forgets that if the code is too smart, it becomes impossible to understand (at a later stage or by another person), and thus impossible to maintain, while many values in many files, while laborious to edit, are at least understandable and editable by anybody, and with a much lower risk of breaking the Lua.
NeonStorm then propose a formula to derive Supply Cost from Metal Cost (which indeed isn't very clear).
Re: Population Cap Gadget
Most pro is to have both.
First try a) but if tag does not exist in unitdef then do b)a) The dumb way is to add a new tag to each one of your unit stat spreadsheet.
b) The smart way is to add a couple lines of code in some gadget or gamedata/*.lua to calculate a value for each unit from a generic formula.
Re: Population Cap Gadget
Ofcourse I prefer the code lines - And this is the "Lua Scripts" subforum.
Spring already has a lot of code - few comments, a lot of side-steps (you need to know another file to know what the code in this file does), etc.
It is not more complex than any config-file (just an example how it would look like for a BA-unit):
x.energyCost is the same as in unit blueprints - just with leading "x."
very hard to break, very easy to find the bug.
It would be special code if just used for 1 thing, but ok if you need it for many stats and write it into a documentation.
Spring already has a lot of code - few comments, a lot of side-steps (you need to know another file to know what the code in this file does), etc.
It is not more complex than any config-file (just an example how it would look like for a BA-unit):
Code: Select all
for unitname,x in pairs(unitdefs) do
x.populationWeight = #offset + (x.metalcost + x.energycost/60) /#mPerWeightUnit
x.energyCost = x.metalCost*60
end
very hard to break, very easy to find the bug.
It would be special code if just used for 1 thing, but ok if you need it for many stats and write it into a documentation.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Population Cap Gadget
The "smart" way would be idiotic. Since when is supply going to directly correlate with cost?
Just because something is expensive doesn't mean that it should use a bunch of supply.
Your assumption is quite faulty.
Just because something is expensive doesn't mean that it should use a bunch of supply.
Your assumption is quite faulty.
Re: Population Cap Gadget
Might be a good idea to set a "default" somewhere (makes 0, uses 1) so that every unit has the stat... and then to manually specify in each unit that differs from the default.
Re: Population Cap Gadget
x.energyCost = x.energyCost or 0
if x.energyCost is not set, it will be set to 0.
But you have to do that before spring inserts own defaults.
I know from Supreme Commander - Forget Alliance, that a Walker-Bot inherits all defaults from a Walker-Class.
All air units inherit from AirUnit-class. A bomber can inherit from a bomber-class, which itself inherits from Plane-class, which inherit values from AirUnit-class.
It is like a Tree - everything inherits what comes from the roots.
if x.energyCost is not set, it will be set to 0.
But you have to do that before spring inserts own defaults.
I know from Supreme Commander - Forget Alliance, that a Walker-Bot inherits all defaults from a Walker-Class.
All air units inherit from AirUnit-class. A bomber can inherit from a bomber-class, which itself inherits from Plane-class, which inherit values from AirUnit-class.
It is like a Tree - everything inherits what comes from the roots.