Quick XML unit question

phungus420

Deity
Joined
Mar 1, 2003
Messages
6,296
I apologize for the unspecific thread title, but couldn't figure out a more descriptive title that wouldn't be too long. To start with, I was rather surprised how simple it is to add in a new unitcombat type. All you need is a button and a single reference. Way easier then adding new units for sure.

My first question is, what do I need to do to create a new specialunittype Currently there are SpecialUnit_Fighter, and SpecialUntit_People, I'd also like to add a SpecialUnit_Infantry. There are no specialunit buttons, and I have no idea if there are any other references to them. Can I add a new special unit type via XML (I'm assuming so), and if so what files would I need to add references to the new created type (if any)?

Second question. How can I reduce the ammount of damage done by an air unit to ground units, but keep it so the air unit is still strong in air combat value? For an air unit let's say you have something like this:

<iCombat>0</iCombat>
<iCombatLimit>0</iCombatLimit>
<iAirCombat>10</iAirCombat>
<iAirCombatLimit>50</iAirCombatLimit>
<iXPValueAttack>4</iXPValueAttack>
<iXPValueDefense>4</iXPValueDefense>

I'm not seeing here anything I can adjust to make the fighter type aircraft stay strong in air combat, but reduce it's value in striking ground targets. Is this possible in XML? If so what do I need to change.

Thanks to anyone that can help me.
 
1. You can add a new special unit into CIV4SpecialUnitInfos in the Units folder.

2. :dunno:
 
Not sure on the air units but you may want to test these tags:

<iCollateralDamage>
<iCollateralDamageLimit>
<iCollateralDamageMaxUnits>
 
I actually know what these tags do:

<iCollateralDamage> -Ammount of damage done to other units by collateral damage. Alot of units start with Zero here (tank) and thus don't do collateral damage until recieving the apropriate promotion
<iCollateralDamageLimit> The max damage that can be done to units via collateral damage. Expressed in %
<iCollateralDamageMaxUnits>The ammount of units affected by collateral damage.

I've figured out a way to do it with the <domainmods> tag. Just set the fighter unitclass to have a + modification to Domain_Air in this tag. And for bombers, + values on ground and sea domains. Testing has shown this to be effective. I could also use the <unitcombatmods> tag, but domain is easier and more appropriate for what I'm doing.

I'll have to check out the CIV4SpecialUnitInfos file. Is this file the only reference to specialunittypes I need to work with to add new special unit types?
 
OK, checked out the specialunitinfos file. This file leads me to ask a new question :lol:
<CarrierUnitAIs>
<CarrierUnitAI>
<UnitAIType>UNITAI_MISSILE_CARRIER_SEA</UnitAIType>
<bUnitAI>1</bUnitAI>
</CarrierUnitAI>
</CarrierUnitAIs>

OK, this CarrierUnitAIs tag. Let's say I create my own special unit type. Let's call this SPECIALUNIT_INFANTRY Now if I define infantry units they will remain loadable in regular transports with these tags like so:
<bValid>1</bValid>
<bCityLoad>0</bCityLoad>

If not, someone please tell me what I'd need to do to make them loadable in regular transports.

Now the difficult question. Could I just create my own Unit AI tag, such as UNITAI_INFANTRY_CARRIER_SEA and the AI would understand, or would I need to teach myself C++ (not going to happen, but I'd like to know) and deal with the AI code itself. If the answer is that I'd need to delve into the AI code itself (not going to happen) are there any workarounds? Or is this idea dead in the water. Pretty much I'm limited to XML, or standard text edits when it comes to modding. And I'd like to know if I've hit a brick wall here with regards to Special unit types.
 
Finished doing a thourough search of the forums. And I couldn't find any leads to help me with the UnitAI_Carrier tags.

Mainly my question is will the AI be able to utilize new specialunit types without a proper UnitAI_Carrier tag in the specialunitinfos file? Will creating a tag such as:

<CarrierUnitAIs>
<CarrierUnitAI>
<UnitAIType>UNITAI_INFANTRY_CARRIER_LAND</UnitAIType>
<bUnitAI>1</bUnitAI>
</CarrierUnitAI>
</CarrierUnitAIs>

Be understood by the AI, or would the AI understand a new specialunit type without a created tag? Would the AI understand a new specialunit type without an UnitAI_Carrier tag, or with a preexisting one? In regards to creating a tag, it seems like just typing in a line like this in the file would result in XML errors, as I doubt the AI can parse concepts like this, but I do not know.

Does anyone know?

Even a response from someone that's messed with stuff like this would be helpful. Meanwhile I'll start to test some stuff, and see what happens. But if anyone could save me some time with a "Yes that'll work" or a "Nope, tried that, and it fails" It'd be very nice.

Edit:
Did some testing. You can't just make up a logical syntax CarrierUnitAI. It doesn't cause a serious error, no crash at least (you do get an invalid XML notification, but the involved unit works as though there was no invalid UnitAI reference). The AI doesn't seem to understand Land transports. At least I haven't seen them use the function.

Going to start a new thread about this, since this thread title is no longer appropriate.
 
Back
Top Bottom