New here and full of questions

br0k3n_p4rr0t

Chieftain
Joined
Feb 4, 2020
Messages
3
Location
Austria, Graz
Hi, fanatics!
I have been playing civilization games more or less sporadically since CIV III. In recent weeks I have played a few games of CIV VI GS and started looking into mods. I dabbled a bit here and there tweaking some numbers in existing mods but that has not satisfied my desires. I found this forum to be the best resource on modding CIV VI so I decided to join. Now I have questions :D

I have searched for and read about several of the topics I ask about below. However, it seems to me that at least some of the information I found might be outdated (last post in respective discussion 2+ years ago). I hope it is okay for me to ask these questions in this way. I have the impression that they don't quite fit the "Quick modding questions" thread, but please tell me if I'm wrong and I will repost them there separately.

[1] Is the CIV V Lua introduction in the wiki a good place to start getting used to Lua in CIV VI?

[2] Having a bit of a SW Dev background, but never having gotten in touch with Lua before, here is a thing bothering me: Why do many of the Lua files in the admittedly extensive mods I found have 1000+ lines of code? Is that "bad style" (not to discredit any of the very capable modders here :hatsoff::worship:) or does Lua not allow splitting code across many files (like Python)?

[3] What would it take to introduce new tile types? Two concepts to illustrate what I mean:
highlands: land tile that is higher in elevation and associated with mountain regions, but passable,
less food and production but higher strategic resource yields
river: sweet water tile that is not coast and not lake and features embankments on either side

Obviously these require new art for the tiles. Can this be done at all?

[4] What is a good way to let units disband and join (adjacent/closest) settlements? (Provided they cost population during production, which I already figured out how to do and later found in another mod :lol::hammer2:)
One instance of this is that I would like builders to cost 1 pop, have 2 charges, but rejoin the settlement when they used their last charge.

[5] What would be a good way to make food a per civilization stockpiling resource? I'm thinking that each city could choose to send part of its food production to this stockpile or get some food from it. I would find it amazing if additionally unit upkeep could be supported through this stockpile, since they would count as pop.

[6] What would it take to introduce diversified civilian units that get different yields out of different tiles? I'm thinking of Colonization (the original and the CIV IV remake). I hope that works as a reference in this forum :think: The different yields could be taken care of with the modifier system I suppose, and some tweaks to the city screen UI would be necessary.

[7] How would one go about introducing new settlement types? I'm thinking of classification like village, town, city, metropolis.

[8] Can production be removed as a resource entirely and replaced with construction resources? I suspect that this might be hard since it is such a low-level thing that permeates the entire game.


Now, I realize that many of the things I ask about would almost certainly break the AI. But that is not my concern for now. If some of these things would be possible I would worry about the AI later. Then again the operations, agendas and behavior trees could most likely be adapted to work with new game concepts.

Thanks in advance for all your replies! :dance:
I hope the structure of this post makes it easy for you to reply to the individual questions.:wavey:
 
  1. Not really I would not think. Some of the basic concepts are similar but the implementation of lua and its API is quite different in Civ6.
  2. If a mod reworks a User Interface file, then the file will usually be quite lengthy.
    • Civ6 has its own sandboxed system for including the contents of one file within another, but sharing of data across different UI contexts (ie, Pop Up panels) is not accomplished by usage of the command
      Code:
      include("Filename.lua")
    • Essentially at least as lua is implemented in Civ6 for User Interface scripts, each file is it own sandboxed entity even though it can share toolkit text from the same toolkit lua file that multiple other user interface scripts are also using.
    • For GameplayScripts, the text contents of a toolkit file can also be included within another lua file, but this is merely the same as in all other cases (ie, User Interface usage) where the "include()" command is used to copy the text contents of one file into another. Data-sharing is not therefore accomplished using a toolkit file, and any changes to a variable value stated within a toolkit file are not shared dynamically with any other lua file that might be using the same toolkit file.
  3. I'm not sure we can as a practical matter without access to the game's DLL sourcecode which we do not have at the moment. Tbh I'd have to think more about this apart from the art issues which can probably be solved (see the Civ5 art reskin mod on Steam pubbed as an example of what can be accomplished if one has mad art skills like the Firaxis dude who created the mod).
  4. Builders don't actually cost population -- only Settlers do. But if you enacted a change to make Builders cost pop and be "refunded" to the nearest player city, then I think lua would be the answer. There's a hook event called Events.UnitRemvedFromMap(PlayerID, UnitID) that will trigger and pass argument data for the Player ID # and the Unit ID # any time a unit is removed from the map for any reason. There is also a hook event called Events.UnitChargesChanged(playerID, unitID, newCharges, oldCharges) that fires whenever a unit's charges alter. The problem with units that are "dead" is that they do not give valid data for their XY position, which would be needed to find the nearest city for example. You would have to test to see if the events fire before or after the unit is actually made "dead" by the game.
  5. I don't know that you can except by essentially "cheating the system" and giving a player X amount of "Resource_Food" depending on the excess food each city is producing. Production, Food, Science, Culture, etc., are not resources and are also so wrapped up in the basic and essential way the game works that I don't think you'd be able to implement such a system by directly attempting to adjust the way Yields function. I think you'd have to create "fake" resource(s) and deal with all the resource creation and accumulation issues related.
  6. I'd have to think about that one.
  7. Since "City" is not actually defined anywhere I don't think you could. You could certainly rewrite the UI to make a city with a pop of 1/2 be referred to as a village for example, but this would have no actual gameplay effect.
  8. See previous about food stockpiling
 

Thanks so much for all the insights provided. I wasn't really expecting that most of it would be possible. So from that angle, I am very pleased as you didn't explicitly state that all of them are undoable. I get the limitations of not being able to see inside the dlls. Also thanks for the Lua answers. That cleared up an essential concept. Also, I now know where to look (hook events).

Really, big thank you!


No about that idea concerning settlement tiers [7]:
A quick search in 01_GameplaySchema.sql yielded the following table that I find interesting.

CREATE TABLE "Districts" (
"DistrictType" TEXT NOT NULL,
...
PRIMARY KEY(DistrictType),
...
FOREIGN KEY (DistrictType) REFERENCES Types(Type) ON DELETE CASCADE ON UPDATE CASCADE);​

Here is what I gather from that:
Since city centers are treated as districts "all" that would need to be done is to introduce new district types for various levels of city centers and all of the changes that entail for the file districts.xml.
Is that a feasible way to go about this? What I would like to achieve is to have villages that can't have buildings in them (except for maybe a palisade wall), offer a limited amount of housing for the population (up to 3?) but provide more places in which population can spawn and which need defending from those pesky barbarians. Oh, and they can only work tiles directly adjacent to the village. The gist of it being that some of the villages are going to be upgraded to higher-tier settlements after some tech becomes available.
 
Cities own Districts, and "DISTRICT_CITY_CENTER" is autoplaced whenever a city is founded on the map tile where the "Found City" Settler-Action was conducted. CityCenter="true" defines to the game that this district is the city-center, and everything else a city-center does is hidden away in the game's DLL.
Code:
<Row DistrictType="DISTRICT_CITY_CENTER" Name="LOC_DISTRICT_CITY_CENTER_NAME" Description="LOC_DISTRICT_CITY_CENTER_DESCRIPTION"
PlunderType="NO_PLUNDER" AdvisorType="ADVISOR_GENERIC" Cost="54" RequiresPlacement="false" RequiresPopulation="false"
CityCenter="true" Aqueduct="false" FreeEmbark="true" NoAdjacentCity="false" InternalOnly="false" ZOC="true" HitPoints="200"
TradeEmbark="true" CaptureRemovesBuildings="true" CaptureRemovesCityDefenses="true"
MilitaryDomain="NO_DOMAIN" AirSlots="1" TravelTime="4"/>
There's nothing in that definition about allowing naval units to exit and enter, or to traverse through when the city-center is placed on a plot that has two different water-bodies on either side, and yet the District City Center enables all of this by its inherent definition of the CityCenter Boolean.

Without access to the game's DLL I don't see any way to get to where you want to be.

You can accomplish some of it via database methods probably, but I don't see how you would accomplish the major part of it without being able to rewrite the game's DLL.
 
About point [2], we weren't even able to use "include" for custom file at the beginning, this was solved in a later patch.
 
Alright, so a bit of tangent question here: would any of this be easier in CIV V? I think I read somewhere that modding for that game is easier but not sure if that has anything to do with it.
 
Except [3], because changing terrain was an issue in the civ5 modding framework IIRC, everything else would be easier because the source code is available for civ5, if you don't care about multiplayer.

Else there is civ4, if you don't care about square tiles.
 
Back
Top Bottom