Forcing war via python

civfan11596

Chieftain
Joined
Feb 1, 2011
Messages
28
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)

However, this isn't working. I've tried some other things but no luck there either. Any suggestions?
 
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.
 
I'm not getting any errors.

New 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)
I don't understand why its not working..
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)
 
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.
 
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.

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?
 
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?*
 
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?*

Yeah, basically. I could make a call, but isn't importing it the same thing? (I understand calls though, I just want to make sure it works before I make one.)
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
 
This isn't a function call:
Code:
War.GRMNdowUSSR
Its just a reference to a name - the name of the function. A function call has parenthesis with the arguments (in this case none):
Code:
War.GRMNdowUSSR[B]()[/B]
 
This isn't a function call:
Code:
War.GRMNdowUSSR
Its just a reference to a name - the name of the function. A function call has parenthesis with the arguments (in this case none):
Code:
War.GRMNdowUSSR[B]()[/B]

I have that, I just forgot to copy it :p
 
Top Bottom