esosorcdc

Chieftain
Joined
Aug 3, 2017
Messages
90
What I want to do is make it where a new building that I made can only be built by human players. So removing a building from the list of available buildings that can the built in the cities of NPC players only.

GAME EVENTS (CityCanConstruct/PlayerCanConstruct) NOT VALID IN CIV 6:

After some research I found the game events GameEvents.CityCanConstruct(iPlayer, iCity, iBuildingType) and GameEvents.PlayerCanConstruct(playerID, buildingTypeID) in the Civ 5 forms so I tried to use them for Civ 6, but neither of them worked so I assume that these two game events are not valid in Civ 6. Also I would like to quote an extremely useful post that I found of a spreadsheet with Civ 6 LUA events and objects (See Below), which does not list the two game events I stated above solidifying my assumption that these two events are not valid in Civ 6. Am I Correct? I just want to make 100% sure and put it out there so others don't waste time trying to use these events in Civ 6.

See the spreadsheets here for a dump of functions in player, unit, city, plot and some of the manager and configuration, as well as a partial dump of _G, and all the events:
https://docs.google.com/spreadsheets/d/1HQSUOmw_pI8dNSr1kmun4qAHj6SsOVfa1vGTbk5mVvs/edit#gid=0

It was made before the fall patch, and shows the difference between what's available in script and UI contexts..

WORKAROUND FOR HUMAN PLAYER ONLY BUILDING:

So I did some more research on finding a workaround. What I did was made it were every time a player has it's turn, the player is tested whether or not its human. If the player is not human, then it tests each of the NPC player's cities on whether or not they have the building in the build queue. If it is, then the building is removed from the build queue before any build progress is made. Then it tests each of the NPC player's cities on whether or not it has the building built in the city. If it does, then the building is removed from the city. So in actual game play, after it is kicked from the build queue the NPC civilizations just go on and start building something else. When they finish building whatever they were building they try to built it again, then something else, etc. The City States however keep trying to build it until I guess they feel like they need more units or something. I can see all this through Fire Tuner by the way. So yea, its not perfect, it does not do exactly what I want it to do, but I would say it is a viable work around. The LUA code is posted below and it works so copy and paste if you want to use it, just change BUILDING_NEW_BUILDING to your building's BuildingType. And if anyone has any other workarounds please post and explain. Like maybe there is a way to make your building not show up in the production panel of an NPC city which would make it where they can't built it? I don't know, just throwing it out there.

THE WORKAROUND LUA CODE (Working Code):

The following code is for your .lua file. Make sure to change BUILDING_NEW_BUILDING to your building's BuildingType. Also don't forget, under your project properties, under In-Game Actions, Add Action > Import Files and add your .lua file to it, then also under In-Game Actions, Add Action > AddGameplayScripts and add your .lua file to that to.

Code:
function NewBuildingHumanOnly( iPlayer, bIsFirstTime )
    local pPlayer = Players[iPlayer]
    local pNewBuilding = GameInfo.Buildings["BUILDING_NEW_BUILDING"].Index
    if (not pPlayer:IsHuman()) and (pPlayer:GetCities():GetCapitalCity() ~= nil) then
        local pCities:table = pPlayer:GetCities()
        for i, pCity in pCities:Members() do
            local pCityBuildQ = pCity:GetBuildQueue()
            local pCityBuildings = pCity:GetBuildings()
            local sCityName = Locale.Lookup(pCity:GetName())
            local pBeingBuilt = pCityBuildQ:CurrentlyBuilding()
            local pBeingBuiltStr = tostring(pBeingBuilt)
            local pNewBuildingStr = "BUILDING_NEW_BUILDING"
            if pBeingBuiltStr == pNewBuildingStr then
                print("An NPC tried to build the New Building at " .. sCityName .. ", so it was removed from the city's build queue.")
                pCityBuildQ:RemoveBuilding(pNewBuilding)
            else
            if pCityBuildings:HasBuilding(pNewBuilding) then
                print("An NPC had the New Building built at " .. sCityName .. ", so the buiding was removed from the city.")
                pCityBuildings:RemoveBuilding(pNewBuilding)
            else
            end
            end
        end
    end
end
Events.PlayerTurnActivated.Add(NewBuildingHumanOnly)
 
Problem with the workaround that I posted is that NPCs won't build walls or a "swarm" of units. I see them build other buildings, districts, settlers, and some combat units, but I guess they keep trying to build it to much and they get super behind and your able to just steam roll them with ease. Anybody know of a better way to make a building available to human players only please reply.
 
and I need to update it to the post-patch version :lol: but I was holding off hoping there would be a hotpatch to fix some of the more egreggious stuff the summer 17 patch seems to have messed up (like everyone telling you you should make nukes in 2500 bc).

The key method I am now using is:
  1. two buildings each of which require the other, so neither can ever be built in any city. (this was Suk's idea)
  2. all dummy buildings in the database are auto-set by my SQL code to require one of these two buildings as a PreReqBuilding
    • other mod-makers now no longer have to fool with this lock-out mechanism: it is automatic for any Building that is assigned IsDummy="true"
    • the SQL file that does this is in an action that has a super-high LoadOrder setting so should almost always execute after any other mod adds its code
  3. You set up that your real building requires a specific "dummy" building in table <BuildingPrereqs> such as
    Code:
    <BuildingPrereqs>
    	<Row Building="BUILDING_CHOCOLATIER_LRS" PrereqBuilding="BUILDING_CHOCOLATIER_LRS_UNLOCKER"/>
    </BuildingPrereqs>
    In this case BUILDING_CHOCOLATIER_LRS_UNLOCKER is the dummy that when placed within a city unlocks the ability to construct BUILDING_CHOCOLATIER_LRS
  4. You then just write lua code to add (as an example) BUILDING_CHOCOLATIER_LRS_UNLOCKER to human cities when they are founded or the human captures a city, and to remove the BUILDING_CHOCOLATIER_LRS_UNLOCKER from a city if the city is conquered by an AI.

I've attached the latest version of the Utility Mod. Note that it conflicts with CQUI and Production Qeue and I've not figured a "cure" for that as yet. A player needs to have the mod available and enabled in their list of mods, and for everything to work correctly you need to set a dependancy within your mod that the utility has to be available and enabled.
 

Attachments

  • Lees' Dummy Buildings Systems.zip
    92.8 KB · Views: 55
  • Like
Reactions: TC_
  1. two buildings each of which require the other, so neither can ever be built in any city. (this was Suk's idea)
I use one requiring itself, seems to work so far.

And while we're talking dummy building, I don't know if you still need it, but I use that for hiding them in the pedia:

in a SQL loaded first
Code:
ALTER TABLE Buildings ADD COLUMN NoPedia         BOOLEAN NOT NULL CHECK (NoPedia IN (0,1)) DEFAULT 0; 

DELETE FROM CivilopediaPageQueries WHERE SectionId ='BUILDINGS'; -- recreated in GamePlay.xml

and in a XML loaded after the SQL
Code:
    <CivilopediaPageQueries> <!-- previous entry deleted in Table.sql -->
        <Row SectionId="BUILDINGS" PageGroupIdColumn="PageGroupId" TooltipColumn="Tooltip" SortIndex="10">
            <SQL>SELECT BuildingType as PageId, PreReqDistrict as PageGroupId, "Building" as PageLayoutId, Name, null as Tooltip FROM Buildings Where IsWonder = 0 AND InternalOnly = 0 AND NoPedia = 0</SQL>
        </Row>
    </CivilopediaPageQueries>

And I set the NoPedia column to 1 for dummy buildings.
 
Code:
	<CivilopediaPageExcludes>
		<Row SectionId="BUILDINGS" PageId="BUILDING_STONEWORKS_LRS_UNLOCKER"/>
		<Row SectionId="BUILDINGS" PageId="BUILDING_CATTLEMARKET_LRS_UNLOCKER"/>
		<Row SectionId="BUILDINGS" PageId="BUILDING_DISTILLERY_LRS_UNLOCKER"/>
		<Row SectionId="BUILDINGS" PageId="BUILDING_TEA_HOUSE_LRS_UNLOCKER"/>
		<Row SectionId="BUILDINGS" PageId="BUILDING_COFFEE_HOUSE_LRS_UNLOCKER"/>
		<Row SectionId="BUILDINGS" PageId="BUILDING_TANNERY_LRS_UNLOCKER"/>
		<Row SectionId="BUILDINGS" PageId="BUILDING_BAKERY_LRS_UNLOCKER"/>
		<Row SectionId="BUILDINGS" PageId="BUILDING_WEAVER_LRS_UNLOCKER"/>
	</CivilopediaPageExcludes>
Built in and you can set for techs and the like as well as I recall. Yes, I remember now I was fooling around with this for dummy techs and as I recall this also hides it from the civilopedia in that it makes no page for the tech or buildings
Code:
INSERT INTO CivilopediaPageExcludes
	(SectionId,		PageId) 
VALUES	('TECHNOLOGIES',	'TECH_LRS_A');
Unfortunately for techs if you try to set two as the prereqs for each other the game just goes direct to CTD
------------------------------------------------------------------------------------------

Does <CivilopediaPageQueries> hide the references automatically from the civilopedia for example wherein the dummy is the "prereq" for the real building so that the dummy does not show as required for the "real" building ?

Currently as I recall I am handing that directly in UI replacer files


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

I should probably just update my SQL "clean-up" file to also just auto-create all the rows in table <CivilopediaPageExcludes> where the Building is defined as a dummy via IsDummy="true" in table Buildings.
 
Last edited:
Commander Balok will spare your lives :lol:

You'll want also to keep an eye on the resource/thread Gedemon linked because I am working on some simplifications of what mod-makers need to do in defining and hiding a dummy building, and hope to push an update out maybe sometime this weekend.
 
Note that it conflicts with CQUI and Production Qeue

Is that why I am getting a religion symbol on all unit buttons in production queue, or did I do something wrong?
(See Below)

upload_2017-8-18_3-58-33.png
 
No. That's a different issue. Can't remember what caused it atm

edit now that I think of it it could be one of the compatibility issues. the one that was reported to me was that the city production panel would just be a black blank area.

But CQUI and Production Qeue have to be considered 100% incompatible with the Dummy Buildings Systems at the moment.
 
Last edited:
If the game is using my version of production panel then these commands should make a set of lines print to the game's lua.log:
Code:
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print(" ")
print("                       ProductionPanel.lua")
print(" ")
print("The version being used is from the 'LeeS' Dummy Buildings Systems' mod")
print(" ")
print("It is the version from the Summer 2017 Patch")
print(" ")
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
The log is found at C:\Users\YourName\Documents\My Games\Sid Meier's Civilization VI\Logs/Lua.log

it should show as
Code:
ProductionPanel: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ProductionPanel: 
ProductionPanel:                       ProductionPanel.lua
ProductionPanel: 
ProductionPanel: The version being used is from the 'LeeS' Dummy Buildings Systems' mod
ProductionPanel: 
ProductionPanel: It is the version from the Summer 2017 Patch
ProductionPanel: 
ProductionPanel: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I get this in-game:


Checking with some other mod-folks we think as we recall the issue with having the Islam Icon on units comes from using a Pre-Summer'17-Patch version of ProductionPanel, which CQUI probably still is if you are using that. I was under the impression that Production Qeue mod had been updated to the patch, but perhaps the author missed this issue if you are running that mod.


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

The extra buildings you do not recognize come from my Buildings Are Fun mod, which uses the Dummy Building systems.
 
If the game is using my version of production panel then these commands should make a set of lines print to the game's lua.log:
Code:
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print(" ")
print("                       ProductionPanel.lua")
print(" ")
print("The version being used is from the 'LeeS' Dummy Buildings Systems' mod")
print(" ")
print("It is the version from the Summer 2017 Patch")
print(" ")
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
The log is found at C:\Users\YourName\Documents\My Games\Sid Meier's Civilization VI\Logs/Lua.log

it should show as
Code:
ProductionPanel: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ProductionPanel:
ProductionPanel:                       ProductionPanel.lua
ProductionPanel:
ProductionPanel: The version being used is from the 'LeeS' Dummy Buildings Systems' mod
ProductionPanel:
ProductionPanel: It is the version from the Summer 2017 Patch
ProductionPanel:
ProductionPanel: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I get this in-game:


Checking with some other mod-folks we think as we recall the issue with having the Islam Icon on units comes from using a Pre-Summer'17-Patch version of ProductionPanel, which CQUI probably still is if you are using that. I was under the impression that Production Qeue mod had been updated to the patch, but perhaps the author missed this issue if you are running that mod.


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

The extra buildings you do not recognize come from my Buildings Are Fun mod, which uses the Dummy Building systems.

Yea, I didn't have your newest one. I clicked on the link Gedemon had in his post, but I see your .zip file now, and downloaded it.
 
Top Bottom