Training Barracks mod

Very good idea, you're a boss ^_^ (python is so hard !). I will use it for my mod.

bye
 
N3pomuk said:
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.
 
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
 
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
 
Houman said:
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('BUILDING_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
 
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!!


Code:
			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
 
Very nice Spocko.

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

Code:
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
 
:)

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.}
 
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? :)
 
Fachy said:
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
 
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
 
Fachy said:
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
 
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?
 
Fachy said:
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 said:
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
 

Attachments

  • trainingBarracksPythonFiles.zip
    3.2 KB · Views: 130
Very same error, I attached a couple of pics for more clarifications
 

Attachments

  • 1.JPG
    1.JPG
    80.6 KB · Views: 143
  • 2.JPG
    2.JPG
    80 KB · Views: 148
: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
 
Top Bottom