Era of Miracles fantasy mod - developer diary

On organization: I hate going up and down the folder structure to get to the core ~15 or so files I need (Units, UnitClasses, Civilizations, Policies, etc.). I recognize these .xml files in an instant but often forget what subfolder to look in. Also, using the standard "XML", "SQL" file structure that everyone else uses was starting to confuse me about what was core Civ5 and what was entirely new (same problem for UI stuff.) So I've come around to this file structure:
  • CoreCiv5Elements - all .xml and .sql files that modify base Civ5 .xml tables (~15 files, no subfolders to slow me down).
  • AddedElements - .xml and .sql files that create and fill completely new tables.
  • CoreCiv5UI - .xml, .lua files that replace base UI files
  • AddedUI - .xml/.lua pairs that add new UI stuff
  • Housekeeping - my Deletor.sql and DeletionFixinator.sql
  • Lua - MyModMain.lua, MyModFunctions.lua, MyModUtils.lua, etc.
  • Art (this folder and subfolders created and filled by my ModBBF utility)

This structure also makes it easier for me to remember what to set VFS = true, what's an UpdateDatabase, and what's an UIInGameAddins.

advantage the promotion system has, vice a pure Lua setup, is that it already leverages the Flavor system (which the AI already understands),

Didn't I just get corrected in another thread for suggesting that the AI "understood" (or rather, didn't "understand") something? :)


AND is stored in a more permanent form than a pure save/load Lua table (which tend to get corrupted easily).

Could you please elaborate on "tend to get corrupted easily"? I know there are all kinds of nasty issues related to cache. However, beyond this, have you seen additional problems? My mod adds about 8 tables (so far) to SavedGameDB and uses them extensively. Based on limited functionality tests (calling functions that add, modify or get from these tables) everything seems to be working properly. But I know that's not the same as trial by actually playing...
 
Didn't I just get corrected in another thread for suggesting that the AI "understood" (or rather, didn't "understand") something?

Okay, "copes" is a better term. The point is, the AI already has mechanisms in place for weighting its choices based on its grand strategies, its needs of the moment, and so on, by using the Flavor system. If you can use that, it saves you a lot of headaches since you won't have to reinvent the wheel.

Could you please elaborate on "tend to get corrupted easily"? I know there are all kinds of nasty issues related to cache. However, beyond this, have you seen additional problems?

Cache and/or version control is the big one, obviously. The cache bugs are especially nasty, because you might THINK you're using my mod when in fact the game thinks you're using my mod plus a bit of someone else's mod. The addressing will all be a little bit off as a result, which can cause a mod dependent on the save/load functions to get screwed up. It'll play fine in your first session, but then when you reload the game the next time everything will be off.

But I've seen bugs happen that had no relation to the cache, where the game just sort of forgets things. Maybe it's a hidden limit, like the 60-promotion cap, where the game internally ran out of room and didn't tell you. I can't explain some of the things I've seen it do to save/load variables, which is unfortunate since my current effort (the Mythology mod) is going to HEAVILY use those save functions.

So what I'm saying is that if it's at all possible, try to store some variables in a more tangible way. Increment a dummy project, place a building in your capital, or in this case, give units a custom promotion that does nothing but acts as a marker for your Lua logic. It doesn't add significant amounts of overhead for you, and it guarantees that the data's being stored in a way that the game considers to be a high priority.
 
The discussion about the cache and such things is getting too advanced for me to understand, but maybe I'll re-read it later, when I have more technical knowledge about how the game works.

2011-09-18: Civ#5 - Stone People

(The civ's name doesn't sound very "creative", but somehow I like it. Suggestions for a better name are welcome though :))

Stone People are the masters of sculpture and construction. They get more Stone resource (yes, it will be a strategic resource in this mod), and extra yields from Quarries. Their city defense structures and forts are superior to those of other civs. They are able to build a special improvement (using the Landmark graphics), that gives culture and increases the strength of nearby units.

I have some questions to the modding experts here, related to my plans for this civ:

1. How to make an improvement that can't be built when an improvement of the same type is located (or being built) in a specified radius? (This would be also useful for some other improvements, like Villages. I want to create a Village improvement that gives relatively high yields, but you shouldn't be able to build them next to one another.) I think I should use Player:CanBuild, but I need some advice how to make it work. Also, I don't want AI workers to "think" that they can build that improvement, go to that hex, realize that they can't build it, and go to another hex where they "think" they can build it, and so on. If such thing is already done in a mod, tell me which one it is.

2. If an improvement gives only culture, which is not technically a yield, will the AI build it? (I don't have the Polynesia DLC, so I don't know if it builds the Moai).

3. Does the AI build Forts and Citadels? I've never seen them building these improvements, but I haven't played many civ5 games.

PS I have some new civ ideas, so the total number will probably be around 18, not 15 as I wrote earlier.
 
How to make an improvement that can't be built when an improvement of the same type is located (or being built) in a specified radius?
I don't know, but it should be possible in theory. Certainly there were Civ4 mods that made this work (eg Dune Wars mod prevents you from building windtraps in adjacent tiles and the AI handles it fine).

3. Does the AI build Forts and Citadels?
No. Certainly not intelligently. I think the AI builds improvements based only on yields.
 
1. How to make an improvement that can't be built when an improvement of the same type is located (or being built) in a specified radius? (This would be also useful for some other improvements, like Villages. I want to create a Village improvement that gives relatively high yields, but you shouldn't be able to build them next to one another.) I think I should use Player:CanBuild, but I need some advice how to make it work. Also, I don't want AI workers to "think" that they can build that improvement, go to that hex, realize that they can't build it, and go to another hex where they "think" they can build it, and so on. If such thing is already done in a mod, tell me which one it is.

I believe this is not possible as a simple build.xml addition. It's possible (though very difficult) to add it as an action controlled entirely through Lua. You would need to also build AI logic in Lua to find appropriate tiles, drive AI unit to the tile, and fire the action. (I'm doing something like this in my mod, but it is only for some very special kinds of improvements built by special units needing special non-Civ5 AI. I would not recommend this for a worker-type build.)
 
No. Certainly not intelligently. I think the AI builds improvements based only on yields.

Not QUITE true, but close. There IS an Improvements_Flavors table, and the AI does seem to accept values you set in that table... but in the vanilla game, the table is completely empty (everything's at zero flavor) and the AI just goes by yields. In my own mod, I set some flavor values on my new improvements, and the AI does seem to build them more than their yield would justify, but it's hard to quantify.

What you can do, and what I've done in my own mod, was to do a split construction algorithm. So make two Improvements, A and B. The Build action creates A, but B is the one with the effect you want. A simple Lua function says "Are there any Improvements of type A in your territory?" On most turns the answer will be no, and it does nothing. But if it says yes, then you loop over the map and replace all instances of A with B. (This takes a little time, but since it won't do it on most turns it's not a big deal.) This allows you to put a temporary yield on A to set its priority, knowing that it'll be deleted as soon as it's created. This is the core of my terraforming logic (where B is a forest or jungle, or terrain change, and not an actual improvement) and my Monolith (where B is both an improvement AND a Feature).

The only problem is, if B has no yield, then the AI might decide to replace it with A since it'll think there'd be an improvement in yield. This'd get you stuck in an infinite loop.
 
Thanks for the answers. Seems it's quite complicated to make an improvement that can't be built too close to each other, so I think I'll just make it a random LUA event that creates villages (and other "rare improvements" for some civs) randomly under favorable circumstances. They will have high yields, so the AI shouldn't remove them. (I assume Player:GetImprovementCount can be used to determine the number of instances of a specific improvement in a specific player's territory, right?)

What about my question #2? Does the AI take culture into account when deciding which improvement to build, or only yields? (when there are no flavors)

Also, does it take into account yields that come from Trait_ImprovementYieldChanges? (I'm going to use it for civ-specific improvements, so other civs can't use them.)

2011-09-19: The order of doing things

When creating a total conversion mod, the main question is what to do first. Here is the order that I'm going to use:

1. Tech tree and the general idea what should be available with each tech (this is what I'm doing now, although there is some slowdown in the mod development lately because I play the HoMM6 demo; I found out that it exists by reading the "Civilization 5 Rants Thread", at last something useful came from that thread ;))
2. Detailed design of things that appear on the tech tree - Units, Buildings, Improvements, corrections to the tech tree itself in case of getting new ideas.
3. Other game elements, less dependent on the tech tree - Civ traits, Policies, Promotions (except the unit special abilities, which should be done at the same time as units).
4. General tweaks, testing, more tweaks, more testing and so on.
 
Culture is a yield, landmarks, some Natural Wonders, and a handful of resources (after buildings are built) provide it.
 
Culture is a yield, landmarks, some Natural Wonders, and a handful of resources (after buildings are built) provide it.

It's not defined in CIV5Yields.xml, so technically it's not a yield. It uses different XML tags than yields. That's why I'm not sure if the AI takes it into account.
 
Culture is not a yield, but something that works very similarly in most circumstances, but almost always requiring separate Lua functions.
 
What sneaks said. Culture and Happiness aren't yields, but have parallel sets of Lua functions and XML stubs that do most of the same things.

The AI definitely DOES value Culture from improvements when deciding what to do. However, there are a few small, annoying differences that make it harder to work with. For instance, a policy can add a yield to an improvement (like adding research to a trading post), but the corresponding table for Culture only works if that improvement already generated Culture to begin with, so you can't use it to add +1 Culture to all Plantations or something. And while you can give Technologies the ability to boost yields (making Academies give more science as time goes on), you can't do the same with Culture in the XML.
 
2011-09-20: Policies

I like the policy system in civ5, it looks much like "skill trees" in some RPG games, which is great for a fantasy mod. What I don't like about the policies in the original game is that it's usually hard to tell what's the connection between the policy name and its effect, so I'll make the effects more intuitive in the mod.

I'm going to increase the number of policies to 9 per branch (not counting openers and finishers). As I wrote earlier, the branches will represent different areas of economical and social development, including some magical effects. There won't be a "war branch" (like Honor in normal game), effects that help in a war will be scattered between different branches. For example in the Nature branch there will be a policy called "Ambush" that gives units a combat bonus in Forest and Jungle, and "Spoils of War" in the Wealth branch will give gold for killing units.
 
The discussion about the cache and such things is getting too advanced for me to understand, but maybe I'll re-read it later, when I have more technical knowledge about how the game works.

2011-09-18: Civ#5 - Stone People

(The civ's name doesn't sound very "creative", but somehow I like it. Suggestions for a better name are welcome though :))

Calx is stone in Latin, maybe you could change it to the Calx empire or Calx Tribe/People or just "The Calx". Just an idea ;)
 
it's usually hard to tell what's the connection between the policy name and its effect,

Yep. Same problem in other areas of Civ5 too. What happens then is a lot of metagaming: I don't pick "Liberty" because I want to play a civ that values liberty, but rather because I want to do the GP slingshot. The wonders are mostly pretty forgettable for the same reason...
 
2011-09-21: Civ#6 - The Vodniks

(The name 'Vodnik' comes from Slavic mythology, where it means a water spirit.)

The Vodinks are mysterious people, whose lifeforce comes from inland waters. They receive various bonuses associated with rivers, lakes and swamps. All their units are amphibious (I planned to make a policy that gives this effect, but I decided to use it as a special ability of this civ). I also want them to create trade routes along rivers without the need to use roads, but I don't know if it's possible...
 
Should be possible through Lua. Simply make a Route improvement that costs nothing and does not increase movement, then do a serialevent for tile ownership change where if the tile is owned by the vodnik and riverside, it gets the free improvement.
 
I mean that it should be connected to the capital by a chain of roads, rivers and harbors. I guess it would be quite complicated to check that in LUA, so for now I think I won't implement this idea.

Btw anyone knows how Traits.FasterAlongRiver works? If it gives a faster movement rate for units moving along a river, it would be ideal for this civ...
 
The existence of a Route automatically would cover the "trade route connection" end of things. You would be more or less just putting invisible roads on every riverside tile that cost nothing.
 
Top Bottom