Need Help Making Conditional Spawns in RFC

mrrandomplayer

Hopeless Situation Warrior
Joined
Aug 1, 2012
Messages
3,338
Location
The land of prequel memes
I am right now trying to make a modmod for RFC that makes certain civs conditional. I'm a pretty awful programmer and I mostly copy-pasted the DoC conditional spawn coding into the RhyesandFall.py. When I opened it up, I got a bajillion errors, most of them not even in the python file I edited. Could someone please tell me what I did wrong and tell me how to fix it?

From part of the initBirth function:
Code:
def initBirth(self, iCurrentTurn, iBirthYear, iCiv):
                iHuman = utils.getHumanID()
                if (iCurrentTurn == iBirthYear-1 + self.getSpawnDelay(iCiv) + self.getFlipsDelay(iCiv)):

                        if (iCurrentTurn >= con.tBirth[iVikings]-1 and iCurrentTurn <= con.tBirth[iTurkey]-1):
                                self.processConstantinople()
                        if (iCurrentTurn >= con.tBirth[iEngland]-1 and iCurrentTurn <= con.tBirth[iMali]-1):
                                self.processAfrica()
                    
                        tCapital = tCapitals[iCiv]
                        tTopLeft = tCoreAreasTL[iCiv]
                        tBottomRight = tCoreAreasBR[iCiv]
                        tBroaderTopLeft = tBroaderAreasTL[iCiv]
                        tBroaderBottomRight = tBroaderAreasBR[iCiv]                    
                        if (self.getFlipsDelay(iCiv) == 0): #city hasn't already been founded

				# mrrandomplayer: extra checks for conditional civs
				lConditionalCivs = [iSpain, iFrance, iPortugal, iTurkey, iAmerica]
					if iCiv in lConditionalCivs and utils.getHumanID() != iCiv:

					if iCiv == iSpain;
						if iRome in bSpain:
							if utils.getStability(iRome) >= 20:
								return
						else if iCarthage in bSpain:
							if utils.getStability(iCarthage) >= 20:
								return

					if iCiv == iFrance:
						if iRome in tFrance:
							if utils.getStability(iRome) >= 20:
								return

					if iCiv == iPortugal:
						if not pSpain.isAlive:
							return

					if iCiv == iTurkey:
						if utils.getStability(iArabia) >= 20:
							return

					if iCiv == iAmerica:
						iColonyPlayer = utils.getColonyPlayer(iCiv)
						if iColonyPlayer < 0: return
						elif iColonyPlayer not in tNCAmerica:
							if utils.getStability(iColonyPlayer) >= 20:
								return
 
there are some things in your quote that don't make sense, like:

if iRome in bSpain:

what is bSpain? if it is a boolean, as indicated by the "b", then it cannot have anything "in" it. also, you haven't defined bSpain anyway. all those bajillion errors actually need to be read and understood. it doesn't matter which file they are in, many files affect each other.
 
First of all, most errors you see likely come from the file you have edited. The Python exception screen lists all the methods that have been called until the error has been reached, so the lowest entry is where your problem actually is.

Some errors I've seen:

1. You need to indent (add one tab) the code after every if-clause. The general rule is an additional tab for every colon.

2. At least one of your if statements ends with a semicolon which is invalid in Python.

3. As srpt said, bSpain, tFrance etc. doesn't mean anything if you don't define them. You probably want to check if there's a Roman city in Spain etc. For this you need to get all Roman cities and check whether they're within the cores of these civs as defined in Consts.py. DoC has some handy utility methods for these jobs but I think in RFC you mostly have to do this by hand.
 
Back
Top Bottom