[NFP] My past few days with Civ 6 modding


Nov 1, 2019
I admit I tried to learn it a long while ago, but I gave up. It was too hard. So this is round 2.

I was very interested in the CombatVisBegin() and CombatVisEnd() events. Only a handful of events have begin and end events. These two seem to have some extra coding around them. Whenever there is combat on the screen, CombatVisBegin() will trigger and I played around with it a little bit. I didn't explicitly test that CombatVisEnd() triggers next, but it probably does.

The interesting part about these events, to me, are that they seem to block the processing of the rest of the units. At least the units, but maybe the entire turn processing waits for the animation to end. When the human player in a single player game engages in combat or is attacked, the game will look at each combat one after the next. I saw that this event, along with several others, were categorized as serial by Gedemon in his Lua Objects thread. An extremely helpful bit of information.

I take this to mean that these serial events are processed one at a time, while other events such UnitMoved() are processed in parallel. I don't know that for sure, but what I see as the game plays bears it out as true. So it seems.

What I wanted to know if I could do, was to duplicate the ability that CombatVisBegin() has to stop the rest of the turn from processing, even parallel events, which is something it does when the combat involves the human player, so that I could always witness the moves of a unit, such as, a hero unit. No matter whether he was fighting or just moving. I don't know if that is useful for any game play purpose, but I was interested to see if it could be done. I spent a couple of days with it in mind as I learned the gist of the architecture. I don't think it can be done. First, CombatVisBegin() will trigger for onscreen combat for every player, if you program it that way, but only the human player will look at combat that isn't visible and has to move the camera further to see. That seems to be something done internally. So that was disappointing.

I also tested out how sensitive the game engine is to lua functions that take time to process. It is very sensitive to them. I wrote an infinite while loop and it didn't 't matter if it triggered it by a serial event or a parallel event, the loop would hang the game. So however they achieved the parallel nature of unit move processing, it doesn't appear to be truly parallel processing. I only think that, because a bad lua script can make the game hang and I can deduce that if a script takes too much processing, I expect it can make the game stutter as it runs. So that leads me to believe that execution should enter and exit a lua function with the intention to allow the function to process as quickly as possible and return control back to the game engine.

I am starting to wrap my head around the architecture, thanks to many people on these boards, and to people who have written guides. Lees and Gedemon are two names that I have seen so much of, and without their work and so many other mod makers, it would be too terrible of a puzzle to figure out, for me. For that, I am disappointed in Firaxis for not supplying architectural information. The community of modders would have had a much easier time. I hope they do better with Civ 7.

I just learned about the custom properties we can place on players, cities, and several other things. I had become confused about how I could store data, since the sql and xml files load into a database which can't be updated after the game loads. What a relief, when I realized what the custom properties are. That is a way to store some data and it doesn't look all that bad at first glance. I didn't see any limits to how many properties can be placed on an object. However, looking at the API, which I need to look at a little bit closer, there doesn't seem to be nearly as many set functions as there are get functions, but tomorrow I will look at the set functions more carefully. With the custom properties and lua, if I am smart enough to compute something, I can store it on an object. Hopefully an object that it makes logical sense to store it on. But, if I can't do much with that data, then I guess that will be the limiting factor.
Last edited:
Top Bottom