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



All times are UTC + 1 hour


Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: 14 Dec 2010, 11:30 
AI Coder

Joined: 17 Mar 2008, 19:03
Location: RF
Current algo is:
Code:
      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.


Top
 Offline Profile  
 
PostPosted: 14 Dec 2010, 12:29 
AI Coder

Joined: 17 Mar 2008, 19:03
Location: RF
Hm, i noticed all fbi files of anti-air units in BA have tags like these:
Code:
  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.


Top
 Offline Profile  
 
PostPosted: 14 Dec 2010, 13:22 
Evolution RTS Developer
User avatar

Joined: 17 Nov 2005, 02:43
Location: Raegquitting Spring on 04/24/12
Dunno if you can do it this way, but you could check the target categories of the weapons for "VTOL". *Shrug*


Top
 Offline Profile  
 
PostPosted: 14 Dec 2010, 13:56 
AI Coder

Joined: 17 Mar 2008, 19:03
Location: RF
No, i can't: 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:
   unit->realLosRadius=(int) (ud->losRadius/(SQUARE_SIZE*2));
   unit->realAirLosRadius=(int) (ud->airLosRadius/(SQUARE_SIZE*4));


EDIT2
Actually more complicated :/
Code:
   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));
   }


Top
 Offline Profile  
 
PostPosted: 14 Dec 2010, 15:35 
AI Coder

Joined: 17 Mar 2008, 19:03
Location: RF
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?


Top
 Offline Profile  
 
PostPosted: 14 Dec 2010, 15:40 
Spring Developer

Joined: 08 Oct 2006, 15:58
modInfo(.lua) | modRules(.tdf)


Top
 Offline Profile  
 
PostPosted: 14 Dec 2010, 15:54 
AI Coder

Joined: 17 Mar 2008, 19:03
Location: RF
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.


Top
 Offline Profile  
 
PostPosted: 15 Dec 2010, 00:57 
User avatar

Joined: 28 Jul 2008, 05:51
Location: Australia
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.


Top
 Offline Profile  
 
PostPosted: 22 Dec 2010, 12:15 
AI Coder

Joined: 17 Mar 2008, 19:03
Location: RF
Training is bad for constantly modifying games.

Created mantis request #2264.


Top
 Offline Profile  
 
PostPosted: 23 Dec 2010, 15:38 
User avatar

Joined: 14 Jan 2006, 04:09
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.


Top
 Offline Profile  
 
PostPosted: 23 Dec 2010, 17:30 
AI Coder

Joined: 17 Mar 2008, 19:03
Location: RF
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.


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.