Callback help needed

j_mie6

Deity
Joined
Dec 20, 2009
Messages
2,963
Location
Bristol (uni)/Swindon (home)
Hi,

does anybody know what these callbacks in CvGameUtils do?

Code:
	def doHolyCity(self):
		return False

	def doHolyCityTech(self,argsList):
		eTeam = argsList[0]
		ePlayer = argsList[1]
		eTech = argsList[2]
		bFirst = argsList[3]
		return False

	def doReligion(self,argsList):
		pCity = argsList[0]
		return False

	def cannotSpreadReligion(self,argsList):
		iOwner, iUnitID, iReligion, iX, iY = argsList[0]
		return False

I want some code that prevents the founding of a religion untill a certain turn, so I was thinking one of these might be able to do something about it.
 
Why not just attach the religions to later techs?
Edit: Or forbid via python that the techs are researched before X turns.

But @ topic: The first 3 will only allow you to positively override the religion mechanics (so force founding), but not negatively.
Not sure what the last one will do if the religion has not yet been founded.
But I'd also guess that it would cause problems, because it might be that the second researcher of the founding tech will not be able to found it.
 
It's not code for me ;) the request specified that christianity is founded on 0AD (turn 350 in his mod) for I have this code:
Code:
                ## Found Christianity ##
                iTurn = 350
                tHolyCoords = (0,0) #coords of Rome or Jerusalem
                eChrist = gc.getInfoTypeForString("RELIGION_CHRISTIANITY")
                Map = CyMap()
                if iGameTurn == iTurn - 1:
                        iX, iY = tHolyCoords
                        pHolyCity = Map.plot(iX, iY).getPlotCity() 
                        pHolyCity.setHasReligion(eChrist, True, True, True)
                        Game.setHolyCity(eChrist, pHolyCity, True)
                ## Found Christianity ##

for onBeginGameTurn. Just looking for a more lag efficient way... presumeably the first could be used to force (just remove the foundign tech all together)...
 
ah excellent :p good to know I do some good work around here :p
 
If you define your codes under onEndGameTurn, you can just use iGameTurn = 350 rather than 350 - 1.
I find it more accurate when i wanna use anything related to game turns.
Anyway, 1 less step in calculations is definitely better in performance, since this code is going to trigger every turn.

On a side note, it seems that Christianity will be forced to be founded in Rome only. Then what happens if Rome is razed before it is founded? No Christianity forever?
 
probably :p that's a design flaw that would need to be addressed for the designer.

I will move it to on game turn end then thanks!
 
On a side note, it seems that Christianity will be forced to be founded in Rome only. Then what happens if Rome is razed before it is founded? No Christianity forever?

It will likely also throw some errors. I would recommend adding an if pHolyCity != -1: statement before you start trying to do things to pHolyCity
 
Note: You don't need to re-invent the wheel, as I have done half of your work for you. In my limited religions mod, I turned off the founding of religions in the doHolyCity and doHolyCityTech functions in favor of running onTechAcquired, which checks for prerequisite qualifications to found a religion. You could use the onTechAcquired function to specify a prerequisite turn threshold or even an Era that must be met to found a religion. If you use onBeginGameTurn or onEndGameTurn, the code will make a check on every turn, which may slow the game down some. Restricting the founding of a religion to a tech prerequisite limits the check to only those turns, when a tech is discovered; which is significantly fewer than every turn. Just a thought.
 
problem is with that:

the original design specified that Christianity is founded on the year 0AD exactly :p
 
problem is with that:

the original design specified that Christianity is founded on the year 0AD exactly :p

If it has to be on a specified year, then you are left with little choice but to use a Python check on every turn. I just wanted to give you some alternatives.

Cheers.
 
thanks anyway! I will keep it in mind for the future!
 
But what if the starting era starts after 0 AD...
 
Top Bottom