View Full Version : Can you mod the experience levels?


jefmart1
Jan 13, 2006, 09:13 AM
Is there any way to mod the experience levels so units get promotions quicker?

rebel5555
Jan 28, 2006, 04:51 AM
Yes there is go to this thread: http://forums.civfanatics.com/showthread.php?t=151492 (The Training Barracks Mod)

It's a neat mod that gives your units stationed in a city Experiance. Only with a barracks (for land units) and a drydock (for naval units)

You can edit the TrainingBarracks.py to give you more experiance each turn.

Hope that helps. :goodjob:

snarko
Jan 28, 2006, 05:19 AM
You can also change MIN_EXPERIENCE_PER_COMBAT, MAX_EXPERIENCE_PER_COMBAT and EXPERIENCE_FROM_WITHDRAWL in GlobalDefines.xml.

TheLopez
Jan 28, 2006, 07:06 AM
Yes there is go to this thread: http://forums.civfanatics.com/showthread.php?t=151492 (The Training Barracks Mod)

<Shameless Plug>There's also the Military Base's mod</Shameless Plug>

For more info check out my sig. :)

The Great Apple
Jan 28, 2006, 07:19 AM
Or you could go right to the core, and actually change the expereince breakpoints manually.

sensoukami
Jan 29, 2006, 12:21 AM
Or you could go right to the core, and actually change the expereince breakpoints manually.Hi. Sorry, but where can you do that? I've opened up every single XML file there is, and searched but I must have missed it...could someone help me out?

Just to clarify, I want to change the levels at which units gain a level, not how much experience they gain...

Also, there is a field called MAX_EXPERIENCE_AFTER_UPGRADE...does that do what I think it does?

thanks in advance...

Kael
Jan 29, 2006, 12:33 AM
Hi. Sorry, but where can you do that? I've opened up every single XML file there is, and searched but I must have missed it...could someone help me out?

Just to clarify, I want to change the levels at which units gain a level, not how much experience they gain...

Also, there is a field called MAX_EXPERIENCE_AFTER_UPGRADE...does that do what I think it does?

thanks in advance...

MAX_EXPERIENCE_AFTER_UPGRADE is the amount of experience points a unit retains after you upgrade it (say from a warrior to an axeman).

rebel5555
Jan 29, 2006, 12:35 AM
:goodjob: Try this website! It has very good information on the XML files.
http://civ4wiki.com/wiki/index.php/Main_Page Check it out it has the info on what the variables do an the Civ4 XML files.

snarko
Jan 29, 2006, 03:58 AM
Hi. Sorry, but where can you do that? I've opened up every single XML file there is, and searched but I must have missed it...could someone help me out?

I think that what he means is changing it in python. Atleast I don't know of any other way to change the levels and not experience itself.

The Great Apple
Jan 29, 2006, 05:28 AM
Sorry, I should have been more clear.

Yes, you can change it in python, triggering a check on combat result to see if you can promote. I've just realised I have made, and posted such a mod for somebody with a similar question. You can find it here:

http://forums.civfanatics.com/showthread.php?t=146848

At the moment the interface doesn't show the experience breakpoints correctly, but if you like I can fix that.

Exel
Jan 29, 2006, 05:35 AM
Sorry, I should have been more clear.

Yes, you can change it in python, triggering a check on combat result to see if you can promote. I've just realised I have made, and posted such a mod for somebody with a similar question. You can find it here:

http://forums.civfanatics.com/showthread.php?t=146848

At the moment the interface doesn't show the experience breakpoints correctly, but if you like I can fix that.

I'd very much appreciate it if you could correct the GUI as well. I've also been searching for a way to change the exp levels, but it feels a little "cheap" if the GUI still displays the old values.

The Great Apple
Jan 29, 2006, 05:48 AM
I'd very much appreciate it if you could correct the GUI as well. I've also been searching for a way to change the exp levels, but it feels a little "cheap" if the GUI still displays the old values.Okies, will be done shortly...

Exel
Jan 29, 2006, 06:05 AM
Okies, will be done shortly...

You are my hero... :love:

The Great Apple
Jan 29, 2006, 06:08 AM
Done! Be aware that I have been unable to test the interface as I don't have Civ with me at uni. Also, I have fiddled around with the other files, so I may have made a typing error somewhere...

If it doens't work, switch python error logging on in the ini file, and post up the error and I'll see if I can fix it. As I said I don't think there will be any, but one or two might have slipped in.

Supports up to 20 experience breakpoints, after that you won't be able to promote any more. I can add more if you want me to.

To edit the breakpoints, open up CvCusExp_CFG, and change the number before the # for each breakpoint.

Here is the file:

EDIT: File had one or two small/big bugs. Will be uploading a new version as soon as somebody answers my question on the last post, and I notice that they have answered it.

Exel
Jan 29, 2006, 09:29 AM
:thanx:

Will be sure to test and adopt it. :goodjob:

sensoukami
Jan 29, 2006, 11:33 AM
You are my hero... :love:
Yeah, what he said!

Seriously Great Apple, thanks so much. Heck, I ain't even tried it yet, but props for the effort!

<long-winded explanation>

I like the combat experience, but realisitcally, it was too bloody hard to get a unit up there. It takes A LOT of work to get a Level 5 unit (needed for West Point), and I just wasn't realistically able to repeat that feat too many times, and I went to war a fair bit. But changing the experience gained from combat would allow units to get too good too fast, but still leave anything above level 5 mostly out of reach (imho). This will be much better.

</long-winded explanation>

:goodjob: U da :king:

Exel
Jan 29, 2006, 02:04 PM
I like the combat experience, but realisitcally, it was too bloody hard to get a unit up there. It takes A LOT of work to get a Level 5 unit (needed for West Point), and I just wasn't realistically able to repeat that feat too many times, and I went to war a fair bit. But changing the experience gained from combat would allow units to get too good too fast, but still leave anything above level 5 mostly out of reach (imho). This will be much better.

I completely agree with this statement. Getting high-level units without constant warring is so difficult that once you get them, they'll almost be too valuable to be used in combat where the odds are even slightly in doubt. And that sort of neglects the whole point of having all those promotions.

I'd like easier level-ups but with slightly less effective promotions. I'm planning on a mod to this end. Been thinking something like 2/4/8/12/16 for the exp levels.

TheLopez
Jan 29, 2006, 02:08 PM
I completely agree with this statement. Getting high-level units without constant warring is so difficult that once you get them, they'll almost be too valuable to be used in combat where the odds are even slightly in doubt. And that sort of neglects the whole point of having all those promotions.

I'd like easier level-ups but with slightly less effective promotions. I'm planning on a mod to this end. Been thinking something like 2/4/8/12/16 for the exp levels.

Exel, thats one of the reasons why I developed the military bases mod. During peace time your units can sit and train on one of your military bases and gain experience. If you want you can use my mod as a starting point for your mod.

sensoukami
Jan 29, 2006, 11:06 PM
Done! Be aware that I have been unable to test the interface as I don't have Civ with me at uni. Also, I have fiddled around with the other files, so I may have made a typing error somewhere...

If it doens't work, switch python error logging on in the ini file, and post up the error and I'll see if I can fix it. As I said I don't think there will be any, but one or two might have slipped in.

Supports up to 20 experience breakpoints, after that you won't be able to promote any more. I can add more if you want me to.

To edit the breakpoints, open up CvCusExp_CFG, and change the number before the # for each breakpoint.

Here is the file:
Hey Great Apple. Don't want to sound whiny, but methinks something is amiss...

I set my first few breakpoints at 2 / 4 / 6 / 8 / 10
I have a scout that the interface says has 4 experience, but he is still only has the one promotion, not the two he should have. <-- I'm back after further play --> That same scout just won a fight pushing him to 5xp. Now he got his level 3. Isn't it greater than OR equal for breakpoints? Shouldn't he have got his promotion at 4xp? Plus, I have anohter scout that is at level 2 with 2xp (as expected), but graphically is showing 2/6.

I have the mod in the My Documetns folder...which I've just read the sticky telling me it shouldn't be there. Is that a problem?

Also, the appearance in the interface is correct in terms of showing the breakpoint at 6, for example, but if you hover over the unit, a small display will appear, above the main unit display window. This amount is not accurate. It still shows the '5' from the default (I don't care so much about this part honestly...just mentioning it).

Sorry, it might just be something I did wrong, but I thought I'd mention it.

thanks in advance

Exel
Jan 30, 2006, 07:35 AM
The system works as it should, but there's still a glitch in the GUI.

For example, if the breakpoints are set to 2, 4 and 8, the GUI shows that a unit with 1 xp will promote at 4. It does promote correctly at 2 though, but after doing so it claims that the next promotion happens at 8 xp points. That is wrong again, as the promotion does correctly occur with 4 xp.

So the GUI is jumping levels in advance. I tried editing the numbers both in CvCusExp.py and CvCusExp_CFG.py but to no avail, at least not yet. I'll keep troubleshooting til I run out of ideas.

EDIT:
I think I found the source of the problem. The script enables the promotions on the breakpoints defined in the CvCusExp_CFG.py regardless of what the "elif (pUnit.getLevel() ==" lines say in the CvCusExp.py.

For example, if I edit "if (pUnit.getLevel() == 1) and (pUnit.getExperience() >= CFG_ExpLevel1):" and change the "CFG_ExpLevel1" to "CFG_ExpLevel20" it will still use "CFG_ExpLevel1" to actually define the breakpoint.

Now, this doesn't explain to me why it jumps the levels in the GUI, but maybe it gives you a clue about what might be wrong.

The Great Apple
Jan 30, 2006, 07:36 AM
Right - it would appear that the inferface error is because in the interface I coded for a starting level of level 0, while in the worky bits I coded for a starting level of 1. It would also appear that the code isn't actually running (you got the level on 5, which is the default). This would lead me to think that there is some sort of bug in there which would be picked up very nicely by a compiler... something that I don't have :p. If you run the code with python error logging switched on does it come up with any errors?

The mousover text is unfortunetly hardcoded. I'm pretty certain there is no way of accessing it.

The Great Apple
Jan 30, 2006, 07:39 AM
Ah, so the code works apart from the interface?

Great - I'll post up the fixed files!

EDIT: Actually... before I do so - how to promotions after combat work? Do you get the promotion in the next turn? Does it depend on how many moves you've got left?

Exel
Jan 30, 2006, 08:38 AM
Halt the presses! The solution was just as simple as... changing the CFG_ExpLevel numbers in CvCusExp_CFG.py from CFG_ExpLevel1 to CFG_ExpLevel2 and so forth. :eek: No other changes needed.

Still, the "(pUnit.getExperience() >= CFG_ExpLevelX):" definitions in the CvCusExp.py seem to be defunct. But at least it works now. :yeah:

Exel
Jan 30, 2006, 08:40 AM
Actually... before I do so - how to promotions after combat work? Do you get the promotion in the next turn? Does it depend on how many moves you've got left?

I got varied results. Initially, before making any changes to the scripts, the promotions came instantly even if you had 0 movement left. Now that the thing works correctly though you only get the promotion on the next turn, even if you have movement left after combat. Kinda weird, considering the only real change was in the GUI.

The Great Apple
Jan 30, 2006, 10:17 AM
Right... am slightly confused as to what you've done. This code:if (pUnit.getLevel() == 1) and (pUnit.getExperience() >= CFG_ExpLevel1):
return true
checks to see if the unit has enough experience to be eligable for a promotion, and if it does it'll return true. If true is returned then it sets the unit to be able to have a promotion.

The way the whole code works is to interrupt the default promotion logic, then do a new test based on that line of code, and enable promotions if the test is passed.

The file that actually needs changing to fix the interface is CvMainInterface.py - I need to change all the numbers in a similar way to the way you described.

Could somebody please clarify what is meant to happen when you get enough experience for a promotion? Am I right in thinking that if you have moves left you can promote instantly, otherwise you can't? The attached updated version is assuming that this is the case.

I'll make a new thread in the new forum once somebody has confirmed to me that it's working fine :p. Really sorry I can't test it myself!

Exel
Jan 30, 2006, 10:54 AM
Right... am slightly confused as to what you've done. This code:if (pUnit.getLevel() == 1) and (pUnit.getExperience() >= CFG_ExpLevel1):
return true
checks to see if the unit has enough experience to be eligable for a promotion, and if it does it'll return true. If true is returned then it sets the unit to be able to have a promotion.

I figured something like that, but my testing showed that changing the number attached to CFG_ExpLevel does nothing, which leads me to believe that that part of the code is defunct. Instead it checks the CFG_ExpLevel values in CvCusExp_CFG in chronological order.

What I did to fix the problem with the GUI was to add +1 to all the CFG_ExpLevel[insertnumberhere] values in CvCusExp_CFG.py so that they started from 2 and not 1 like previously. Then everything worked fine.

Could somebody please clarify what is meant to happen when you get enough experience for a promotion? Am I right in thinking that if you have moves left you can promote instantly, otherwise you can't? The attached updated version is assuming that this is the case.

You only get the promotion on the next turn after combat, not on the same turn. That applies even if you have movement points left.

Exel
Jan 30, 2006, 10:56 AM
Btw, what other modifications did those files have? I noticed that atleast the clock / year display was different. Like this:

17:30 (Turn 1) 4000 BC

The Great Apple
Jan 30, 2006, 11:01 AM
Oh damn... that's my fault. Sorry. :blush: I based it off another mod which I did for myself and forgot I had changed the clock as well!

Should be just the clock... I'll fix that!

Be prepared for yet another file to appear here!

What I did to fix the problem with the GUI was to add +1 to all the CFG_ExpLevel[insertnumberhere] values in CvCusExp_CFG.py so that they started from 2 and not 1 like previously. Then everything worked fine.
Really? I can see this would fix the interface, but... it should break the actual code. Weird. My fix was to add one to all the numbers in CvMainInterface.py.

Are you saying that everything worked fine after that change? If so... I'm slightly confused.

BTW - do you have python error logging enabled?

From what information I've gotten from everybody - this one should work without a hitch. Nothing extra in the clock section, and the interface working fine (apart from the mousovers).

Exel
Jan 30, 2006, 11:42 AM
Hmm, it appears that I had indeed made another change. I fiddled around with both of the files so much that I had forgotten all the things I had changed. :p

This is the code the way it works perfectly:

in CvCusExp.py:

if (pUnit.getLevel() == 2) and (pUnit.getExperience() >= CFG_ExpLevel1):
return True
elif (pUnit.getLevel() == 3) and (pUnit.getExperience() >= CFG_ExpLevel2):
return True
elif (pUnit.getLevel() == 4) and (pUnit.getExperience() >= CFG_ExpLevel3):
return True
...


in CvCusExp_CFG.py:

# Experience needed for each promotion
CFG_ExpLevel2 = 2 # 2
CFG_ExpLevel3 = 4 # 5
CFG_ExpLevel4 = 8 # 10
CFG_ExpLevel5 = 12 # 17


So I had also changed values in the CvCusExp.py. Note, however, that the CFG_ExpLevel numbers there are still unchanged. Also, not changing the CvCusExp.py values had only one effect: it then gave one free promotion on first level-up, otherwise the script and GUI worked still fine.

Exel
Jan 30, 2006, 11:49 AM
Tested the v1.2 of the mod and it works great. :goodjob:

I hope that the SDK will allow the mouse-over screen to be fixed too so this mod would be flawless. :)

The Great Apple
Jan 30, 2006, 11:50 AM
Weird. I'm having difficulty seeing how that works. Firstly, I would expect python to complain that you haven't defined "CFG_ExpLevel1", and secondly... the logic is out:

elif (pUnit.getLevel() == 3) and (pUnit.getExperience() >= CFG_ExpLevel2):
return True says "if the unit is level 3, and has reached the first promotion breakpoint (as you have defined it), allow it to promote". As you start at level 1... it shouldn't really work.

I think the original code posted worked fine, except for the interface... though you are putting some pretty large doubts in my mind!

EDIT: Aaah, excellent. Glad that's sorted. I'll post it up in the mod components section! Thanks for the testing guys.

Exel
Jan 30, 2006, 02:06 PM
Weird. I'm having difficulty seeing how that works. Firstly, I would expect python to complain that you haven't defined "CFG_ExpLevel1", and secondly... the logic is out

The only way I could figure it out is that the code automatically searches for the CFG_ExpLevel entries in chronological order and it doesn't really identify the number at all. Still, it is weird.

I think the original code posted worked fine, except for the interface... though you are putting some pretty large doubts in my mind!

Yes, the original code worked fine except for the GUI. I had no other problems with it. Though I still can't quite grasp why the interface bugged so oddly when the only difference was what number started the list.

But that's why I don't do coding unless I absolutely "have" to. ;)

Thanks for the testing guys.

Thanks for the code in the first place. It will allow me to take a whole new approach to the promotions and that way kind of to the whole combat system.

sensoukami
Jan 30, 2006, 09:02 PM
Okay...I downloaded the 1.2 code. no change to the interface. Still shows the wrong values in the main unit window. Isn't that part of the fix with 1.2? Or is it just the "no promotion until next turn" thing?

Exel
Jan 31, 2006, 03:03 AM
Okay...I downloaded the 1.2 code. no change to the interface. Still shows the wrong values in the main unit window. Isn't that part of the fix with 1.2? Or is it just the "no promotion until next turn" thing?

1.2 should work correctly, at least it does so for me. Have you placed the numbers in the right place? You only need to edit the CvCusExp_CFG.py.

sensoukami
Feb 01, 2006, 09:35 PM
Okay. There is definitely a glitch somewhere. It's small but its there. In fact, other than the glitch (which I am about to describe) it works great.

Here is what I did.

1. Completely deleted all the old mod files, old saves, cleared the cache and wiped out my recycle bin too.
2. Installed the new version of the mod into the Program Files directory.
3. Carefully changed the xp breakpoints (no, i didn't make a mistake).
4. Started a new game.

Everything worked great except..I had one archer unit. It got into combat, hit 4xp (the breakpoint), and wouldn't level up. I took a screenshot, I can send it if anyone likes. Not only would it NOT level up, but I would tell it to heal, and the order would have to be repeated everyturn. It wouldn't heal on its own like it should. AND during the AI's turn, I would notice that it woudl glow green (indicatin promotion) but at the start of my turn....no such luck. I had to wait till it got into another fight and hit 5xp before I could level it. It was fine after that. It was very strange, and only the one time, but it is real.

Other than that, the mod is great. If that is the only glitch I run into and it is not too frequent, I am happy.

Later,

sensoukami
Feb 01, 2006, 10:25 PM
Okay, happend again. Hit 7/6, glowed green during enemy turn. no chance to level up on my turn. Hit 8/6 (8 is the next breakpoint), glowed green on enemy turn, no chance to level up on my turn.

Nice try Great Apple. But your mod is currently too flawed to be used. Great idea though. Just got to track down the source of that glitch, and all will be well...

Thanks for the work. If I can do anything to help track it down, let me know.

Exel
Feb 02, 2006, 03:07 AM
Strange, I didn't run into such problems. Guess I'll have to do a bit more testing with it to make sure.

The Great Apple
Feb 02, 2006, 11:24 AM
Sorry. I have no idea why it would be doing what you say it is. Most odd. Was there anything special about the units that it happened to? Did they gain their experience in a different way to units which worked properly?

sensoukami
Feb 02, 2006, 04:37 PM
I've been thinking over the same thing. The only thing of note was that it happened in combat (not barracks), and when my guy was defending. But I've had other units do that, and there was no problem at all. I hate bugs like that!!!

I looked over the python code, and the logic looked solid. Only thing I can think off is if there is something happening within the main Civ engine that is preventing your code from running? Maybe a flag is getting changed in an unforseen manner before you're code gets a chance to do its thing...