How to make the AI prioritze a (buffed) building

Tomice

Passionate Smart-Ass
Joined
Oct 5, 2009
Messages
2,353
Location
Austria, EU, no kangaroos ;)
The new per-city trade routes in BE make me wonder how Civ5 would play out this way.
There is a mod giving 1 extra trade route per caravansery, which is already close to what I want.

But will the AI understand the importance of the building? What makes them build it ASAP in every city as they should?

Or is there a better way to give one extra TR per city?
 
High flavors are the thing that makes the AI build a building more often.
 
A free dummy building in each city could also do this.
There are several ways like free civilisation building class, you can also hide it from the city view.

Example for a free trade route building for venice

Code:
<Civilization_FreeBuildingClasses>
<Row>
<CivilizationType>CIVILIZATION_VENICE</CivilizationType>
<BuildingClassType>BUILDINGCLASS_CCTPDUMMY1</BuildingClassType>
</Row>
</Civilization_FreeBuildingClasses>

<Buildings>
	<Row>
		<Type>BUILDING_CCTPDUMMY1</Type>
		<BuildingClass>BUILDINGCLASS_CCTPDUMMY1</BuildingClass>
		<!--hide this building-->
		<PrereqTech>NULL</PrereqTech>
		<Cost>-1</Cost>
		<FaithCost>-1</FaithCost>
		<GreatWorkCount>-1</GreatWorkCount>
		<!--hide this building-->
		<NumTradeRouteBonus>1</NumTradeRouteBonus>
		<NeverCapture>true</NeverCapture>
		<NukeImmune>true</NukeImmune>
		<IconAtlas>BW_ATLAS_1</IconAtlas>
		<PortraitIndex>19</PortraitIndex>
	</Row>
</Buildings>	

<BuildingClasses>
	<Row>
	<Type>BUILDINGCLASS_CCTPDUMMY1</Type>
	<DefaultBuilding>BUILDING_CCTPDUMMY1</DefaultBuilding>
	<Description>TXT_KEY_CCTPDUMMY1</Description>
</Row>
 
Thank you! You both helped me a lot!

@Gilgamesh:

How to give this building to every civ? I'd like to make it a general rule that all civs get 1 TR per city as incentive to go wide.
 
You would need to create a entry for every civ, like the example shows for venice.

Example
Spoiler :
<Row>
<CivilizationType>CIVILIZATION_VENICE</CivilizationType>
<BuildingClassType>BUILDINGCLASS_CCTPDUMMY1</BuildingClassType>
</Row>
<Row>
<CivilizationType>CIVILIZATION_POLYNESIA</CivilizationType>
<BuildingClassType>BUILDINGCLASS_CCTPDUMMY1</BuildingClassType>
</Row>
<Row>
<CivilizationType>CIVILIZATION_BRAZIL</CivilizationType>
<BuildingClassType>BUILDINGCLASS_CCTPDUMMY1</BuildingClassType>
</Row>
 
Thank you! You both helped me a lot!

@Gilgamesh:

How to give this building to every civ? I'd like to make it a general rule that all civs get 1 TR per city as incentive to go wide.
I can think of two methods that could be used.
  1. Add a <FreeBuilding> column to Palaces.
    • Any Building, National Wonder, or World Wonder that has a <FreeBuilding> column statement will give the specified building in all cities of that player, and will continue to do so throughout the remainder of the game. So in this case all civs' palaces would give the building for free to every city of that empire.
    • The flaw in this method is that when a capital city is captured, the Palace goes *poof*, and will take all the Free Buildings with it. This would mean that all the extra trade routes will likely go *poof* as well.
  2. Use an lua program to add the building to every city of a major player whenever they found a city.
    • In XML, the building would need to have a <ConquestProb>100</ConquestProb> so that it is always captured along with the city. This would be put in place of the <NeverCapture>true</NeverCapture> in Gilgamesch's example.
    • In this method you would also need to eliminate the <Civilization_FreeBuildingClasses> table shown in Gilgamesch's example.
You would need to create a entry for every civ, like the example shows for venice.

Example
Spoiler :
<Row>
<CivilizationType>CIVILIZATION_VENICE</CivilizationType>
<BuildingClassType>BUILDINGCLASS_CCTPDUMMY1</BuildingClassType>
</Row>
<Row>
<CivilizationType>CIVILIZATION_POLYNESIA</CivilizationType>
<BuildingClassType>BUILDINGCLASS_CCTPDUMMY1</BuildingClassType>
</Row>
<Row>
<CivilizationType>CIVILIZATION_BRAZIL</CivilizationType>
<BuildingClassType>BUILDINGCLASS_CCTPDUMMY1</BuildingClassType>
</Row>
This will not work if using the <Civilization_FreeBuildingClasses> table for these <Row> entries. <Civilization_FreeBuildingClasses> is only effective in the capital city. Whoward clarified this to me some time ago, and I verified through some testing that the building is only added in the capital city. Adding a <FreeBuilding> to all leader traits is not really a solution either, since it will interfere with Carthage (?) and the Free Harbors.
 
3. Set its FreeStartEra to ERA_ANCIENT - it's the simplest method, I learned it from the Nights mod
 
3. Set its FreeStartEra to ERA_ANCIENT - it's the simplest method, I learned it from the Nights mod
Ah! Elegant and simples! It has never occured to me to do that with a building :)

Using the method suggested by PawelS, you would have this in an XML file. This is a quick edit to Gilgamesch's original XML shown on this thread:
Code:
<GameData>
	<Buildings>
		<Row>
			<Type>BUILDING_CCTPDUMMY1</Type>
			<BuildingClass>BUILDINGCLASS_CCTPDUMMY1</BuildingClass>
			<Description>TXT_KEY_CCTPDUMMY1</Description>
			<FreeStartEra>ERA_ANCIENT</FreeStartEra>
			<!--hide this building-->
			<PrereqTech>NULL</PrereqTech>
			<Cost>-1</Cost>
			<FaithCost>-1</FaithCost>
			<GreatWorkCount>-1</GreatWorkCount>
			<!--hide this building-->
			<NumTradeRouteBonus>1</NumTradeRouteBonus>
			<ConquestProb>100</ConquestProb>
			<NukeImmune>true</NukeImmune>
			<IconAtlas>BW_ATLAS_1</IconAtlas>
			<PortraitIndex>19</PortraitIndex>
		</Row>
	</Buildings>	

	<BuildingClasses>
		<Row>
			<Type>BUILDINGCLASS_CCTPDUMMY1</Type>
			<DefaultBuilding>BUILDING_CCTPDUMMY1</DefaultBuilding>
			<Description>TXT_KEY_CCTPDUMMY1</Description>
		</Row>
	</BuildingClasses>

	<Language_en_US>
		<Row Tag="TXT_KEY_CCTPDUMMY1">
			<Text>Trade Routes</Text>
		</Row>
	</Language_en_US>
</GameData>
  • I also advocate getting in the habit of creating a valid <Description> tag set-up even for hidden buildings because there a few conditions where if it is omitted can cause game lock-ups or CTD or other game-ending errors. This is the only reason I specifically added the <Language_en_US> to the example.
  • You might also want to change all the CCTPDUMMY1 to something more unique to you. Remember that ALL CAPS (and/or numbers) is best practice for TXT_KEYS and the XML building and building-class names. (IE, all the TXT_KEY_SOMETHING, BUILDING_SOMETHING, and BUILDINGCLASS_SOMETHING statements).
 
That's awesome! So basically, the above code would work as it stands, I just need to change the "name"?
Yup. Otherwise if you are also using the CCTP mod, its version of BUILDING_CCTPDUMMY1 and your version of BUILDING_CCTPDUMMY1 will step all over each other and cause problems.

If you've never built a mod before, see these for how to create a mod using ModBuddy, how to activate the XML file in ModBuddy, and how to enable logging to allow for some error-debugging tools if you run into difficulty:
  1. LuvToBuild's The Newbie’s Guide to Modding Civilization 5
  2. whoward69's what ModBuddy setting for what file types tutorial
  3. whoward69's enable error logging tutorial
 
Right i missed the part with the text entries, with the huge amount of dummy buildings i only added them to spy and other mayor impact buildings.
But i will add them when i find some time for it.

For the free civ building class, thanks for pointing this out, that only the capital gets one.
I wasnt aware of this fact, i guess i need to write some ub palace buildings with the free building tag, to get the needed feature.
 
Top Bottom