Using the sunparser with virtual files

Using the sunparser with virtual files

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

Moderators: hoijui, Moderators

Post Reply
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Using the sunparser with virtual files

Post by krogothe »

To get unit information is easy enough, open a virtualfile "units\\ud->name", now how do i get weapon information? some mods have a weapons.tdf, some have all sorts of weird names, so its not straightforward as with units since i dont know where the information is held unless i look and type it in the code myself, which is very impractical.

How do i load a unit's weapon up in sunparser to get its stats?
User avatar
Nemo
Spring 1944 Developer
Posts: 1376
Joined: 30 Jan 2005, 19:44

Post by Nemo »

Well..I don't know much about the technical part of it, but I know that the filenames of the .tdf files don't matter in the slightest - Spring just loads all the weapons in the weapons folder regardless of what the name of the file the actual stats are in. Hence why some mods have 20mm.tdf, US_M2Browning.tdf, or GER_MG42.tdf, while others just have weapons.tdf, and all of them are in that single .tdf file.

The .tdf files are all just in plaintext, if that helps any.

Sorry I can't be any more specific, I'm very much on the code-ignorant end of things.
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

The unit's UnitDef has a list of WeaponDef's, which define the weapon (and contains all info about it). It would also be inefficient to let spring parse the files and then have the AI parse the same file again.
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

Zaphod wrote:The unit's UnitDef has a list of WeaponDef's, which define the weapon (and contains all info about it). It would also be inefficient to let spring parse the files and then have the AI parse the same file again.
Yes, im well aware of that, but unfortunately def->reload returns zero and def->salvosize returns something like 13 billion(unless its a real burst weapon, then sometimes it works), for every weapon for every unit for every mod and it seems to have been broken recently since it used to work a few versions ago!

What syntax should i use then to load the weapons? I need to specify a filename, which works for units, now if all weapons are in one file then i need to know its name, and this doesnt work:

Code: Select all

		ai->parser->LoadVirtualFile("weapons\");
		ai->parser->GetDef(testint1, "-1", "LIGHTLASER\\DAMAGE\\default");
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

err, you'd need to have a way of getting a list of files in that folder.


Eitherway I think aprsing the weapons file directly is better because nobody has documented the unitweapondef structure and it's full of thgins like categories that hold int values repesenting thgins and we arent given a key/index/list of what representss what etc, unlike the Comand structure where everything is self explanatory and even has comments....

For example does the weapon only target certain categories, is it air only?
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

Any updates on this? Any way to get weapon information reliably will help, the mod balancing groupAI is done and just waiting on that key component to bring joy and happiness to all modders and players alike!
If nothing else works, ill convince them all to stick all weapons in a weapons.tdf and then release it.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

looks like you'll have to go into the weapons laoder class in spring and see what went wrong and send a patch/diff to the mailing list
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

indeed, ive been looking around for a while now...

how do i send stuff to the mailing list? i dont even know where it is, and wouldnt it be better to create an svn patch and e-mail it?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

erm diff's are easier for them to use apparently.

mailing list:
http://lolut.utbm.info/cgi-bin/mailman/ ... ring-linux
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

I had a look through the source, it seems fine to me, spring seems to use both reload and reloadtime, but even if it chose the wrong one, the default vallue would still be 1 provided the sunparser is working. I havent a clue yet why this is happening.
Post Reply

Return to “AI”