Your way sounds interesting but would require nearly every widget to be fixed. My proposal requires that virtually no widget and a small select few gadgets be changed.SpliFF wrote:Alright I understand the issue now. Supcom does this using a "blip" class for radar objects. This is also important for correctly implementing false or incomplete radar returns like seismic ping and spoofing.
A blip should have the following exposed (widgets and ai) properties:
So I'll restate my outline now that there's been some discussion:
Each allyteam has a local set of unit IDs. Every unit that enters radar range of an allyteam is for all intents and purposes a new unit given an incremented unique ID.
Nearly all widgets can remain unchanged. Widget callins and get-functions provide these local unit IDs instead of the real ones. Set-functions inside widgets take the local IDs as parameters and the engine will convert it to the real unit ID.
Gadgets that receive luarules messages from widgets where they expect a unitID will need to use a conversion function: GetRealUnitID(playerID, localUnitID) -> unitID. This is a quick and easy fix.
Have a modrule flag useLocalUnitIDs = true to apply the new rule so that existing gadgets won't break and give the modder time to convert them.
Some rare widgets might involve sending a unit ID from one player to another when they are on different ally teams. I don't know how to solve this case but I also don't know of any such widgets.
If a widget sends a unit ID and the receiving player is a spec, the widget should have access to the above gadget conversion function when used by a spec. These widgets would need quick modification. The only example I can think of is my widget SelectionSend.