Disable experience for certain units

ugh2460

Chieftain
Joined
Jan 7, 2014
Messages
9
Location
Freedonia
I'm trying to create units that cannot gain experience, but in order to do that, I'm probably going to have to code it into the game. And to do that, I'm either going to have to learn Python and C++ in an amount of time that I wouldn't start questioning whether it's worth the trouble to mod this or not, or ask you programming wizards here at CivFanatics how to do it.

I think it's gonna be the latter, so do you think you can help me how to do this? If so, then please be very specific. I only have experience in editing numbers in XML... :p
 
You could easily set iXPValueAttack and iXPValueDefense to 0 in CIV4UnitInfos.xml. Your unit would still receive XP from e.g. Barracks, Theocracy and Great Generals then.

There might also be a proper solution using XML: Define an additional UnitCombatType in CIV4UnitCombatInfos.xml, e.g. "UNITCOMBAT_NO_XP" (and a matching TXT_KEY in CIV4GameTextInfos_Objects.xml). No promotions would be associated in CIV4PromotionInfos.xml, so the game should recognize units of that type as unpromotable and assign no XP to them. To make a unit unpromotable, set it to <Combat>UNITCOMBAT_NO_XP</Combat> in CIV4UnitInfos.xml. (Just setting <Combat>NONE</Combat> without the previous steps would also make a unit unpromotable, but has undesired side-effects because the game treats such units as noncombatants.)

I'd better wait a little if someone has a simpler solution before trying this.
 
I went ahead and tried it. Essentially works. Artifacts:
(a) I've added a no-XP duplicate for each UnitCombatType. The duplicates show up in the Civilopedia under "Unit categories".
(b) Having no applicable promotions doesn't prevent units from receiving XP in combat. The collected XP is visible when a unit is selected, but the unit can't be promoted (it doesn't glow blue either). Setting the iXPValues to 0 didn't help; units get at least 1 XP per combat regardless of those values.
This is easy to fix in the DLL, but maybe not worth having a custom DLL for.

I'm attaching what I have so far: The two modified XML files. I've set Warriors to non-promotable in CIV4UnitInfos.xml.
 

Attachments

I went ahead and tried it. Essentially works. Artifacts:
(a) I've added a no-XP duplicate for each UnitCombatType. The duplicates show up in the Civilopedia under "Unit categories".
(b) Having no applicable promotions doesn't prevent units from receiving XP in combat. The collected XP is visible when a unit is selected, but the unit can't be promoted (it doesn't glow blue either). Setting the iXPValues to 0 didn't help; units get at least 1 XP per combat regardless of those values.
This is easy to fix in the DLL, but maybe not worth having a custom DLL for.

I'm attaching what I have so far: The two modified XML files. I've set Warriors to non-promotable in CIV4UnitInfos.xml.

I guess all I wanted was to disable certain units from being able to get promotions, and that's what your simple modification did. Thank you!
 
Note that changing the combat classes of units will prevent the existing modifiers from working against them.

For example, an axeman gets +50% vs. melee units, but a spearman who's combat type has been changed is not a melee unit so an axeman won't get the bonus when fighting that unit.

The fix to this is to go through all the units that get bonuses vs. combat classes and give them bonuses vs. the new combat classes too. Then go through the promotions (Shock and such) and do the same.

This fix will fix the modifiers, but it will also make the new modifiers show up in the civilopedia and the unit mouseover help text, cluttering things up.

So it is more work than it seems, and has a probably somewhat undesirable side-effect. But it requires no DLL changes. Adding a new "bNoXP" flag (or whatever) to the unit info XML with the necessary changes to the DLL to read it and get it to work is cleaner but more complicated, especially if you are not set up to build the DLL already, and it gets much worse than that if you don't know C++.
 
How'd I miss that? :o

For non-promotable archery units, XML may still be acceptable (few combat bonuses against those), but duplicate help text on Axemen sounds bad. Python? (Not my forte ... not that XML changes are.)
 
So it is more work than it seems, and has a probably somewhat undesirable side-effect. But it requires no DLL changes. Adding a new "bNoXP" flag (or whatever) to the unit info XML with the necessary changes to the DLL to read it and get it to work is cleaner but more complicated, especially if you are not set up to build the DLL already, and it gets much worse than that if you don't know C++.

Of course, it's possible to add a special "bNoXP" flag but when a unit gains XP? Or on the attack, or on the defense.

Thus, we can change to ZERO both values

iXPValueAttack - the value, in Experience Points, that this unit is worth on the attack.
iXPValueDefense - the value, in Experience Points, that this unit is worth on the defense.

Code:
<iXPValueAttack>0</iXPValueAttack>
<iXPValueDefense>0</iXPValueDefense>

should work, IMHO....
 
Back
Top Bottom