Platyping's Python

Been awhile since I post something here :D
Since I am more or less done with World Builder, time to solve the problems.

Bugs Fixed:
1) Apadana Palace
No more production overflow in capital itself.

2) Magellan's Voyage
Changed from +1 Move and Cargo to simply +2 Move.
The cargo is a problem when unit upgrades to new unit type because it is lost.
This problem can be solved if I create a new "Magellan" promotion that grants the +1 Cargo, but I rather simplify it.

3) Tomb of Khalid
Fixed 5454366908927 Great Generals born at high levels.

4) Leaning Tower of Pisa
Fixed 5443465476 Great People born at high levels.

Standalones, Megapack and Gigapack updated.
Will look into Terapack later to see if any additions necessary beside fixing the bugs.
 
You may have to check the BUG mode or The_J instead.
Never did anything to do with interface before.

But chances are, it should be in CvMainInterface if you wanna put it in the main screen.
 
Updates

Great Zimbawee (Bug Fixing)
Effects:
Allows all cities to continue growing even while training units requiring food (settlers and workers)

Bug Fixes:
1) Cities stop growing during disorder now.
2) If food > threshold, population growth during that turn instead of next turn.
3) City Screen now shows correct food growth instead of not growing. (Refer to screenshot)

Known Issue:
City still show as stagnant in World View, but at least the city screen shows correct one now :D

Project Help Tags
For Megapack and Gigapack ONLY. (Can't be bothered to update all the standalones.)

1) Scrap all the if else statements in CvPediaProject and CvWonderMovieScreen.
2) Project Movie now display effects in Help Tag brilliantly. (Refer to screenshot)
 

Attachments

  • Civ4ScreenShot0000.JPG
    Civ4ScreenShot0000.JPG
    104.5 KB · Views: 88
  • Civ4ScreenShot0001.JPG
    Civ4ScreenShot0001.JPG
    124.6 KB · Views: 121
Awesome, thanks for those fixes. I've applied them to HR's Pyramids. I'd had a go at trying to adjust CvMainInterface.py myself before but got hopefully lost. Beyond my skills for sure.

HR uses BUG so my CvMainInterface.py was a bit different to the one you posted. I had a go at merging the changes and it seems to work (no error messages at least) but while the growth bar in the city screen progresses when building a Worker in a city with the wonder, it has no label.

Could you take a look and see what I've done wrong or could have done better? I made the merge using code comparison and guess work, rather than by any true understanding of the code...

Code:
			### HR - Pyramids
				if not pHeadSelectedCity.isDisorder():
					iPlayer = pHeadSelectedCity.getOwner()
					if gc.getPlayer(iPlayer).getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_PYRAMIDS")) == 1:
						if pHeadSelectedCity.isFoodProduction():
							iFoodDifference += pHeadSelectedCity.getYieldRate(0) - pHeadSelectedCity.foodConsumption(False, 0)
				###

				iProductionDiffNoFood = pHeadSelectedCity.getCurrentProductionDifference(True, True)
				iProductionDiffJustFood = (pHeadSelectedCity.getCurrentProductionDifference(False, True) - iProductionDiffNoFood)

				szBuffer = u"<font=4>"

				if (pHeadSelectedCity.isCapital()):
					szBuffer += u"%c" %(CyGame().getSymbolID(FontSymbols.STAR_CHAR))
				elif (pHeadSelectedCity.isGovernmentCenter()):
					szBuffer += u"%c" %(CyGame().getSymbolID(FontSymbols.SILVER_STAR_CHAR))

				if (pHeadSelectedCity.isPower()):
					szBuffer += u"%c" %(CyGame().getSymbolID(FontSymbols.POWER_CHAR))

				szBuffer += u"%s: %d" %(pHeadSelectedCity.getName(), pHeadSelectedCity.getPopulation())

				if (pHeadSelectedCity.isOccupation()):
					szBuffer += u" (%c:%d)" %(CyGame().getSymbolID(FontSymbols.OCCUPATION_CHAR), pHeadSelectedCity.getOccupationTimer())

				szBuffer += u"</font>"

				screen.setText( "CityNameText", "Background", szBuffer, CvUtil.FONT_CENTER_JUSTIFY, screen.centerX(512), 32, -0.3, FontTypes.GAME_FONT, WidgetTypes.WIDGET_CITY_NAME, -1, -1 )
				screen.setStyle( "CityNameText", "Button_Stone_Style" )
				screen.show( "CityNameText" )

			### BUG - Food Assist
				if ( CityUtil.willGrowThisTurn(pHeadSelectedCity) or (iFoodDifference != 0) or not (pHeadSelectedCity.isFoodProduction() ) ):
					if (CityUtil.willGrowThisTurn(pHeadSelectedCity)):
						szBuffer = localText.getText("INTERFACE_CITY_GROWTH", ())
					elif (iFoodDifference > 0):

				### HR - Pyramids
						iFoodTurnsLeft = (pHeadSelectedCity.growthThreshold() - pHeadSelectedCity.getFood()) / iFoodDifference
						if (pHeadSelectedCity.growthThreshold() - pHeadSelectedCity.getFood()) % iFoodDifference > 0:
							iFoodTurnsLeft += 1
					###
						szBuffer = localText.getText("INTERFACE_CITY_GROWING", (pHeadSelectedCity.getFoodTurnsLeft(), ))

					elif (iFoodDifference < 0):
						if (CityScreenOpt.isShowFoodAssist()):
							iTurnsToStarve = pHeadSelectedCity.getFood() / -iFoodDifference + 1
							if iTurnsToStarve > 1:
								szBuffer = localText.getText("INTERFACE_CITY_SHRINKING", (iTurnsToStarve, ))
							else:
								szBuffer = localText.getText("INTERFACE_CITY_STARVING", ())
						else:
							szBuffer = localText.getText("INTERFACE_CITY_STARVING", ())
				###
					else:
						szBuffer = localText.getText("INTERFACE_CITY_STAGNANT", ())

					screen.setLabel( "PopulationText", "Background", szBuffer, CvUtil.FONT_CENTER_JUSTIFY, screen.centerX(512), iCityCenterRow1Y, -1.3, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
					screen.setHitTest( "PopulationText", HitTestTypes.HITTEST_NOHIT )
					screen.show( "PopulationText" )

			### HR - Pyramids
				if not pHeadSelectedCity.isDisorder():
					if not pHeadSelectedCity.isFoodProduction() or gc.getPlayer(iPlayer).getBuildingClassCount(gc.getInfoTypeForString("BUILDINGCLASS_PYRAMIDS")) == 1:

					### BUG - Food Assist
						if (CityScreenOpt.isShowFoodAssist()):
							iFoodYield = pHeadSelectedCity.getYieldRate(YieldTypes.YIELD_FOOD)
							iFoodEaten = pHeadSelectedCity.foodConsumption(False, 0)
							if iFoodYield == iFoodEaten:
								szBuffer = localText.getText("INTERFACE_CITY_FOOD_STAGNATE", (iFoodYield, iFoodEaten))
							elif iFoodYield > iFoodEaten:
								szBuffer = localText.getText("INTERFACE_CITY_FOOD_GROW", (iFoodYield, iFoodEaten, iFoodYield - iFoodEaten))
							else:
								szBuffer = localText.getText("INTERFACE_CITY_FOOD_SHRINK", (iFoodYield, iFoodEaten, iFoodYield - iFoodEaten))
						else:
							szBuffer = u"%d%c - %d%c" %(pHeadSelectedCity.getYieldRate(YieldTypes.YIELD_FOOD), gc.getYieldInfo(YieldTypes.YIELD_FOOD).getChar(), pHeadSelectedCity.foodConsumption(False, 0), CyGame().getSymbolID(FontSymbols.EATEN_FOOD_CHAR))
						###

						screen.setLabel( "PopulationInputText", "Background", szBuffer, CvUtil.FONT_RIGHT_JUSTIFY, iCityCenterRow1X - 6, iCityCenterRow1Y, -0.3, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
						screen.show( "PopulationInputText" )

				else:
					if not pHeadSelectedCity.isFoodProduction():
						szBuffer = u"%d%c" %(iFoodDifference, gc.getYieldInfo(YieldTypes.YIELD_FOOD).getChar())

				screen.setLabel( "PopulationInputText", "Background", szBuffer, CvUtil.FONT_RIGHT_JUSTIFY, iCityCenterRow1X - 6, iCityCenterRow1Y, -0.3, FontTypes.GAME_FONT,
						*BugDll.widget("WIDGET_FOOD_MOD_HELP", -1, -1) )
				screen.show( "PopulationInputText" )
				###


EDIT: Attached a before and after copy of my CvMainInterface.py
 

Attachments

  • CvMainInterface.zip
    78 KB · Views: 63
Code:
## Great Zimbawee Start ##
						iFoodTurnsLeft = (pHeadSelectedCity.growthThreshold() - pHeadSelectedCity.getFood()) / iFoodDifference
						if (pHeadSelectedCity.growthThreshold() - pHeadSelectedCity.getFood()) % iFoodDifference > 0:
							iFoodTurnsLeft += 1
## Great Zimbawee End ##
						szBuffer = localText.getText("INTERFACE_CITY_GROWING", ([COLOR="Lime"]iFoodTurnsLeft[/COLOR], ))

I forgot to include this line within the comments
 
Ugh I've clearly done something horribly wrong. I made that change, but now when the wonder is in the city and I select a worker to build, the food display to the left of the growth bar is replaced by the name of the city ><

Attached the files to my previous post if that helps.
 
... ... ... ... ...
I was wondering what is wrong as well... until I check the BuildingClassInfo file.
Pyramid is not PYRAMIDS lol

Anyway, the help text of pyramid is inaccurate.
It is effective so long as the unit is produced with food, so it includes settlers too.
 
Haha! All seems to work now, thanks so much!
 
You should ask them not ask me :D
Mod components made for vanilla BTS can be used for any other BTS mod.
If they do not work, it is because the particular mod modified such that:
1) It no longer loads a particular python file
2) Standard python codes no longer work
 
Updates

Been a long time since I updated Terapack.

1) Fixed those problematic wonders like Leaning Tower.
2) Removed the last 2 that need callback. Now Terapack does not need a single callback activated.
3) Updated Promotions to include newer ones.
4) Adds Natural Wonders
5) Adds Enhanced Great People
6) Adds World Builder
 
Hi platy

Can i merge all projects and wonders from this thread? Is this possible?

Is that will influence on game speed (turn waiting etc) or something other in game, i have already your promotions pack with platypedia?
 
Possible but not advisable.
The more you add the more performance taxing it is.
Try running gigapack at huge map end game and see how it goes.
 
@whoever sent me the PM
Your inbox is already full...

Anyway either open CvEventManager file of terapack to see how to merge python codes of traits and wonders.

Else ask in quick modding thread cos I am buzy in RL
 
Basically, those in Terapack are the better performance ones which do not require callbacks or intensive checks.
 
I am download Merlion as single wonder. It's work nice, but that wonder ignore U.N. resolution for banned nuclear weapons and ignore Manhattan Project requirements, in all other cities i can't build nukes if Nuclear weapons are banned.

How i can change Merlion, that this building respect U.N. resolution for banned nuclear weapons and Manhattan Project requirements?

Merlion codes:

PHP:
	def canTrain(self,argsList):
		pCity = argsList[0]
		eUnit = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		bIgnoreUpgrades = argsList[5]
## Merlion Start ##
		if pCity.getNumActiveBuilding(gc.getInfoTypeForString("BUILDING_MERLION")) == true:
			eUnitInfo = gc.getUnitInfo(eUnit)
			if eUnitInfo.getPrereqAndBonus() != -1 or eUnitInfo.getPrereqOrBonuses(0) != -1:
				pPlayer = gc.getPlayer(pCity.getOwner())
				pTeam = gc.getTeam(pPlayer.getTeam())
				if pTeam.isHasTech(eUnitInfo.getPrereqAndTech()) == false:
					return False
				i = 0
				while eUnitInfo.getPrereqAndTechs(i) != -1:
					if pTeam.isHasTech(eUnitInfo.getPrereqAndTechs(i)) == false:
						return False
					i += 1
				if pCity.allUpgradesAvailable(eUnit, 0) == -1:
					return True
## Merlion End ##
		return False
 
Code:
## Merlion Start ##
		if pCity.getNumActiveBuilding(gc.getInfoTypeForString("BUILDING_MERLION")):
			eUnitInfo = gc.getUnitInfo(eUnit)
			bRequireBonus = False
			if eUnitInfo.getPrereqAndBonus() > -1:
				bRequireBonus = True
			if not bRequireBonus:
				for iBonus in xrange(gc.getNUM_UNIT_PREREQ_OR_BONUSES()):
					if eUnitInfo.getPrereqOrBonuses(iBonus) > -1:
						bRequireBonus = True
						break
			if bRequireBonus:
				pPlayer = gc.getPlayer(pCity.getOwner())
				pTeam = gc.getTeam(pPlayer.getTeam())
				if not pTeam.isHasTech(eUnitInfo.getPrereqAndTech()):
					return False
				for iTech in xrange(gc.getNUM_UNIT_AND_TECH_PREREQS()):
					if eUnitInfo.getPrereqAndTechs(iTech) > -1:
						if not pTeam.isHasTech(eUnitInfo.getPrereqAndTechs(iTech)):
							return False
				if eUnitInfo.getNukeRange() > -1:
					if not CyGame().canTrainNukes():
						return False
				if eUnitInfo.getStateReligion() > -1:
					if pPlayer.getStateReligion() != eUnitInfo.getStateReligion():
						return False
				if eUnitInfo.getPrereqReligion() > -1:
					if not pCity.isHasReligion(eUnitInfo.getPrereqReligion()):
						return False
				if eUnitInfo.getPrereqCorporation() > -1:
					if not pCity.isHasCorporation(eUnitInfo.getPrereqCorporation()):
						return False
				if eUnitInfo.getPrereqBuilding() > -1:
					if not pCity.isHasBuilding(eUnitInfo.getPrereqBuilding()):
						return False
				iUnitClass = eUnitInfo.getUnitClassType()
				UnitClassInfo = gc.getUnitClassInfo(iUnitClass)
				if isWorldUnitClass(iUnitClass):
					if CyGame().getUnitClassCreatedCount(iUnitClass) >= UnitClassInfo.getMaxGlobalInstances():
						return False
				if isTeamUnitClass(iUnitClass):
					if pTeam.getUnitClassCountPlusMaking(iUnitClass) >= UnitClassInfo.getMaxTeamInstances():
						return False
				if isNationalUnitClass(iUnitClass):
					if pPlayer.getUnitClassCountPlusMaking(iUnitClass) >= UnitClassInfo.getMaxPlayerInstances():
						return False
				if pCity.allUpgradesAvailable(eUnit, 0) == -1:
					return True
## Platyping Wonders End ##
 
Top Bottom