Page 1 of 1
Detecting Missile Launchers
Posted: 04 May 2006, 09:06
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;
Posted: 04 May 2006, 12:47
by jcnossen
WeaponDef has changed without GLOBAL_AI_INTERFACE_VERSION changing. (Wrong indeed)
Posted: 04 May 2006, 16:52
by submarine
ok is there anything i can do about it?
or do i have to wait for another update?
Posted: 04 May 2006, 18:52
by jcnossen
Use the WeaponDefHandler.h from the current repository.
Posted: 04 May 2006, 19:11
by submarine
hmm just the current source code or do i have to build spring on my own then?
Posted: 04 May 2006, 20:14
by AF
hmm I'm havign the same problem nwo with antimissile installations
Posted: 04 May 2006, 23:13
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.
Posted: 05 May 2006, 00:24
by submarine
yeha after downloading the current source its working fine again :)
Posted: 05 May 2006, 14:05
by AF
And all is good ehre too, I just wish i ahd an explanation fo the category values like onlyTargetCategory
Posted: 05 May 2006, 16:23
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.
Posted: 06 May 2006, 10:15
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.
Posted: 06 May 2006, 12:41
by krogothe
Zaphod wrote:Use the WeaponDefHandler.h from the current repository.
So now the reload times, salvosizes, aoe etc will work?? bless!
Posted: 07 May 2006, 17:24
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
Posted: 10 May 2006, 15:23
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");