Detect Civic Change(s)

Arian

No more ghostbusting!!
Joined
May 10, 2008
Messages
2,088
Location
The Netherlands
Is there a function in Python to detect when a civilization changes its civic(s)?
I did not find it in the CvEventManager.py :(

Think of something like:

def onCivicChanged(self, argsList):
*** CODE ***

or

def onEndRevolution(self, argsList):
*** CODE ***

Someone has a clue?
 
I'm not sure where it is, but it has to be in there. You are definatly alerted when a rival civ you have contact with changes civics. It could of course be in the dll, but I doubt it, as this is more of an interface python thing. I'd wager the BUG people know where it is, as they are always tweaking the interface and must have ran across it; If you don't get directed to it here you might consider asking in the BUG forums.
 
You could do it the old-fashioned way: store the civics of each player at the beginning of the turn and compare the to the previous civics stored last turn.
 
How does Civ4 do it now? Whenever a rival changes civics you get notified... so the interface is making this call somehow...
 
The DLL can display messages in the event log, too. It displays a message for each civic that is changed.
 
You could do it the old-fashioned way: store the civics of each player at the beginning of the turn and compare the to the previous civics stored last turn.

Wouldn't this slow down the game considerably?

I think your best bet would be to go into the SDK and expose that function.
 
Wouldn't this slow down the game considerably?

Slow it down, sure. Considerably, I doubt it. It's a pretty small nested loop that runs only once per turn. Cases where you bribe a rival to swap civics won't trigger until your next turn.

I think your best bet would be to go into the SDK and expose that function.

Definitely, but Arian said he doubted he could use SDK changes. I don't know exactly what that means, though.
 
Slow it down, sure. Considerably, I doubt it. It's a pretty small nested loop that runs only once per turn. Cases where you bribe a rival to swap civics won't trigger until your next turn.



Definitely, but Arian said he doubted he could use SDK changes. I don't know exactly what that means, though.

If it would be exposed in Python via the CvEventManager.py I can probably use it (and a lot of other modders too I think)!
 
Any Idea what functions need to be exposed? I mean specifically, what are the calls the SDK makes when civics change?
 
If it would be exposed in Python via the CvEventManager.py I can probably use it (and a lot of other modders too I think)!

Any Idea what functions need to be exposed? I mean specifically, what are the calls the SDK makes when civics change?

The easiest solution is to fire a new event in CvPlayer::setCivics() passing the player ID, civic option type and civic type.

playerChangeCivics ( PlayerTypes , CivicOptionTypes , CivicTypes )​

The downside is that multiple civics changes that occur together would be reported with separate events--just like the on-screen messages. To rectify this we'd need to fire an event from CvPlayer::revolution() if we can pass a tuple from C++ to Python.

playerRevolution ( PlayerTypes , int iAnarchyLength , CivicTypes[] )​
 
That was easier than I expected. I have added the second event form (playerRevolution) that reports the number of turns the player will spend in anarchy and the list of their new civics, including any they didn't change.

I'm tempted to add the list of old civics to make it easier for modders to find which ones changed. I would like to get some feedback on this event before I commit it to SVN.
 
That was easier than I expected. I have added the second event form (playerRevolution) that reports the number of turns the player will spend in anarchy and the list of their new civics, including any they didn't change.

I'm tempted to add the list of old civics to make it easier for modders to find which ones changed. I would like to get some feedback on this event before I commit it to SVN.

Awesome. I was thinking that this was a BULL worthy addition, but It's nice that you did the work.

I think adding the old list of civics might be important, so I would want them, but that's just me.
 
Right now I fire the event before switching civics, but I think it would be more helpful to record the old civics, switch, and then fire the event with both the old and new civics. It makes more sense to me that modders will want to do something after the civics have been changed.
 
Yes, I added a playerRevolution event to BULL. It passes the player's ID, turns of anarchy, and two arrays holding the old and new civics. Check out the release of BULL 1.0 for details (see my sig).
 
I have no time to package individual BULL features as separate modcomps. I comment all my code with markers for each feature to make it easier for modders to extract what they want.
 
Back
Top Bottom