Training Barracks mod

Martock said:
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
 
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
 
Caterpillar said:
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
 
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).
 
Alpedar said:
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 said:
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
 
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
 
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
 
Amask said:
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
 
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?
 
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'.
 
Arminius said:
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
 
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
 
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.
 
Springsteen84 said:
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
 
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?
 
Springsteen84 said:
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
 
good idea, but is ther a cap to the max that they can get? after all training can only do so much.
 
Back
Top Bottom