• We are currently performing site maintenance, parts of civfanatics are currently offline, but will come back online in the coming days. For more updates please see here.

Second golden age instead of UHV

Kalina

Just lurking...
Joined
Sep 29, 2008
Messages
536
Location
Łódź, Poland
Hi,

I (like we all here ;>) really love UHV concept but recently wanted to play all the way till end with one civ, but still trying to achieve civ's historical goals. I know I can turn off UHVs but is it possible to easily (I mean XML/python) mod game, so when I achieve third goal I get second golden age instead of winning game ?
 
I agree. But a golden age is to little.

What I think would be fun is if someone could code it so that after the UHV is achieved you don't win. But instead your civilization becomes unable to collapse (immune to any sort of bad stability in total) thus allowing you to play the game for fun from that point.
 
Disabling victory is rather easy. Open Victory.py and search for the following bit of code:
Code:
                        if (gc.getGame().getWinner() == -1):                              
                                if (self.getGoal(iPlayer, 0) == 1 and self.getGoal(iPlayer, 1) == 1 and self.getGoal(iPlayer, 2) == 1):
                                        gc.getGame().setWinner(iPlayer, 7) #Historical Victory
Place # symbols at the beginning of each line (this will cause the code to ignore them and is better than outright deleting in case you want to re-enable the old mechanic).

If you want it to trigger another golden age, change it to the following instead:
Code:
                        if (gc.getGame().getWinner() == -1):                              
                                if (self.getGoal(iPlayer, 0) == 1 and self.getGoal(iPlayer, 1) == 1 and self.getGoal(iPlayer, 2) == 1):
                                        pPlayer = gc.getPlayer(iPlayer)
                                        pPlayer.changeGoldenAgeTurns(pPlayer.getGoldenAgeLength())

Making collapsing impossible is a little bit more complicated, you'd have to save somewhere that a civ has achieved 3/3 goals and check that before you trigger a collapse in Stability.py (or was it RiseAndFall.py? Not sure).
 
Now that Golden Ages prevent collapse, could that piece of code not be hijacked for this?
 
It's just another if-clause at the right place. One just has to find that place and implement a way to convey that one player has achieved all three goals.
 
You're welcome :)
 
I agree. But a golden age is to little.

What I think would be fun is if someone could code it so that after the UHV is achieved you don't win. But instead your civilization becomes unable to collapse (immune to any sort of bad stability in total) thus allowing you to play the game for fun from that point.
Try this (Stability.py):
Spoiler :
Code:
        def checkImplosion(self, iGameTurn):
    
                if (iGameTurn > con.i350BC and iGameTurn % 10 == 5):
                        for iPlayer in range(iNumPlayers):
                                if (gc.getPlayer(iPlayer).isAlive() and iGameTurn >= con.tBirth[iPlayer] + 25 and not gc.getPlayer(iPlayer).isGoldenAge()):
                                        if (self.getStability(iPlayer) < -40): #civil war
                                                
[B]                                                scriptDict = pickle.loads( gc.getGame().getScriptData() )
                                                if scriptDict[lGoals][iPlayer][0] == scriptDict[lGoals][iPlayer][1] == scriptDict[lGoals][iPlayer][2] == 1: return[/B]

                                                print ("COLLAPSE: CIVIL WAR", gc.getPlayer(iPlayer).getCivilizationAdjective(0))                                                        
                                                if (iPlayer != utils.getHumanID()):
                                                        if (gc.getPlayer(utils.getHumanID()).canContact(iPlayer)):
                                                                CyInterface().addMessage(utils.getHumanID(), False, con.iDuration, gc.getPlayer(iPlayer).getCivilizationDescription(0) + " " + \
                                                                                                    CyTranslator().getText("TXT_KEY_STABILITY_CIVILWAR", ()), "", 0, "", ColorTypes(con.iRed), -1, -1, True, True)
                                                        if (iGameTurn < con.i1400AD):
                                                                utils.pickFragmentation(iPlayer, iIndependent, iIndependent2, iBarbarian, False)
                                                        else:
                                                                utils.pickFragmentation(iPlayer, iIndependent, iIndependent2, -1, False)
                                                else:
                                                        if (gc.getPlayer(iPlayer).getNumCities() > 1):
                                                                CyInterface().addMessage(iPlayer, True, con.iDuration, CyTranslator().getText("TXT_KEY_STABILITY_CIVILWAR_HUMAN", ()), "", 0, "", ColorTypes(con.iRed), -1, -1, True, True)
                                                                utils.pickFragmentation(iPlayer, iIndependent, iIndependent2, -1, True)
                                                                utils.setStartingStabilityParameters(iPlayer)
                                                                self.setGNPold(iPlayer, 0)
                                                                self.setGNPnew(iPlayer, 0)
                                                                
                                                return
It only disables collapses due to bad (less than -40) stability with all UHV goals reached.
 
Finally I can conquer all of Europe with Germany and keep playing.
Thanks!

Now if you excuse me. I have a meeting with Poland. ;)
 
What are the other causes of collapses?
Losing half of your cities inside some number of turn, losing your capital and losing cities to barbarians, respectively. But I think these other causes only affect the AI though, and there is a time delay built into them all.

Basically the game counts the number of cities every once and awhile. The next time it does it the number of cities is checked against the last recorded value. This causes the delay.
 
Well then. That explains why I have some times taken a capitol and another city and the civ collapses the next turn, and other times I have razed half their cities and am wondering why they are still around.
 
BTW, this code alternation you showed gives someone who achieved 3/3 goals golden age every turn, which means unlimited golden age. I'm not saying it's not a good thing, just unexpected ;)
Yeah, you need to set a custom value in StoredData.py for this... The mod just expanded.
 
You're right - should've been obvious, but that happens when you throw around code without properly testing it :mischief:
 
A rather dirty solution that works without stored data is to set all UHV goals to NO after you've achieved 3/3:
Code:
                        if (gc.getGame().getWinner() == -1):                              
                                if (self.getGoal(iPlayer, 0) == 1 and self.getGoal(iPlayer, 1) == 1 and self.getGoal(iPlayer, 2) == 1):
                                        pPlayer = gc.getPlayer(iPlayer)
                                        pPlayer.changeGoldenAgeTurns(pPlayer.getGoldenAgeLength())
                                        self.setGoal(iPlayer, 0, 0)
                                        self.setGoal(iPlayer, 1, 0)
                                        self.setGoal(iPlayer, 2, 0)
 
A rather dirty solution that works without stored data is to set all UHV goals to NO after you've achieved 3/3:
Nice! :goodjob:
 
The perpetual GA after 3/3 UHV sounds kind of nice, actually.
Since I guess none of the civs ever managed to achieve UHV (some came close), it doesn't sound all that inplausible either. :D

I have a related question - is it possible to make so that if one civ has already 3/3 from UHV, it does not prevent the other civ from getting neither the temporary golden age after 2/3, nor the 3/3 perpetual golden age?

You can talk code.
I'm new to py, but experienced programmer otherwise, so I will manage.
Thanks! :)
 
Back
Top Bottom