| General | Hosted Sites | Civ5 | CivRev | Civ4Col | Civ4 | Civ3 | Civ2 | Civ1 | Misc | Marketplace |
![]() |
|
|
Welcome to Civilization Fanatics' Center. You are currently viewing our site as a guest which gives you limited access to our site features. By joining our free community, you will be able to participate in the discussions, search the forum, send private messages, vote in polls, upload your own screenshots to the gallery, and access many other special features. Registration is fast, simple and absolutely free, so sign up today! If you have any problems with the registration process or your account login, please contact support. |
|
|||||||
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Chieftain
Join Date: Feb 2011
Posts: 28
|
Forcing war via python
My goal was to be able to script when a civ would declare war on another civ fro my scenario mod I'm making. After looking through the API and some other mods for some guidance, I made this:
Code:
## Sid Meier's Civilization 4 ## Copyright Firaxis Games 2005 from CvPythonExtensions import * gc = CyGlobalContext() def GRMNdowUSSR(): gc.getTeam(1).declareWar(0, false, WarPlanTypes.WARPLAN_TOTAL) Last edited by civfan11596; Mar 11, 2011 at 04:10 PM. |
|
|
|
|
|
#2 |
|
Deity
Join Date: Apr 2008
Location: California
Posts: 4,727
|
Is GRMNdowUSSR() ever called by some other code you wrote?
__________________
Come see the Fury Road sub-forum! Everybody wants post-apocalyptic desert warfare with crossbows! |
|
|
|
|
|
#3 |
|
"Hit It"
Join Date: Dec 2009
Location: Sweden
Posts: 5,530
|
I'm don't know if the sample code is complete or not, but what class instance is the name self referring to?
If you enable Python exceptions in CivilizationIV.ini you should be able to pinpoint the issue you're experiencing. Make sure pop-ups are enabled so that you can't miss it.
__________________
How to Make a Python Mod - Python modding tutorial CivIV Python Class Reference - modding Python API How to Think Like a Computer Scientist - online Python textbook CivPlayer - Python scripting tool Spoiler:
|
|
|
|
|
|
#4 | |
|
Chieftain
Join Date: Feb 2011
Posts: 28
|
I'm not getting any errors.
New Code: Quote:
in the API this is the entry for the declare war instance: declareWar (TeamType eTeam, BOOL bNewDiplo, WarPlanType eWarPlan) which is what I did besides adding the gc.getTeam(1) |
|
|
|
|
|
|
#5 |
|
Deity
Join Date: Apr 2008
Location: California
Posts: 4,727
|
I am not sure if you have done any programming in python before. You are declaring a function. You are never calling the function. You need to make sure that this function is called at some point when the game is running, for example during startplayerturn.
__________________
Come see the Fury Road sub-forum! Everybody wants post-apocalyptic desert warfare with crossbows! |
|
|
|
|
|
#6 |
|
Chieftain
Join Date: Feb 2011
Posts: 28
|
Right now I'm just starting the game, going into the python console and hitting "import War" (no quotations) into the console I know how to call the function, I just haven't. Does this effect it?
|
|
|
|
|
|
#7 |
|
Deity
Join Date: Apr 2008
Location: California
Posts: 4,727
|
Sorry, let me make sure I understand. You define a function. You import the function. You never call the function. And you don't understand why the function effect does not happen. Is there a part I am missing?
*Does anything happen when you call the function?*
__________________
Come see the Fury Road sub-forum! Everybody wants post-apocalyptic desert warfare with crossbows! |
|
|
|
|
|
#8 | |
|
Chieftain
Join Date: Feb 2011
Posts: 28
|
Quote:
Let me try. edit*** Nothing. Here's the entry in the Event Manager Code:
def onBeginGameTurn(self, argsList):
'Called at the beginning of the end of each turn'
iGameTurn = argsList[0]
CvTopCivs.CvTopCivs().turnChecker(iGameTurn)
###Downfall
if iGameTurn == 10:
War.GRMNdowUSSR
Last edited by civfan11596; Mar 12, 2011 at 01:32 PM. |
|
|
|
|
|
|
#9 |
|
"Hit It"
Join Date: Dec 2009
Location: Sweden
Posts: 5,530
|
This isn't a function call:
Code:
War.GRMNdowUSSR Code:
War.GRMNdowUSSR()
__________________
How to Make a Python Mod - Python modding tutorial CivIV Python Class Reference - modding Python API How to Think Like a Computer Scientist - online Python textbook CivPlayer - Python scripting tool Spoiler:
|
|
|
|
|
|
#10 |
|
Chieftain
Join Date: Feb 2011
Posts: 28
|
|
|
|
|
|
|
#11 |
|
Say No 2 Net Validations
![]() ![]() |
Are the python exceptions enabled?
|
|
|
|
![]() |
| Bookmarks |
|
| Thread Tools | |
|
|