Question about experience and promotions

Exel

Prince
Joined
Nov 25, 2001
Messages
440
Location
Finland
I've been thinking of tweaking the promotion system so that you'd have basic level-up promotions that you would get free each level and that would unlock all the other promotions for that level, which you would then have to buy normally with your promotion points. The Combat promotions would imo seem ideal for that purpose. They would act as the level-up promotions and every other promotion would be linked to them.

The question is, can it be made so that once your units gains enough exp for a level-up, he'd automatically get the Combat promotion for free and still have the points to buy another promotion manually?

Thanks in advance! :)
 
EDIT: Look at snako's post just below this - this method doesn't actually work

I think so, you should be able to do it in python, under the "onUnitPromoted" event in CvEventManager.py. I'm not really that used to python, so I don't know exactly how you would do it - however I'm almost certain it's quite easy to work.

Something like:

Code:
if iExperience >= a:
	pUnit.setHasPromotion(b, True)

Where a is the experience of the unit, and b is the index of the promotion to be granted. I'm not entirely sure iExperience is a tag.... but it seems logical!
 
Short answer: yes.

Long answer: onCombatResult in CvEventManager.py. Check if the winning unit can promote and if so if it has the promotions it should. If it doesn't have the promotions it should add them. You'll have to add the same check to onUnitBuilt.
 
The Great Apple said:
I think so, you should be able to do it in python, under the "onUnitPromoted" event.

onUnitPromoted triggers when you give a unit a promtion, not when it earns one.


The Great Apple said:
Something like:

Code:
if iExperience >= a:
[tab]pUnit.setHasPromotion(b, True)

Where a is the experience of the unit, and b is the index of the promotion to be granted. I'm not entirely sure iExperience is a tag.... but it seems logical!

Problem with checking experience is what if you change how fast you get levels? I haven't tried it but experienceNeeded() might tell you 0 if the unit can be promoted but haven't been yet.
 
snarko said:
Short answer: yes.

Long answer: onCombatResult in CvEventManager.py. Check if the winning unit can promote and if so if it has the promotions it should. If it doesn't have the promotions it should add them. You'll have to add the same check to onUnitBuilt.

I'm really not familiar with Python. So would you mind showing me the script that would automatically give the next Combat promotion on each level up without disabling other promotions?
 
Exel said:
I'm really not familiar with Python. So would you mind showing me the script that would automatically give the next Combat promotion on each level up without disabling other promotions?

I'd have to first make it and then test it. Don't have time for either atm. I might do it later if I don't have anything better to do :p
(In other words I'll problably do it in <5h :undecide:)
 
This is a very easy change so I'll just paste the code here. However with the way I did it you need to paste it in three places - when a unit wins combat, when a unit is promoted and when a unit is built. You can remove everything after # if you want to since that's just comments.

All of these goes into CvEventManager.py and the function I mention. Put it before you see something like this:
Code:
(not self.__LOG_SOMETHING):
[tab]return

This goes to onCombatResult:
Code:
if pWinner.experienceNeeded() - pWinner.getExperience() <= 0 and pWinner.getLevel() <= 5: #Checking if the unit have enough XP for promotion. Also checking if level is over 5. Change the 5 to whatever is the highest PROMOTION_COMBATX there is.
[tab]pWinner.setHasPromotion(gc.getInfoTypeForString('PROMOTION_COMBAT' + str(pWinner.getLevel())), True) #Giving the unit the promotion for it's level (level 1 get combat 1 etc). Note that this checks what level it IS, not what level it will be after promoting. Also note that this promotion does not increase the level.

This goes under onUnitBuild:
Code:
if unit.experienceNeeded() - unit.getExperience() <= 0 and unit.getLevel() <= 5: #Checking if the unit have enough XP for promotion. Also checking if level is over 5. Change the 5 to whatever is the highest PROMOTION_COMBATX there is.
[tab]unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_COMBAT' + str(unit.getLevel())), True) #Giving the unit the promotion for it's level (level 1 get combat 1 etc). Note that this checks what level it IS, not what level it will be after promoting. Also note that this promotion does not increase the level.

And finally this goes under onUnitPromoted:
Code:
if pUnit.experienceNeeded() - pUnit.getExperience() <= 0 and pUnit.getLevel() <= 5: #Checking if the unit have enough XP for promotion. Also checking if level is over 5. Change the 5 to whatever is the highest PROMOTION_COMBATX there is.
[tab]pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_COMBAT' + str(pUnit.getLevel())), True) #Giving the unit the promotion for it's level (level 1 get combat 1 etc). Note that this checks what level it IS, not what level it will be after promoting. Also note that this promotion does not increase the level.

Remember: indention is important in python.
 
Neat idea!
One question though: what about the units for agressive civs that already have Combat 1?

-RdF

p.s. Ok, I lied, 2 questions. What about units that start out with enough experience to advance?
 
roidesfoux said:
What about the units for agressive civs that already have Combat 1?

What about units that start out with enough experience to advance?

Combat promotions simply unlock the other promotions (in addition to their basic strenght bonus) so units starting with Combat 1 can get other promotions instantly. That's the way it would go if no other changes were made at least, but I'm not excluding anything if balancing is needed.

I haven't tested snarko's code yet (just woke up :blush: ) so I'm not sure how it works in the game, but I'm assuming and hoping that units that start with enough experience would promote with the next Combat level automatically. But I'll have to test and see.
 
Back
Top Bottom