Unit Categories
Moderator: Moderators
Unit Categories
Does Spring read the unit category tag? For instance, you know...
all
arm
core
level1
kbot
weapon
notair
etc.
It is my understanding that these are used for the intelligent creation of selection categories. If this is the case, I would like to collaborate with other mod makers and the community in general to produce a standard which will function for most mods, if that seems reasonable.
all
arm
core
level1
kbot
weapon
notair
etc.
It is my understanding that these are used for the intelligent creation of selection categories. If this is the case, I would like to collaborate with other mod makers and the community in general to produce a standard which will function for most mods, if that seems reasonable.
Re: Unit Categories
Categories are not used for selection in Spring.
They are however, used. Mainly for controlling the targetting of weapons. c.f. OnlyTargetCategory, BadTargetCategory, NoChaseCategory
They are however, used. Mainly for controlling the targetting of weapons. c.f. OnlyTargetCategory, BadTargetCategory, NoChaseCategory
-
- Posts: 916
- Joined: 27 Jun 2009, 01:32
Re: Unit Categories
Those tags in fact are read by Spring but except for "Commander" and things like "CTRL_B" it's all about internal stuff. You want a unit to fire just at ground stuff you give that unit a "onlytargetcategory1=NOTAIR;" and so it'll just target units which have a "NOTAIR" category...
So there's no need to collaborate here or anything because you can name stuff as you want...
So there's no need to collaborate here or anything because you can name stuff as you want...
Re: Unit Categories
oicic... I wonder why not? Many of them were originally made for this purpose, it seems only logical.
-
- Posts: 916
- Joined: 27 Jun 2009, 01:32
Re: Unit Categories
Well you still should be able to create selection groups by doing some CTRL_X tags (not sure if that functionality was removed in the meantime - was a long time ago since I checked that). Apart from that it's a good thing that categories work the way they do now as the targeting / chasing options are very handy and special tags like "Level3" are also used for e.g. the morph widget which only lets something morph once you've "reached" the specific tech level - i.e. you've built a lab with that tag...
Re: Unit Categories
icic...
Thanks for the info
Thanks for the info
-
- Posts: 916
- Joined: 27 Jun 2009, 01:32
Re: Unit Categories
Well the tags are limited as you can only give them one category. In your case of a guardian targetting either a flea or a bulldog that'll happen automatically as the auto-targetting picks the "strongest" target. You still could give the guardian a "badcategory" for units it shouldn't focus on...
So in the end you need to think of what different sort of such categories you need in your game and build it up according to that...
So in the end you need to think of what different sort of such categories you need in your game and build it up according to that...
In which order you write down the category a unit applies to has no effect at all - it'll just be a member of all of them...Caydr wrote:What I'm asking is, does the order in which categories is specified have any bearing on the targeting priority?
- Evil4Zerggin
- Posts: 557
- Joined: 16 May 2007, 06:34
Re: Unit Categories
You will probably want to read this:
http://springrts.com/phpbb/viewtopic.php?f=12&t=19323
I do not recommend using categories for selection purposes. You are limited to 32 categories, beyond which unit targeting may fail to work properly. Note that the default selection keys now select commanders and aircraft by their tags regardless of category, so it is no longer necessary to use the COMMANDER and VTOL categories.
http://springrts.com/phpbb/viewtopic.php?f=12&t=19323
I do not recommend using categories for selection purposes. You are limited to 32 categories, beyond which unit targeting may fail to work properly. Note that the default selection keys now select commanders and aircraft by their tags regardless of category, so it is no longer necessary to use the COMMANDER and VTOL categories.
Re: Unit Categories
Aha! Very interesting read, thanks.
Is there a limit on armor categories now as well?
Is there a limit on armor categories now as well?
Re: Unit Categories
Is FALSE.Well the tags are limited as you can only give them one category
All the category related tags can take multiple categories as the category tag itself does.
e.g. onlyTargetCategory1=BUILDING INFANTRY SOFTVEH OPENVEH HARDVEH SHIP DEPLOYED;
Re: Unit Categories
It's a pity you can't assign different degrees of priority, you can only say "never attack this" "attack this unless there's something better" "always attack this".
I mean, suppose you have a heavy bomber, you want it to attack commanders with top priority, fusions with second priority, factories with third priority, fleas with fourth priority.
I mean, suppose you have a heavy bomber, you want it to attack commanders with top priority, fusions with second priority, factories with third priority, fleas with fourth priority.
Re: Unit Categories
IIRC, targets with highest metal cost are targetted first.Caydr wrote:It's a pity you can't assign different degrees of priority, you can only say "never attack this" "attack this unless there's something better" "always attack this".
I mean, suppose you have a heavy bomber, you want it to attack commanders with top priority, fusions with second priority, factories with third priority, fleas with fourth priority.
FWIW, you could probably lua a very specific targetting priority system.
Re: Unit Categories
One of the factors in targetting is value / hp. Value is based off of cost and unit xp.
- Evil4Zerggin
- Posts: 557
- Joined: 16 May 2007, 06:34
Re: Unit Categories
I'm pretty sure that target categories have always had a limit of 32, whereas armor categories have no practical limit. The difference is that a unit can belong to more than one target category but only one armor category. Since Spring uses a 32-bit integer for each, this means that you can only have 32 target categories, but 2^32 = more than 4 billion armor categories (although at anything above a dozen or so you're probably better off Lua'ing a damage system instead).Caydr wrote:Is there a limit on armor categories now as well?
Re: Unit Categories
Why is that?Evil4Zerggin wrote:(although at anything above a dozen or so you're probably better off Lua'ing a damage system instead).
I currently have about 20 I think.
Re: Unit Categories
Im glad i read this cause I'm working on a mod that needs at least 1 billion different unit categories.Evil4Zerggin wrote:I'm pretty sure that target categories have always had a limit of 32, whereas armor categories have no practical limit. The difference is that a unit can belong to more than one target category but only one armor category. Since Spring uses a 32-bit integer for each, this means that you can only have 32 target categories, but 2^32 = more than 4 billion armor categories (although at anything above a dozen or so you're probably better off Lua'ing a damage system instead).Caydr wrote:Is there a limit on armor categories now as well?

- Evil4Zerggin
- Posts: 557
- Joined: 16 May 2007, 06:34
Re: Unit Categories
Just for cleanliness's sake; that way you don't have to go around explicitly defining piles of "this weapon does X damage against Y target". You can also add code to gamedata/unitdefs_post.lua to simplify things, e.g. my damagetypes.Caydr wrote:Why is that?Evil4Zerggin wrote:(although at anything above a dozen or so you're probably better off Lua'ing a damage system instead).
I currently have about 20 I think.
(Sorry to be plugging my own stuff so much; it's the code I know best :p)
Re: Unit Categories
Does unitcategory=all serve any purpose anymore? You would give this category to every unit in a mod.
In OTA it helped units be less dumb sometimes if you set them to badtargetcategory=all. Specifically I think it helped them to be less fixated on a particular target, and just pick a new one if the original is no longer available for any reason rather than waiting.
It was mainly of use on anti-air units. You can imagine, a flakker not firing for even a fraction of a second while it waited to see if one particular bomber wanted to come back for seconds would be pretty frustrating and silly.
So does it still help with that or should I not bother with it anymore? No sense keeping useless categories around.
In OTA it helped units be less dumb sometimes if you set them to badtargetcategory=all. Specifically I think it helped them to be less fixated on a particular target, and just pick a new one if the original is no longer available for any reason rather than waiting.
It was mainly of use on anti-air units. You can imagine, a flakker not firing for even a fraction of a second while it waited to see if one particular bomber wanted to come back for seconds would be pretty frustrating and silly.
So does it still help with that or should I not bother with it anymore? No sense keeping useless categories around.
- Evil4Zerggin
- Posts: 557
- Joined: 16 May 2007, 06:34
Re: Unit Categories
For assigning the categories, I suggest keeping a set of categories that each unit belongs to exactly one of. For example, AIR, LAND, SEA, HOVER, and SUB. Then instead of saying badTargetCategory=ALL; you can say badTargetCategory=AIR LAND SEA HOVER SUB; This way you don't have to define a separate ALL category. Instead of onlyTargetCategory=NOTAIR, you can put onlyTargetCategory=LAND SEA HOVER SUB; And so forth.
As for the behavior side, I'm not sure exactly what happens in terms of engine source, although it seemed to work well enough without it when I tried it.
As for the behavior side, I'm not sure exactly what happens in terms of engine source, although it seemed to work well enough without it when I tried it.
Re: Unit Categories
I'm not sure I follow you... as far as I can tell there's no reason not to use an "all" category if you want all the units to be in one of them, but regardless, why do you use that method if you're not even sure it has an effect? What sort of units do you use it on, and for what reason?