Help with a FfH2 Worldspell

Sir Falstaff

Chieftain
Joined
Feb 7, 2010
Messages
10
My apologies if this is in the wrong place, but the issue is python-related so I figured I'd be most likely to get help here.

I'm modding FfH2, trying to add a few civilizations to the mix geared toward the playing styles of myself and some friends. One of the Civs is basically a civilization of revolutionaries out to break down the old order. I thought it would be appropriate to give them a worldspell that causes all the other Civs' cities to break out into revolt.

Problem is, I don't really know what I'm doing.

I figured at first I could take the River of Blood spell, which reduces all non-vampire cities' population by 2, and just switch out the commands. Problem is, when I did that, it doesn't actually do anything.

Here's the code. Can someone here show me where I went wrong? And hopefully how to fix it?

Code:
def spellFortheRevolution(caster):
	iOwner = caster.getOwner()
	for iPlayer in range(gc.getMAX_PLAYERS()):
		pPlayer = gc.getPlayer(iPlayer)
		if pPlayer.isAlive():
			if iPlayer != iOwner:
				for pyCity in PyPlayer(iPlayer).getCityList() :
					pCity = pyCity.GetCy()
						pCity.setOccupationTimer(4)
						CyInterface().addMessage(pCity.getOwner(),True,25,CyTranslator().getText("TXT_KEY_MESSAGE_FOR_THE_REVOLUTION", ()),'',1,'Art/Interface/Buttons/Spells/For the Revolution.dds',ColorTypes(7),pCity.getX(),pCity.getY(),True,True)

...like I said, I don't really know what I'm doing here. :confused:
 
Please enable the python exceptions first:
In My Documents\My Games\BtS\Civilization4.ini change
PHP:
; Set to 1 for no python exception popups
HidePythonExceptions = 1

to 0 and tell us if it throws an exception after clicking on the spell button.


Else the question: Do you know any kind of programming, or really nothing?
 
Actually, it throws up an exception even before I hit the spell button. Says pCity.setOccupationTimer(4) is causing a syntax error.

And no, what little programming experience I have is so far back in the mists of time, it's really not worth mentioning.
 
Well, only basic programming skills would be needed for understanding the problem. E.g. if you know what an if clause is, what a for loop does, and how {} and ; are used other programming languages would be enough to explain you, where the problem here is.
So if you can answer that with yes, then i could elaborate the problem.
But first to the important thing, how to fix it:
Do you see the indentation in the code? Then i have to tell you: It matters. Indent the last 2 lines in the same way like the line before, so one tabulator less, and it should hopefully work.
 
Ah, yeah, I remember that much about programming languages; IIRC, curly brackets tend to be used as BEGIN and END, and a semicolon in C is used to tell the compiler that it's reached the end of a command. I also know how if-then clauses work.

I reduced the indentation like you said, and that got rid of the syntax error, but it still doesn't do anything - no cities go into revolt when it's used.
 
Does the message for the spell pop up fine, or does that not show either? (This might help find where the problem is.)


Ah, yeah, I remember that much about programming languages; IIRC, curly brackets tend to be used as BEGIN and END, and a semicolon in C is used to tell the compiler that it's reached the end of a command. I also know how if-then clauses work.

This stuff changes from language to language, actually. Can sometimes be a pain to figure put.
 
No, the only message that appears is "A player has cast For the Revolution." No list of cities, unlike the spell on which this one is based.
 
If the message works, but no cities are effected, it would mean that a good place to start looking for the code problem would be in the code that actually sets off the revolts, or possibly in the city selection code. (Or I may be misunderstanding the problem, but those two possibilities are where I'd probably start looking.)


If you google the civilization 4 python API, what does it show for the "setOccupationTimer" function? (Which category it is in, what it says, what values it takes/gives out, etc.) I' guessing it was copy-pasted from somewhere else, which usually works fine, but sometimes create issues with different variable names and types, missing single lines of code, etc.
 
Back
Top Bottom