add a victory condition on F8 scren

juni_be_good

Black mage
Joined
Jun 26, 2005
Messages
115
Location
Caen, France
I have made a mod that adds a new victory condition : being able to get the shrine of every religion. The mod works, but something is missing in it : I don't know how to display the player's progression on this victory on the F8 screen. I know is it set in the CvVictoryScreen file, but I don't understand how it works

Can someone help me a little with this damned Python script ?
 
There're two parts. First find your score and the best score for your opponents. Second display your score and opponent's best score.

A good place to put the code for the first part is right before # Vote (about line 430). for ex, i made a victory condition when you have 30,000 gold.
PHP:
# Total Gold
		ourGold = activePlayer.getTeam().countTotalGold()
		
		iBestGoldTeam = -1
		bestGold = -1
		for iLoopTeam in range(gc.getMAX_CIV_TEAMS()):
			if (gc.getTeam(iLoopTeam).isAlive() and not gc.getTeam(iLoopTeam).isMinorCiv() and not gc.getTeam(iLoopTeam).isBarbarian()):
				if (iLoopTeam != iActiveTeam and (activePlayer.getTeam().isHasMet(iLoopTeam) or gc.getGame().isDebugMode())):
					teamGold = gc.getTeam(iLoopTeam).countTotalGold()
					if (teamGold > bestGold):
						bestGold = teamGold
						iBestGoldTeam = iLoopTeam

it loops through all teams and stores the team with the bestGold.

then go to the place to display the scores on the screen. look for the line that says if (bEntriesFound): (about line 630). right before this line, add your code to check for the condition and add table entries. indent it to match the previous conditions. my code looks like this:

PHP:
## CA edit -- added section for commercial victory
				if (victory.getTotalGold() > 0):
					iRow = screen.appendTableRow(szTable)
					
					screen.setTableText(szTable, 0, iRow, localText.getText("TXT_KEY_VICTORY_SCREEN_TOTAL_GOLD", (victory.getTotalGold(),)), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
					screen.setTableText(szTable, 1, iRow, activePlayer.getTeam().getName() + ":", "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
					screen.setTableText(szTable, 2, iRow, unicode(ourGold), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
					if (iBestGoldTeam != -1):
						screen.setTableText(szTable, 3, iRow, gc.getTeam(iBestGoldTeam).getName() + ":", "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
						screen.setTableText(szTable, 4, iRow, unicode(bestGold), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
					bEntriesFound = True
## CA edit -- end
					
				if (bEntriesFound):

also, make new XML texts. for ex:

PHP:
<TEXT>
	<Tag>TXT_KEY_VICTORY_COMMERCIAL</Tag>
	<English>Commercial</English>
</TEXT>
<TEXT>
	<Tag>TXT_KEY_VICTORY_COMMERCIAL_PEDIA</Tag>
	<English>Commercial Victory Pedia</English>
</TEXT>
<TEXT>
	<Tag>TXT_KEY_VICTORY_SCREEN_TOTAL_GOLD</Tag>
	<English>%d1 total gold</English>
</TEXT>

%d1 will match your condition set in your CIV4VictoryInfo.xml. in my case, it will say 30,000 total gold because of code in the previous section:

PHP:
localText.getText("TXT_KEY_VICTORY_SCREEN_TOTAL_GOLD", (victory.getTotalGold(),))
 
Chinese American said:
There're two parts. First find your score and the best score for your opponents. Second display your score and opponent's best score.

A good place to put the code for the first part is right before # Vote (about line 430). for ex, i made a victory condition when you have 30,000 gold.
PHP:
# Total Gold
		ourGold = activePlayer.getTeam().countTotalGold()
		
		iBestGoldTeam = -1
		bestGold = -1
		for iLoopTeam in range(gc.getMAX_CIV_TEAMS()):
			if (gc.getTeam(iLoopTeam).isAlive() and not gc.getTeam(iLoopTeam).isMinorCiv() and not gc.getTeam(iLoopTeam).isBarbarian()):
				if (iLoopTeam != iActiveTeam and (activePlayer.getTeam().isHasMet(iLoopTeam) or gc.getGame().isDebugMode())):
					teamGold = gc.getTeam(iLoopTeam).countTotalGold()
					if (teamGold > bestGold):
						bestGold = teamGold
						iBestGoldTeam = iLoopTeam

it loops through all teams and stores the team with the bestGold.

then go to the place to display the scores on the screen. look for the line that says if (bEntriesFound): (about line 630). right before this line, add your code to check for the condition and add table entries. indent it to match the previous conditions. my code looks like this:

PHP:
## CA edit -- added section for commercial victory
				if (victory.getTotalGold() > 0):
					iRow = screen.appendTableRow(szTable)
					
					screen.setTableText(szTable, 0, iRow, localText.getText("TXT_KEY_VICTORY_SCREEN_TOTAL_GOLD", (victory.getTotalGold(),)), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
					screen.setTableText(szTable, 1, iRow, activePlayer.getTeam().getName() + ":", "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
					screen.setTableText(szTable, 2, iRow, unicode(ourGold), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
					if (iBestGoldTeam != -1):
						screen.setTableText(szTable, 3, iRow, gc.getTeam(iBestGoldTeam).getName() + ":", "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
						screen.setTableText(szTable, 4, iRow, unicode(bestGold), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
					bEntriesFound = True
## CA edit -- end
					
				if (bEntriesFound):

also, make new XML texts. for ex:

PHP:
<TEXT>
	<Tag>TXT_KEY_VICTORY_COMMERCIAL</Tag>
	<English>Commercial</English>
</TEXT>
<TEXT>
	<Tag>TXT_KEY_VICTORY_COMMERCIAL_PEDIA</Tag>
	<English>Commercial Victory Pedia</English>
</TEXT>
<TEXT>
	<Tag>TXT_KEY_VICTORY_SCREEN_TOTAL_GOLD</Tag>
	<English>%d1 total gold</English>
</TEXT>

%d1 will match your condition set in your CIV4VictoryInfo.xml. in my case, it will say 30,000 total gold because of code in the previous section:

PHP:
localText.getText("TXT_KEY_VICTORY_SCREEN_TOTAL_GOLD", (victory.getTotalGold(),))



ive been trying to add this same victory condition with no success. is this all the code for it or is this just the code to display it on the victory screen? i didnt see where it specified the amount of gold for the victory... 30,000 as you said. if this isnt all, could i possibly get ahold of the rest and if it is indeed all, where is the "30,000" in the code? thanks!
 
you also need to change schema and sdk files. in CFC file database, look for "trade routes"; I uploaded two zips. the zip with SDK changes includes the victory code. XML files can be found in the separate Trade Routes mod. those changes to victory are found in CIV4GameInfoSchema.xml and CIV4VictoryInfo.xml ; basically just added one element.

in schema file, I added
<ElementType name="iTotalGold" content="textOnly" dt:type="int"/>
and
<element type="iTotalGold" minOccurs="0"/>


in victoryinfo, it's found in a new commercial victory condition
<iTotalGold>30000</iTotalGold>
 
Chinese American said:
you also need to change schema and sdk files. in CFC file database, look for "trade routes"; I uploaded two zips. the zip with SDK changes includes the victory code. XML files can be found in the separate Trade Routes mod. those changes to victory are found in CIV4GameInfoSchema.xml and CIV4VictoryInfo.xml ; basically just added one element.

in schema file, I added
<ElementType name="iTotalGold" content="textOnly" dt:type="int"/>
and
<element type="iTotalGold" minOccurs="0"/>


in victoryinfo, it's found in a new commercial victory condition
<iTotalGold>30000</iTotalGold>


thanks again
 
Back
Top Bottom