[NFP] Questions regarding limitations of Mods

dunkleosteus

Roman Pleb
Joined
Aug 17, 2015
Messages
534
Location
Toronto, Canada
I've created a mod for civ 6 before, and am planning to update it soon. I have ideas I'm planning to implement, but I'm unsure whether it's possible to accomplish them. I'll update this post if/when I have more questions or get answers.

1. Can I use SQL to make a unit require multiple technologies? (Even if it requires some tricky work, like hidden buildings) Ex: a ranged unit that requires archery and iron working.
"with Lua and dummy buildings, yes" - Gedemon
"Dummy tech works. Or something we've done frequently in the game is add a tech with a research cost and one of these as prereq techs -- but then make the other tech be a boost toward this. Makes it a "soft prereq". In scenarios we've even given such boosts 100% value." -Ed Beach

2. Can I add new base yield types? (They don't have to necessarily appear on the map)
"not directly, unless it has changed" -Gedemon
3. Can I make a tech or civic unresearchable? Ex: a tech or civic that can only be unlocked via a district project.
"no" -Gedemon
4. Can I make it so that a resource is consumed on a turn only when a unit performs an action? Ex: boats require oil, musketmen require niter. Can I make the boat only consume the oil if it moves and the musketman only consume niter if it is in a combat?
"no, well, more a maybe, but I don't see how to enforce it on the AI" -Gedemon
5. Can I change unit healing based on tile yield or district? Ex: units can't heal in snow or desert, unit gets extra healing when in a district with a specific building.
"yes, may require scripting (in the later case it could be quite complex as you may have to override/rewrite the whole healing mechanism)" -Gedemon​

6. Can I add verbose descriptions to hover text in cities? Ex: city reads "+3 production from modifiers". Can I make it specifically list which modifiers?
"I suppose, with scripting" -Gedemon​

7. Can I change/alter district placement requirements? Ex: make it so that district B can be (or can only be) placed on top of and replace district A.
"maybe, with UI/gameplay coding, human only ability (unless you code something in Lua for the AI)" -Gedemon​

8. Can I allow resources to be traded per-turn instead of in a lump sum? Ex: trade deal for 3 iron per turn instead or 90 iron up front.

9. Can I change how much housing is generated from fresh water and the penalties for exceeding housing?

10. Can I change which yields an improvement provides for different resources? Ex: a plantation adds gold to a tile, regardless of what resource you're improving with it. Can I make it so that resource A gets gold from the plantation, but resource B gets culture? Would this require me to add multiple copies of the plantation improvement with a different yield for each, or can I accomplish this with the one improvement?

11. Can I add toggleable buttons to the city screen UI to enable or disable features unlocked by technologies or buildings? Ex: a button to increase taxes, which increases gold production but decreases loyalty and amenities.
"maybe, with UI/gameplay coding, human only ability (unless you code something in Lua for the AI)" -Gedemon​

12. When a city has multiple copies of the same district such as a neighborhood, can I allow a building to be constructed once in each copy of the district rather than only once per city, choosing which district to place it in?

13. Can I add new governments tiers/types? Ex: a fourth type of classical government, or additional governments in the ancient era.

14. Can I add zone of control to any district or improvement?

15. Can I add a cost to unit healing? Ex: healing a boat requires spending gold. Maybe with a button/action for the unit.
"yes, may require scripting (in the later case it could be quite complex as you may have to override/rewrite the whole healing mechanism)" -Gedemon​

16. Can I add storage for units on a tile in the same way that an aerodrome or airstrip stores planes? Ex: a shipyard allows a harbor to hold a bunch of boats. Follow up: can I decrease maintenance cost for units stored in this way?
"no" -Gedemon​

17. Can I put a world wonder inside of a district? Ex: eifel tower built in the city center instead of adjacent. If so, would I be able to restrict which wonders are built on a tile or in the world, and can I limit each district to 1 wonder slot?

18. Similarly to my question about units stored in districts, can I have other types of units stored inside of other units the same way that an aircraft carrier can hold planes?
"no" -Gedemon​

19. Can I change how combat strength is affected by unit health?
"you can change parameters IIRC, but not the formula" -Gedemon​

20. Can I change how combat is evaluated? Civ 6 combat evaluates based on absolute strength difference rather than relative difference. This means a 10 vs 5 is the same as 100 vs 95. Can I evaluate based on the strength ratio?
"you can change parameters IIRC, but not the formula" -Gedemon​

21. Can I enable/disable the "powered" bonus for a building? Ex: if a building could benefit from power and the city has no power, the city displays an icon claiming it is underpowered, and there are abilities which provide power to cities. This interferes if you want to give a bonus from power to a building unlocked before power can be generated, such as a bank. Can I make it so that the bank only receives a bonus from power after a certain technology is unlocked?
"I would look and see if there is a GameEffect to add such a bonus. If so this would work you'd attach the effect to TECH_COMPUTERS. But I'm not sure if there is..." -Ed Beach

22. Can I enable/disable spy missions based on modifiers? Ex: a specific type of spy mission is only unlocked after completing a one-time district project.
"no" -Gedemon​

Edit:
23. Can I make it so that only worked tiles grant resources? Ex: an improved source of iron only generates iron when a citizen is assigned to the tile. Optional: improved resources generate more when a citizen works the tile.

24. Can I choose which type of improvement "improves" a resource? Ex: in my mod, I enabled camps for cows and sheep (allowing camps before pastures) so that you can hunt these animals before pasturing them. I realized that I can't do the same for horses because putting a camp on a horse counts as improving it, granting horses per turn. Can I script it so that only a pasture improves the resource?

Edit 2:


25. Can I remove technologies from a civ after it has earned that technology? Ex: add a science penalty for the number of technologies a civ has researched, so that unlocking techs decreases science per turn. If science goes negative, techs can be removed. Represents not being able to educate your citizens enough to maintain a level of advancement.
 
Last edited:
For those I think I know the answer (but I can be wrong for the "no", and please note that "yes" may still require a lot of work):

1/ with Lua and dummy buildings, yes
2/ not directly, unless it has changed (last time I tried the game crashed)
3/ no
4/ no, well, more a maybe, but I don't see how to enforce it on the AI
5/ yes, may require scripting (in the later case it could be quite complex as you may have to override/rewrite the whole healing mechanism)
6/ I suppose, with scripting
7/ maybe, with UI/gameplay coding, human only ability (unless you code something in Lua for the AI)
11/ same as 7/
15/ same as 5/
16/ no
18/ no
19-20/ you can change parameters IIRC, but not the formula
22/ no

civ6 is globally a very good modding platform, but gameplay modding is its biggest weakness, civ5-4 are still better on that point.
 
For those I think I know the answer (but I can be wrong for the "no", and please note that "yes" may still require a lot of work):

1/ with Lua and dummy buildings, yes
2/ not directly, unless it has changed (last time I tried the game crashed)
3/ no
4/ no, well, more a maybe, but I don't see how to enforce it on the AI
5/ yes, may require scripting (in the later case it could be quite complex as you may have to override/rewrite the whole healing mechanism)
6/ I suppose, with scripting
7/ maybe, with UI/gameplay coding, human only ability (unless you code something in Lua for the AI)
11/ same as 7/
15/ same as 5/
16/ no
18/ no
19-20/ you can change parameters IIRC, but not the formula
22/ no

civ6 is globally a very good modding platform, but gameplay modding is its biggest weakness, civ5-4 are still better on that point.
I've updated my original post with your answers and added two more questions. Thanks!

Follow up to making a unit require multiple technologies: using the example of a unit that requires archery and iron working, if I added a new tech that requires archery and iron working, gave it a cost of 1 science and unlocked the unit with that technology, that would accomplish virtually the same thing with only delaying your research by 1 point of science, as the following turn you'd have 2 turns worth of science minus 1 science point. Would the tech tree properly display this technology after iron working and archery, or would its cost of 1 put it next to pottery?
 
cost is used for the x axis (in the tech tree UI), but I suppose Ed's solution solve the issue.
 
You can un-enable a player from being able to train a specific UnitType ("train" in this sense means buy or produce with city production) using lua. You can also later on enable the player to train that UnitType.

So requiring a player to have two different techs (or civics) or some combination of Tech(s) + Civic(s) before they can train a unit is actually quite straightforward using lua.

It's actually quite easy to disable and enable acquiring a unit based on just about anything you can dream up assuming what you can dream up can be scripted in lua. Has to have six cities, for example, or has to have four but no more than six cities. Has to have at least 1 plot with horses being worked by a city. Has to have at least one city where the city center is located adjacent to at least four non-lake coastal tiles. Any of these can be scripted, and used as the "trigger" for whether or not the player can train UNIT_X

Generally though you should probably avoid doing this for Unique Units because I have no earthly idea how the gamecore will react to a player that cannot train the unit assigned to it via a TraitType in table Units (regardless of how the 'blockage' is accomplished). You would need to experiment and be prepared for mystery CTDs.
 
You can un-enable a player from being able to train a specific UnitType ("train" in this sense means buy or produce with city production) using lua. You can also later on enable the player to train that UnitType.

So requiring a player to have two different techs (or civics) or some combination of Tech(s) + Civic(s) before they can train a unit is actually quite straightforward using lua.

It's actually quite easy to disable and enable acquiring a unit based on just about anything you can dream up assuming what you can dream up can be scripted in lua. Has to have six cities, for example, or has to have four but no more than six cities. Has to have at least 1 plot with horses being worked by a city. Has to have at least one city where the city center is located adjacent to at least four non-lake coastal tiles. Any of these can be scripted, and used as the "trigger" for whether or not the player can train UNIT_X

Generally though you should probably avoid doing this for Unique Units because I have no earthly idea how the gamecore will react to a player that cannot train the unit assigned to it via a TraitType in table Units (regardless of how the 'blockage' is accomplished). You would need to experiment and be prepared for mystery CTDs.
Thanks, this sounds really helpful! I don't think it'd be too big of a deal to block a player from their UU. You're essentially "blocked" from training it if you don't have the right tech, or if its a boat and you don't have any coastal cities or harbors. One thing that stood out to me is that you said "have at least 1 plot with horses being worked by a city". When you say "worked" do you mean having a citizen assigned to the plot, or do you mean that the tile was improved by a builder? If it's the former, that sounds like I'd be able to implement the system where players only receive resources when they work improvements with citizens, though I guess I'd have to teach the AI how to work tiles to get resources.

Depending on the UU, I'd probably end up adding extras anyway. For example, Nubia's UU is the Pítati Archer. The reason I want a unit to require multiple techs is I want to be able to upgrade units into stronger versions when other techs are unlocked. For example, I want to be able to upgrade the archer into an archer with bronze arrows after bronze working and again into one with iron arrows after iron working, increasing the base combat by a few points each time and the base production cost. Since the production difference is low, the upgrade cost would be small, but it would feel like a tangible difference for players. My mod currently does this by adding modifiers to these units when bronze working and iron working are unlocked, but I think using an upgrade feels better because it requires you to be in friendly territory and spend the gold, and it allows me to potentially change where exactly a UU comes in. I think from a historical perspective, Pítati Archers are bronze age. They are referenced in 1350 BC. This would mean that Nubia would get regular archers when unlocking archery, but would be able to upgrade them into Pítati Archers after researching bronze working and then upgrade them into a slightly stronger Pítati Archer after researching Iron working. I'd have to see if delaying the unit felt balanced.

My mod does something similar for horse archers and chariot archers, and gives spearmen an upgrade at iron working, too. If I could implement this system though, I'd use it all over the place.
 
Last edited:
"Worked" means being worked by a citizen of a city.
"Improved" specifically refers to whether or not a Builder has constructed a Terrain Improvement on a tile. You can have a tile that is improved and yet not worked by any citizen, or the other way round.
 
Update on having a unit unlocked by multiple technologies. I was looking through the columns in the unit table when I came across the TraitType column. Usually this is used so that a unit it limited to something like TRAIT_BARBARIAN, but I noticed that Lahore's UU is locked with a trait. The trait has a modifier on it PLAYER_IS_SUZERAIN. This leads me to believe that I'll be able to do this with a trait. As a test, I have my unit named Bronze-Age Archer unlocked in Bronze Working. I added a trait called TRAIT_BRONZE_ARROWS which has a modifier (I think ATTACH_TO_ALL_PLAYERS, the same as Lahore's trait for being suzerain) with the requirement set being PLAYER_HAS_BRONZE_WORKING and PLAYER_HAS_ARCHERY. In theory this should work, and the unit should be available to any player once they satisfy the condition, just as it is for a player that become's Lahore's suzerain. In the brief testing I did, it didn't seem to work: the unit didn't show up on the tech tree under bronze working and wasn't available to build in the city. It was listed under bronze working in the civilopedia however. I wonder if it's related to the fact that Lahore's UU has to be bought with faith? Unsure. If anyone has any more information, I'd welcome it.

Is it because the requirement PLAYER_HAS_BRONZE_WORKING is only true after bronze working is unlocked? I hope it isn't that. Should there be no tech requirement? That feels weird as well. If I can get this working, I'm probably going to lock a bunch of early units in this way. I plan to have small upgrades for bronze and iron for ranged units (possibly spearmen as well) so that they can get stronger as you unlock techs without being upgraded out-right.

Wait a sec- do I have to assign the trait?? It didn't occur to me to check- is Lahore's trait assigned to all civs and then the unit is enabled when the suzerain condition becomes true?

Alright, so if I assign the trait to each civ, they get they seem to get access to the unit without meeting the requirements (might be an error on my part) and the unit shows up as a UU in the loading screen which I don't want. If I understand it correctly, the only civ that possesses the trait to build the Nihang is Lahore itself, and Lahore passes the modifier to all civs in game which allows them to build the unit when they're Lahore's suzerain. I'm working at it from this angle now. I have a dummy trait attached to the unit (no civs have this dummy trait) and then I have an invisible trait attached to all civs (could do it a different way I guess) which has the requirement set and MODIFIER_PLAYER_ADJUST_VALID_UNIT_BUILD. I believe I've set it up the same way it's done for Lahore, but it doesn't seem to work.

Update: after pressing next turn, it worked, but I was testing a couple things at once. I think I can give a better description of what worked once I test a few more things.

Update 2: Ok, so here's how to get a unit to be locked behind two techs: (Edit: I found an easier way to do it, so I'm updating this post with that information)

Spoiler Code :


--Declare our type, the new unit
insert into Types([Type],Kind) values('UNIT_BRONZE_ARCHER','KIND_UNIT');

--Create our requirement for having bronze working
insert into Requirements (RequirementId,RequirementType) values ('REQUIRES_PLAYER_HAS_BRONZE_WORKING','REQUIREMENT_PLAYER_HAS_TECHNOLOGY');
insert into RequirementArguments (RequirementId,Name,[Value]) values ('REQUIRES_PLAYER_HAS_BRONZE_WORKING','TechnologyType','TECH_BRONZE_WORKING');

--Create our requirement for having archery
insert into Requirements (RequirementId,RequirementType) values ('REQUIRES_PLAYER_HAS_ARCHERY','REQUIREMENT_PLAYER_HAS_TECHNOLOGY');
insert into RequirementArguments (RequirementId,Name,[Value]) values ('REQUIRES_PLAYER_HAS_ARCHERY','TechnologyType','TECH_ARCHERY');

--Create the requirement set for having bronze working and archery
insert into RequirementSets (RequirementSetId,RequirementSetType) values ('BRONZE_ARROW_REQUIREMENTS','REQUIREMENTSET_TEST_ALL');
insert into RequirementSetRequirements (RequirementSetId,RequirementId) values ('BRONZE_ARROW_REQUIREMENTS','REQUIRES_PLAYER_HAS_BRONZE_WORKING');
insert into RequirementSetRequirements (RequirementSetId,RequirementId) values ('BRONZE_ARROW_REQUIREMENTS','REQUIRES_PLAYER_HAS_ARCHERY');

--Create a modifier which enables the unit to be built
insert into Modifiers(ModifierId,ModifierType,OwnerRequirementSetId) values ('BRONZE_ARROWS_UNIT','MODIFIER_PLAYER_ADJUST_VALID_UNIT_BUILD','BRONZE_ARROW_REQUIREMENTS');

--Set the unit that is unlocked
insert into ModifierArguments(ModifierId,Name,[Value]) values ('BRONZE_ARROWS_UNIT','UnitType','UNIT_BRONZE_ARCHER');

--Make sure that researching either Bronze Working or Archery adds the modifier to a player
insert into TechnologyModifiers(TechnologyType,ModifierId) values('TECH_ARCHERY','BRONZE_ARROWS_UNIT');
insert into TechnologyModifiers(TechnologyType,ModifierId) values('TECH_BRONZE_WORKING','BRONZE_ARROWS_UNIT');

--Create the new Bronze Archer unit, using the existing archer as a template. Increase the cost by a bit, give it 3 extra combat, set "CanTrain" to 0
insert into Units (CanTrain,UnitType,Cost,Maintenance,BaseMoves,BaseSightRange,ZoneOfControl,[Domain],Combat,RangedCombat,[Range],FormationClass,PromotionClass,AdvisorType,Name,Description,PurchaseYield,MandatoryObsoleteTech,PrereqTech)
select 0,'UNIT_BRONZE_ARCHER',Round(Cost + 5),Maintenance,BaseMoves,BaseSightRange,ZoneOfControl,[Domain],Round(Combat + 3),Round(RangedCombat + 3),[Range],FormationClass,PromotionClass,AdvisorType,'LOC_UNIT_BRONZE_ARCHER_NAME','LOC_UNIT_BRONZE_ARCHER_DESCRIPTION',PurchaseYield,MandatoryObsoleteTech,'TECH_BRONZE_WORKING' from Units where UnitType='UNIT_ARCHER';




I was using a trait to disable the unit before, but that introduces a lot of difficult things. I then realized I could enable Great people to be buildable like regular units, and that the column CanTrain can be overridden with MODIFIER_PLAYER_ADJUST_VALID_UNIT_BUILD.
 
Last edited:
9. EFFECT_ADJUST_CITIES_FRESHWATER_HOUSING_BONUS
EFFECT_ADJUST_WATER_HOUSING

14. There is EFFECT_ADJUST_UNIT_EXERT_ZOC. You can make units in distrits exert ZOC.

21
EFFECT_ADJUST_CITY_FREE_POWER
EFFECT_ADJUST_CITY_REQUIRED_POWER

23
EFFECT_ADJUST_PLAYER_RESOURCE_ACCUMULATION_MODIFIER
 
Last edited:
Back
Top Bottom