[BNW] Morius Modest Mods Musings

Well, I had written a more-detailed response but the forum ate it. You have fatal errors in your mod being reported by Database.log

There's no <Row> openers or closers here:
Code:
<GameData>
<Traits>
	<Type>TRAIT_BLOOD_MEXICA</Type>
	<Description>TXT_KEY_TRAIT_CULTURE_FROM_KILLS</Description>
	<ShortDescription>TXT_KEY_TRAIT_CULTURE_FROM_KILLS_SHORT</ShortDescription>
	<PrereqTech>TECH_SCIENTIFIC_THEORY</PrereqTech>
	<GoldenAgeGreatArtistRateModifier>20</GoldenAgeGreatArtistRateModifier>
	<GoldenAgeGreatMusicianRateModifier>20</GoldenAgeGreatMusicianRateModifier>
	<GoldenAgeGreatWriterRateModifier>20</GoldenAgeGreatWriterRateModifier>
	<CultureFromKills>100</CultureFromKills>
</Traits>
</GameData>
This entire code is incorrect:
Code:
<GameData>
	<Leader_Flavors>
			<Update>
				<Set
					MINOR_CIV_APPROACH_FRIENDLY="8" DoFWillingness="9" WarmongerHate="9" FLAVOR_ANTIAIR="6" DiploBalance="5" FLAVOR_RECON="5" Forgiveness="4" FLAVOR_NUKE="6"  MinorCivCompetitiveness="4" FLAVOR_AIR="5" FLAVOR_USE_NUKE="2" FLAVOR_NAVAL_RECON="5" FLAVOR_WATER_CONNECTION="5"/>
				<Where LeaderType="LEADER_GANDHI" />
				<Set
		FLAVOR_MILITARY_TRAINING="7" MAJOR_CIV_APPROACH_HOSTILE="9" MAJOR_CIV_APPROACH_WAR="9" FLAVOR_OFFENSE="9" Meanness="9" FLAVOR_MOBILE="9" FLAVOR_I_SEA_TRADE_ROUTE="3" FLAVOR_NAVAL="2" FLAVOR_NAVAL_GROWTH="2" FLAVOR_NAVAL_TILE_IMPROVEMENT="2" FLAVOR_HAPPINESS="7" Boldness="9" FLAVOR_PRODUCTION="7" FLAVOR_RECON="8" FLAVOR_NAVAL_RECON="5" FLAVOR_WATER_CONNECTION="2"/>
				<Where LeaderType="LEADER_ATTILA" />
				<Set
FLAVOR_INFRASTRUCTURE="5" FLAVOR_WATER_CONNECTION="3" DenounceWillingness="4" FLAVOR_CULTURE="6" FLAVOR_RELIGION="6" FLAVOR_NAVAL_GROWTH="3" FLAVOR_ARCHAEOLOGY="4" FLAVOR_ESPIONAGE="4" FLAVOR_I_LAND_TRADE_ROUTE="8" FLAVOR_I_SEA_TRADE_ROUTE="3" FLAVOR_NAVAL_RECON="3" FLAVOR_NAVAL="3" FLAVOR_USE_NUKE="6" FLAVOR_NUKE="6" FLAVOR_I_TRADE_DESTINATION="8" FLAVOR_I_TRADE_ORIGIN="8"/>
				<Where LeaderType="LEADER_GENGHIS_KHAN" />
				<Set
Boldness="5" Loyalty="5" MAJOR_CIV_APPROACH_WAR="5" MAJOR_CIV_APPROACH_GUARDED="5" MAJOR_CIV_APPROACH_AFRAID="4" MAJOR_CIV_APPROACH_DECEPTIVE="7" FLAVOR_USE_NUKE="4" FLAVOR_NUKE="3" MinorCivCompetitiveness="5" FLAVOR_OFFENSE="5" FLAVOR_RELIGION="5" Neediness="5"/>
				<Where LeaderType="LEADER_DARIUS" />
			</Update>
		</Leader_Flavors>
</GameData>
You cannot have multiple "Where" commands nor multiple "Set" commands within one <Update>. You need to break each of the "Where" and "Set" pairs into individual <Update> sets. Plus you have multiple other errors going on: There is for example no column called "MAJOR_CIV_APPROACH_WAR" nor "MinorCivCompetitiveness" within table "Leader_Flavors".

Database.log errors reported:
Code:
[947045.781] Database::XMLSerializer (Aztec changes/After Science.xml): 'Row' or 'Delete' expected, got 'Type'.
[947047.187] Database::XMLSerializer (Leader Flavors/FlavorsChange.xml): Duplicate <Set> elements are not allowed.
[947051.031] Validating Foreign Key Constraints...
[947052.171] Invalid Reference on Trait_FreePromotionUnitCombats.TraitType - "TRAIT_BLOOD_MEXICA" does not exist in Traits
[947052.171] Invalid Reference on Trait_FreePromotionUnitCombats.TraitType - "TRAIT_BLOOD_MEXICA" does not exist in Traits
[947052.171] Invalid Reference on Trait_FreePromotionUnitCombats.TraitType - "TRAIT_BLOOD_MEXICA" does not exist in Traits
[947052.171] Invalid Reference on Trait_FreePromotionUnitCombats.TraitType - "TRAIT_BLOOD_MEXICA" does not exist in Traits
[947052.171] Invalid Reference on Trait_FreePromotionUnitCombats.TraitType - "TRAIT_BLOOD_MEXICA" does not exist in Traits
[947052.171] Invalid Reference on Trait_FreePromotionUnitCombats.TraitType - "TRAIT_BLOOD_MEXICA" does not exist in Traits
[947052.171] Invalid Reference on Trait_FreePromotionUnitCombats.TraitType - "TRAIT_BLOOD_MEXICA" does not exist in Traits
[947052.171] Invalid Reference on Trait_FreePromotionUnitCombats.TraitType - "TRAIT_BLOOD_MEXICA" does not exist in Traits
[947052.171] Invalid Reference on Trait_FreePromotionUnitCombats.TraitType - "TRAIT_BLOOD_MEXICA" does not exist in Traits
[947052.171] Invalid Reference on Trait_FreePromotionUnitCombats.TraitType - "TRAIT_BLOOD_MEXICA" does not exist in Traits
[947052.171] Invalid Reference on Trait_FreePromotionUnitCombats.TraitType - "TRAIT_BLOOD_MEXICA" does not exist in Traits
[947052.171] Invalid Reference on Trait_FreePromotionUnitCombats.TraitType - "TRAIT_BLOOD_MEXICA" does not exist in Traits
[947052.171] Invalid Reference on Trait_FreePromotionUnitCombats.TraitType - "TRAIT_BLOOD_MEXICA" does not exist in Traits
[947052.171] Invalid Reference on Trait_FreePromotionUnitCombats.TraitType - "TRAIT_BLOOD_MEXICA" does not exist in Traits
[947052.171] Invalid Reference on Trait_ImprovementYieldChanges.ImprovementType - "IMPROVEMENT_LUMBER_CAMP" does not exist in Improvements
[947054.296] Invalid Reference on UnitPromotions.Help - "TTXT_KEY_PROMOTION_COHORT_HELP" does not exist in Language_en_US
The final two of these errors will be typos it looks like, and the other Invalid Reference errors will be cured by fixing the fatal syntax errors.

See whoward69's enable error logging tutorial
Follow the tutorial so you can know which errors reported in the log are "Firaxis" errors everyone gets
Disable all mods that are not 100% necessary for your mod to execute properly
Add all your promotions code back into the mod
Start a test game and then exit directly to desktop rather than return to main menu
Open and inspect Database.log for reported errors

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

With your mod enabled at the same time as the "usual" mods I run there were over 260 promotions in table UnitPromotions and so far as I was able to tell everything was working properly.
 
Last edited:
The AI has (IIRC) four types of strategy - grand, economic, military and city (see C:\Program Files (x86)\Steam\steamapps\common\Sid Meier's Civilization V\Assets\Gameplay\XML\AI). Within each type there are individual strategies (eg AICITYSTRATEGY_SMALL_CITY, AICITYSTRATEGY_LANDLOCKED, AICITYSTRATEGY_NEED_TILE_IMPROVERS) - which are all defined in XML but completely useless to us as XML/SQL/Lua modders as …

For each strategy, within the DLL, there are two C++ methods - one to ascertain if the strategy should be turned on if it is off, and one to ascertain if it should turned off if it is on. The ones for SMALL_CITY are simple, they just check the population size for a threshold, others are more complex. NEED_TILE_IMPROVERS is the one that works out how many unimproved and workable tiles a city has and decides if a worker should be trained next.

There are strategies for all kind of things - lets say both NEED_GOLD and NEED_FAITH are turned on. A city finishes its current build item … what to build next … a gold building (market) or a faith building (temple)? This is when flavours come into effect - from all the buildings it could build, FOR THE CURRENTLY ACTIVE STRATEGIES, it will choose the one with the highest flavour. Note, that if the NEED_FAITH strategy is not active, no matter how high the faith/religion flavour value, it will never build a temple.

Strategies are also biased. If a civ is at war, the NEED_UNITS military strategy will trump everything else

Flavours are NOT simple values.
 
LeeS, thank you so much! I owe you my digital life! Tremendous help! I had activated the whoward69 Datalog, but i reinstaled the game and forgot to activate again. I'll make the corrections and test it.

whoward69: Thanks for such didactic answer! So, if i understood correctly, those changes would alter AI behaviour as a whole, not just with Great Person Improvments. I assume Smat AI mod solve the Great Improvement "problem" already.
 
LeeS, a question. When you mentioned that there are no MAJOR_CIV_APPROACH_WAR column, it meant that i can't change it as if it was a column. I should make a separete <Update> for <Leader_MajorCivApproachBiases> table, is this correct? If its so, how do i change it? Set and Where works fine if just two columns, but there are three of them (LeaderType, MajorCivApproachType and Bias)
 
Last edited:
For your Gandhi updates to table <Leader_Flavors> you need like this:
Code:
<GameData>
	<Leader_Flavors>
		<Update>
			<Set Flavor="6"/>
			<Where LeaderType="LEADER_GANDHI" FlavorType="FLAVOR_ANTIAIR" />
		</Update>
		<Update>
			<Set Flavor="5"/>
			<Where LeaderType="LEADER_GANDHI" FlavorType="FLAVOR_RECON" />
		</Update>
		<Update>
			<Set Flavor="5"/>
			<Where LeaderType="LEADER_GANDHI" FlavorType="FLAVOR_AIR" />
		</Update>
		<Update>
			<Set Flavor="2"/>
			<Where LeaderType="LEADER_GANDHI" FlavorType="FLAVOR_USE_NUKE" />
		</Update>
		<Update>
			<Set Flavor="5"/>
			<Where LeaderType="LEADER_GANDHI" FlavorType="FLAVOR_NAVAL_RECON" />
		</Update>
		<Update>
			<Set Flavor="5"/>
			<Where LeaderType="LEADER_GANDHI" FlavorType="FLAVOR_WATER_CONNECTION" />
		</Update>
		<Update>
			<Set Flavor="6"/>
			<Where LeaderType="LEADER_GANDHI" FlavorType="FLAVOR_NUKE" />
		</Update>
	</Leader_Flavors>
</GameData>
Each type of flavor, such as "FLAVOR_NUKE" and "FLAVOR_AIR" needs its own update with a requirement in the "Where" portion that the change only should be applied to that row in the table with both LeaderType="LEADER_GANDHI" and FlavorType matches to a specified type of flavor.

None of the following can be stated as update "Set" values in table <Leader_Flavors> because these columns and their data belong to differing tables than <Leader_Flavors>:
Code:
MINOR_CIV_APPROACH_FRIENDLY="8"
DoFWillingness="9"
WarmongerHate="9"
DiploBalance="5"
Forgiveness="4"
MinorCivCompetitiveness="4"
"MINOR_CIV_APPROACH_FRIENDLY" is not actually a column-name in any table, it is a type of Minor Civ Approach, and so belongs under table <Leader_MinorCivApproachBiases> and needs an update as:
Code:
<GameData>
	<Leader_MinorCivApproachBiases>
		<Update>
			<Set Bias="8"/>
			<Where LeaderType="LEADER_GANDHI" MinorCivApproachType="MINOR_CIV_APPROACH_FRIENDLY" />
		</Update>
	</Leader_MinorCivApproachBiases>
</GameData>
The others belong under table <Leaders>:
Code:
<GameData>
	<Leaders>
		<Update>
			<Set DoFWillingness="9" WarmongerHate="9" DiploBalance="5" Forgiveness="4" MinorCivCompetitiveness="4"/>
			<Where Type="LEADER_GANDHI"/>
		</Update>
	</Leaders>
</GameData>
In this case there is no second requirement in the "Where" clause because there can only ever be one "LEADER_GANDHI" registered within table <Leaders>.

But we can designate multiple data-changes within the "Set" clause since they will all apply to "LEADER_GANDHI".

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

And you can of course pack all these correct update methods into one file, and you can place updates for the correct tables for multiple leaders into one unified file for all these changes. You just have to write the correct update data to the correct table.
 
Last edited:
Another question concerning my mod (or any mod, really): If i have one error in a text, the whole text doesn't work. Am i right?
 
I've find out an embarassing problem with the Auxilia promotion of the Romans.

First of all, the Romans have the Roman Army Promotion. It does nothing, except allowing to choose unique promotions.

There are two types of promotions: Regular and Auxilia.

Auxilia gives a random promotion to the unit first time it fights. Well, as it happens, when you fight for the first time, you lose the Auxilia Promotion. Then you can get it back next "level up". This is not intended.

I thought about a solution. Instead of the Auxilia promotion gives a random promo, the Roman Army Promotion would take this role. The downside is that the roman promotions will happen to be too random for Roman tastes.

The ideal was if Auxilias promotions (there are four: Auxilia, Mounted Auxilia, Archer Auxilia and Auxilia Scouts) could be taken only once, and if you take them you couldn't take the Cohort and Equites promotions. This, i think, is beyond xml codding. So i'm deactivating all Auxilia promotions until i came up with something.
 
Another question concerning my mod (or any mod, really): If i have one error in a text, the whole text doesn't work. Am i right?
  1. In xml files any one syntax error in the file causes the entire file to be ignored by the game. This is true whether writing to the <Language_en_US> and other language tables, or to any other game-table such as <Leaders> or <Traits>.
  2. in sql files the game implements everything up to the point where the first syntax error is encountered and ignores everything lower-down within the file.

SQL can allow for more complex data-changing in less total code, but on the other hand can actually lead to conditions where it seems like one's code is loading properly when it is not. SQL files also do not generate as much information in Database.log related to syntax errors as xml files do. Because of this, SQL code that is incorrect can be much harder for the inexperienced modder to chase down the errors.
 
The equivalent SQL code to the example <Leader_Flavors> updates for Gandhi would be:
Code:
UPDATE Leader_Flavors SET Flavor = 6 WHERE LeaderType = 'LEADER_GANDHI' AND FlavorType = 'FLAVOR_ANTIAIR';
UPDATE Leader_Flavors SET Flavor = 5 WHERE LeaderType = 'LEADER_GANDHI' AND FlavorType = 'FLAVOR_RECON';
UPDATE Leader_Flavors SET Flavor = 5 WHERE LeaderType = 'LEADER_GANDHI' AND FlavorType = 'FLAVOR_AIR';
UPDATE Leader_Flavors SET Flavor = 2 WHERE LeaderType = 'LEADER_GANDHI' AND FlavorType = 'FLAVOR_USE_NUKE';
UPDATE Leader_Flavors SET Flavor = 5 WHERE LeaderType = 'LEADER_GANDHI' AND FlavorType = 'FLAVOR_NAVAL_RECON';
UPDATE Leader_Flavors SET Flavor = 5 WHERE LeaderType = 'LEADER_GANDHI' AND FlavorType = 'FLAVOR_WATER_CONNECTION';
UPDATE Leader_Flavors SET Flavor = 6 WHERE LeaderType = 'LEADER_GANDHI' AND FlavorType = 'FLAVOR_NUKE';
Bear in mind that you cannot mix and match XML code and SQL code in the same file, but your mod can have some files written in XML and other files written in SQL.
 
New question: To include things i may simply do like that?
Code:
<Unit_AITypes>
<Row>    <UnitType>UNIT_HUN_HORSE_ARCHER</UnitType>    <UnitAIType>UNITAI_FAST_ATTACK</UnitAIType>
</Row>
</Unit_AITypes>
 
Rush, shush! No need to answer the former question, the answer is "yes, of course you damn noob!" (my words)

Another, more pertinent question: I've saw policies giving units (one or multiple), wonders giving units (one, multiple, multiplying existing), wonders giving units between turns (thanks LeeS and his Knight's Templar wonder), policies allowing purchase of exclusive units, technologies allowing purchase of exclusive units (JFD and Poukai's Mercenaries).

But, what about allowing training of exclusive units? Is this possible?

Another thing, i want to make a promotion that gives more range to a archer unit who is atop of a hill. I know this is achievable only with LUA codding, but i fail even to implement in my mods existing LUA codding, less so create one. This is a request, can anyone help me do that? I think this code would be usefull even in CIV VI
 
Last edited:
To require a building or wonder be present in order to purchase or train a unit, see the Archaeologist. The pertinent table is
Code:
	<Unit_BuildingClassRequireds>
		<Row>
			<UnitType>UNIT_ARCHAEOLOGIST</UnitType>
			<BuildingClassType>BUILDINGCLASS_UNIVERSITY</BuildingClassType>
		</Row>
	</Unit_BuildingClassRequireds>
You have to specify by the Class of Building rather than directly stating BUILDING_UNIVERSITY.

Otherwise the answer to
But, what about allowing training of exclusive units? Is this possible?
Is both "yes" and "it depends on exactly what you mean by exclusive" and "it depends on what you mean".

As far as the idea with the archer being able to shoot farther when on a hill this is doable with a promotion that is added or removed as needed, but the problemn with making this reactive in "real-time" as the units move around the map is that it can get pretty processing-heavy and cause significant lag perceptible to the human player, especially in the mid to late game when there are more units on the map.

The code would not be usable in Civ6. Civ6 does not allow pretty much anything dynamic like this wrt to units. Promotions are of no real value in lua modding, lua cannot attach objects such as modifiers or unit-abilities directly to individual game-objects. There are still a lot of cool or kooky things we can do with lua in civ6, but manipulating existing units to any usable degree is not within the scope of achievable.
 
Well, my idea is inspired by your Knights Templar wonder....
Spoiler My fond memories of Civ 3, MAY BE BORING! :
You see, when i played Civilization 3, i remembered quite fondly of mine Russian empire conquering all they could see in the enourmous earth map i downloaded here. I remember my Statue of Zeus and my Knight's Templar wonders making my empire go bankrupt by their incessant unit spawns!

Anyway, my idea was to buff Honor Policy by allowing the civ who managed to unlock Professional Army or Military Caste to produce the House Guard unit, it will be compared to the Longswordsman, but have defensive promotions.
Second, make a religion enhancement that allows the civ to purchase wit faith "Holy Warriors" and "Fanatics". Holy warriors would be the Crusaders, Jihadis, Soheis, Shaolin Monks, Indian Warpaths and you get it. Fanatics would be basically cheap cannon fodder armed with sticks! Hahaha!
I had to remove many of my Roman promotions :)c5angry:, more of that here: https://forums.civfanatics.com/threads/morius-wider-traits.637704/), and i was thinking to make a unique Coleseum or Barracks to Rome, from wich you could produce unique Auxilia units.

About the idea to get more range on hills, my idea is to make this a promotion that you can have on the Radio discovery. I think, as a promotion, the game engine would not suffer, because not all units would have it (it would have prereq, probably accuracy/barrage 2 or 3).

Man, i'm seriouly thinking to mark you guys as co-creator to my mods, you think it's too much?
 
Last edited:
Policy-Enabling:
Code:
		<Row>
			<Class>UNITCLASS_LANDSKNECHT</Class>
			<Type>UNIT_GERMAN_LANDSKNECHT</Type>
			<PrereqTech>TECH_CIVIL_SERVICE</PrereqTech>
			<Combat>16</Combat>
			<Cost>45</Cost>
			<Moves>2</Moves>
			<CombatClass>UNITCOMBAT_MELEE</CombatClass>
			<Domain>DOMAIN_LAND</Domain>
			<DefaultUnitAI>UNITAI_COUNTER</DefaultUnitAI>
			<Description>TXT_KEY_UNIT_GERMAN_LANDSKNECHT</Description>
			<Civilopedia>TXT_KEY_CIVILOPEDIA_UNITS_MEDIEVAL_LANDSKNECHT_TEXT</Civilopedia>
			<Strategy>TXT_KEY_UNIT_GERMAN_LANDSKNECHT_STRATEGY</Strategy>
			<Help>TXT_KEY_UNIT_HELP_LANDSKNECHT</Help>
			<PurchaseOnly>true</PurchaseOnly>
			<MoveAfterPurchase>true</MoveAfterPurchase>
			<MilitarySupport>true</MilitarySupport>
			<MilitaryProduction>true</MilitaryProduction>
			<Pillage>true</Pillage>
			<GoodyHutUpgradeUnitClass>UNITCLASS_LANCER</GoodyHutUpgradeUnitClass>
			<AdvancedStartCost>20</AdvancedStartCost>
			<XPValueAttack>3</XPValueAttack>
			<XPValueDefense>3</XPValueDefense>
			<PolicyType>POLICY_TRADE_UNIONS</PolicyType>
			<Conscription>3</Conscription>
			<UnitArtInfo>ART_DEF_UNIT_U_GERMAN_LANDSKNECHT</UnitArtInfo>
			<UnitFlagIconOffset>33</UnitFlagIconOffset>
			<IconAtlas>UNIT_ATLAS_1</IconAtlas>
			<PortraitIndex>34</PortraitIndex>
		</Row>

Unit Faith-Purchasing is controlled by selected beliefs and by era the unit belongs to. You can't allow faith-purchase of specific units without some lua code-gymnastics. The usual solution is to make the unit only purchasable in the Database with Gold, and then use an lua script to disallow the purchase if the player's treasury and current faith amount are not sufficient to cover the "faith" cost of the unit: the lua code then returns the gold spent on the unit and subtracts the required faith-amount from the player's faith-score.
 
Last edited:
I've read about promotions limits here: http://modiki.civfanatics.com/index.php?title=Modding_Limits_and_Issues_(Civ5)
Unfortunately, this site is not updated since, it seems, Gods and Kings.
That's quite a gymnastics indeed. If it was gymnastics, it would be like climbing wall, and i would be a quadruped. I don't know nothing of LUA!
I didn't paid enough attention on the landsknecht!
<PurchaseOnly>true</PurchaseOnly> and
<PolicyType>POLICY_TRADE_UNIONS</PolicyType>
are the key columns here.
 
The extra shooting range when on hills is actually made a more complicated script in lua by requiring the unit have accuracy/barrage prereq promotions. lua does not actually inherently care about prereqs found in the game database, so it would be necessary for every unit that moved to first check if it's an archery unitcombat unit, then if it has promtions X or Y, then if it has just moved onto a hill. The reverse side for moving off the hill would be a bit simpler perhaps because in that case you would only be looking for whether the unit already has the Hill Extra Range promotion, and then checking whether it is no longer on a hill so the script would know whether to remove the Hill Extra Range promotion.

Only allowing the promotion to become active after some player discovers Radio would tend to reduce the need for the code to run (thereby eliminating the potential lag issues in the earlier parts of the game) but it actually complicates the script needed.
 
Wow, that's disheartening. Let me see if i can pull out some LUA codding. I achieved to alter other LUA codding (like the one that produces a resource nearby when a building is produced, i changed the resource type), but failed to integrate LUA codding on my mods. I didn't get how to do it in the LUA tutorials...
 
Back
Top Bottom