Damaged buildings and checking the find
The fourth kind of search looks for what needs repairing. And on the way, why the answer sometimes sticks
ulocate damaged core true @copper damagedX damagedY found damagedThere are two duos on the map, and one of them is damaged: it has 60 health out of 250.
That is the one the search finds — its intact neighbour does not count.
damaged looks only at your own buildings: it does not use the “flag” and “is it theirs”
fields at all. It finds the building nearest the unit whose health is below its maximum.
That is exactly what a repairer needs:
ubind @polyulocate damaged core true @copper x y found aimjump 0 equal found 0ucontrol approach x y 4 0 0The poly flies up to the damaged building, and repairs it by itself in the game: repairing is its own business and needs no order. All the program has to do is bring it to the work.
“Found” is always checked
Section titled ““Found” is always checked”That is a general rule for all four kinds of search, not a quirk of damaged.
The answer does not refresh every iteration
Section titled “The answer does not refresh every iteration”ulocate, like uradar, recomputes its find once every 40 ticks, and in between gives
back the previous answer. The reason is simple: walking the whole map is expensive, and
a program spins several hundred times a second.
A couple of habits follow from that:
- do not try to “refresh” a search by repeating the instruction several times in a row: the answer will be the same;
- do not be surprised that a repaired building counts as damaged for another two thirds of a second.
The fourth kind: spawn
Section titled “The fourth kind: spawn”ulocate has a fourth kind of search — spawn, the point where enemy waves appear. It works
the same way: coordinates plus “found”, with no building.
Unofficial fan project, not affiliated with Anuke. Mindustry sprites, fonts and translations © Anuke, used under GPL-3.0; Fira Code under OFL-1.1. Site code is GPL-3.0.