How do I start a Golden Age with Python?

tsentom1

Bubble Dragon
Joined
Jul 24, 2007
Messages
1,000
Location
New York
EDIT: Nevermind... I figured it out. Thanks anwyay.

I'm really bad at searching the SDK to find vocabulary, if anyone knows the command off hand?

Edit:

I pulled this from CvUnit.cpp:

GET_PLAYER(getOwnerINLINE()).changeGoldenAgeTurns(GET_PLAYER(getOwnerINLINE()).getGoldenAgeLength());

Besides that I could only find isGoldenAge to check if it is a Golden Age. If it's what I posted anyone know the python equivalent?

(If doing so is possible, but I don't see why I wouldn't be able to start a Golden Age with Python)

The broad context is I'm ultimately trying to have someone acquire a free golden age upon being the first to research a specific tech. I can write the python to check if someone is the first to acquire the tech, I just can't then give that player a golden age.
 
The <bGoldenAge> tag in BTS Random Events would have been the easiest solution. With the eventtrigger for being the first to discover a tech, you wouldn't even need Python.

What was your solution?
 
The <bGoldenAge> tag in BTS Random Events would have been the easiest solution. With the eventtrigger for being the first to discover a tech, you wouldn't even need Python.

What was your solution?

Haha, yeah that would have been a good way to do it. I didn't even think about using an event to do it.

Anyway, I found out it's just a simple line of code to start a golden age with python:

pPlayer.changeGoldenAgeTurns( pPlayer.getGoldenAgeLength())

The first to find the tech is easy using ontechacquired, then just have it check all players if anyone else has it.
 
Cool, so you can set a mini-golden age too, like for 5 turns.

Looks like you can. How about having a 1- or 2-turn golden age whenever at least X% of your cities (and at least Y total cities, Z cities happy minimum) love the king at the same time? For example, at least 9 cities total, 25%, 3 minimum.
 
Yeah, mini 1,2,3, etc turn golden ages are easy to do. Just remember to add some code to scale it with game speed.

Looks like you can. How about having a 1- or 2-turn golden age whenever at least X% of your cities (and at least Y total cities, Z cities happy minimum) love the king at the same time? For example, at least 9 cities total, 25%, 3 minimum.

Not a bad idea. Off hand running a check for that with onBeginPlayerturn should work. Though I never really understood how "we love the king" was determined, if it was set factors or just random.
 
Though I never really understood how "we love the king" was determined, if it was set factors or just random.

A little of both. From memory, though the rules are pretty straight-forward in the code IIRC:

  • No unhappiness
  • No unhealthiness
  • Minimum size (3, 5?)
  • If all above true, random chance of celebration
I don't remember seeing what makes it end (fixed length, random, whatever). I would bet that the celebration would end if any of the above changed during it.
 
Top Bottom