Page 1 of 1
Capping assistance
Posted: 09 Apr 2014, 17:26
by Jools
Is it somehow possible to cap the number of units that can assist the building of stuff? I guess it can be handled by gadget, but what would be the best practise? There are lot's of things being built and handling them outside the object is silly. The property of "being assisted" should be an object property. handling it in a global gadget is silly imo...
Re: Capping assistance
Posted: 09 Apr 2014, 17:31
by smoth
why is handling it via a gadget silly?
Re: Capping assistance
Posted: 09 Apr 2014, 17:34
by Jools
Because the propoerty of being assisted belongs to the unit in question and not to the gadget. It should be OO. But maybe it becomes OO if one stores the property in UnitRulesParams. Maybe I'm just writing to clear my thoughts :)
Re: Capping assistance
Posted: 09 Apr 2014, 17:41
by smoth
Jools wrote:Because the propoerty of being assisted belongs to the unit in question and not to the gadget. It should be OO. But maybe it becomes OO if one stores the property in UnitRulesParams. Maybe I'm just writing to clear my thoughts :)
I am not sure what OO has to do with it.
The unit in question could have the thing as a tag in customparams.
Why should the engine enforce that property? A gadget utilizing rules param could reasonably handle it.
Re: Capping assistance
Posted: 09 Apr 2014, 17:46
by Jools
I'm not saying that the engine necessarily should enforce it. I was asking about best practise.
It's OO because the unit is an object and the gadget is not.
Re: Capping assistance
Posted: 09 Apr 2014, 17:48
by smoth
that isn't OO.
I would do it in a gadget but then again, I am with the camp we should move as much as we can to gadgets so it is more flexible.
Re: Capping assistance
Posted: 09 Apr 2014, 17:57
by Jools
It needs then some kind of a callin that tells when an unit begins assisting another, and also conversely when the assisting stops. There is atm addon.UnitCommand, but there is no notification from that when it is cancelled, and also this is called when the order is given and not when assistance begins.
There is addon.UnitCmdDone, which is called when a project has been completed. But I don't think too catches abandoned commands.
Re: Capping assistance
Posted: 09 Apr 2014, 17:59
by FLOZi
Checking in AllowCommand should be feasible
Re: Capping assistance
Posted: 09 Apr 2014, 18:05
by Jools
You can have units on the other side of the map given assist order. They should all receive the order, but only the first n number that reaches the construction site should be allowed to actually assist. How to check that? Units can also be moving and assisting. Would be easier to have a buildbegins callin or something.
Re: Capping assistance
Posted: 09 Apr 2014, 18:10
by FLOZi
Jools wrote:You can have units on the other side of the map given assist order. They should all receive the order, but only the first n number that reaches the construction site should be allowed to actually assist. How to check that? Units can also be moving and assisting. Would be easier to have a buildbegins callin or something.
Catch StartBuilding in unitscript and communicate back.

Re: Capping assistance
Posted: 09 Apr 2014, 18:43
by Jools
Re: Capping assistance
Posted: 09 Apr 2014, 18:51
by knorke
ugly but could work:
Get the buildprogress every second.
If the nanoframe is being built too fast, then set its progress to the maximum allowed growth per second. Give the extra resources back to team.
Periodically check if too many cons are trying to build and send them away. That can be a slow check since the actual limit is via tracking the buildprogress.

Also not for XTA please

Re: Capping assistance
Posted: 09 Apr 2014, 18:57
by FLOZi
Re: Capping assistance
Posted: 09 Apr 2014, 19:03
by Jools
Oh, yeah, of course. Thank you!
I knew I had seen that callin somewhere, and it was in the unit script. How bad would it be to send the event to lua from an unitscript that is in cob? Better than buildprogress I think? It still says using GET variables is about 100 times faster...
Re: Capping assistance
Posted: 11 Apr 2014, 15:39
by Google_Frog
You can also use AllowUnitBuildStep if the script callins do not work for your purpose. Try the script first because AllowUnitBuildStep would be more resource intensive.
Re: Capping assistance
Posted: 11 Apr 2014, 16:46
by CarRepairer
I already made a gadget that limits assisting units to 5. See Supreme Annihilation. It was long ago though.
Re: Capping assistance
Posted: 11 Apr 2014, 16:56
by Jools
Yes, but this gets very complicated. Especially ince if it has to be a modoption, you have to communicate from lua to cob if the option is on/off.
Where did you handle the checking of allow condition? In AllowBuildStep?
Because if you do it in AllowCommand then what happens if 10 guys are assisting something and one dies? The extra one should be allowed to assist then. Bleh. It would be a nice modoption but not if it gets too taxing...