Quick Modding Questions Thread

Hello, I am trying to make a custom civilization whose unique ability grants them a free scout when starting their first city - just like how the Maori get a builder on their first city.
I've looked through the game files and found that the Maori's unique ability is handled with
Code:
<ModifierId>BUILDER_PRESETTLEMENT</ModifierId>
            <ModifierType>MODIFIER_PLAYER_BUILT_CITIES_GRANT_FREE_UNIT</ModifierType>
            <SubjectRequirementSetId>PLAYER_HAS_ONE_CITY</SubjectRequirementSetId>
I was wondering if anyone knew where the requirement set "PLAYER_HAS_ONE_CITY" is handled in the games files so that I could take a look at how it was configured and set it up myself since my attempts at coding the requirement set by myself have failed. Cheers!
You don't have to code it yourself thought? Just reuse it, no?
@criZp is correct. You can just reuse it without needing to worry about re-defining it. It is the BUILDER_PRESETTLEMENT ModifierId you need to look at in both tables Modifiers and ModifierArguments to create a copy with a new ModifierId name and an edit in table ModifierArguments to give a free scout instead of a free builder.

The place to look at the way the BUILDER_PRESETTLEMENT ModifierId is defined is
C:\Program Files (x86)\Steam\steamapps\common\Sid Meier's Civilization VI\DLC\Expansion2\Data\Expansion2_Leaders_Major.xml
The RequirementSet, its Requirement, etc., is all defined in file Expansion2_Leaders.xml within the same folder.
 
Last edited:
Hello, I am trying to make a custom civilization whose unique ability grants them a free scout when starting their first city

Just a thought - and feel free not to take any notice of this - but given that most civilizations found their first civilization immediately at the start of the game, another way you could achieve this is by defining the starting units for your custom civilization to include an extra Scout.

Of course, the Maori example works better being triggered from their first city because they are essentially saving them from having to sail around with that unit. This may not be any easier to achieve in terms of code, but just offers an alternative mechanism via which you could achieve similar.
 
any way to decrease units overall max hitpoints? or make units do more damage to each other in general?
From what I know, two units of equal strength attacking each other will take about 4 attacks for one or both of them to die. I'm trying to make that about 2.
 
@criZp is correct. You can just reuse it without needing to worry about re-defining it. It is the BUILDER_PRESETTLEMENT ModifierId you need to look at in both tables Modifiers and ModifierArguments to create a copy with a new ModifierId name and an edit in table ModifierArguments to give a free scout instead of a free builder.

The place to look at the way the BUILDER_PRESETTLEMENT ModifierId is defined isThe RequirementSet, its Requirement, etc., is all defined in file Expansion2_Leaders.xml within the same folder.
Thank you so much! I already had the BUILDER_PRESETTLEMENT new modifierId figured out and configured, I just needed to know where the requirements of the requirement set were defined.
 
any way to decrease units overall max hitpoints? or make units do more damage to each other in general?
From what I know, two units of equal strength attacking each other will take about 4 attacks for one or both of them to die. I'm trying to make that about 2.
code in SQL, to test and tweak:
UPDATE GlobalParameters SET Value = 48 WHERE Name = 'COMBAT_BASE_DAMAGE'; -- default = 24
UPDATE GlobalParameters SET Value = 24 WHERE Name = 'COMBAT_MAX_EXTRA_DAMAGE'; -- default = 12

(I was doing the opposite, ie longer combats, in my mod using 12/6)
 
The max random value added to the base combat damage I suppose.

I've just realized there is also a COMBAT_MAX_HIT_POINTS value in <GlobalParameters> (default 100) you may want to try that one first.
 
If I had to guess it determines If C is correct flag for A and B equality.
If A is not equal to B and C is FALSE it's TRUE
If A is equal to B and C is TRUE it's TRUE

I haven't dug deeply into LUA so maybe it's so modern it understands this as If all three values are equal, though.
 
You can test how this works on the lua demo site here: https://www.lua.org/cgi-bin/demo

Code:
a = "text"
b = "text"
c = true


if a == b == c then
print("a == b == c")
else
print("nope")
end
My bad. It works as @Jeppetto said. I forgot about the reverse logic issues in the construction. When a is /is-not equal to b (integer, text, or boolean) and c is the boolean equivalent to (a == b) then you get a boolean true result (ie, "a == b == c" is printed). "c" must be a boolean, whereas "a" and "b" can be anything except for implied "nil". This causes a syntax error:
Code:
a
b
c = true


if a == b == c then
print("a == b == c")
else
print("nope")
end

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

Essentially it is the same as
Code:
if ((a == b) == c) then
   print("true")
else
   print("false")
end
Hopefully this makes it clearer why "c" must always be a boolean value whereas "a" and "b" can be any valid data-type. Evaluation for whether it is true that "a" is equal to "b" is done first in both code versions, and only then is evaluation made as to whether this boolean result is the same as the boolean value of "c".

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

It would seem like the conditional evaluation ought to be the same as this
Code:
a = "text"
b = "text"
c = "text"


if a and b and c then
print("a == b == c")
else
print("nope")
end
But it is not.

This evaluates the same way when using the "and" stringing method
Code:
a = "text"
b = 1
c = "text"


if a and b and c then
print("a == b == c")
else
print("nope")
end
This is because the method using "and" instead of "==" is an implied true evaluation rather than an actual evaluation against boolean true. Lua evaluates any variable that is not nil and is not boolean false as being "true" when using the implied true method. Nor in this case will the boolean value of "c" be compared against whether or not "a" is equivalent to "b". Nor would this
Code:
if ((a and b) == c) then
give quite the same results as the original code in question
Code:
if a == b == c then
because when not using the equality requirement for "a" against "b" (ie, ==) you will get a comparison as to whether boolean value "c" is the same as whether or not "a" and "b" are not nil values and are not boolean false.


You get a similar evaluation by lua when you do this
Code:
a = "cheeseburgers"
if a then
   print("boolean true")
else
   print("boolean false")
end
Obviously the text string "cheeseburgers" is not the same as boolean true, but you get boolean true nonetheless.
 
Last edited:
Additional note: the demo page I just linked to is lua 5.1 whereas Civ6 uses a newer but customized version of lua, so some commands such as table.count(TableName) are not understood by the demo page. The demo page also does not understand Civ specific lua commands like Players[PlayerID]:GetUnits() because that is not "generic" lua code, it is specific to the Civ6 application.
 
I haven't been able to find a mod that does this: Is there any way to add Age points to a tech? I find that I get stuck with nothing that can pull me out of a Dark Age in the Information Era, and so I wanted Future Techs to give 1 Age point each. I'm not sure that's feasible...
 
I haven't been able to find a mod that does this: Is there any way to add Age points to a tech? I find that I get stuck with nothing that can pull me out of a Dark Age in the Information Era, and so I wanted Future Techs to give 1 Age point each. I'm not sure that's feasible...

As far as I can tell, we are limited to the functional 'moments' that already exist. While we can theoretically add new moments to the Types table (of the KIND_MOMENT), I don't see a way to define how these are identified to the game as pertaining to a different trigger point.

The only two tech-related moments that grant era score are:

MOMENT_TECH_RESEARCHED_IN_ERA_FIRST
MOMENT_TECH_RESEARCHED_IN_ERA_FIRST_IN_WORLD

Perhaps someone else will come along and confirm how we can know the triggers for these moments or indeed that there is a way to configure others.
 
Drat. I just found those two entries myself, and thought, "Blast, those Era moments are programmed from the Era side, not the Tech side."

So, I'd have to figure out a way to define a new Era Moment, and then find a way to make it trigger on each Future Tech researched, instead of firing as "first-in-era". Sounds like it would require working in the background programming like I did for Civ IV, which I'm not sure is even possible in VI. -sigh-

What about City Radius? I found the tag for max buy radius, but I'd like to change the max radius (currently 5). Any pointers? Thanks!
 
Drat. I just found those two entries myself, and thought, "Blast, those Era moments are programmed from the Era side, not the Tech side."

So, I'd have to figure out a way to define a new Era Moment, and then find a way to make it trigger on each Future Tech researched, instead of firing as "first-in-era". Sounds like it would require working in the background programming like I did for Civ IV, which I'm not sure is even possible in VI. -sigh-

I'm not sure there's any meaningful access to derive things from the source files - it's a fairly well-known position that the source DLL files are not being released, unfortunately.

draco963 said:
What about City Radius? I found the tag for max buy radius, but I'd like to change the max radius (currently 5). Any pointers? Thanks!

I suspect there's a similar story with the Global Parameters settings. We can derive what they do, perhaps even work out what those do which we're not sure of through trial-and-error, but I don't imagine there is a way to program a new one.

You could try amending the value of the one underneath the one you found, which is CITY_MIN_RANGE - though I suspect this is used to define the minimum distance between two cities. I don't see anything that looks related to the maximum radius to which a city's (workable? Is that what you meant?) plots could grow. Again, perhaps someone with more knowledge in this subject may come through with a more decisive answer.
 
CITY_MAX_BUY_PLOT_RANGE determines radius of tiles obtainable through purchase by Gold
PLOT_INFLUENCE_MAX_ACQUIRE_DISTANCE determines radius of tiles obtainable though Culture naturally (Influence is often the term they use in the code for the Culture-fueled natural growth of borders, the border growth is supposed to represent your cultural influence spreading across the plains and fields of small folk who join your city, though it is confusing since the game has the Influence towards Envoys)

I think there's still no way to change the radius of workable tiles.
 
You can't increase the range of workable tiles. it is hardcoded in the DLL. Values of greater than 3 for the GlobalParameter are simply ignored. I have not tried whether Civ6 also ignores values of less than 3. Besides game balance the basic reason for this is that each additional range of 1 workable tile distance just about doubles the number of tiles a city can work and thus the number of tiles the game engine has to process for each city for each and every thing the game needs to do related to the tiles a city owns or is working.

Civ5 would implement values of less than 3 but required a custom DLL for values greater than 3 for the max work/buy range. CITY_MAX_BUY_PLOT_RANGE is used for both the gold purchasing and workable range so far as we know. But since the workable bit is also hardcoded in the DLL we cannot be 100% sure.

CITY_MIN_RANGE is indeed the distance between cities. In Civ5 this was one less for cities on different landmasses but I have not tested whether this is also true for Civ6.

It would be nice to have access to the DLL sourcecode (even if we could not create custom versions) because we could at least then see farther into the engine to know what actually does what and what that seems unmoddable actually is moddable once the way the DLL code works is understood.

PLOT_INFLUENCE_MAX_ACQUIRE_DISTANCE should be the maximum distance a city can expand to "naturally". Civ5 allowed this number to be adjusted higher, but any number higher than about 7 is pretty much meaningless anyway since the exponentiation of cultural plot expansion cost will tend to make no city ever be able to accumulate the needed culture must past about 7 tiles distance.
 
Is there a way to apply a modifier to a unit if they are adjacent to an enemy unit?
I know the varu unit applies a modifier to enemy units adjacent to it, but not to itself. We're trying to attach the modifier to the unit itself, not the units surrounding it. For that reason I do not think 'REQUIREMENT_PLOT_ADJACENT_TO_OWNER_AT_WAR' (used for the varu unit) will work here.
For example, giving a player's unit more movement if it starts its turn adjacent to an enemy unit.
 
Back
Top Bottom