KnuckleCracker / CW4-bug-tracker

The gathering point for bugs and supporting information, or suggestions about additional features.
Creative Commons Attribution Share Alike 4.0 International
13 stars 1 forks source link

[4RPL Bug] GetUnitsInRange ignores units with "occupies land" turned off. #649

Closed Sanian-Creations closed 3 years ago

Sanian-Creations commented 3 years ago

Switching off the setting "occupies land" will hide that unit from showing up in any search done with GetUnitsInRange.

Reproduce

On one hand it makes sense that it doesn't detect units with the setting turned off because they don't take up any space, but this is a real thorn in the eye when trying to work with units that either fly, dig in the ground or just move over the ground without preventing the player from building there, those units mustn't occupy land but we still want to check whenever they get in range of something.

knucracker commented 3 years ago

Yeah, that's basically how this API works at its core. It searches the "map footprint" array for units. So this API (as is) will have to stay.

An alternate might be GetUnitsByType and then to do a range check. That's have some things work internally (like snipers shooting at blobs or skimmers).

I could add a new API that searches all units, but the efficiency of that could be problematic. It would O(n) where n is the number of units on a map which can be in the hundreds or even a thousand. The current API only has to search nearby array cells to see if they have unit footprints in them.

Of course if the entire map is being searched, the current API is terrible when it comes to efficiency... So maybe another API that looks across all units would be warranted. Or an API that looks across all units of a certain type (like GetUnitsByType) but it also has filter options (like range, etc).

knucracker commented 3 years ago

Added a new GetUnits API.