HELP with merging my mod and BUG!!!

@ EmeperorFool: I'd like to revisit the PROMOTION_LEADER issue from before. I am adding a few new wonders to my mod and one of them is Leonardo's Workshop by Tsentom1.

I noticed within this code there is a reference to the PROMOTION_LEADER tag or whatever. I added this python to my mod, and while I can build Leonardo's Workshop there is no effect on unit upgrade costs (it is supposed to halve the cost to upgrade a unit). Since someone in Tsentom's thread told me it worked, and since I definitely added it correctly (I compared my python to his) I was wondering if it wasn't working becuase of the missing PROMOTION_LEADER tag from this assert failure:

No. As I understand it, those are not loaded before the XML. They are used when the game calls them. They operate exactly like python callbacks. So that promotion leader call is not causing an assert.

I think Afforess said he had the same issue when he ran BUG with a DebugDLL. I'm just wondering if BUG is incompatible with the Leonardo's Workshop python (from Tsentom1's Python Wonders) that I have here. I ask this because a couple people have reported on Tsentom1's thread that the wonder works, the building is completely buildable and is properly inserted (as a wonder, with working video and art, and you get the effects from BuildingInfos too) it is just that the python effect (the -50% upgrade cost) doesn't happen at all.

Also, you will notice that it references the GraphicOptions xml file, not the PromotionInfos XML, so I'm wondering why it is looking for the Promotion there anyway.

Two things here. Check that you have this block of code in CvUnit.cpp

Code:
        CyArgsList argsList;
        argsList.add(getOwnerINLINE());
        argsList.add(getID());
        argsList.add((int) eUnit);
        long lResult=0;
        gDLL->getPythonIFace()->callFunction(PYGameModule, "getUpgradePriceOverride", argsList.makeFunctionArgs(), &lResult);
        if (lResult >= 0)
        {
            return lResult;
        }

That's the code that calls the python section that adjusts the units upgrade prices. If it is not there or commented out, your code won't work. If it is there, then you code should work fine.

Second things, the reason it is looking at graphic infos XML file for the assert is because that is the last XML file to have been loaded. It is not significant. For those who don't understand, Civ loads XML files in a specific order, a few at a time. It loads the python before it loads 98% if the XML. That's why you are getting the assert, it is trying to find an XML value before it is loaded. Now, I looked at the PLE that Ruff was creating, and it seems that the line

Code:
iLeaderPromo = gc.getInfoTypeForString('PROMOTION_LEADER')

Can simply be removed. It isn't used for anything, he resets the value later on. I removed a week or so ago and have had no issues and no asserts.
 
Excuse my ignorance/stupidity (this stuff is like Greek to me, I make units and LHs normally, so this is my worst area of expertise when it comes to modding), but I can't seem to find a CvUnit.cpp in my mod at all. Should there be one there? And what folder should it be in?

And also, from what file do I remove that line about the PROMOTION_LEADER?

And furthermore I don't have a custom SDK or DLL or whatever in my mod, I just use the regular BtS one I suppose, here is what I found in the regular file though:

Code:
int CvUnit::upgradePrice(UnitTypes eUnit) const
{
	int iPrice;

	CyArgsList argsList;
	argsList.add(getOwnerINLINE());
	argsList.add(getID());
	argsList.add((int) eUnit);
	long lResult=0;
	gDLL->getPythonIFace()->callFunction(PYGameModule, "getUpgradePriceOverride", argsList.makeFunctionArgs(), &lResult);
	if (lResult >= 0)
	{
		return lResult;
	}

	if (isBarbarian())
	{
		return 0;
	}

	iPrice = GC.getDefineINT("BASE_UNIT_UPGRADE_COST");

	iPrice += (std::max(0, (GET_PLAYER(getOwnerINLINE()).getProductionNeeded(eUnit) - GET_PLAYER(getOwnerINLINE()).getProductionNeeded(getUnitType()))) * GC.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION"));

	if (!isHuman() && !isBarbarian())
	{
		iPrice *= GC.getHandicapInfo(GC.getGameINLINE().getHandicapType()).getAIUnitUpgradePercent();
		iPrice /= 100;

		iPrice *= std::max(0, ((GC.getHandicapInfo(GC.getGameINLINE().getHandicapType()).getAIPerEraModifier() * GET_PLAYER(getOwnerINLINE()).getCurrentEra()) + 100));
		iPrice /= 100;
	}

	iPrice -= (iPrice * getUpgradeDiscount()) / 100;

	return iPrice;
}

Which looks to be what you are talking about. Could it be that the Debug DLL I am using is causing this to fail?
 
If you haven't modified the SDK at all, then the Leonardo Workshop should be working. Yes, that's the spot.

As for the file, it the "BugUnitPlot.py", line # 18. Just set it to -1, so it reads this:
Code:
iLeaderPromo = -1
. Then you are good to go.
 
Well, that did get rid of the Assert Failure, but Leo's still doesn't work for me. I suppose I could post the code I am using again:

Code:
	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 was told to comment out this line:

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

By somebody who helped me out earlier. I suppose I could try uncommenting that line, but I'm not sure if that will do anything.

Should I try changing BUILDING_LEONARDO to BUILDINGCLASS_LEONARDO or something? I'm just at a loss right now. I should probably point out, again, that my mod has Next War as part of it, I'm not sure if this would effect anything but I should at least mention it.
 
Yes, uncomment that line (in CvGameUtils). It will cause strange things to occur otherwise.

Now, in your Civ4BuildingInfos.xml, do you have a building called "BUILDING_LEONARDO"? If not, there is your problem.
 
Yes, uncomment that line (in CvGameUtils). It will cause strange things to occur otherwise.

Now, in your Civ4BuildingInfos.xml, do you have a building called "BUILDING_LEONARDO"? If not, there is your problem.

Yeah, I do, everything looks good to me. Here it is though just in case...

Code:
		<BuildingInfo>
			<BuildingClass>BUILDINGCLASS_LEONARDO</BuildingClass>
			<Type>BUILDING_LEONARDO</Type>
			<SpecialBuildingType>NONE</SpecialBuildingType>
			<Description>TXT_KEY_BUILDING_LEONARDO</Description>
			<Civilopedia>TXT_KEY_BUILDING_LEONARDO_PEDIA</Civilopedia>
			<Strategy>TXT_KEY_BUILDING_LEONARDO_STRATEGY</Strategy>
			<Help>TXT_KEY_BUILDING_LEONARDO_HELP</Help>
			<Advisor>ADVISOR_MILITARY</Advisor>
			<ArtDefineTag>ART_DEF_BUILDING_LEONARDOS_WORKSHOP</ArtDefineTag>
			<MovieDefineTag>ART_DEF_MOVIE_LEONARDO</MovieDefineTag>
			<HolyCity>NONE</HolyCity>
			<ReligionType>NONE</ReligionType>
			<StateReligion>NONE</StateReligion>
			<bStateReligion>0</bStateReligion>
			<PrereqReligion>NONE</PrereqReligion>
			<PrereqCorporation>NONE</PrereqCorporation>
			<FoundsCorporation>NONE</FoundsCorporation>
			<GlobalReligionCommerce>NONE</GlobalReligionCommerce>
			<GlobalCorporationCommerce>NONE</GlobalCorporationCommerce>
			<VictoryPrereq>NONE</VictoryPrereq>
			<FreeStartEra>NONE</FreeStartEra>
			<MaxStartEra>ERA_INDUSTRIAL</MaxStartEra>
			<ObsoleteTech>TECH_ASSEMBLY_LINE</ObsoleteTech>
			<PrereqTech>TECH_PAPER</PrereqTech>
			<TechTypes>
				<PrereqTech>TECH_ENGINEERING</PrereqTech>
				<PrereqTech>NONE</PrereqTech>
				<PrereqTech>NONE</PrereqTech>
			</TechTypes>
			<Bonus>NONE</Bonus>
			<PrereqBonuses/>
			<ProductionTraits/>
			<HappinessTraits/>
			<NoBonus>NONE</NoBonus>
			<PowerBonus>NONE</PowerBonus>
			<FreeBonus>NONE</FreeBonus>
			<iNumFreeBonuses>0</iNumFreeBonuses>
			<FreeBuilding>NONE</FreeBuilding>
			<FreePromotion>NONE</FreePromotion>
			<CivicOption>NONE</CivicOption>
			<GreatPeopleUnitClass>UNITCLASS_ENGINEER</GreatPeopleUnitClass>
			<iGreatPeopleRateChange>2</iGreatPeopleRateChange>
			<iHurryAngerModifier>0</iHurryAngerModifier>
			<bBorderObstacle>0</bBorderObstacle>
			<bTeamShare>1</bTeamShare>
			<bWater>0</bWater>
			<bRiver>0</bRiver>
			<bPower>0</bPower>
			<bDirtyPower>0</bDirtyPower>
			<bAreaCleanPower>0</bAreaCleanPower>
			<DiploVoteType>NONE</DiploVoteType>
			<bForceTeamVoteEligible>0</bForceTeamVoteEligible>
			<bCapital>0</bCapital>
			<bGovernmentCenter>0</bGovernmentCenter>
			<bGoldenAge>0</bGoldenAge>
			<bAllowsNukes>0</bAllowsNukes>
			<bMapCentering>0</bMapCentering>
			<bNoUnhappiness>0</bNoUnhappiness>
			<bNoUnhealthyPopulation>0</bNoUnhealthyPopulation>
			<bBuildingOnlyHealthy>0</bBuildingOnlyHealthy>
			<bNeverCapture>0</bNeverCapture>
			<bNukeImmune>1</bNukeImmune>
			<bPrereqReligion>0</bPrereqReligion>
			<bCenterInCity>0</bCenterInCity>
			<iAIWeight>0</iAIWeight>
			<iCost>800</iCost>
			<iHurryCostModifier>100</iHurryCostModifier>
			<iAdvancedStartCost>-1</iAdvancedStartCost>
			<iAdvancedStartCostIncrease>0</iAdvancedStartCostIncrease>
			<iMinAreaSize>-1</iMinAreaSize>
			<iConquestProb>100</iConquestProb>
			<iCitiesPrereq>0</iCitiesPrereq>
			<iTeamsPrereq>0</iTeamsPrereq>
			<iLevelPrereq>0</iLevelPrereq>
			<iMinLatitude>0</iMinLatitude>
			<iMaxLatitude>90</iMaxLatitude>
			<iGreatPeopleRateModifier>0</iGreatPeopleRateModifier>
			<iGreatGeneralRateModifier>0</iGreatGeneralRateModifier>
			<iDomesticGreatGeneralRateModifier>0</iDomesticGreatGeneralRateModifier>
			<iGlobalGreatPeopleRateModifier>0</iGlobalGreatPeopleRateModifier>
			<iAnarchyModifier>0</iAnarchyModifier>
			<iGoldenAgeModifier>0</iGoldenAgeModifier>
			<iGlobalHurryModifier>0</iGlobalHurryModifier>
			<iExperience>0</iExperience>
			<iGlobalExperience>0</iGlobalExperience>
			<iFoodKept>0</iFoodKept>
			<iAirlift>0</iAirlift>
			<iAirModifier>0</iAirModifier>
			<iAirUnitCapacity>0</iAirUnitCapacity>
			<iNukeModifier>0</iNukeModifier>
			<iNukeExplosionRand>0</iNukeExplosionRand>
			<iFreeSpecialist>0</iFreeSpecialist>
			<iAreaFreeSpecialist>0</iAreaFreeSpecialist>
			<iGlobalFreeSpecialist>0</iGlobalFreeSpecialist>
			<iMaintenanceModifier>0</iMaintenanceModifier>
			<iWarWearinessModifier>0</iWarWearinessModifier>
			<iGlobalWarWearinessModifier>0</iGlobalWarWearinessModifier>
			<iEnemyWarWearinessModifier>0</iEnemyWarWearinessModifier>
			<iHealRateChange>0</iHealRateChange>
			<iHealth>0</iHealth>
			<iAreaHealth>0</iAreaHealth>
			<iGlobalHealth>0</iGlobalHealth>
			<iHappiness>0</iHappiness>
			<iAreaHappiness>0</iAreaHappiness>
			<iGlobalHappiness>0</iGlobalHappiness>
			<iStateReligionHappiness>0</iStateReligionHappiness>
			<iWorkerSpeedModifier>0</iWorkerSpeedModifier>
			<iMilitaryProductionModifier>0</iMilitaryProductionModifier>
			<iSpaceProductionModifier>0</iSpaceProductionModifier>
			<iGlobalSpaceProductionModifier>0</iGlobalSpaceProductionModifier>
			<iTradeRoutes>0</iTradeRoutes>
			<iCoastalTradeRoutes>0</iCoastalTradeRoutes>
			<iGlobalTradeRoutes>0</iGlobalTradeRoutes>
			<iTradeRouteModifier>0</iTradeRouteModifier>
			<iForeignTradeRouteModifier>0</iForeignTradeRouteModifier>
			<iGlobalPopulationChange>0</iGlobalPopulationChange>
			<iFreeTechs>0</iFreeTechs>
			<iDefense>0</iDefense>
			<iBombardDefense>0</iBombardDefense>
			<iAllCityDefense>0</iAllCityDefense>
			<iEspionageDefense>0</iEspionageDefense>
			<iAsset>10</iAsset>
			<iPower>10</iPower>
			<fVisibilityPriority>1.0</fVisibilityPriority>
			<SeaPlotYieldChanges/>
			<RiverPlotYieldChanges/>
			<GlobalSeaPlotYieldChanges/>
			<YieldChanges/>
			<CommerceChanges/>
			<ObsoleteSafeCommerceChanges>
				<iCommerce>0</iCommerce>
				<iCommerce>0</iCommerce>
				<iCommerce>4</iCommerce>
			</ObsoleteSafeCommerceChanges>
			<CommerceChangeDoubleTimes>
				<iCommerce>0</iCommerce>
				<iCommerce>0</iCommerce>
				<iCommerce>1000</iCommerce>
			</CommerceChangeDoubleTimes>
			<CommerceModifiers/>
			<GlobalCommerceModifiers/>
			<SpecialistExtraCommerces/>
			<StateReligionCommerces/>
			<CommerceHappinesses/>
			<ReligionChanges/>
			<SpecialistCounts/>
			<FreeSpecialistCounts/>
			<CommerceFlexibles/>
			<CommerceChangeOriginalOwners>
				<bCommerceChangeOriginalOwner>0</bCommerceChangeOriginalOwner>
				<bCommerceChangeOriginalOwner>0</bCommerceChangeOriginalOwner>
				<bCommerceChangeOriginalOwner>1</bCommerceChangeOriginalOwner>
			</CommerceChangeOriginalOwners>
			<ConstructSound/>
			<BonusHealthChanges/>
			<BonusHappinessChanges/>
			<BonusProductionModifiers/>
			<UnitCombatFreeExperiences/>
			<DomainFreeExperiences/>
			<DomainProductionModifiers/>
			<BuildingHappinessChanges/>
			<PrereqBuildingClasses/>
			<BuildingClassNeededs/>
			<SpecialistYieldChanges/>
			<BonusYieldModifiers/>
			<ImprovementFreeSpecialists/>
			<Flavors>
				<Flavor>
					<FlavorType>FLAVOR_MILITARY</FlavorType>
					<iFlavor>10</iFlavor>
				</Flavor>
				<Flavor>
					<FlavorType>FLAVOR_GOLD</FlavorType>
					<iFlavor>5</iFlavor>
				</Flavor>
				<Flavor>
					<FlavorType>FLAVOR_PRODUCTION</FlavorType>
					<iFlavor>5</iFlavor>
				</Flavor>
			</Flavors>
			<HotKey/>
			<bAltDown>0</bAltDown>
			<bShiftDown>0</bShiftDown>
			<bCtrlDown>0</bCtrlDown>
			<iHotKeyPriority>0</iHotKeyPriority>
		</BuildingInfo>

And for good measure...

Code:
		<BuildingClassInfo>
			<Type>BUILDINGCLASS_LEONARDO</Type>
			<Description>TXT_KEY_BUILDING_LEONARDO</Description>
			<iMaxGlobalInstances>1</iMaxGlobalInstances>
			<iMaxTeamInstances>-1</iMaxTeamInstances>
			<iMaxPlayerInstances>-1</iMaxPlayerInstances>
			<iExtraPlayerInstances>0</iExtraPlayerInstances>
			<bNoLimit>0</bNoLimit>
			<bMonument>0</bMonument>
			<DefaultBuilding>BUILDING_LEONARDO</DefaultBuilding>
			<VictoryThresholds/>
		</BuildingClassInfo>

I'll uncomment that line and try it again I guess.
 
I got a bunch of python pop-ups when the mod was loading after I uncommented that line, so something is up.

And I got some python pop-ups when I loaded the save to test the wonder, then the interface didn't show up. This sucks, and I have no idea what to do about it. :sad:
 
I don't see anything actually wrong with it. It has a few issues, like some of it is redundant and I cut out, but both code segments should work the same. Here's my tweaks to it, mostly to make it more understandable and remove redundant code:

Code:
	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 *= pHandicapInfo.getAIUnitUpgradePercent() / 100
			iPrice *= max(0, ((pHandicapInfo.getAIPerEraModifier() * pPlayer.getCurrentEra()) + 100)) / 100

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

		b_Leonardo = gc.getInfoTypeForString("BUILDING_LEONARDO")
		obsoleteTech = gc.getBuildingInfo(b_Leonardo).getObsoleteTech()
		if ( obsoleteTech == -1 or gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false ):
			for iCity in range(pPlayer.getNumCities()):
				ppCity = pPlayer.getCity(iCity)
				if ( ppCity.getNumActiveBuilding(b_Leonardo) > 0 ):
					iPrice /= 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 ##

Try my changes if it still doesn't work. Also, do you have python error logging enabled? Perhaps something is going wrong and we can't see it. If it isn't enabled, enable it (In the Civilization4.ini) and if it is, check and make sure that the PythonErr.log is empty after starting up Civ4.


Edit:

The Leader Promotion line isn't important, you can remove it and the line right below it without affecting the Leonardo building. Basically, what that code is doing is making it so upgrading Great Generals is free. So if you don't want that, you can remove it.
 
Well I didn't get any python errors as far as I can tell (the PythonErr.txt file is empty), although I didn't clear it before trying it again. So I just go into the BtS folder, and delete everything in the Logs folder to clear it right?

Anyway here is a screen-shot. The Axeman cost 125 gold to upgrade to Maceman before I built Leo's, after I built it (I circled it in the attachment) it still costs 125 so obviously it still isn't working. I guess I'll clear out the Logs folder and try it again (I'm not sure what the AutoLog folder in the mod does, but there isn't anything in there). I also want to say that I really appreciate you helping me, I know it is probably annoying for you and I'm sure you have better things you could be doing with your time, but this does mean a lot to me because I've put a lot of work into this mod and there are a lot of people waiting for it who have helped me playtest, so just thanks for helping me out man. :goodjob:
 
Well I didn't get any python errors as far as I can tell (the PythonErr.txt file is empty), although I didn't clear it before trying it again. So I just go into the BtS folder, and delete everything in the Logs folder to clear it right?

Anyway here is a screen-shot. The Axeman cost 125 gold to upgrade to Maceman before I built Leo's, after I built it (I circled it in the attachment) it still costs 125 so obviously it still isn't working. I guess I'll clear out the Logs folder and try it again (I'm not sure what the AutoLog folder in the mod does, but there isn't anything in there). I also want to say that I really appreciate you helping me, I know it is probably annoying for you and I'm sure you have better things you could be doing with your time, but this does mean a lot to me because I've put a lot of work into this mod and there are a lot of people waiting for it who have helped me playtest, so just thanks for helping me out man. :goodjob:

No problem. I don't mind helping people.

Okay, onto the issue. I suspect that your code isn't loading at all. Are you using CvEventManager? If so, it isn't loaded with BUG unless you explicitly set up the config to load it.

You're going to need to create a config file for them. I won't start the (lengthy) explanation unless I need to...
 
No problem. I don't mind helping people.

Okay, onto the issue. I suspect that your code isn't loading at all. Are you using CvEventManager? If so, it isn't loaded with BUG unless you explicitly set up the config to load it.

You're going to need to create a config file for them. I won't start the (lengthy) explanation unless I need to...

Uh, I am using CvEventManager actually, but this code is in the CvGameUtils.py file. I do have code that gives you no unhapiness for defying UN Resolutions in the CvEventManager file and code for my King Richard's Crusade wonder (spreads state religion to conquered cities) which caused a python error too (the second one did, the first did not but I'm not sure if it works). I removed the KRC stuff though so that isn't in effect right now.

So I have to create a config file? That sounds scary.
 
So I have to create a config file? That sounds scary.

Yes, but is actually not that bad and once it's done, you should be good indefinitely.

Create a new config XML file in the "Config" folder called "TheCapoSettings" (Or whatever you mod name is called). Inside it, put this information:
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>

<mod id="TheCapoSettings"
    module="CvEventManager" 
    name="YOURMODNAMEHERE" 
    author="TheCapo" 
    version="1.0" 
    date="01/29/2010"
    url="">
    
    <events module="CvEventManager"/>
     
    <gameutils module="CvGameUtils" class="CvGameUtils" override="True"/>
</mod>

Then, edit the init.xml file

look for this line:
Code:
<load mod="Advanced Combat Odds"/>

One line underneath is, put this line:
Code:
<load mod="TheCapoSettings"/>

Hopefully, it should work now.
 
Alright, I'll give it a shot, that's all I have to do? And you are saying (hopefully) that when this occurs everything I put in the CvEventManager file should work? What if it is in the CvGameUtils.py file (like Leonardo's stuff is)?
 
Yes, everything should work after that. If you get errors, or it still doesn't work, just post them, and I'll show up again tomorrow and give it my best shot.
 
Okay, good news and bad news. The good news is that Leonardo's Workshop worked. The upgrade costs were halved like they should be. :goodjob:

Now for the bad news, although I *THINK* I know what might be going on here, maybe. I got the python pop-ups in the attached image. I loaded the autosave which starts right when Leo's is constructed, so I'm not sure if this would have happened anyway or only happened because I built the wonder. But it looks to me like there was some conflict involving the BUGConfig.py file somehow. Now, does this mean that the new settings I made are conflicting with BUG, and if that is the case does this mean I can just edit some BUG file with what I put in my settings (TheCapoSettings)?

EDIT: There was another pop up that happened too, I forget what it said and I tried to get a screen but it showed up as a blank screenshot, so I couldn't get it, but it said something about two things happening when there should be one thing happening or something like that. I suppose I could recreate this and get that for you if you need to see that too.
 
BUG has its own CvGameUtils replacement (BugGameUtils) just as it has its own CvEventManager (BugEventManager). Instead of modifying CvGameUtils, you should move that one callback function to its own module assuming that function is all that's needed. I suspect the errors you're seeing are about duplicate callbacks, but I'm not sure without seeing it.

Here are the docs for using Game Utils in BUG. While it may seem complicated, I think if you read over that page and compare what you have to the example it will become more clear. All you really need is this:

Code:
# LeonardosWorkshop.py

from CvPythonExtensions import *

...

# no class necessary

def getUpgradePriceOverride(argsList):    # remove self from args list
    ... rest of function as-is, outdented one level
    ...
## Leonardo's Workshop End ##

Then to hook this up change the <gameutils> line Afforess posted with this one:

Code:
<gameutils module="LeonardosWorkshop" handler="getUpgradePriceOverride"/>

That should be it.
 
That does seem pretty complicated. So you're saying I should remove the code I have added (Leonardo's Workshop, the change to the Police State civic, and the King Richard's Crusade code) and basically give them each their own individual file (LeonardosWorkshop.py, KingRichardsCrusade.py, PoliceStateDefyUn.py) and then reference them in the init file like Afforess mentioned? How do I create my own python file for these seperately then?

Also that first cell of code you posted there, I have no idea what that is or what it means. Could you maybe explain that bit a little?

Sorry, I am not computer savvy at all, I just know how to make art. :crazyeye:
 
No, you can put all of your callbacks into a single module. I thought you just had the one. The code I posted was a summary of the Python module you need to create. Pull out everything you added from CvGameUtils into your own new module. Name it whatever you want (e.g. CapoMod.py).

In CvGameUtils there is a class, and each callback is a function in that class. You can do the same thing in your module. Create a class named CapoGameUtils and put those functions into it. This will work just like CvGameUtils but have only your own stuff. Then you can use <gameutils> to hook it up. It will look like the one Afforess posted:

Code:
<gameutils module="CapoMod" class="CapoGameUtils"/>

The work I did in BUG makes it a lot easier for experienced modders to do their modding. Unfortunately, that tends to make it a little more difficult for inexperienced coders. Give it a try; post your code; and ask questions. I can help if you post code so I can critique. Just asking what to do means I have to write all the instructions again each time.

Take a look at the existing BUG code for help, too. Config/init.xml uses <gameutils> to hook up a callback handler in BugUtil (getWidgetHelp).
 
Alright, but I have no idea what any of this means at all.

Code:
# LeonardosWorkshop.py

from CvPythonExtensions import *

...

# no class necessary

def getUpgradePriceOverride(argsList):    # remove self from args list
    ... rest of function as-is, outdented one level
    ...
## Leonardo's Workshop End ##


The code I posted was a summary of the Python module you need to create. Pull out everything you added from CvGameUtils into your own new module. Name it whatever you want (e.g. CapoMod.py).

Alright, but what does this mean exactly? Just copy the code I need and name it whatever.py? I don't understand what I'm supposed to do. And what if I have some in different files (the Leonardo's workshop code is in the CvGameUtils file, the other stuff is mostly in CvEventManager)? Can I still put them all together or what?

I don't want you to continue to rewrite instructions, but I didn't even realize what you wrote were instructions, it doesn't make much sense to me.
 
Back
Top Bottom