Page 1 of 2
Move armordefs to unitdefs
Posted: 20 Mar 2014, 17:40
by code_man
It seems really stupid to me having to write down all the unit names in a single sperate file instead of just being able to declare the armor inside the unitdefs themselfs.
I know its a small thing, but this gave me some grief and its really an oditty.
Re: Move armordefs to unitdefs
Posted: 20 Mar 2014, 17:44
by SinbadEV
code_man wrote:It seems really stupid to me having to write down all the unit names in a single sperate file instead of just being able to declare the armor inside the unitdefs themselfs.
I know its a small thing, but this gave me some grief and its really an oditty.
... couldn't you have the unitdefs define an armordef property and just have a script in armordefs that sets the armordef of each unitdef to said value?
Re: Move armordefs to unitdefs
Posted: 20 Mar 2014, 17:47
by smoth
Really dude? Codeman I did this sat least 3 years ago bro! EVO RTS uses the code
Re: Move armordefs to unitdefs
Posted: 20 Mar 2014, 17:50
by Silentwings
I guess the point is that usually what one wants to know is which units are in a particular armordef.
Either way - amordefs could be indexed via category names or via unit names - you have to text search when you want to see the information indexed the other way around. This way you only have to text search one file instead of all your unitdefs.
Re: Move armordefs to unitdefs
Posted: 20 Mar 2014, 17:52
by code_man
SinbadEV wrote:
... couldn't you have the unitdefs define an armordef property and just have a script in armordefs that sets the armordef of each unitdef to said value?
Well i could ... or the engine could just have a armor parameter builtin so armordefs isnt needed anymore at all.
Re: Move armordefs to unitdefs
Posted: 20 Mar 2014, 17:53
by Anarchid
I wonder if there's an armordefs_post... that'd make that stuff easy.
Re: Move armordefs to unitdefs
Posted: 20 Mar 2014, 17:55
by SinbadEV
code_man wrote:SinbadEV wrote:
... couldn't you have the unitdefs define an armordef property and just have a script in armordefs that sets the armordef of each unitdef to said value?
Well i could ... or the engine could just have a armor parameter builtin so armordefs isnt needed anymore at all.
In the TA paradigm things like armordefs and movedefs are expected to be shared by multiple units so setting them in a central place made more sense than duplicating the same settings in every unit that had the same armor or movement parameters.
Re: Move armordefs to unitdefs
Posted: 20 Mar 2014, 17:55
by smoth

anarchid, It would wouldn't it...
Lol nah sinbad
Re: Move armordefs to unitdefs
Posted: 20 Mar 2014, 19:28
by code_man
SinbadEV wrote:
In the TA paradigm things like armordefs and movedefs are expected to be shared by multiple units so setting them in a central place made more sense than duplicating the same settings in every unit that had the same armor or movement parameters.
Movedefs make kinda sense, but armordefs.lua is just a a list of a list with unit names.
I cannot imagine armordefs.lua ever being an advantage over a simple armor parameter in the unitdefs.
Re: Move armordefs to unitdefs
Posted: 20 Mar 2014, 19:33
by smoth
The solution is simple lua
Re: Move armordefs to unitdefs
Posted: 20 Mar 2014, 19:48
by code_man
smoth wrote:The solution is simple lua
Seems like serious overkill to me, a simple unitdef param in the engine and marking armordefs.lua as deprecated would do it i think. I doubt anyone would miss that file.
But well i guess having lua read it from customparams is gonna do the trick ok.
Tough i still hope devs would consider this, it seems very out of place to me and inconsitency can drag itself a long way.
Re: Move armordefs to unitdefs
Posted: 20 Mar 2014, 19:53
by smoth
Adding to the engine is overkill when you could have already added it
Re: Move armordefs to unitdefs
Posted: 20 Mar 2014, 20:02
by Silentwings
Seems like serious overkill to me, a simple unitdef param in the engine and marking armordefs.lua as deprecated would do it i think. I doubt anyone would miss that file.
I would miss it, for reasons explained above.
Re: Move armordefs to unitdefs
Posted: 20 Mar 2014, 20:15
by code_man
smoth wrote:Adding to the engine is overkill when you could have already added it
I dont see why armor should be treated any different from say autoheal or category or sounds or maybe even build parameters.
What bothers me is that this is the only param that must be specified in a seperate file with a different format.
Now being able to compute parameters trough lua is great and all, but in this case it just feels like doing extra work that could be done by the engine simply having another unitdef param, considering dmg calculations are already done by the engine its more like having to "fix" something the engine should be handling straight forward.
Silentwings wrote:
I would miss it, for reasons explained above.
Assuming you reference your post above, then i dont see how say health doenst fall in the same batch as armor.
Re: Move armordefs to unitdefs
Posted: 20 Mar 2014, 20:49
by smoth
Ok I do not agree and see we are now in the realm of opinions. your problem is easily solved if you would bother to spend some actual time looking into it
Re: Move armordefs to unitdefs
Posted: 20 Mar 2014, 20:51
by Silentwings
Assuming you reference your post above, then i dont see how say health doenst fall in the same batch as armor.
I rarely have a need to know e.g. a list of units that have >x heath. However, I do often want to know how much health unit y has. So health is better in unitdefs.
Maybe you didn't understand above so let me give you a specific example - whenever I redesign a unit (in particular, how much damage it does) I need to know how much damage it does to each other unit. For that I need a place to look up the armourclasses of _all_ units, ideally one that doesn't involve a grep across multiple files. So armourclass is better not in unitdefs.
Re: Move armordefs to unitdefs
Posted: 20 Mar 2014, 21:24
by code_man
Silentwings wrote:Assuming you reference your post above, then i dont see how say health doenst fall in the same batch as armor.
I rarely have a need to know e.g. a list of units that have >x heath. However, I do often want to know how much health unit y has. So health is better in unitdefs.
Maybe you didn't understand above so let me give you a specific example - whenever I redesign a unit (in particular, how much damage it does) I need to know how much damage it does to each other unit. For that I need a place to look up the armourclasses of _all_ units, ideally one that doesn't involve a grep across multiple files. So armourclass is better not in unitdefs.
I dont get it, if you want to know much damage it does against other units then you still need the heath from each of the unitdefs.
Re: Move armordefs to unitdefs
Posted: 20 Mar 2014, 21:26
by knorke
I agree it is a bit of oddity.
While ago there was armor.txt which afaik was really just a list of unit names, guess that where it comes from.
Deprecating armordefs.lua is not good idea imo. Usually cleaning things up a bit is nice but here is not much too gain. All mods would need updating and the easiest fix would be to "reinvent" the armordefs.lua...
Like SinbadEV said, in armordefs.lua you can read the unitDefs table and all parameters of units.
So can read the units parameters and build your armor table based on that. For example:
http://sourceforge.net/p/mwspring/code/ ... ordefs.lua from
http://springrts.com/wiki/Armordefs.lua ... e_Examples
In your case it would be simpler, maybe something like this:
Code: Select all
for unitName, unitDef in pairs(unitDefs) do
table.insert(armorDefs[unitDef.customparams.armorType], unitName)
end
(just to show principle idea)
Putting such construct in armordefs.lua basically does what you want: Can now put armorType="paperarmor" in unit files.
Yes maybe it would "feel cleaner" in engine, but you could just never look at the file

because functionality wise it is the same.
armordefs_post: what would it do that armordefs.lua can not do already?
Re: Move armordefs to unitdefs
Posted: 20 Mar 2014, 21:51
by Silentwings
I dont get it, if you want to know much damage it does against other units then you still need the heath from each of the unitdefs.
No, I don't. (Although, if I did want to know that, which as I said above I rarely do, unlike armordefs, I can pretty remember all those anyway.)
Re: Move armordefs to unitdefs
Posted: 21 Mar 2014, 07:23
by Forboding Angel
Code_man, you aren't getting it. It has already been done. I can help you out if you like whenever I have a chance.