Open WatchTheFort opened 1 year ago
So the request is to make the unit categories dynamic based on the unit's circumstances? From what I see at the moment, the engine doesn't understand what these categories are. It is something the the game decides and puts meaning to. The engine just provides the mechanism.
What we can do is provide a call where you can change the unit's category. Then the game has to decide on when the category changes and to what.
If it's done in the game, it will have to be synced with the engine retargeting rate, so we don't get stale categories. If it has to be run every frame for every mobile or transportable unit, will that have a large performance impact?
So the request is to make the unit categories dynamic based on the unit's circumstances? From what I see at the moment, the engine doesn't understand what these categories are. It is something the the game decides and puts meaning to. The engine just provides the mechanism.
What we can do is provide a call where you can change the unit's category. Then the game has to decide on when the category changes and to what.
From my pov, ability to change a category dynamically could be very helpful. It may enable certain game mechanics, like a unit changing its type (from land to sea and vice versa; consider SupCom's destroyer ships, which are able to embark on land with legs. They are different from a unit like Pelican/Platypus, because they are 100% ships while in sea, not hovers, thus a more complicated type) and many others. I'm also thinking of badtargetcategory. Ability to mark a target on the fly as bad or good for specific set of units is very useful too.
If it's done in the game, it will have to be synced with the engine retargeting rate, so we don't get stale categories. If it has to be run every frame for every mobile or transportable unit, will that have a large performance impact?
You should only need to call it at the point in time where a unit has met the conditions for a category change. Most units won't update the state for their entire life. When an aircraft takes off, it can set its category to FLYING
, when it lands, it can set it to SURFACE
it shouldn't need to call the update every frame.
Given that different units will be updating their targets every frame, you won't be able to sync a category change conveniently - just do it when it makes sense, and then within a half-second the unit targeting should have taken effect (I'm assuming that the category checks are carried out in this case.)
You might be able to achieve dynamic targeting categories already by returning the appropriate boolean values from gadget:AllowWeaponTarget
.
That looks like it could work, though it would require removing all onlytargetcategory
tags from all units. The description says,
Controls blocking of a specific target from being considered during a weapon's periodic auto-targeting sweep.
Does this mean it doesn't get called for manually issued attack orders?
Looks like there is some game-side logic to handle manually issued attack orders?
Does ^it work correctly with Fight command as well? Does Fight command generate an Attack command that goes through this check when it meets a target, or this is not how it works?
Does this mean it doesn't get called for manually issued attack orders?
Looks like it is just for target acquisition when idle. In that case consider this comment a feature request for a callin that gets called after native onlyTargetCategory
checks. A callout to edit categories would probably still be okay but is strictly less powerful than an explicit targeting check.
Does ^it work correctly with Fight command as well? Does Fight command generate an Attack command that goes through this check when it meets a target, or this is not how it works?
fight command rellies on the fact that the unit can engage a target this even means if the unit is on hold fire , the unit will simply move to the fight command point and not engage or stop moving i believe it generates an attack order to stop moving and engaging the enemy unit
Checking whether gadget:AllowWeaponTarget
can do this seems like a decent first step. If it can't then perhaps it would be reasonable to request whatever extra is required for it to work.
Currently, unit def weapons use the
onlytargetcategory
tag to determine whether a target is valid or not. This is static, so a target is either universally valid, or universally invalid, regardless of what it is doing. This results, for instance, in ground units not being able to target landed planes, while AA still can.Instead, if the target categories were based on the unit's current behaviour, then targeting could be dynamic, and more intuitive. The categories I can think of are
SURFACE
,FLOATING
,SUBMERGED
,HOVER
,FLYING
. An aircraft would then have the FLYING category while flying, but when landed would have the SURFACE category. So AA could shoot it in the air, but not on the ground, and tanks could shoot it on the ground, but not in the air.