[BtS] Technology Affected Buildings

xednix

Chieftain
Joined
Dec 27, 2007
Messages
10
Location
Earth
Hi,

I was trying to figure how to make buildings change as new technologies are discovered, and created this little mod component.
Maybe someone else can also use it for something.

Here is a download link:
http://forums.civfanatics.com/downloads.php?do=file&id=7892



Technology Affected Buildings (TAB) v0.21

1. What is this?

Technology Affected Buildings (TAB) is a mod component which does nothing on it's own, but allows creating buildings that improve or change as the player discovers new technologies.
It is based on BTS 3.13 + Bhruic 1.21.



2. What bonues can technologies provide?

New techonlogies can modify the following parameters of the buildings:
- yield (food, production, commerce) change
- commerce (gold, research, culture, espionage) change
- max specialists
- yield (food, production, commerce) modifier (%)
- commerce (gold, research, culture, espionage) modifier (%)

Negative numbers are allowed, but they are very local in scope: they affect only the technology affected part of the building.
This means that negative numbers can be used to make previous tech bonuses obsolete, but they can not change the city's yield, commerce or max specialist values.

Example:
Let's say a forge is affected by Banking (+1 gold) and Industrialism (-1 gold, +1 production)
This means that with the discovering of Banking all forges start to produce +1 gold. After researching Industrialism the forges no longer produce gold, but they will provide +1 production.

If the forge is modified that it is only affecetd by Industrialism (-1 gold, +1 production) then with the discovery of Industrialism all forges start to give +1 production and the -1 gold is ignored.



3. Does the AI know about these bonuses?

I tried to make the active bonuses visible in the int CvCityAI::AI_buildingValueThreshold(BuildingTypes eBuilding, int iFocusFlags, int iThreshold) method.
I am not quite sure if I managed to add this to every place where needed so any feeedback is welcome.

The bonuses are not visible when the AI tries to select a new technology to research.

You should consider adjusting the flavors on the buildings and technologies you change in your mod.




4. How can I use TAB in a mod that does not have other SDK changes?

Copy the CvGameCoreDLL.dll to the Assets folder of your mod.
Copy the CvMainInterface.py to the Assets\Python\Screens folder of your mod.
(Or just copy the changes marked by Techology Affected Buildings BEGIN and END blocks.)
Copy the CIV4BuildingsSchema.xml to the Assets\XML\Buildings folder of your mod.
Copy the CIV4GameText_TAB.xml to the Assets\XML\Text folder of your mod.
Edit the BuildingInfos.xml in the Assets\XML\Buildings folder of your mod.



5. How can I use TAB in an SDK mod?

See the previous post and add the changes from the attacjed source files to your source.
(Be sure to apply BTS 3.13 patch and Bhruic's 1.21 patch before using this one).

I put all changes I made into a
//****************************************
// Technology Affected Buildings: BEGIN
//****************************************

//****************************************
// Technology Affected Buildings: END
//****************************************
block.

If instead of adding new content I changed existing lines, I put the original lines in the closing part after a "Was:" word.
//****************************************
// Technology Affected Buildings: END
// Was:
// <Original code.>
//****************************************


Hope it helps.



6. What are the new XML elements available in the Civ4BuildingInfos.xml?

To affect commerce change add a TechCommerceChanges element to the end of a building type definition:

Code:
	<ElementType name="TechCommerceChanges" content="eltOnly">
		<element type="TechCommerceChange" minOccurs="0" maxOccurs="*"/>
	</ElementType>
	<ElementType name="TechCommerceChange" content="eltOnly">
		<element type="PrereqTech"/>
		<element type="TechCommerce"/>
	</ElementType>
	<ElementType name="PrereqTech" content="textOnly"/>
	<ElementType name="TechCommerce" content="eltOnly">
		<element type="iCommerce" minOccurs="0" maxOccurs="*"/>
	</ElementType>
	<ElementType name="iCommerce" content="textOnly" dt:type="int"/>


Example:
Add 5 espionage with computers.
Code:
<TechCommerceChanges>
	<TechCommerceChange>
		<PrereqTech>TECH_COMPUTERS</PrereqTech>
		<TechCommerce>
			<iCommerce>0</iCommerce>
			<iCommerce>0</iCommerce>
			<iCommerce>0</iCommerce>
			<iCommerce>5</iCommerce>
		</TechCommerce>		
	</TechCommerceChange>
</TechCommerceChanges>

To affect yield change add a TechYieldChanges element to the end of a building type definition:

Code:
	<ElementType name="TechYieldChanges" content="eltOnly">
		<element type="TechYieldChange" minOccurs="0" maxOccurs="*"/>
	</ElementType>
	<ElementType name="TechYieldChange" content="eltOnly">
		<element type="PrereqTech"/>
		<element type="TechYield"/>
	</ElementType>
	<ElementType name="PrereqTech" content="textOnly"/>
	<ElementType name="TechYield" content="eltOnly">
		<element type="iYield" minOccurs="0" maxOccurs="*"/>
	</ElementType>
	<ElementType name="iYield" content="textOnly" dt:type="int"/>



Example:
Add 1 food with refrigeration.
Code:
<TechYieldChanges>
	<TechYieldChange>
		<PrereqTech>TECH_REFRIGERATION</PrereqTech>
		<TechYield>
			<iYield>1</iYield>
		</TechYield>		
	</TechYieldChange>
</TechYieldChanges>


To affect allowed max specialists add TechSpecialistChanges element to the end of a building type definition:

Code:
	<ElementType name="TechSpecialistChanges" content="eltOnly">
		<element type="TechSpecialistChange" minOccurs="0" maxOccurs="*"/>
	</ElementType>
	<ElementType name="TechSpecialistChange" content="eltOnly">
		<element type="PrereqTech"/>
		<element type="SpecialistCounts"/>
	</ElementType>
	<ElementType name="PrereqTech" content="textOnly"/>
	<ElementType name="SpecialistCounts" content="eltOnly">
		<element type="SpecialistCount" minOccurs="0" maxOccurs="*"/>
	</ElementType>
	<ElementType name="SpecialistCount" content="eltOnly">
		<element type="SpecialistType"/>
		<element type="iSpecialistCount"/>
	</ElementType>
	<ElementType name="SpecialistType" content="textOnly"/>
	<ElementType name="iSpecialistCount" content="textOnly" dt:type="int"/>

Example:
Can turn 2 citizens to artist with mass media.
Code:
<TechSpecialistChanges>
	<TechSpecialistChange>
		<PrereqTech>TECH_MASS_MEDIA</PrereqTech>	
		<SpecialistCounts>
			<SpecialistCount>
				<SpecialistType>SPECIALIST_ARTIST</SpecialistType>
				<iSpecialistCount>2</iSpecialistCount>
			</SpecialistCount>
		</SpecialistCounts>
	</TechSpecialistChange>
</TechSpecialistChanges>

To affect commerce modifier add a TechCommerceModifiers element to the end of a building type definition:

Code:
	<ElementType name="TechCommerceModifiers" content="eltOnly">
		<element type="TechCommerceModifier" minOccurs="0" maxOccurs="*"/>
	</ElementType>
	<ElementType name="TechCommerceModifier" content="eltOnly">
		<element type="PrereqTech"/>
		<element type="TechCommerce"/>
	</ElementType>
	<ElementType name="PrereqTech" content="textOnly"/>
	<ElementType name="TechCommerce" content="eltOnly">
		<element type="iCommerce" minOccurs="0" maxOccurs="*"/>
	</ElementType>
	<ElementType name="iCommerce" content="textOnly" dt:type="int"/>

Example:
Add 10% espionage with computers.
Code:
<TechCommerceModifiers>
	<TechCommerceModifier>
		<PrereqTech>TECH_COMPUTERS</PrereqTech>
		<TechCommerce>
			<iCommerce>0</iCommerce>
			<iCommerce>0</iCommerce>
			<iCommerce>0</iCommerce>
			<iCommerce>10</iCommerce>
		</TechCommerce>		
	</TechCommerceModifier>
</TechCommerceModifiers>

To affect yield modifier add a TechYieldModifiers element to the end of a building type definition:

Code:
	<ElementType name="TechYieldModifiers" content="eltOnly">
		<element type="TechYieldModifier" minOccurs="0" maxOccurs="*"/>
	</ElementType>
	<ElementType name="TechYieldModifier" content="eltOnly">
		<element type="PrereqTech"/>
		<element type="TechYield"/>
	</ElementType>
	<ElementType name="PrereqTech" content="textOnly"/>
	<ElementType name="TechYield" content="eltOnly">
		<element type="iYield" minOccurs="0" maxOccurs="*"/>
	</ElementType>
	<ElementType name="iYield" content="textOnly" dt:type="int"/>


Example:
Add 10% food with refrigeration.
Code:
<TechYieldModifiers>
	<TechYieldModifier>
		<PrereqTech>TECH_REFRIGERATION</PrereqTech>
		<TechYield>
			<iYield>10</iYield>
		</TechYield>		
	</TechYieldModifier>
</TechYieldModifiers>


7. What about the save files?

The mod adds and looks for new data in the save files, so it is not compatible with other saves, not even with TAB v0.1.
Sorry.



8. What is in the download?

There are three folders in the attached zip file:
TAB
This directory contains the compiled CvGameCoreDLL.dll and the support files. If you are creating a mod that does not have other SDK changes you need only these files to use TAB.
Assets\CvGameCoreDLL.dll
Assets\XML\Buildings\CIV4BuildingsSchema.xml
Assets\XML\Text\CIV4GameText_TAB.xml
Assets\Python\Screens\CvMainInterface.py

Src
The modified source files.
CvCity.cpp
CvCity.h
CvCityAI.cpp
CvDLLWidgetData.cpp
CvDLLWidgetData.h
CvEnums.h
CvGameTextMgr.cpp
CvGameTextMgr.h
CvInfos.cpp
CvInfos.h
CvTeam.cpp
CvTeam.h
CyEnumsInterface.cpp
CyTeam.cpp
CyTeam.h
CyTeamInterface.cpp

Example

Contains an example BuildingInfos.Xml which demonstrates how TAB can be used to modify the science buildings in the following way:
With education universities (seowons) can turn 1 citizen to scientist and 1 citizen to priest (+1 scientist, +1 priest).
With scientific method univerities (seowons) can turn 2 citizens to scientist and 0 to priest (+1 scientist, -1 priest).
With computers libraries (madrasas), observatories (salons) and laboratories (research institutes) provide +2 research.
With computers universities (seowons) provide +10% science.
Libraries (madrasas) can turn only 1 citizen to scientist (This is not TAB, just to balance out the extra scientists the universities add).


X
 
Cool idea!

Any chance of extending it to allow modifiers like +10% rather than fixed values? This would make it possible to stop obsoleting monastaries and just obsolete their research bonus. As it stands right now though you can do a lot to resolve minor annoyances like that with your current setup.

I think I might have to add this to my mod :)
 
I was thinking about making something like this, but it was low on my to do list. Thanks for saving me the work and nice job! :thumbsup:


Another possible thing would be yield/commerce modifiers... so Factories could go from giving +50% Production (is that what it is?) to 50% plus an additional 25% with Computers or something.
 
I was also thinking about adding yield and commerce modifiers(%). Well, next year maybe...

X
 
Added commerce and yield modifiers (%).
Updated the opening post to the new version.

X
 
Is seems the file is still in the moderation queue. I think it will be available when a moderator approves it.
 
Following this path, do you think 'Technology Affected Units' is doable ?

It's doable, but what factors would you like the Techs to influence?

Off the top of my head I'd say
  • Unit Strength
  • Production time
  • Bonus Prereq removal
  • Free (inherent) promotions (covers a lot of potential modifiers with this)

What else would be useful?
 
Following this path, do you think 'Technology Affected Units' is doable ?

Probably it is doable, but I think units are already - in some way - technology affected. You can upgrade them after discovering new technologies, what results in more power and sometimes more speed and other bonuses as well.
 
Yes, but there are units staying the same from beginning til end of game ( worker - settler - ... ).
Each unit can have 3 era graphics and, therefore, it will be nice to have such a feature to complement the art change.

ex 1 :
Legionnary I str 7 mov 1 ...
Legionnary II str 8 mov 1 ... with Marius reform
Legionnary III str 8 mov 1 ... 10% more against melee with Empire

ex 2 :
Riflemen I str 14 str 1 mov ...
Riflemen II str 15 str 1 mov ... with Military Tradition
Riflemen III str 17 str 1 mov ... with Railroad

and so on for flexibility inside the same uniit type. Think of Jet fighter from 1955 until now, of subs from 1925 until now, etc ... etc ...
 
Thank you xienwolf. I have corrected this in the opening post.

Just incorporated this for FfH mod-modding. Wanted to point out that in your examples in the first post & Readme you list "TechYields" instead of "TechYield" which will cause some errors for people :)
 
xednix, please check your private messages.
 
great job xednix, this should prove useful for many modders :thumbsup:
 
Top Bottom