HELP with merging my mod and BUG!!!

Alright, so the wonder still isn't working, I ran the debug and I opened the PythonDbg.log, but it's huge. Is there something I should be looking for particularly? Something I can search for?

I've never really done this before.
 
Check to see if the debug statements you added appear in the log. If they do, follow them until they stop. Figure out where the code broke down by where the logging cut out. If you can't tell where, add more debug statements.
 
Check to see if the debug statements you added appear in the log. If they do, follow them until they stop. Figure out where the code broke down by where the logging cut out. If you can't tell where, add more debug statements.

Okay thanks guys, I assume the debut statements are these:
  • "Unit %d is a missionary for religion %d"
  • "City has correct religion"
  • "Player has less than 6 missionaries"

So I searched for those comments in the PythonDbg.log and none of them were present. So you are saying this means that the code may be fine, but it means that it was never run?

If that is the case does this mean there is an error in the way I entered it? Here is my DiplomacyGameUtils file with the added stuff highlited:

Code:
## Sid Meier's Civilization 4
## Copyright Firaxis Games 2005
##
## Implementaion of miscellaneous game functions

import CvUtil
from CvPythonExtensions import *
import CvEventInterface
[COLOR="Blue"]import BugUtil[/COLOR]

# globals
gc = CyGlobalContext()

class DiplomacyGameUtils:
[COLOR="Blue"]	def canTrain(self,argsList):
		pCity = argsList[0]
		eUnit = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		bIgnoreUpgrades = argsList[5]
## BAMYAN BUDDHA STATUES Start ##
		iMissionary = []
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_JEWISH_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_CHRISTIAN_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ISLAMIC_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_HINDU_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_BUDDHIST_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_CONFUCIAN_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_TAOIST_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_OLYMP_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ASEN_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_VOODOO_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_SHINTO_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ZORO_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_RA_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_TOLTEC_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_SHAMAN_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_LEVANT_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_DRUID_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ANUNNAKI_MISSIONARY'))        
		iMoreMissionariesWonder = CvUtil.findInfoTypeNum(gc.getBuildingInfo,gc.getNumBuildingInfos(),'BUILDING_BAMYAN')
		obsoleteTech = gc.getBuildingInfo(iMoreMissionariesWonder).getObsoleteTech()

		pPlayer = gc.getPlayer(pCity.getOwner())
		NumReligions = 18
		for i in range (NumReligions):
						if eUnit == iMissionary[i]:
								BugUtil.debug("Unit %d is a missionary for religion %d", eUnit, i)
								if pCity.isHasReligion(i):
										BugUtil.debug("City has correct religion")
										pUnit = gc.getUnitInfo (eUnit)
										Class = pUnit.getUnitClassType ()
										MissionaryCount = pPlayer.getUnitClassCount(Class)
										if MissionaryCount <6:
												BugUtil.debug("Player has less than 6 missionaries")
												if (obsoleteTech == -1 or not gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech)):
														for iCity in range(pPlayer.getNumCities()):
																ppCity = pPlayer.getCity(iCity)
																if ppCity.getNumActiveBuilding(iMoreMissionariesWonder) > 0:
																		return True

## BAMYAN BUDDHA STATUES End ##[/COLOR]


		return False 
		
	def cannotConstruct(self,argsList):
		pCity = argsList[0]
		eBuilding = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		
		# player can't build an arcology if they have shielding or advanced shielding
		if eBuilding == gc.getInfoTypeForString("BUILDING_ARCOLOGY"):
			if pCity.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_ARCOLOGY_SHIELDING")) or pCity.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DEFLECTOR_SHIELDING")):
				return True
		
		# player can't build shielding if they have advanced
		if eBuilding == gc.getInfoTypeForString("BUILDING_ARCOLOGY_SHIELDING"):
			if pCity.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DEFLECTOR_SHIELDING")):
				return True

		return False

		
	def getUpgradePriceOverride(self, argsList):
		iPlayer, iUnitID, iUnitTypeUpgrade = argsList
		
## Leonardo's Workshop Start ##

		pPlayer = gc.getPlayer(iPlayer)
		pUnit = pPlayer.getUnit(iUnitID)

		iPrice = gc.getDefineINT("BASE_UNIT_UPGRADE_COST")
		iPrice += (max(0, (pPlayer.getUnitProductionNeeded(iUnitTypeUpgrade) - pPlayer.getUnitProductionNeeded(pUnit.getUnitType()))) * gc.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION"))

		if ((not pPlayer.isHuman()) and (not pPlayer.isBarbarian())):
			pHandicapInfo = gc.getHandicapInfo(gc.getGame().getHandicapType())
			iPrice = iPrice * pHandicapInfo.getAIUnitUpgradePercent() / 100
			iPrice = iPrice * max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100

		iPrice = iPrice - ((iPrice * pUnit.getUpgradeDiscount()) / 100)

		b_Leonardo = gc.getInfoTypeForString("BUILDING_LEONARDO")
		obsoleteTech = gc.getBuildingInfo(b_Leonardo).getObsoleteTech()
		if ( gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
			for iCity in range(pPlayer.getNumCities()):
				ppCity = pPlayer.getCity(iCity)
				if ppCity.getNumActiveBuilding(b_Leonardo) == true:
					iPrice = ((gc.getDefineINT("BASE_UNIT_UPGRADE_COST"))/2)
					iPrice += (((max(0, (pPlayer.getUnitProductionNeeded(iUnitTypeUpgrade) - pPlayer.getUnitProductionNeeded(pUnit.getUnitType()))) * gc.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION")))/2)

					if ((not pPlayer.isHuman()) and (not pPlayer.isBarbarian())):
						pHandicapInfo = gc.getHandicapInfo(gc.getGame().getHandicapType())
						iPrice = ((iPrice * pHandicapInfo.getAIUnitUpgradePercent() / 100)/2)
						iPrice = ((iPrice * max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100)/2)

						iPrice = ((iPrice - ((iPrice * pUnit.getUpgradeDiscount()) / 100))/2)

		if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_LEADER')):

			iPrice = 0
		
		return iPrice

## Leonardo's Workshop End ##	

## Leonardo's Workshop Start ##	
#
## NOTE: You need to comment out (add a # before) the original return -1 (done below) ##
#
#		return -1	# Any value 0 or above will be used
#
## Leonardo's Workshop End ##

I guess what I am asking is if this file itself (i.e. the code in it) is fine and there is something else I failed to do?
 
Ugh, sorry guys, don't worry about this right now. I just found out that it doesn't work anyway. So it isn't anything I did wrong, which I suppose is a good thing, however also a bad thing because I'd rather have it work and the problem be my own. Anyway, thanks. :goodjob:

EDIT: By doesn't work, I mean that the mod itself doesn't work, even in the regular game. So I suppose the code is wrong or something.
 
Did you set USE_CAN_TRAIN_CALLBACK to 1 in PythonCallbackDefines.xml?

Do you see your callback handler function being added by BUG in the debug log?

Code:
DEBUG: BugGameUtils - canTrain - adding DiplomacyGameUtils handler
 
You mean this:

Code:
16:01:20 DEBUG: BUG: looking up DiplomacyGameUtils.DiplomacyGameUtils
load_module DiplomacyGameUtils

16:01:20 DEBUG: BugGameUtils - registering DiplomacyGameUtils.DiplomacyGameUtils
[COLOR="Blue"]16:01:20 DEBUG: BugGameUtils - canTrain - adding DiplomacyGameUtils handler[/COLOR]
16:01:20 DEBUG: BugGameUtils - getUpgradePriceOverride - adding DiplomacyGameUtils handler
16:01:20 DEBUG: BugGameUtils - cannotConstruct - adding DiplomacyGameUtils handler
16:01:20 DEBUG: Timer - load mod [TheCapoSettings] took 78 ms
16:01:20 DEBUG: BUG: looking up BugGeneralOptionsTab.BugGeneralOptionsTab
load_module BugGeneralOptionsTab

:confused:
 
That tells Civ4 to actually call your function. Otherwise it is totally ignored. Many of the callbacks are disabled in the vanilla game using that XML file. It helps to maintain decent performance for mods that don't use the callback.
 
Back
Top Bottom