Detecting Missile Launchers

Detecting Missile Launchers

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

Moderators: hoijui, Moderators

Post Reply
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Detecting Missile Launchers

Post by submarine »

correct me if im wrong but this code worked with the older spring versions but now it doesnt recognize retaliators etc. as missile launchers.

any suggestions?

Code: Select all

for(vector<UnitDef::UnitDefWeapon>::const_iterator weapon = unitList[def_id-1]->weapons.begin(); weapon != unitList[def_id-1]->weapons.end(); ++weapon)
{
	if(weapon->def->stockpile)
	return true;
}

return false;
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

WeaponDef has changed without GLOBAL_AI_INTERFACE_VERSION changing. (Wrong indeed)
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Post by submarine »

ok is there anything i can do about it?

or do i have to wait for another update?
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

Use the WeaponDefHandler.h from the current repository.
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Post by submarine »

hmm just the current source code or do i have to build spring on my own then?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

hmm I'm havign the same problem nwo with antimissile installations
User avatar
Rafal99
Posts: 162
Joined: 14 Jan 2006, 04:09

Post by Rafal99 »

Hi
I am writing an AI as well and I just had problem with WeaponDef->onlyTargetCategory which was giving me bad values.
So I downloaded Spring source from the SVN and everything works now.
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Post by submarine »

yeha after downloading the current source its working fine again :)
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

And all is good ehre too, I just wish i ahd an explanation fo the category values like onlyTargetCategory
User avatar
Rafal99
Posts: 162
Joined: 14 Jan 2006, 04:09

Post by Rafal99 »

WeaponDefHandler.cpp wrote:

Code: Select all

weaponDefs[id].onlyTargetCategory=0xffffffff;
if(atoi(sunparser->SGetValueDef("0", weaponname +  \\toairweapon").c_str())){
 weaponDefs[id].onlyTargetCategory=CCategoryHandler::Instance()->GetCategories("VTOL");
 //fix if we sometime call aircrafts otherwise
}
This is the only place where onlyTargetCategory is modified, so it equals 0xffffffff if toairweapon is set to 0, and is different than 0xffffffff if toairweapon is set to 1.
But i agree that some explanations in files like this would be very helpful.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

maybe it's a bitfield, every bit in onlyTargetCategory being a different target category.

E:you guys are lucky, I just checked: it is a bitfield, only the bits are 'dynamically allocated', ie. the first category ever read gets bit 1, the second gets bit 2, etc. (see Sim/Misc/CategoryHandler.{cpp,h}). Unfortunately I don't think it is possible to map category names to bits using the AI interface yet... making the field useless until the AI interface is extended.
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

Zaphod wrote:Use the WeaponDefHandler.h from the current repository.
So now the reload times, salvosizes, aoe etc will work?? bless!
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

def->type gives more information, i had to make NTai manually output the type data of every weapon it could but it seems that it's currently the oynl way to detect Dgun weapons.

the old def->manualfire always returns false even if

Code: Select all

def->type == string("Dgun")
User avatar
Rafal99
Posts: 162
Joined: 14 Jan 2006, 04:09

Post by Rafal99 »

I have just foung a bug in WeaponDefHandler.cpp - line 74.
There is:
sunparser->GetDef(balistic, "0", weaponname + "\\balistic");
It should be:
sunparser->GetDef(balistic, "0", weaponname + "\\ballistic");
Post Reply

Return to “AI”