View Full Version : Training Barracks mod


RogerBacon
Jan 01, 2006, 09:58 PM
[edit] 02/07/2006 version 1.1


Hello all,

This is a mod that replaces the 4 experience you get from barracks and drydock with a chance of getting 1 experience each turn. You can customize the chance of getting experience (currently set to 10%) and also you can customize the maximum amount of experience you can get from a barracks or drydock (currently set to 10).
Units must be in a city with a barracks (land units) or drydock (naval units) to have a chance of gaining experience each turn. Each unit is checked for independently to see if it gets experience each turn.

Version history:

Version 1.1 (02/07/2006)
Changed the requirement for naval units to "Harbor" rather than "Drydock" because drydocks come so late in the game and the naval aspects of Civ need as much of a boost as they can get.

Added an alternative method for calculating the chance of a unit getting an exp point each turn:

# Linear chance method
#iRandNum = gc.getGame().getMapRand().get(pUnit.getExperience( )*2+1, "Barracks Training")

Lowered max exp to 8

Version 1.01 (1/02/2006) (247 downloads)
Optimized some code to help with make it compatible with future patches.
Added code to make sure the units in the city belonged to the player before giving the exp bonus.

Version 1.0 (1/01/2006)
Initial release. Designed to work with Civ4 version 1.52
Roger Bacon

Bhruic
Jan 01, 2006, 10:42 PM
Now I see what you wanted it for. ;)

A couple points :
if ( (uType > 0) and (uType != 8)):
Not really a good idea. If someone mods the combat types, or worse, a new patch comes out that changes them, it'll break your mod. A better way:
if ( (uType != gc.getInfoTypeForString("UNITCOMBAT_NAVAL") and (uType > gc.getInfoTypeForString("NO_UNITCOMBAT")) ):

Second, and more importantly, your mod doesn't check the owner of a unit. So if you have an open borders agreement with someone, you could put your unit in their city (with a barracks) and gain a bunch of XP. That would be somewhat exploitable.

Otherwise, a nice little mod. I haven't tried it yet, have you tested it with a 10% chance? Thought that seemed a little high to me, although it's easy enough to change.

Good job. :)

Bh

RogerBacon
Jan 01, 2006, 11:58 PM
Thanks for the advice. I have updated the mod to make the changes you suggested.

I had thought of the open borders thing and I was going to leave it that way. I was thinking that it is kind of like how the US and UK or US and Japan train together. After some more thought, however, I decided that such things didn't happen very often during more of the time period in Civ4 so I changed it.

Roger Bacon

jollyroger3
Jan 02, 2006, 04:47 AM
It's a really good idea - I like it very much :) Today I'll try out your mod :goodjob:

AAGamer
Jan 08, 2006, 08:14 PM
Interestiing. I like this very much thanks.

Thalassicus
Jan 09, 2006, 03:42 AM
It definitely makes make defensive units much more useful, balances out the steamrolling advantage. It'd probably be best to limit the cap to below 10 until you build the Heroic Epic, as 10 XP enables that wonder :)

You can also calculate the percentage required to gain an average of 1 experience per X turns with the formula: 1-0.5^(1/x). It can be made a factor of game speed this way:

dTurnsPerXP = turns * gc.getGame().getGameSpeedType().getTrainPercent() / 100.0
dPercentage = 1.0 - 0.5 ^ (1.0 / dTurnsPerXP)

RogerBacon
Jan 09, 2006, 08:36 AM
You can also calculate the percentage required to gain an average of 1 experience per X turns with the formula: 1-0.5^(1/x). It can be made a factor of game speed this way:

dTurnsPerXP = turns * gc.getGame().getGameSpeedType().getTrainPercent() / 100.0
dPercentage = 1.0 - 0.5 ^ (1.0 / dTurnsPerXP)

Thanks for the idea. I'll probably implement that in the next version.

I don't think I am understanding the formula correctly though? If X = 1 ( expect 1 exp per turn) you would get:
1 - 0.5^(1/1)
= 1- 0.5
= 0.5
This would be 50% chance, which would average out to 1 exp per 2 turns.

Roger Bacon

fishhead
Jan 09, 2006, 08:43 AM
If X = 1 ( expect 1 exp per turn) you would get:
no, x is not the exp per turn in this formula... x is the game speed.. when the game speed is faster (less turns) the chance of a unit getting exp is higher and when game speed is slow (more turns) the chance is lower

Defectiv
Jan 09, 2006, 03:03 PM
Nice idea, i do agree with Thalassicus that it should be capped, because i feel only battle should produce high exp. units. Training can only harden and train you upto a certain point. Maybe 8 EXP as a max? And 10% seems too high but i havn't tried it yet so don't know that for sure.

Kidinnu
Jan 10, 2006, 07:53 AM
At 10%, it'll take your defenders somewhere around 100 turns to reach 10 xp; that's, what, a quarter of the game? So your capital might have l4 defenders by the time anybody attacks it (non-blitz), but there'll certainly be a window of vulnerability in all your new conquests, unless you're training up large masses of defenders in your core cities and rotating them out to the provinces as they top out.

Another idea would be to make it exponentially decaying: chance of gaining a new experience point in the next turn is 1/(current xp + 4). So 25% chance for a new unit, but lower for an older unit. Or 1/(2*current xp + 1) makes it certain for a new unit, but a unit that just dinged lvl 3 (5 xp) only has a 9% chance of gaining, and a unit is expected to take 20 turns to go from 9 xp to 10. This only increases expected time to 10xp from 100 turns to 110, but it means you get the early levels faster (more like the current barracks) and the last level much slower. And if you uncap XP, it shouldn't be too horrible - I think it'd take an expected 300+ turns to reach 20 xp.

kevjm
Jan 10, 2006, 08:31 AM
Perhaps the civics and wonders which affect exp could be changed too? affecting the cap or the rate of increas?

RogerBacon
Jan 10, 2006, 09:55 AM
Perhaps the civics and wonders which affect exp could be changed too? affecting the cap or the rate of increas?

Yes, I plan to do something like that this weekend. I've also got an idea to incoprorate an element from someone else's mod into mine. I'll be able to do something with it that he wanted to do but couldn't do the way old barracks worked.

@Kidinnu
I thought about more complicated, non-linear ideas but I wanted to keep the formula simple so people could customize it easily. Also, as suggested above, I plan to eventually add in modifiers such as civic type, leader traits, etc.

Roger Bacon

AAGamer
Jan 12, 2006, 07:54 PM
Hi,

Does this mod set the starting barracks level to 1 from 4?

If so How do I reset it back to 4?

Thanks.

RogerBacon
Jan 12, 2006, 10:52 PM
Hi,

Does this mod set the starting barracks level to 1 from 4?

If so How do I reset it back to 4?

Thanks.

I'm not sure I understand your question but I think you are asking if it changes the exp you get when a unit is created.

Yes, this barracks gives you zero exp when a unit is created instead of the 4 you normally get. To change it back to 4 just don't install the CIV4BuildingInfos.xml file (or delete mine if you already installed it). That was the only change in my CIV4BuildingInfos.xml file.

Roger Bacon

Thalassicus
Jan 13, 2006, 09:57 AM
Thanks for the idea. I'll probably implement that in the next version.

I don't think I am understanding the formula correctly though? If X = 1 ( expect 1 exp per turn) you would get:
1 - 0.5^(1/1)
= 1- 0.5
= 0.5
This would be 50% chance, which would average out to 1 exp per 2 turns.

Roger Bacon
Half the values in a range fall below average, half fall above it. So if X=1, then half the time it takes 1 turn to gain 1 experience, and half the time it takes more than that: the average time is one elapsed turn. :)

To give another example, if the percentage to gain XP is 15%, you have an 85% chance per turn of not gaining XP. After 4 turns, the chance of not having gained XP is 0.85*0.85*0.85*0.85 (or 0.85 ^ 4) = 50%. So after 4 turns, you have a 50% chance of having gained/not having gained 1 XP, and 4 turns is thus the average time required to gain experience at a 15% chance per turn. Working this formula backwards gives you the one listed previously, allowing you to calculate the percentage required when given the average time.


On a side note, this can also be solved the other way to calculate the average number of turns with a given percentage using the formula log(0.5)/log(1-P), where P is the percent chance per turn in decimal. So for example, with a 0.1 chance per turn, the average turns required to gain one XP is about 6.5, or 65 turns to gain 10 XP. (A normal length game is something like 450 turns, in comparison.)

AAGamer
Jan 13, 2006, 03:28 PM
Roger,

Yes you got my question right. Only problem is I want the units to start out with 4 xp and then use your mod.. LOL>. so I guess I have to find out what you changed in the building file.. Time for digging about in it now.

AAGamer
Jan 13, 2006, 03:32 PM
I did find out my own answer, rather quickly actually. (Thanks again for the reply it is appreciated. )

The lines to place back into your mod to add the experience back and use your mod are..

<DomainFreeExperiences>
<DomainFreeExperience>
<DomainType>DOMAIN_LAND</DomainType>
<iExperience>4</iExperience>
</DomainFreeExperience>

Martock
Jan 13, 2006, 05:20 PM
Sadly, while I followed the instructions on making this the 'default' setting for my CIV IV, I've noticed that it didn't seem to work with the 'Graves Mega Mod v2.1'. It's a shame as I really like this idea and think it should be implemented as a default addition to Civ IV.

RogerBacon
Jan 14, 2006, 12:15 AM
Sadly, while I followed the instructions on making this the 'default' setting for my CIV IV, I've noticed that it didn't seem to work with the 'Graves Mega Mod v2.1'. It's a shame as I really like this idea and think it should be implemented as a default addition to Civ IV.

Graves Mega Mod v2.1 uses a CustomEventManager, just like my mod. You can only have one file with the same name laoded at one time. Since files in the MODS folder load before those inthe CumstomAssets folder, the Graves one will load and keep mine from loading.

You can combine mine with Granves. It's pretty simple.

1 Open Graves CustomEventManager and add one more "import" line:

import TrainingBarracks

2 Add this to Graves CustomEventManager on the line after sr = SettlerReligion.SettlerReligion():

sho = TrainingBarracks.TrainingBarracks()

3 Add this to Graves CustomEventManager on the line after
def onBeginGameTurn(self, argsList):
iGameTurn = argsList[0]
researchProgress.onBeginGameTurn(argsList)
self.parent.onBeginGameTurn(self, argsList):

sho.onBeginGameTurn(argsList)



4 Add TrainingBarracks.py into the same directory as Graves CustomEvenManager (You can also keep a copy in CustomAssets like my readme says so that you can continue to use TrainingBarracks with and without Graves mod.

I hope that helps.

Roger Bacon

Martock
Jan 14, 2006, 03:20 PM
Sweet! I'll give that a try when I get back home later. Can this be added to a game already in progress or will I have to start a new one?

RogerBacon
Jan 14, 2006, 09:05 PM
Sweet! I'll give that a try when I get back home later. Can this be added to a game already in progress or will I have to start a new one?

The python can be added to a game already in progress.
I believe if you want to see XML changes you need to hold down the shift key when you load or something like that - I'm not really sure.

Roger Bacon

Caterpillar
Jan 18, 2006, 09:00 AM
Hello all. This is a nice mod!
Is it possible to set the probabilities depending on the experience of the unit? For instance, you could have 50% probability if he has no experience, 33% for 1 exp pt., etc. Something like this:

Level #turns to wait
0 2
1 3
2 4
3 5
4 10
5 15
6 20
7 25
8 33
9 50
10+ 100

This would keep players from getting a bunch of level 10 units real fast.

Caterpillar

RogerBacon
Jan 18, 2006, 11:02 AM
Hello all. This is a nice mod!
Is it possible to set the probabilities depending on the experience of the unit? For instance, you could have 50% probability if he has no experience, 33% for 1 exp pt., etc. Something like this:

Level #turns to wait
0 2
1 3
2 4
3 5
4 10
5 15
6 20
7 25
8 33
9 50
10+ 100

This would keep players from getting a bunch of level 10 units real fast.

Caterpillar

Yeah, a lot of people have been asking for a more complicated, non-linear meathod so I'll probably write one this weekend. For a quick fix you can replace this:

iRandNum = gc.getGame().getMapRand().get(barracksChance, "Barracks Training")


with this:

iRandNum = gc.getGame().getMapRand().get(pUnit.getExperience( )*2+1, "Barracks Training")

So the range of numbers rolled would be:

Exp Range (where 0 gives you the exp that turn)
0 0-1
1 0-2
2 0-4
3 0-6
etc.

Roger Bacon

Alpedar
Jan 18, 2006, 11:36 AM
I have question. What does the "Barracks Training" string (in 'gc.getGame().getMapRand().get(barracksChance, "Barracks Training")') mean?
I didnt found it anywhere else and i'm not python programer and i dont know where to find civ4 python object documentation. (But i'm familiar with pascal, java and c/c++ so python is not hard tu understand for me, i simply dont know these objects).

RogerBacon
Jan 18, 2006, 12:50 PM
I have question. What does the "Barracks Training" string (in 'gc.getGame().getMapRand().get(barracksChance, "Barracks Training")') mean?
I didnt found it anywhere else and i'm not python programer and i dont know where to find civ4 python object documentation. (But i'm familiar with pascal, java and c/c++ so python is not hard tu understand for me, i simply dont know these objects).

It's just a string that gets written to a debug log so I can find the values quickly. It has no effect on the game.

Roger Bacon

Amask
Jan 28, 2006, 04:18 PM
is is possible that someone here merges this mod with Zuul's Promotions&Traits mod, found at http://forums.civfanatics.com/showthread.php?t=142086

i believe only one file is conflicting - CvCustomEventManager, but since I don't know anything python I can't figure it out on my own

RogerBacon
Jan 28, 2006, 04:43 PM
is is possible that someone here merges this mod with Zuul's Promotions&Traits mod, found at http://forums.civfanatics.com/showthread.php?t=142086

i believe only one file is conflicting - CvCustomEventManager, but since I don't know anything python I can't figure it out on my own

It's funny you should mention that. I've been using his promotions since before I wrote my training barracks mod and I actually had to seperate the two before I released this. :)

You can combine them. It's pretty simple.

1 Open his CustomEventManager and add one more "import" line:

import TrainingBarracks

2 Add this to his CustomEventManager anywhere after the "import"s but before the class begins:

sho = TrainingBarracks.TrainingBarracks()

3 Add this to his CustomEventManager on the line after
def onBeginGameTurn(self, argsList):
self.parent.onBeginGameTurn(self, argsList):

sho.onBeginGameTurn(argsList)

4 Add TrainingBarracks.py into the same directory as his CustomEvenManager (You can also keep a copy in CustomAssets like my readme says so that you can continue to use TrainingBarracks with and without his mod.

Roger Bacon

Amask
Jan 30, 2006, 09:56 AM
thanks a lot

Amask
Jan 30, 2006, 09:34 PM
this is what my CvCustomEventManager (txt to be able to upload) file looks like

in that file, I can't find the lines you mentioned in step 3.

i also tried adding those lines in every possible place in that file, and every time I get a "failed to initialize CvEventInterface" error

Amask
Feb 01, 2006, 06:45 PM
ok, i figured it out on my own.
you failed to specify that i have to add the lines you mentioned after ############### on event #################, which I also had to add.
but thanks for even incomplete help, most other people would've just ignored me

RogerBacon
Feb 08, 2006, 07:27 AM
ok, i figured it out on my own.
you failed to specify that i have to add the lines you mentioned after ############### on event #################, which I also had to add.
but thanks for even incomplete help, most other people would've just ignored me

I'm glad you got it working. Sorry I wasn't able to be 100% accurate. When I make a mod to release to the public I actually have to extract it from my combined set of mods I play with and sometimes it not the cleanest opperation.

A new version is now out. The only file that changed was the trainingBarracks.py file. There were only a couple of minor changes but one includes a new (optional) formula for calculating exp which some people expressed interest in.

Roger Bacon

Arminius
Feb 10, 2006, 06:27 PM
version 1.1 isn't working for me. I followed your directions in the readme. I even changed barracksChance=12 to barracksChance=1, and yet I still don't get any change. Any ideas on why it isn't working?

Chizzy
Feb 11, 2006, 07:37 PM
I've been thinking about something similar along these lines. A new building, available when you discover either computers, or fiber optics. a 'vr training center' that would boost the experience points of units in the city. If an army can do true virtual training then even the novice troop can get virtually 'blooded'.

RogerBacon
Feb 13, 2006, 09:42 AM
version 1.1 isn't working for me. I followed your directions in the readme. I even changed barracksChance=12 to barracksChance=1, and yet I still don't get any change. Any ideas on why it isn't working?

Did you install it to your custom assets folder or as a mod? If as a mod, make sure the mod is loading.

Try uncommenting line 64 and see if it is printing the message.

Also, check the log files to see if there is an error message.

Roger Bacon

Springsteen84
Mar 13, 2006, 07:49 AM
Hi RogerBacon I also downloaded your Mod and with me it also doesn't seem to work. You're reffering to a log file where I can find this one.

Thanks

Springsteen84
Mar 13, 2006, 07:52 AM
Oh yeah, I forgot, I also tried modifying the script while in Civ4. When I return to Civ4, I see a message on the screen Reloading Python Module. But it doesn't print any other message, also when uncomment some of the lines in the script.

RogerBacon
Mar 13, 2006, 12:19 PM
Oh yeah, I forgot, I also tried modifying the script while in Civ4. When I return to Civ4, I see a message on the screen Reloading Python Module. But it doesn't print any other message, also when uncomment some of the lines in the script.

That's a good sign. That means that the mod is loading correctly otherwise you wouldn't see the reloading message when you made changes during a game.

The log file is in mygames\civ\customassets\logs or something limke that, I'm at work now and don't remember the exact directory structure.

Uncomment line 64 and it should print the result of each random roll on the screen. Let me know if you see that.

Roger Bacon

Springsteen84
Mar 17, 2006, 02:00 PM
No, no messages appear on the screen. I have set it up as a Mod.
I found the log file it give the following error message in every turn:

load_module TrainingBarracks
load_module pickle
PY:OnInit
load_module CvTranslator
load_module CvGameInterface
iTurn: 40
Traceback (most recent call last):
File "CvEventInterface", line 23, in onEvent
File "CvCustomEventManager", line 33, in handleEvent
File "CvEventManager", line 164, in handleEvent
File "CvCustomEventManager", line 96, in onBeginGameTurn
File "TrainingBarracks", line 16, in onBeginGameTurn
NameError: global name 'theGame' is not defined
PY:City Washington's culture has expanded
iTurn: 41
Traceback (most recent call last):
File "CvEventInterface", line 23, in onEvent
File "CvCustomEventManager", line 33, in handleEvent
File "CvEventManager", line 164, in handleEvent
File "CvCustomEventManager", line 96, in onBeginGameTurn
File "TrainingBarracks", line 16, in onBeginGameTurn
NameError: global name 'theGame' is not defined


I think it fails over the following line in your:
playerList = theGame.getCivPlayerList()

But It seems that I'm the only one who has this problem, or not?

RogerBacon
Mar 17, 2006, 04:51 PM
No, no messages appear on the screen. I have set it up as a Mod.
I found the log file it give the following error message in every turn:

load_module TrainingBarracks
load_module pickle
PY:OnInit
load_module CvTranslator
load_module CvGameInterface
iTurn: 40
Traceback (most recent call last):
File "CvEventInterface", line 23, in onEvent
File "CvCustomEventManager", line 33, in handleEvent
File "CvEventManager", line 164, in handleEvent
File "CvCustomEventManager", line 96, in onBeginGameTurn
File "TrainingBarracks", line 16, in onBeginGameTurn
NameError: global name 'theGame' is not defined
PY:City Washington's culture has expanded
iTurn: 41
Traceback (most recent call last):
File "CvEventInterface", line 23, in onEvent
File "CvCustomEventManager", line 33, in handleEvent
File "CvEventManager", line 164, in handleEvent
File "CvCustomEventManager", line 96, in onBeginGameTurn
File "TrainingBarracks", line 16, in onBeginGameTurn
NameError: global name 'theGame' is not defined


I think it fails over the following line in your:
playerList = theGame.getCivPlayerList()

But It seems that I'm the only one who has this problem, or not?

Make sure you have this line "theGame = PyHelpers.PyGame()" somewhere earlier in the file. My version is a little different than the one that's been released so my line numbers are different otherwise I'd tell you the exact line number.

Roger Bacon

N3pomuk
Mar 28, 2006, 10:31 AM
good idea, but is ther a cap to the max that they can get? after all training can only do so much.

jojoweb
Mar 28, 2006, 03:14 PM
Very good idea, you're a boss ^_^ (python is so hard !). I will use it for my mod.

bye

zyphyr
Mar 28, 2006, 06:45 PM
good idea, but is ther a cap to the max that they can get? after all training can only do so much.

Yes, there is a cap. It defaults to 8, but that can be changed.

Houman
Mar 30, 2006, 03:01 PM
Is this mod working 100%? And how do the units get the experience? Several people have suggested a solution, what is the end formula?

Many thanks
Houman

Houman
Apr 01, 2006, 01:33 PM
Hello Roger,

I really like your idea and would like to implement it into my mod. The code is still quite a lot mentioning the drydock even though you have changed the traning to Harbor instead of Drydock. The variables and some messages etc are still mentioning drydock.

It is a bit confusing, since I don't understand the whole code. :)

Thanks
Houman

RogerBacon
Apr 01, 2006, 08:49 PM
Hello Roger,

I really like your idea and would like to implement it into my mod. The code is still quite a lot mentioning the drydock even though you have changed the traning to Harbor instead of Drydock. The variables and some messages etc are still mentioning drydock.

It is a bit confusing, since I don't understand the whole code. :)

Thanks
Houman

The message mentioning Drydock was just a debugging message; it won't show up in the game. The variable name doesn't matter. The only important thing is the line if pCity.hasBuilding(gc.getInfoTypeForString('BUILDIN G_HARBOR')):. That tells the game to check if the city has a harbor.

This was my first mod and I'm sure the code could be cleaned up a lot but it works, even if it isn't always the clearest thing in the world to read.

Roger Bacon

Spocko
Apr 16, 2006, 10:59 AM
I've enhanced this mod (thanx RogerBacon!!) to check for a specific state religion and a few different civics. The state religion herein (Vaalkazism) is a martial religion of Alulim's Alt Religion Mod.

The series of checks are all listed before the error-check against whether a variable has fallen below 0 (e.g., the series of error-checks starting with "if (barracksChance < 1):")

I've made similar enhancements to RogerBacon's Assassin and Bad People mods.

Now I've got to start figuring out whether the AI knows about these effects... knows to implement a Police State and Nationhood and pursue Vaalkazism for optimal training opportunities. {sighs}

Enjoy!!



if (pPlayer.getStateReligionKey() == "TXT_KEY_RELIGION_VAALKAZISM"):
barracksChance = barracksChance -3
harborChance = harborChance -3
barracksMaxExp = barracksMaxExp +3
harborMaxExp = harborMaxExp +3

civGovernment = pPlayer.getCivics(0)
if ( civGovernment == gc.getInfoTypeForString('CIVIC_POLICE_STATE')):
barracksChance = barracksChance -1
harborChance = harborChance -1

civLegal = pPlayer.getCivics(1)
if ( civLegal == gc.getInfoTypeForString('CIVIC_NATIONHOOD')):
barracksChance = barracksChance -1
harborChance = harborChance -1
if ( civLegal == gc.getInfoTypeForString('CIVIC_VASSALAGE')):
barracksChance = barracksChance -1
harborChance = harborChance -1

civReligion = pPlayer.getCivics(4)
if ( civLegal == gc.getInfoTypeForString('CIVIC_PACIFISM')):
barracksChance = barracksChance +4
harborChance = harborChance +4

if (barracksChance < 1):
barracksChance = 1
if (barracksMaxExp < 1):
barracksMaxExp = 1
if (harborChance < 1):
harborChance = 1
if (harborMaxExp < 1):
harborMaxExp = 1

RogerBacon
Apr 16, 2006, 06:24 PM
Very nice Spocko.

You can also check for specific civilizations and leader traits. I do this in my personal version of hte mod.


if (pPlayer.getCivilizationDescriptionKey() == "TXT_KEY_CIV_JAPAN_DESC"):
barracksChance = barracksChance -1
harborChance = harborChance -2
barracksMaxExp = barracksMaxExp +1
harborMaxExp = harborMaxExp +2

if (pPlayer.hasTrait(gc.getInfoTypeForString("TRAIT_AGGRESSIVE"))):
barracksChance = barracksChance -2
harborChance = harborChance -2
barracksMaxExp = barracksMaxExp +2
harborMaxExp = harborMaxExp +2


Roger Bacon

Spocko
Apr 16, 2006, 07:57 PM
:)

Yea, I have to remember to check your mods for favoritism toward Japan!!

I'm going to update the pedia text for bad people (sorry for off-thread topic) and I'll send/post my updates once I done.

I like the idea of checking with respect to leader traits. I'll play with that too.

Cheers,
Spocko

{EDIT: I see the text for bad people STRATEGY specify the actual game effect of these units... so I just copied the one-liner strategy text to the first line of the pedia text.}

Fachy
Jun 25, 2006, 09:47 PM
I just love this mod, but I couldn't merge it with mine! Could you point out the exact changes please so we could all enjoy fusing it into our composite mods? :)

RogerBacon
Jun 26, 2006, 07:55 AM
I just love this mod, but I couldn't merge it with mine! Could you point out the exact changes please so we could all enjoy fusing it into our composite mods? :)

Thanks; I'm glad you like it.

This mod is about as simple as they come. It uses one event: onBeginGameTurn. Take whatever customEventManager you are using and add an import for this file in the imports section

import trainingBarracks

They you need to create an object

train = trainingBarracks.trainingBarracks()

and then, in the onBeginPlayerTurn section you need to call the trainingBarrack's onBeginGameTurn() function

train.onBeginGameTurn(argsList)

All of the above is from memory because I don't have the code in front of me. If some of the names are sligfhtly different then make the appropriate adjustments.

Roger Bacon

Fachy
Jun 26, 2006, 05:48 PM
I have no "onBeginPlayerTurn" line in my CvCustomEventManager.py!!

Also, my CvCustomEventManager file is only 6 kb, while yours is 10 kb. Does this have to do anything with me not being able to work it out or find the BeginPlayer thingy? Excuse me but I just began teaching myself python yesterday to merge mods :p

RogerBacon
Jun 26, 2006, 10:15 PM
I have no "onBeginPlayerTurn" line in my CvCustomEventManager.py!!

Also, my CvCustomEventManager file is only 6 kb, while yours is 10 kb. Does this have to do anything with me not being able to work it out or find the BeginPlayer thingy? Excuse me but I just began teaching myself python yesterday to merge mods :p

If your CvCustomEventManager doesn't have onBeginPlayerTurn then that is good. It means merging the mod will be easy. Just copy my onBeginPlayerTurn function into your CvCustomEventManager. Any line after class CvCustomEventManager should be fine.

The difference in file size is not important. That just means I have more things in mine than in yours. What functions do you have in your CvCustomEventManager?

Roger Bacon

Fachy
Jun 26, 2006, 10:26 PM
I'm not sure what you mean.. I'm totally programming illetrate! I think you want me to copy this paragraph:

def onBeginPlayerTurn(self, argsList):
'Called at the beginning of a players turn'
self.parent.onBeginPlayerTurn(self, argsList);

Into my file right?

RogerBacon
Jun 27, 2006, 12:40 PM
I'm not sure what you mean.. I'm totally programming illetrate! I think you want me to copy this paragraph:

def onBeginPlayerTurn(self, argsList):
'Called at the beginning of a players turn'
self.parent.onBeginPlayerTurn(self, argsList);

Into my file right?

Yes. Put that in your customEventsManager and then add a call to the training barrack's onBeginPlayerTurn:
train.onBeginPlayerTurn(argsList)

Here I'm calling it train but you use whatever you call in when you define it in the defines section of yoru customEventManager.

Roger Bacon

Fachy
Jun 27, 2006, 04:38 PM
Roger I did that but it's still giving me errors at the game startup :(
My CvCustomEventManager.py file: http://www.savefile.com/files/8651175

RogerBacon
Jun 27, 2006, 05:24 PM
Roger I did that but it's still giving me errors at the game startup :(
My CvCustomEventManager.py file: http://www.savefile.com/files/8651175

You are using Dr. Jiggles' customEventManager setup so things are a little different. I've recently switched to that format but my old mods still use the original way of doing things. Try these files and it should work.

Roger Bacon

Fachy
Jun 27, 2006, 05:47 PM
Very same error, I attached a couple of pics for more clarifications

RogerBacon
Jun 27, 2006, 06:11 PM
Which module is it failing on at line 52?

Roger Bacon

Fachy
Jun 27, 2006, 06:18 PM
:confused:
I don't know.. it gives many errors after this one too, I was just showing those 2 SSs as an example. When I remove your mod again, it loads fine.. so it must be something wrong with me incorporating it into my python, but what?

I don't know if this could help, but here is all my current customAssets folder, WITHOUT your mod:
http://www.savefile.com/files/1760379

RogerBacon
Jun 27, 2006, 07:13 PM
Look in your \My Games\Civ4\Logs and see what the error message is in PythonErr2.log and PythonErr.log

Roger Bacon

Fachy
Jun 27, 2006, 08:10 PM
Ok, when I got desperate I load the original files unto a MOD (not custom assets), and it didn't work!! Barracks acted just like normal! I don't know what's wrong but I dno't think I'll ever be able to play it :cry:

Thanks Roger for answering my questions anyway

RogerBacon
Jun 27, 2006, 10:18 PM
Fachy,

I'm sorry I wasn't able to help you get it to work. Actually, it is a pretty simple mod. If you look over the code you can probably implement it yourself in any other mod file you have that is working. If you have any other mod that uses the same event onBeginPlayerTurn() you could just move my code there and it should work. As to why it didn't work when you loaded it as I mod, I really can't say. Of course, when you load a mod the program also loads your custom assets after that for all files that weren't loaded in the mod so it might be the case that the conflicting file was still being loaded after you loaded the mod. When I want to play a mod I always zip up my customassets and then delete the folder (which is a pain so I don't do it often)

Roger Bacon

Fachy
Jun 27, 2006, 10:24 PM
I don't know if that's the case, but I think that MODS overpower ASSETS in general. Otherwise, if there's some code in my other mods which is preventing it from working, that means that I can't play both of them together

Fachy
Jun 30, 2006, 08:30 PM
Roger stupid question here: The files you posted initially, do they contain this mod alone or other mods included? I'm still confused about the 6kb vs 10kb file

RogerBacon
Jun 30, 2006, 10:21 PM
Roger stupid question here: The files you posted initially, do they contain this mod alone or other mods included? I'm still confused about the 6kb vs 10kb file

The training barracks was my first mod so the files are just for that. There is nothing else included.

Roger Bacon

Fachy
Jul 01, 2006, 06:04 PM
So the 4 KB difference of CVCustomEventManager is solely for it? I'm asking coz the one you posted for me was 4 or 5 KB.. so where did the rest of the 10 KB go?