Ticket #1511 (closed defect: fixed)
Workers will start building field foundations when the building they worked on is built
| Reported by: | wraitii | Owned by: | Deiz |
|---|---|---|---|
| Priority: | Should Have | Milestone: | Alpha 11 |
| Component: | UI & Simulation | Keywords: | unitAI field farm building |
| Cc: |
Description
Builders, when they become idle, will switch to any nearby foundation and start building it. While this is the intended behavior, it has the unfortunate side-effect of also working with farms: a builder may see an unbuilt farm and go build it... Turning him into a farmer when the farm is finished.
I find it inconvenient: one usually wants to return the builders to their original task/something else and one may "lose" units from sight.
I suggest changing the UnitAI behavior to only work with all nearby non-field foundations.
Attachments
Change History
comment:2 Changed 12 months ago by picobyte
I thought, maybe in ResourceGatherer.prototype.GetTargetGatherRate
binaries/data/mods/public/simulation/components/ResourceGatherer.js 325
we could do something like this:
var rates = this.GetGatherRates(); + if (type.generic == "food" && type.specific == "grain" && rates.length) // only one can farm + return 0;
but this doesn't seem to change the farming behavior yet. without the rates.length it does stop all of them
comment:3 Changed 12 months ago by wraitii
Well, I think the case here is "auto-order at a dropsite". In that case, the unit can help build the building, but should not start gathering. If it's player order, start gathering (unless, like right now, there are other orders after that).
comment:4 Changed 12 months ago by picobyte
This appears to work, I haven't run tested it thoroughly though.
Changed 12 months ago by picobyte
- Attachment harvest_on_cmd.patch added
Harvest only when unit initiated the building

Dropsites are the same way, when a builder finishes a dropsite, they will start gathering the nearest supported resource, unless the order was a queued build order. I can see this being unintended behavior in the same sense.
The cases to think about are: queued vs. non-queued orders, dropsite/field vs. other building, player order vs. auto order, and initial vs. final target. It would be easy to fix one and break another.