cannotResearch causes OS lockup

Joined
Oct 20, 2007
Messages
470
Location
Spokane, WA
Goal:

I want players to select an unfounded religion after researching monument (fka: obelisk) before proceeding to monastery.

Implementation:

Ideally, I'd like to use the "choose religion" popup, but don't know how to modify it. So I created a tech for each religion with the idea of setting obelisk as the OrPreReq for each religion tech, then monastery with each religion tech as an OrPreReq. ie: monument tech => 7 religion techs => monastery tech. Turns out the game can't handle that many OrPreReqs on the monastery tech, so I removed all OrPreReqs and am doing it by modifying the "cannotResearch" python def to selectively disable and enable as needed.

I've written the code to only allow players to research one religion tech until they have all been founded, at which point, players can go straight from the obelisk tech to the monastery tech. I clear the research queue when a player is researching a religion tech that gets founded by another player.

Example:

Step 1 - can research obelisk; can not research any religion tech; can not research monastery.

Step 2 - researched obelisk; can research any unfounded religion tech; can not research any founded religion tech; can not research monastery. OR... researched obelisk; all religions founded; can not research any religion tech; can research monastery.

Step 3 - researched obelisk; researched one religion tech; can not research any other religion tech; can research monastery.

Working:

All disable and enable functionality.

Problem:

Shortly after two religions have been founded, the screen display becomes micro-jittery. A couple turns later, major pauses in interface and mouse control, followed by hard drive grinding and eventual lockup of the operating system. Upon reboot, bios and boot drive warnings. Upon second reboot, boots to the desktop.

Code:

Code:
	def cannotResearch(self,argsList):
		ePlayer = argsList[0]
		eTech = argsList[1]
		bTrade = argsList[2]
		pPlayer = gc.getPlayer( ePlayer )
		pTeam = gc.getTeam( pPlayer.getTeam() )
		
		bHasObelisk = pTeam.isHasTech( gc.getInfoTypeForString('TECH_OBELISK'))
		bHasBuddhism = pTeam.isHasTech( gc.getInfoTypeForString('TECH_BUDDHISM'))
		bHasHinduism = pTeam.isHasTech( gc.getInfoTypeForString('TECH_HINDUISM'))
		bHasJudaism = pTeam.isHasTech( gc.getInfoTypeForString('TECH_JUDAISM'))
		bHasConfucianism = pTeam.isHasTech( gc.getInfoTypeForString('TECH_CONFUCIANISM'))
		bHasToaism = pTeam.isHasTech( gc.getInfoTypeForString('TECH_TAOISM'))
		bHasChristianity = pTeam.isHasTech( gc.getInfoTypeForString('TECH_CHRISTIANITY'))
		bHasIslam = pTeam.isHasTech( gc.getInfoTypeForString('TECH_ISLAM'))
		
		bReligious = False
		if(bHasBuddhism or bHasHinduism or bHasJudaism or bHasConfucianism or bHasToaism or bHasChristianity or bHasIslam):
			bReligious = True
		
		bBuddhism = gc.getGame().isReligionFounded( gc.getInfoTypeForString('RELIGION_BUDDHISM'))
		bHinduism = gc.getGame().isReligionFounded( gc.getInfoTypeForString('RELIGION_HINDUISM'))
		bJudaism = gc.getGame().isReligionFounded( gc.getInfoTypeForString('RELIGION_JUDAISM'))
		bConfucianism = gc.getGame().isReligionFounded( gc.getInfoTypeForString('RELIGION_CONFUCIANISM'))
		bToaism = gc.getGame().isReligionFounded( gc.getInfoTypeForString('RELIGION_TAOISM'))
		bChristianity = gc.getGame().isReligionFounded( gc.getInfoTypeForString('RELIGION_CHRISTIANITY'))
		bIslam = gc.getGame().isReligionFounded( gc.getInfoTypeForString('RELIGION_ISLAM'))
		
		bFaithFull = False
		if(bBuddhism and bHinduism and bJudaism and bConfucianism and bToaism and bChristianity and bIslam):
			bFaithFull = True
		
		if(bBuddhism and pPlayer.isResearchingTech( gc.getInfoTypeForString('TECH_BUDDHISM'))):
			pPlayer.clearResearchQueue()
		if(bHinduism and pPlayer.isResearchingTech( gc.getInfoTypeForString('TECH_HINDUISM'))):
			pPlayer.clearResearchQueue()
		if(bJudaism and pPlayer.isResearchingTech( gc.getInfoTypeForString('TECH_JUDAISM'))):
			pPlayer.clearResearchQueue()
		if(bConfucianism and pPlayer.isResearchingTech( gc.getInfoTypeForString('TECH_CONFUCIANISM'))):
			pPlayer.clearResearchQueue()
		if(bToaism and pPlayer.isResearchingTech( gc.getInfoTypeForString('TECH_TAOISM'))):
			pPlayer.clearResearchQueue()
		if(bChristianity and pPlayer.isResearchingTech( gc.getInfoTypeForString('TECH_CHRISTIANITY'))):
			pPlayer.clearResearchQueue()
		if(bIslam and pPlayer.isResearchingTech( gc.getInfoTypeForString('TECH_ISLAM'))):
			pPlayer.clearResearchQueue()
		
		if(eTech == gc.getInfoTypeForString('TECH_BUDDHISM')):
			if(not bHasObelisk or bReligious):
				return True
			else:
				return bBuddhism
		if(eTech == gc.getInfoTypeForString('TECH_HINDUISM')):
			if(not bHasObelisk or bReligious):
				return True
			else:
				return bHinduism
		if(eTech == gc.getInfoTypeForString('TECH_JUDAISM')):
			if(not bHasObelisk or bReligious):
				return True
			else:
				return bJudaism
		if(eTech == gc.getInfoTypeForString('TECH_CONFUCIANISM')):
			if(not bHasObelisk or bReligious):
				return True
			else:
				return bConfucianism
		if(eTech == gc.getInfoTypeForString('TECH_TAOISM')):
			if(not bHasObelisk or bReligious):
				return True
			else:
				return bToaism
		if(eTech == gc.getInfoTypeForString('TECH_CHRISTIANITY')):
			if(not bHasObelisk or bReligious):
				return True
			else:
				return bChristianity
		if(eTech == gc.getInfoTypeForString('TECH_ISLAM')):
			if(not bHasObelisk or bReligious):
				return True
			else:
				return bIslam
		
		if(eTech == gc.getInfoTypeForString('TECH_MONASTERY')):
			if(not bReligious and not bFaithFull):
				return True
		
		return False
 
First, it sounds like you are getting Python exceptions from this callback. Look in My Games / BTS / Logs for PythonErr.log.

Second, can you explain more clearly what it is you want to have happen? It sounds like you want Mysticism to found a religion just like the other religious techs. Why not just specify that in the XML? Mysticism is already a prereq for all the religious techs, so I don't understand the need for the extra prereqs.

Finally, you keep mentioning Monument/Obelisk and Monastery. Do you mean the techs that make these buildings available? I ask because you write, "can not research any other religion tech; can research monastery," but the tech that enables Monasteries is a religious tech. :confused:
 
Basically, I'm trying to make the players choose a religion until all the religions have been founded. It's not the same as current religion founding because I want to allow multiple players to choose a religion at the same point in the tech tree, but not be able to found more than one per player.

Actually, I think it was more clear the way I said it the first time.

For other reasons, I have created techs called "obelisk" and "monastery", which allow for those building. In essence, obelisk leads to founding one religion for each player and only one religion for each player until all religions are founded. Only once a player has founded a religion, or until all religions are founded, can that player research monastery.

It's actually really clear in the provided code. The code itself works. The problem simply comes along for the ride, and I don't know why.
 
The only immediate problem I can see is that clearing the research queue may cause issues from this function. For one thing, it only needs to be cleared once a founding tech is completed, right? If so, I would do all the checks that clear the queue inside onTechAcquired().

Other than that, this function could be cleaned up a bit to be a) more generic and b) faster, but I don't think this would be causing the issues you are seeing.
 
Make sure you're reading the PythonErr.log file without the 2 in the name. Post it (or a snippet if seems to be repeating itself) and maybe we can spot something.
 
Okay, i know it's completly to late, but in Assets\XML\GlobalDefines.xml:

PHP:
<Define>
		<DefineName>NUM_OR_TECH_PREREQS</DefineName>
		<iDefineIntVal>4</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>NUM_AND_TECH_PREREQS</DefineName>
		<iDefineIntVal>4</iDefineIntVal>
	</Define>
 
Top Bottom