Quick question

Déja

Beyond the Mod
Joined
Dec 19, 2005
Messages
353
If I were to add a new element to the UnitInfo of a particular unit, would that be available along with all the other data (unit type, bomber range, etc)? Or is it necessary to read the XML manually?
 
Déja said:
If I were to add a new element to the UnitInfo of a particular unit, would that be available along with all the other data (unit type, bomber range, etc)? Or is it necessary to read the XML manually?

Are you trying to add something not defined in the UnitInfo schema? or is it something that is already defined in the schema but not in the actual UnitInfo of a particular unit?

If it isn't something defined in the schema then you will need to modify the schema and then you can add it to the UnitInfo of a particular unit and look it up using the CvUnitInfo or PyInfo classes for instance.

I think I answered your question ...
 
yeah, that's pretty much what I'm looking for... I want to add an <iMaxAmmo> element to the UnitInfo
 
Lord Olleus said:
noone has yet managed to scusesfuly mod a schema file. I am quite sure that you need to modify the game engine to tell it what <imaxammo> actualy means.


Thanks for the challenge Lord Olleus. Now I am going to have to leave work as soon as I can to be the first one to do so...

:D
 
Lord Olleus said:
you might a well start learning C++ now then.

I already know C++, but I really haven't used those skills since my Q2 modding days, my claim to fame there is/was the Q2 mod WoD:LoX - better known as Lethal Orifice eXamination, lol. Those were fun times, but I digress ...

I am a software architect by trade, but I love to tinker with game internals.
 
Déja said:
yeah, that's pretty much what I'm looking for... I want to add an <iMaxAmmo> element to the UnitInfo

Ok Déja, I'm home now, I'll see what I can do regarding your question. If I get something worked out I'll let you know.
 
TheLopez said:
Ok Déja, I'm home now, I'll see what I can do regarding your question. If I get something worked out I'll let you know.

Déja, here's the good news, I was able to modify the UnitInfoSchema file, add the <iMaxAmmo>100</iMaxAmmo> to a unit and have it load up in my game without any issues.

What I wasn't able to figure out right now was how to read the value using the Python API. I'll look into it some more tomorrow as I am a bit burnt out and are trying to put the final touches on my new mod.

TheLopez
 
I did this to add a race attribute to all of my units. Modifying schema isn't hard, adding the attribute in xml isn't hard, the hard part is that none of the code will recognize the new attribute.

The mods that come with the game use defines to set this sort of information. The following is from the desertwar mod:

Code:
forbiddenUnitList =	[	iCrusader,
				iMatilda,
				iTransport,
				iDestroyer,
				iBattleship,
				iSubmarine,
				iCarrier	]

You could use something similiar to set some ammo numbers for your units and then refer to your array to pull the numbers. I am NOT a programmer so I would create 2 of these, one with the unit names and another with the iMaxAmmo numbers. Then I would search the first array for the name, and when it finds the number I would pull the same offset in the second array to get the iMaxAmmo number. There has got to be a better way than that, but as I said I am just learning this stuff.
 
actually, it'd be better to use a tuple so it would look like this:

ammoList = [ (unitname, maxammo), (unitname, maxammo) ]
 
Déja said:
actually, it'd be better to use a tuple so it would look like this:

ammoList = [ (unitname, maxammo), (unitname, maxammo) ]

See, real programming. :D
 
I have been in love with python for more than five years
 
Back
Top Bottom