View Full Version : Detect Civic Change(s)
Arian Sep 27, 2009, 01:52 PM 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?
phungus420 Sep 27, 2009, 02:27 PM 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.
The_J Sep 27, 2009, 04:43 PM No, this event is not exposed to python :(.
If it was, the civics could be modified much better.
But Dom Pedro has exposed this and some other callbacks with a SDK modification (see here (http://forums.civfanatics.com/showthread.php?t=328626)).
Arian Sep 28, 2009, 03:02 AM No, this event is not exposed to python :(.
If it was, the civics could be modified much better.
But Dom Pedro has exposed this and some other callbacks with a SDK modification (see here (http://forums.civfanatics.com/showthread.php?t=328626)).
Thanks, but I doubt if I can use this.
EmperorFool Sep 28, 2009, 03:32 AM 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.
phungus420 Sep 28, 2009, 04:29 AM How does Civ4 do it now? Whenever a rival changes civics you get notified... so the interface is making this call somehow...
EmperorFool Sep 28, 2009, 05:39 AM The DLL can display messages in the event log, too. It displays a message for each civic that is changed.
Afforess Sep 28, 2009, 08:00 AM 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.
EmperorFool Sep 28, 2009, 03:44 PM 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.
Arian Sep 28, 2009, 04:46 PM 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)!
Afforess Oct 02, 2009, 04:25 PM Any Idea what functions need to be exposed? I mean specifically, what are the calls the SDK makes when civics change?
EmperorFool Oct 02, 2009, 05:55 PM 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[] )
EmperorFool Oct 02, 2009, 08:18 PM 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.
Afforess Oct 02, 2009, 08:38 PM 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.
EmperorFool Oct 02, 2009, 09:47 PM 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.
Arian Nov 16, 2009, 06:19 AM Any progress?
EmperorFool Nov 17, 2009, 03:54 AM 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).
Arian Nov 17, 2009, 04:48 AM 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).
Any chance of releasing this as a standalone modcomp?
Afforess Nov 17, 2009, 06:13 AM Any chance of releasing this as a standalone modcomp?
Why wouldn't you just want to use all of BULL? It's a great mod, and it's very very handy.
EmperorFool Nov 17, 2009, 09:02 PM 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.
|
|