Ticket #1387 (closed enhancement: fixed)
[PATCH] Limit gatherers per resource
| Reported by: | historic_bruno | Owned by: | wraitii |
|---|---|---|---|
| Priority: | Should Have | Milestone: | Alpha 13 |
| Component: | UI & Simulation | Keywords: | patch review |
| Cc: |
Description
Currently you can order a ridiculous number of units to gather from a single resource. We need to enforce some sensible limits, whether it be farms, trees, or mines. It should be added as a new element to the ResourceSupply component. Units can be tasked to gather normally, but when reaching the target, a check is performed on the number of current gatherers. The "extra" units can move on to a similar nearby resource or go idle (or we can add some kind of queue system where units wait for a slot to open, without constantly using the pathfinder).
Attachments
Change History
comment:2 Changed 3 months ago by crezax
Attached diff, that allows limiting amount of workers per resource supply.
Tested following scenarios (with limit of 5 workers per field):
- built 2 fields, sent 6 workers to work in one field. One moved to the 2nd field and worked there
- built 1 field, sent 6 workers to work there. One worker went back to base and stood there idle
Now, the problem is - resource supply templates won't load, unless max number of workers is specified, so I guess there should be some discussion about these limits per each resource and it should be added to diff.
comment:3 Changed 3 months ago by crezax
- Summary changed from Limit gatherers per resource to [PATCH] Limit gatherers per resource
comment:6 Changed 2 months ago by wraitii
Thanks or the patch crezax. It seemed to work (pretty good for a beginner :) ), but I think this behaviour should be handled more by UnitAI than by passively recounting now and then in ResourceSupply?. Using you patch as a framework I've uploaded a new one.
Units will try to find a new nearby resource if there is one, and if none, they will return to the nearest dropsite. The information about gatherers is broadcast as a message for AIs (and I have updated qBot and Aegis to use them), and "Display Selection State" has been updated too. I have changed all basic templates to have a minimal number of gatherers, the numbers are basically based on "how many units approximately can go around said resource", feel free to discuss.
I have failed to have it bug (then again it took me a good 3 hours to get it to work. Thank god for the JS debugger), but I'd recommend to try it out anyway.
Two issues remaining: should a notification be sent? Formations also begin by walking towards the resource and then only break if there is not enough space. This could be annoying, particularly for treasures (which currently can only be gathered by 1 unit).
comment:7 follow-up: ↓ 8 Changed 2 months ago by crezax
Good to know it wasn't that bad wraitii :) BTW, you mentioned JS debugger, when I tried debugging my code, I tried using http://trac.wildfiregames.com/wiki/JavascriptDebugging but I can't see 0ad/source/tools/jsdebugger/ directory in repository. Tried looking for index.html, jsdebugger etc without any luck. Is there something I'm missing, or is that tutorial outdated? I could really use having working JS debugger for future :)
comment:8 in reply to: ↑ 7 Changed 2 months ago by zoot
Replying to crezax:
Good to know it wasn't that bad wraitii :) BTW, you mentioned JS debugger, when I tried debugging my code, I tried using http://trac.wildfiregames.com/wiki/JavascriptDebugging but I can't see 0ad/source/tools/jsdebugger/ directory in repository. Tried looking for index.html, jsdebugger etc without any luck. Is there something I'm missing, or is that tutorial outdated? I could really use having working JS debugger for future :)
Are you using the latest version from SVN/GitHub? It should be in there: https://github.com/0ad/0ad/tree/master/source/tools/jsdebugger
comment:9 Changed 2 months ago by crezax
ok thanks :) somehow that directory wasn't there when I checked out SVN repository
comment:10 Changed 2 months ago by wraitii
- Owner set to wraitii
- Status changed from new to closed
- Resolution set to fixed
In 13277:
comment:11 Changed 2 months ago by wraitii
In 13288:

Hey, I thought I could try doing this.
I have a small question though. Is there any way to check what a given entity is doing at the moment? Or at least check, if it's collecting suplies?
EDIT: nvm, found UnitAI.js