What's reliable way to detect if unit has antiair weapon?

What's reliable way to detect if unit has antiair weapon?

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

Post Reply
slogic
AI Developer
Posts: 626
Joined: 17 Mar 2008, 19:03

What's reliable way to detect if unit has antiair weapon?

Post by slogic »

Current algo is:

Code: Select all

		if (weapon->def->tracks && !weapon->def->waterweapon 
		&& !weapon->def->stockpile && !weapon->def->canAttackGround)
			return true;
But flak weapons are skipped. I have no access to "toairweapon" tag of weapons.tdf file.

I was thinking about checking ballistic=1 & turret=1 but this is wrong.

Note that i won't parse text resources.
slogic
AI Developer
Posts: 626
Joined: 17 Mar 2008, 19:03

Re: What's reliable way to detect if unit has antiair weapon?

Post by slogic »

Hm, i noticed all fbi files of anti-air units in BA have tags like these:

Code: Select all

  sightDistance=475;
  airSightDistance=900;
So, air sight distance of all anti-air units is 1.5x-2.x higher than usual sight distance. Can be used as additional trigger but also may give false positives.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: What's reliable way to detect if unit has antiair weapon?

Post by Forboding Angel »

Dunno if you can do it this way, but you could check the target categories of the weapons for "VTOL". *Shrug*
slogic
AI Developer
Posts: 626
Joined: 17 Mar 2008, 19:03

Re: What's reliable way to detect if unit has antiair weapon?

Post by slogic »

No, i can't: http://springrts.com/phpbb/viewtopic.php?f=15&t=22988

I just profiled (ud->airLosRadius / ud->losRadius) expression for all registered anti-air units and always get values < 1.0. Very strange. Looks like they are expressed in different items.

EDIT
From some lua widget:

Code: Select all

   unit->realLosRadius=(int) (ud->losRadius/(SQUARE_SIZE*2));
   unit->realAirLosRadius=(int) (ud->airLosRadius/(SQUARE_SIZE*4));
EDIT2
Actually more complicated :/

Code: Select all

	losRadius = udTable.GetFloat("sightDistance", 0.0f) * modInfo.losMul / (SQUARE_SIZE * (1 << modInfo.losMipLevel));
	airLosRadius = udTable.GetFloat("airSightDistance", -1.0f);
	if (airLosRadius == -1.0f) {
		airLosRadius = udTable.GetFloat("sightDistance", 0.0f) * modInfo.airLosMul * 1.5f / (SQUARE_SIZE * (1 << modInfo.airMipLevel));
	} else {
		airLosRadius = airLosRadius * modInfo.airLosMul / (SQUARE_SIZE * (1 << modInfo.airMipLevel));
	}
slogic
AI Developer
Posts: 626
Joined: 17 Mar 2008, 19:03

Re: What's reliable way to detect if unit has antiair weapon?

Post by slogic »

Based on my tests (SQUARE_SIZE * (1 << modInfo.losMipLevel) / modInfo.losMul) = 32. I don't understand where modInfo.losMul & modInfo.losMipLevel are set by game developer? Or are they constants really?
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: What's reliable way to detect if unit has antiair weapon?

Post by Kloot »

modInfo(.lua) | modRules(.tdf)
slogic
AI Developer
Posts: 626
Joined: 17 Mar 2008, 19:03

Re: What's reliable way to detect if unit has antiair weapon?

Post by slogic »

Thanx. Found at mod rules. Also found an outdated information that is was in sensors.tdf files long ago.

Well, i think i'm in a deadlock again like with Spring category tags because modInfo is not accessible via Legacy C++ API.

I see no way to 100% detect anti-air units.
User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

Re: What's reliable way to detect if unit has antiair weapon?

Post by SpliFF »

If you have have any persistence in your AI data you could train that stat by counting total air kills for each unitdef. Then pick a reasonable minimum threshold that avoids those occasional cases where a plane got caught on the ground.
slogic
AI Developer
Posts: 626
Joined: 17 Mar 2008, 19:03

Re: What's reliable way to detect if unit has antiair weapon?

Post by slogic »

Training is bad for constantly modifying games.

Created mantis request #2264.
User avatar
Rafal99
Posts: 162
Joined: 14 Jan 2006, 04:09

Re: What's reliable way to detect if unit has antiair weapon?

Post by Rafal99 »

In my ancient AI code I was detecting AA weapons using weaponDef->onlyTargetCategory.
It was before AI interface rewrite so no idea how the exact code would look like now.
slogic
AI Developer
Posts: 626
Joined: 17 Mar 2008, 19:03

Re: What's reliable way to detect if unit has antiair weapon?

Post by slogic »

I wanna use it too but it is of integer type (not string) & contains flags to which i have no access: they are not static.
Post Reply

Return to “AI”