Page 1 of 1

Help with UnitDefs Weapons

Posted: 22 Oct 2007, 16:03
by very_bad_soldier
Hi all,

I'm trying to figure out if a unit is able to shoot at air or if it does not. For this reason I tried to read the units' onlyTargets-category "notair" to do that.
So I hoped the boolean value would be different for example for the armanni and for the armflak.

Below is the code I use:

Code: Select all

local udef = UnitDefs[Spring.GetUnitDefID(unitID)]
local targetCat = udef.weapons[1].onlyTargets;

local tcat = "true"
if ( targetCat["notair"] == false ) then
  tcat = "false"
end
	    
Spring.Echo( udef.humanName .. " NotAir: " .. tcat )
The problem is that in both cases (armanni and armfalk) the value is true and I expected them to be different since the flak shoots at air while the anni does not.
Could anyone tell me plz what I am doing wrong? Many thanks in advance...

Posted: 22 Oct 2007, 17:02
by jK
There are multiple ways to define if an unit should only attacks air. Also there is a lot of anti air that attacks primarily air, but can still attack ground (see XTA,CA,...).

But if you only want to find units that do the first, you have first to check their UnitDef as you do and if you don't find it there you have to check its WeaponDefs. So you can set a toAirWeapon in the weapon's tdf. Btw there isn't a toAirWeapon tag in the WeaponDef, instead it writes into the onlyTarget category (the one in the WeaponDef!).

Posted: 22 Oct 2007, 17:14
by KDR_11k
toAirWeapon also prevents the unit from shooting at ground. It uses the VTOL category, BTW.

Posted: 06 Nov 2007, 17:41
by Argh
What about games that don't use the VTOL category, then?

Posted: 06 Nov 2007, 17:54
by jK
with the new luaDefs (svn) you will be able to create your own tags like toGround, toWater, toUnderwater, toAir etc. and you will be able to map them to your own categories.

Posted: 06 Nov 2007, 17:54
by KDR_11k
Then you're fucked.

Posted: 06 Nov 2007, 17:56
by tombom
KDR_11k wrote:Then you're fucked.
I prefer this answer.