How to fix unique building and unique units being available to other civilisations?

Joined
Dec 11, 2022
Messages
2,490
If you go to the comments section of the Steam Workshop page for several civilization mods, you will find a lot of complaints about the civilisation's unique unit/building being available to build/purchase for anyone. Unfortunately, a lot of modders seem not to read the comments section, and so these issues remain unresolved.
An example is Urdnot's Yemen mod. The Mud Brick Skyscraper can be built by anyone. However, someone in the comments section suggested the following solution:
The bugs that Mud-brick skyscraper can be built by any civilisation can be solved by fixing YemenDefines.sql as follows:
1. 'BUILDINGCLASS_URD_YEMEN' -> 'BUILDINGCLASS_URD_MBS',
(There are 4 'BUILDINGCLASS_URD_YEMEN's in YemenDefines.sql)
2. 'BUILDING_URD_YEMEN' -> 'BUILDING_URD_ARWA_MBS',
3. replace
INSERT INTO Building_ClassesNeededInCity
(BuildingType, BuildingClassType)
VALUES ('BUILDING_URD_ARWA_MBS_2', 'BUILDINGCLASS_GRANARY'),
with
INSERT INTO Building_ClassesNeededInCity
(BuildingType, BuildingClassType)
VALUES ('BUILDING_URD_ARWA_MBS_2', 'BUILDINGCLASS_URD_MBS' ),

I know next to nothing about modding so I have no idea how to replicate this solution for other mods, eg. JFD's Great Seljuqs, Grant's Chagatai etc. Could someone help me with this?
 
So each building is brought in by a building class like you suggested.

The civ specific/unique building per civ are also added this same way.

So you can have a temple/tomb for instant from the Egypt civ.
It's building class is still a temple then in the civilization coding it you allows it to be assigned to a civ.
Assuming the building code is set up correctly for a unique version.
I assume you have done all that.

Are you adding an all new building type to the game then adding a unique version of it for a civ?

If so set it to -1 production to build the original then set the real production value for the unique replacement.
This will make it impossible to build the standard version making only the civ specific unique building buildable and for that civ only.

From my understanding it seems like the building was added but then they set it up to be unique. But since an all new building class was added. Then the building class was set up to have a unique replacement. But since since a new class was added. One you do not want other civs to be able build set production value needed to -1 this will disable the base class building stopping other civs from being able to build it.

Hope this helps I can come back on my PC and show the coding examples and how to do it.
 
Last edited:
Thank you immensely for answering!
So you can have a temple for instant from the Egypt civ.
It's building class is still a temple then in the civilization coding it you allows it to be assigned to a civ.
Assuming the building code is set up correctly for a unique version.
I assume you have done all that.

Are you adding an all new building type to the game then adding a unique version of it for a civ?
To be clear, I am not myself adding anything. I only want to fix mods created by other modders.

As I'm understanding it, there are two aspects to a unique building: one is building type, which refers to the actual unique building itself (in this case, the Mud-brick Skyscraper) and the other is building class type, which is the type - or class - of building is (in this case, the Mud-brick Skyscraper is a type of Granary).

If the Mud-brick Skyscraper's class is set to granary, then everyone who can build a granary can build it. If the Mud-brick Skyscraper's class is unique, then only civilization with access to the unique can build it (not sure how that's coded).

1. 'BUILDINGCLASS_URD_YEMEN' -> 'BUILDINGCLASS_URD_MBS',
(There are 4 'BUILDINGCLASS_URD_YEMEN's in YemenDefines.sql)
2. 'BUILDING_URD_YEMEN' -> 'BUILDING_URD_ARWA_MBS',
3. replace
INSERT INTO Building_ClassesNeededInCity
(BuildingType, BuildingClassType)
VALUES ('BUILDING_URD_ARWA_MBS_2', 'BUILDINGCLASS_GRANARY'),
with
INSERT INTO Building_ClassesNeededInCity
(BuildingType, BuildingClassType)
VALUES ('BUILDING_URD_ARWA_MBS_2', 'BUILDINGCLASS_URD_MBS' ),
So I guess what's happening here is the building type class is BUILDINGCLASS_URD_MBS instead of BUILDINGCLASS_URD_YEMEN and the building type is BUILDING_URD_MBS instead of BUILDING_URD_YEMEN. Maybe that was an oversight by the original modder? I'll have to check the files when I get home to be sure.

And in the last step, the BuildingClassType is set to BUILDINGCLASS_GRANARY which means anyone can build it, and is replaced by BUILDINGCLASS_URD_MBS so only Yemen can build it? I suppose the code for Skyscraper replacing the Granary is somewhere else?
 
The class needed line means you have to have a granary in order to build it in a city.
it Making it class granary, type your new building. Means it is replacing the granary. The game will then know it's a new granary type building and won't be buildable untill you set it to be built by a civ.
 
3. replace
INSERT INTO Building_ClassesNeededInCity
(BuildingType, BuildingClassType)
VALUES ('BUILDING_URD_ARWA_MBS_2', 'BUILDINGCLASS_GRANARY'),
with
INSERT INTO Building_ClassesNeededInCity
(BuildingType, BuildingClassType)
VALUES ('BUILDING_URD_ARWA_MBS_2', 'BUILDINGCLASS_URD_MBS' ),
So in this step, the BuildingClassType has changed to URD_MBS instead of _GRANARY. Does this mean the building needed to build the MBS (mud-brick skyscraper) is also the MBS, and the replacement is wrong?
 
My PC booting up.

First we need to fix the building code to make it unique.

Then in a different code file. The one containing your civ you will need to set that civ to use the new unique building and I'll write those for you.
 
he did this very different then normal. he added dummy building and some other complicated mechanics.

if you want to make and implement your own unique building or fix other ect...

i would recommend using this as a template

Code:
--Buildings
--------------------------------------------------------------------------------------------------
INSERT INTO Buildings (Type,    BuildingClass,                PrereqTech,                ConquestProb,    Cost,    GoldMaintenance,    Happiness,    SpecialistType,            SpecialistCount,    HurryCostModifier,    IconAtlas,            PortraitIndex,    Description,                Help,                                Strategy,                                Civilopedia,                            ArtDefineTag,        DisplayPosition,    ArtInfoRandomVariation,    MinAreaSize)
SELECT 'BUILDING_MALL',        'BUILDINGCLASS_STADIUM',    'TECH_REFRIGERATION',    100,            450,    0,                    4,            'SPECIALIST_MERCHANT',    1,                    0,                    'FA_UB_ATLAS',        0,                'TXT_KEY_BUILDING_MALL',    'TXT_KEY_BUILDING_MALL_HELP',    'TXT_KEY_BUILDING_MALL_STRATEGY',    'TXT_KEY_BUILDING_MALL_TEXT',    'STADIUM',            2,                    1,                        -1;

this is very organized and easy to follow

this only adds a unique mall improvement but you can see it is
type mall
class stadium

that means it is a replacement for the stadium
at least this would be the standard way
 
Last edited:
Code:
--------------------------------------------------------------------------------------------------
--Unique Buildings
--------------------------------------------------------------------------------------------------
INSERT INTO Civilization_BuildingClassOverrides  (CivilizationType,        BuildingClassType,                BuildingType)
SELECT 'CIVILIZATION_AMERICA',                                            'BUILDINGCLASS_STADIUM',        'BUILDING_MALL';

this code then adds it to America
or i should say allows America to build it
 
Last edited:
Sorry to be bothering you again, but what does the second of the INSERT INTO Buildings do in the following code?

Code:
INSERT INTO Buildings     
        (Type,                       BuildingClass, PrereqTech,      Cost, SpecialistType,    SpecialistCount, FaithCost, GoldMaintenance, MinAreaSize, NeverCapture, Description,                         Help,                                     Strategy,                                    Civilopedia,                              ArtDefineTag, PortraitIndex, IconAtlas)
SELECT    'BUILDING_JFD_NEZAMIYEH', BuildingClass, 'TECH_THEOLOGY', Cost, SpecialistType,    SpecialistCount, FaithCost, GoldMaintenance, MinAreaSize, 1,             'TXT_KEY_BUILDING_JFD_NEZAMIYEH',     'TXT_KEY_BUILDING_JFD_NEZAMIYEH_HELP',     'TXT_KEY_BUILDING_JFD_NEZAMIYEH_STRATEGY',    'TXT_KEY_BUILDING_JFD_NEZAMIYEH_TEXT',   ArtDefineTag, 2,               'JFD_GREAT_SELJUQS_AL_MULK_ICON_ATLAS'
FROM Buildings WHERE Type = 'BUILDING_UNIVERSITY';       

INSERT INTO Buildings     
        (Type,                                  BuildingClass,                                 GreatWorkCount, Cost, FaithCost, PrereqTech, GreatPeopleRateModifier,    NeverCapture,    Description,                                 Help)
VALUES    ('BUILDING_JFD_NEZAMIYEH_GP_GEN',     'BUILDINGCLASS_JFD_GREAT_SELJUQS_AL_MULK',     -1,             -1,   -1,          null,          10,                        1,                'TXT_KEY_BUILDING_JFD_NEZAMIYEH_GP_GEN',    'TXT_KEY_BUILDING_JFD_NEZAMIYEH_GP_GEN_HELP');
 
Trying to fix JFD's Great Seljuq mod, where anyone can purchase the Nezamiyeh Unique Building with faith. As can be seen in the code in the previous post, JFD inserts two buildings: the actual Nezamiyeh, and an upgrade. I believe this is similar to what was happening in the Yemen mod, where there were four upgrades to the Skyscraper building but one of them was not tied to the Yemeni civilization, allowing anyone to purchase it as well.

So what I decided was to create a new entry in BuildingClass_Overrides for the upgrade as well (since the only such entry was for the original building), however this did not resolve matters at all, and I have no idea what else I'm supposed to try.

Edited mod is attached.
.
 

Attachments

  • JFD's Civilizations - Great Seljuqs (Nizam al-Mulk) (v 1).zip
    11.2 MB · Views: 13
Top Bottom