[Python] Need help with custom random events

pPlayer.revolution (CivicTypes paeNewCivics, bool bForce )

So it would be something like that ( let's say there are 4 different civic type with 6 civic in ) . that's done :

pPlayer.revolution ( (0,2,5,1) , True )

or

iCivicType0 = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_PACIFISM')
iCivicType1 = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_SOMETHING')
iCivicType2 = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_SOMETHING')
iCivicType3 = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_SOMETHING')

pPlayer.revolution ( (iCivicType0, iCivicType1, iCivicType2, iCivicType3) , True )

you must define the civic for each civic type in the order of the civic type even if they are unchanged .

Tcho !


Ahhh...I see, so you'd have to actually specify every single civic if you're using "revolution". That will work with what I was planning in a random event, but it isn't as elegant as I'd hoped for. I think I'd better figure out how to trigger a turn or two of anarchy in addition to "setCivic". (Maybe "setOccupationTimer"?)
 
Ahhh...I see, so you'd have to actually specify every single civic if you're using "revolution". That will work with what I was planning in a random event, but it isn't as elegant as I'd hoped for. I think I'd better figure out how to trigger a turn or two of anarchy in addition to "setCivic". (Maybe "setOccupationTimer"?)
Yes you have to specify all civics. But you can specify that some of them should be the same as before.

So if you want to only change to pacifism, ignoring the rest, you could use
Code:
iCivicType0 = pPlayer.getCivics(CivicOptionTypes.CIVICOPTION_GOVERNMENT)
iCivicType1 = pPlayer.getCivics(CivicOptionTypes.CIVICOPTION_LEGAL)
iCivicType2 = pPlayer.getCivics(CivicOptionTypes.CIVICOPTION_LABOR)
iCivicType3 = pPlayer.getCivics(CivicOptionTypes.CIVICOPTION_ECONOMY)
iCivicType4 = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCi vicInfos(),'CIVIC_PACIFISM')

pPlayer.revolution ( (iCivicType0, iCivicType1, iCivicType2, iCivicType3, iCivicType4) , True )
 
Interesting. I tried the above code, however, and it did not trigger a revolution to Pacifism.

I also tried the following variant (attempting to trigger a revolution to Hereditary Rule), and it did not work, either:

Code:
        iEvent = argsList[0]
        kTriggeredData = argsList[1]
        pPlayer = gc.getPlayer(kTriggeredData.ePlayer)
        iCivicType0 = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_HEREDITARY_RULE')
        iCivicType1 = pPlayer.getCivics(CivicOptionTypes.CIVICOPTION_LEGAL)
        iCivicType2 = pPlayer.getCivics(CivicOptionTypes.CIVICOPTION_LABOR)
        iCivicType3 = pPlayer.getCivics(CivicOptionTypes.CIVICOPTION_ECONOMY)
        iCivicType4 = pPlayer.getCivics(CivicOptionTypes.CIVICOPTION_RELIGION)
        
        pPlayer.revolution ((iCivicType0, iCivicType1, iCivicType2, iCivicType3, iCivicType4), True)

I also tried altering the CivicOption variables, and that didn't work, either:

Code:
        iEvent = argsList[0]
        kTriggeredData = argsList[1]
        pPlayer = gc.getPlayer(kTriggeredData.ePlayer)
        iCivicType0 = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_HEREDITARY_RULE')
        iCivicType1 = pPlayer.getCivics(gc.getCivicOptionInfo,gc.getNumCivicOptionInfos(),'CIVICOPTION_LEGAL')
        iCivicType2 = pPlayer.getCivics(gc.getCivicOptionInfo,gc.getNumCivicOptionInfos(),'CIVICOPTION_LABOR')
        iCivicType3 = pPlayer.getCivics(gc.getCivicOptionInfo,gc.getNumCivicOptionInfos(),'CIVICOPTION_ECONOMY')
        iCivicType4 = pPlayer.getCivics(gc.getCivicOptionInfo,gc.getNumCivicOptionInfos(),'CIVICOPTION_RELIGION')
        
        pPlayer.revolution ((iCivicType0, iCivicType1, iCivicType2, iCivicType3, iCivicType4), True)
 
I even tried just specifying every civic, and it still didn't work.

Code:
        iEvent = argsList[0]
        kTriggeredData = argsList[1]
        pPlayer = gc.getPlayer(kTriggeredData.ePlayer)
        iCivicType0 = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_HEREDITARY_RULE')
        iCivicType1 = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_BARBARISM')
        iCivicType2 = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_SLAVERY')
        iCivicType3 = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_DECENTRALIZATION')
        iCivicType4 = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_PAGANISM')
        
        pPlayer.revolution((iCivicType0, iCivicType1, iCivicType2, iCivicType3, iCivicType4), True)
 
Go to the BtS directory, open the _Civ4Config shortcut and change
HidePythonExceptions = 1 to HidePythonExceptions = 0. After that you should get a message about what's wrong.
 
Go to the BtS directory, open the _Civ4Config shortcut and change
HidePythonExceptions = 1 to HidePythonExceptions = 0. After that you should get a message about what's wrong.

Thanks. Thought I'd enabled all the debugging stuff, didn't know that one existed. :goodjob:
 
This is what I got. I was trying to use the most recent script, where I was just specifying each individual civic. The name of the random event is "CROSSING_THE_RUBICON" (here, trying to apply event script "CrossingTheRubicon3", which would trigger the revolution/civics change.)


Code:
Traceback (most recent call last):

  File "CvRandomEventInterface", line 4307, in applyCrossingTheRubicon3

ArgumentError: Python argument types in
    CyPlayer.revolution(CyPlayer, tuple, bool)
did not match C++ signature:
    revolution(class CyPlayer {lvalue}, int, bool)
ERR: Python function applyCrossingTheRubicon3 failed, module CvRandomEventInterface
Traceback (most recent call last):

  File "CvRandomEventInterface", line 4307, in applyCrossingTheRubicon3

ArgumentError: Python argument types in
    CyPlayer.revolution(CyPlayer, tuple, bool)
did not match C++ signature:
    revolution(class CyPlayer {lvalue}, int, bool)
ERR: Python function applyCrossingTheRubicon3 failed, module CvRandomEventInterface
 
Perhaps a list would work.

If you look at how it's done in the civics screen they used
CyMessageControl().sendUpdateCivics(self.m_paeDisplayCivics)
m_paeDisplayCivics is a list. It is problably better to use this function as it should be more multiplayer friendly.
 
You know, I think I'm going about this in an uptight, wrong-headed way. I'm going to stop beating my head against the "revolution" command. Clearly, Python doesn't want me to use it. Fine. :p

I already know how to force a civics change using setCivics. I also know I can force anarchy by using changeAnarchyturns(#). The only thing I don't know is how to set the "Revolution Timer" (i.e., the timer that locks out civics changes for 5 turns after a revolution is undertaken.)

[I can interrogate the value of the Revolution Timer (getRevolutionTimer()), but I didn't see anything in the API to set the timer.]

The event would be a little more elegant if I could do that....but if there's no VOID for it, I guess I can't, eh?
 
You are correct. The set/change functions for revolutiontimer are not accessible in python.
 
Thanks to everyone's help in this forum, I am almost ready to do a beta release of nine new random events. (No rules changes take place, this will just be an addition of these nine events to the standard events from 3.13).

1.) Battle Lasers (this one is more for NEXTWAR, but it technically takes place within the timeframe of the regular 'vanilla' BtS game, so it will be included here as well.)
2.) Futbol War
3.) Napalm
4.) Reactive Armor
5.) Billions and Billions
6.) Greek Fire (Byzantium/Greece only)
7.) Free Enterprise
8.) Fiat Money
9.) Crossing the Rubicon (Rome/Carthage/Greece only)

It's just a matter of cleaning up the code, double-checking the numbers (making sure everything is balanced for the game,) and proofreading the text for these.

If I have some more free time this week (ha ha!), these other events may be released as well:

10.) Carnation Revolution (Portugal only)
11.) The Generals' Putsch (France only)
12.) Darwin's Voyage
13.) Hoover Dam
14.) Cure for Cancer
15.) Mind Control (for NEXTWAR)
16.) Nanite Protection (for NEXTWAR)

Again, I can't thank all of you enough -- I started up this project last month knowing almost nothing about Python. Now, well, I still don't know much python, but I can sure copy & paste and otherwise beg/borrow/steal code with the best of them now! :)
 
Back
Top Bottom