gaia units that waddle around on the map.
The problem is, if you issue an area-attack command the ducks will be targeted along with enemy units.
This is potentially very annoying.
Features have autoReclaimable=false so that area-commands will ignore them. Sadly for units there is no autoAttackable=false.
For each targeted unit AllowCommand() is called with CMD.ATTACK so can easily filter the ducks like this:
Code: Select all
function gadget:AllowCommand(unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions, cmdTag, synced)
Spring.Echo (CMD[cmdID] or "nil")
if cmdID and cmdID == CMD.ATTACK then
if cmdParams and #cmdParams == 1 then
Spring.Echo ("target is unit" .. cmdParams[1] .. " #cmdParams=" .. #cmdParams)
if critterUnits[cmdParams[1]] then Spring.Echo ("target is a critter and ignored!") return false end
end
end
return true
end

Now there is the problem that ducks might block your attack commands. Say you want to fire a nuke, accidently click on a duck - and the nuke does not fire. Outrageous!
Sometimes you might want to attack _single_ ducks, if they block your units.
So how to detect if is a attack-unit or area-attack command?
Or does it need sillyness like "count attack-commands of each unit per frame"
tl;dr
certain units should only be targetable indviually but be ignored by area-attack