Dummy Buildings in Civ6

LeeS

Imperator
Joined
Jul 23, 2013
Messages
7,241
Location
Illinois, USA
Dummy Buildings in Civ6

  1. Dummy Buildings are alive and well in Civ6, and while their use will probably be less widespread than it was in Civ5, some effects that cannot currently be done via the Modifiers system with its Requirements Sets and & etc. wil be accomplishable with dummy buildings.
  2. Use of a Dummy Buildng for the most part will require a combination of the xml to create the building, and some lua to implement adding the building to a city center when the correct conditions are met.
  3. The xml required is not particularly hard, but there will be 3 components needed, each loaded into the game from a different set of commands within the modinfo file. Sorry, but there's no way around this at the moment because of the database system Firaxis chose to implement for Civ6.
  4. You will need the following three elements in three different xml files to implement a dummy building into the game's database:
    1. Definition of the Dummy Building:
      For a Dummy we will call "BUILDING_DUMBO". We will place the code into a file called DumboBuilding.xml
      Code:
      <GameInfo>
      	<Types>
      		<Row Type="BUILDING_DUMBO" Kind="KIND_BUILDING" />
      	</Types>
      	<Buildings>
      		<Row BuildingType="BUILDING_DUMBO" Name="LOC_BUILDING_DUMBO_NAME" PrereqDistrict="DISTRICT_CITY_CENTER"
      			Cost="1" EnabledByReligion="true" />
      	</Buildings>
      </GameInfo>
      And in the modinfo file we will need:
      Code:
      	<Components>
      		<UpdateDatabase id="Dummy_XML">
      			<Items>
      				<File>DumboBuilding.xml</File>
      			</Items>
      		</UpdateDatabase>
      	</Components>
      • We use EnabledByReligion="true" so that the game is faked into thinking the building can only be acquired when a specific religious belief is adopted, but we then also never specify the belief. This results in a building a player cannot build or purchase.
      • We do not specify a purchase type of yield, again to keep the building from becoming acquirable via 'normal' methods.
      • We cannot use InternalOnly="true" because while this allows us the other advantages we are looking for, once we place such a building into a city, we are unable to remove it from the city via an lua script if we would like our code to be able to do so.
    2. Definition of the Dummy Building's Icon
      We will place the code into a file called DumboBuildingIcons.xml
      Code:
      <GameData>
      	<IconDefinitions>
      		<Row Name="ICON_BUILDING_DUMBO" Atlas="ICON_ATLAS_BUILDINGS" Index="0"/>
      		<Row Name="ICON_BUILDING_DUMBO_FOW" Atlas="ICON_ATLAS_BUILDINGS_FOW" Index="0"/>
      	</IconDefinitions>
      </GameData>
      And in the modinfo file we will need:
      Code:
      	<Components>
              	<Icons id="Dummy_ICONS">
                  		<Items>
                      		<File>DumboBuildingIcons.xml</File>
                  		</Items>
              	</Icons>
      	</Components>
      • We want to define the Icon so we do not get the ugly question mark in-game related to this dummy building.
      • Note that I am borrowing the monument's icon. we can do this. In fact, we can re-use a pre-existing icon as many times as we want.
      • Note also that the name of the icon string and the name of the building must conform to the patterns given of
        Code:
        ICON_ + Building-Name-As-Used-in-Table-<Buildings>
        
        and
        
        ICON_ + Building-Name-As-Used-in-Table-<Buildings> + _FOW
    3. Definition of the Dummy Building's Name
      We will place the code into a file called DumboBuildingText.xml
      Code:
      <GameData>
      	<LocalizedText>
      		<Row Tag="LOC_BUILDING_DUMBO_NAME" Language="en_US">
      			<Text>Dumbo</Text>
      		</Row>
      	</LocalizedText>
      </GameData>
      And in the modinfo file we will need:
      Code:
      	<Components>
      		<LocalizedText id="Dummy_Text">
      			<Items>
      				<File>DumboBuildingText.xml</File>
      			</Items>
      		</LocalizedText>
      	</Components>
      We want to define the Name for similar reasons as for defining the Icon.
  5. Lua for adding a dummy building to a city.

    We will place the code into a file called DumboBuilding.lua, but I am not going to attempt to show all the lua code that would be necessary to fully create an lua script for adding a dummy building. I am currently in the process of testing a dynamic system that allows dummy buildings to be linked to whether or not a city has for example revealed Aluminum within the working confines of the city's plots, and to add a dummy to the city when this is the case. I will link from here to that mod once I have done a bit more testing and ensured the system is not creating any wierd unforeseen bugs.

    What I am presenting here is two basic functions that can be tucked into an lua file and used as needed. in this particular example, along with other code, they'd be included within file DumboBuilding.lua
    1. Adding a dummy to a city:
      You need to send the city pointer-object as argument pCity and the building's index # as the argument for iBuilding
      Code:
      function PlaceBuildingInCityCenter(pCity, iBuilding)
      	local iCityPlotIndex = Map.GetPlot(pCity:GetX(), pCity:GetY()):GetIndex()
      	if not pCity:GetBuildings():HasBuilding(iBuilding) then
      		pCity:GetBuildQueue():CreateIncompleteBuilding(iBuilding, iCityPlotIndex, 100);
      	end
      end
    2. Removing a dummy from a city:
      You need to send the city pointer-object as argument pCity and the building's index # as the argument for iBuilding
      Code:
      function RemoveBuildingFromCityCenter(pCity, iBuilding)
      	if pCity:GetBuildings():HasBuilding(iBuilding) then
      		pCity:GetBuildings():RemoveBuilding(iBuilding);
      	end
      end
    And in the modinfo file we will need:
    Code:
    	<Components>
    		<GameplayScripts id="Dummy_LUA">
    			<Items>
    				<File>DumboBuilding.lua</File>
    			</Items>
    		</GameplayScripts>
    	</Components>
  6. In any lua script, you can get a building's index # via this:
    Code:
    local iBuilding = GameInfo.Buildings["BUILDING_DUMBO"].Index


Now for the bad news, because Firaxis there always is some:
  1. The dummy building will show in the city list of "Buildings and Wonders" view
  2. If you remove a building via lua from a city, the building does not disappear from the list of buildings in the city's "Buildngs and Wonders" view. The building is actually gone, but the Icon of the Building and its description remain.
  3. In order to eliminate the building from the list shown in the city's list, you have to save and reload the game. Civ5 graphics not update is alive and well in even more permutations in civ6 than it was in civ5.
  4. Adding and removing the building via lua acts correctly and the Building performs correctly as a Prereq for another building, etc., if that is what you are after. It is just that the display is not friendly to the modder.
 
Last edited:
Also, I'm pretty sure dummy buildings can be pillaged, at which point they will appear in the City Production menu for repairing.
 
LeeS, one thing you should test is Rome's ability which grants the player the cheapest city center building on founding of a city. Could be a problem.
 
Already tested. Isn't a problem because Trajan's ability is the cheapest buildng Trajan can have based on all other rules apllying to the building. Since he can't actually have the building because it is linked to religion, he gets the usual Monument.
 
I think that the flexibility of the Modifier system will make dummy buildings less of a necessity in Civ 6 mods. Though there are some things that Modifiers can't do but dummy buildings could, e.g. add Amenities or Housing to districts.
 
And act as prerequisites for units or for other buildings when certain conditions are met, such as having a resource available to a city. Adjaceny bonuses do not work for this unless the Building is a Wonder. So far as I know no one has had success attempting to create a Modifier that will only allow Building-X to be Constructed in a city if the city has Resource-Y somewhere in its borders.

There will almost certainly be more such conditions that arise as modders get more creative and attempt more sets of conditions, and encounter one that Firaxis did not think of and therefore implemented nothing in the Modifiers system to handle the specific effect needed.

-------------------------------------------------------------------------------------------------------------------------------

What will be the long-term best of course will be for Firaxis to implement a proper set of event hooks to lua, so that a CityCanConstruct or CityCanTrain event can be handled directly (for example) without the intermediary need for a dummy building to create the boolean for whether the city can do X or Y

But that discussion is really not the purview of this thread
 
Last edited:
So far as I know no one has had success attempting to create a Modifier that will only allow Building-X to be Constructed in a city if the city has Resource-Y somewhere in its borders.

Pretty sure you can have a requirement that achieves this.
 
Top Bottom