Shooting
A turret shoots well enough on its own. Logic is for when it matters who exactly it shoots
Without logic a turret picks its target itself: the nearest one in range. Logic steps in when that choice will not do — when one enemy has to be finished off instead of spreading fire, or when the more dangerous one has to be hit.
Press “run”. The duo turns east and starts firing at the point 13 4, where a dagger stands:
ammo goes down, and so does the dagger’s health.
control shoot turret x y shoot
Section titled “control shoot turret x y shoot”| Field | What is in it |
|---|---|
| first | the turret |
| second and third | a point in map tiles, not in world units |
| fourth | shoot or only aim: zero means turn silently |
The coordinates are the same as any block’s @x and @y, so aiming at a building is just
taking its coordinates and handing them to the turret.
The order lasts two seconds
Section titled “The order lasts two seconds”A turret obeys logic for 120 ticks after the last command, then returns to its own aim and starts choosing targets by itself again.
Shooting a unit: control shootp
Section titled “Shooting a unit: control shootp”Here the target is found by a radar, and shootp aims the turret with lead: it fires not
where the unit is now but where it will be when the bullet arrives.
radar enemy any any distance duo1 1 aimcontrol shootp duo1 aim 1| Field | What is in it |
|---|---|
| first | the turret |
| second | a unit, not coordinates |
| third | shoot or only aim |
The lead is worked out by the game, from the target’s speed and the bullet’s. So a duo leads a flying flare and puts its shot straight into a standing dagger.
What a turret will tell you about itself
Section titled “What a turret will tell you about itself”| Property | What it gives |
|---|---|
@shooting |
whether it is firing right now |
@ammo |
how many units of ammunition are left |
@ammoCapacity |
how many fit |
@currentAmmoType |
the item it is loaded with: @copper, @graphite |
@progress |
how ready the next shot is, from 0 to 1 |
@rotation |
where the barrel points |
@shootX, @shootY |
where it is aiming |
Ammo is counted not in items but in units of ammunition: one lump of copper gives two,
graphite four. So a full duo’s @ammo is 30 while it holds fifteen items of copper.
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.