[BNW] Morius Modest Mods Musings

First you need a reference in your mod to zenlightenment Era so that Enlightenment Era loads first when both are enabled. Then you generally need stand-alone files with code that is for the support. Because when EE is not enabled the game will not implement your "support" code, and you do not want this taking out the other code in your mod. It is also always better to have "support" code lowest-down in your mod's UpdateDatabase actions.

Quick Tutorial on adding a reference in Modbuddy
The Enlightenment Era: Adding a Reference in ModBuddy

Primarily what you would be doing would be updates to existing data either in your mod or to the stuff that EE adds to the game to make the two mods more seamlessly work together. For example
Code:
UPDATE Buildings 
SET Strategy = 'TXT_KEY_BUILDING_LRS_SAILMAKER_STRATEGY_EE', Help = 'TXT_KEY_BUILDING_LRS_SAILMAKER_HELP_EE'
WHERE Type = 'BUILDING_LRS_SAILMAKER'
AND EXISTS (SELECT 1 FROM Eras WHERE Type = 'ERA_ENLIGHTENMENT');
You'd almost certainly want to use SQL for your compatibility code. Stuff you have in TXT_KEY tags you can simply create a new tag to be used only when EE is enabled, and redirect from the usual TXT_KEY to use the TXT_KEY_EE instead. As I am doing in the example update snippet.
 
Last edited:
Thanks for that! I'll try to implement it as soon as i solve this other mystery:

I'm trying to tweak on the Infantry. I want them avaliable on Combined Arms, because i find annoying two gun units in the same era. I also want that they become the ultimate infantry, not advancing to Mechnized Infantry (i have other plans for it). So, i tried to delete the references tying the Infantry with the Mechanized infantry, but failing miserably. Currently, all i can manage is delete Infantry entirely from the game. Here is my code:

Code:
<Gamedata>
    <Units>
        <Delete Type="UNIT_INFANTRY" GoodyHutUpgradeUnitClass="UNITCLASS_MECHANIZED_INFANTRY"/>
        <Delete Type="UNIT_INFANTRY" ObsoleteTech="TECH_MOBILE_TACTICS"/>
        <Update>
            <Set PrereqTech ="TECH_COMBINED_ARMS"/>
            <Where Type ="UNIT_INFANTRY" />
        </Update>
    </Units>
   
    <Unit_FreePromotions>
        <Row>
            <UnitType>UNIT_INFANTRY</UnitType>
            <PromotionType>PROMOTION_GRENADES</PromotionType>
        </Row>
    </Unit_FreePromotions>

    <Unit_ClassUpgrades>
        <Delete UnitType="UNIT_INFANTRY" UnitClassType="UNITCLASS_MECHANIZED_INFANTRY"/>
    </Unit_ClassUpgrades>
</Gamedata>
 
Last edited:
Both your delete statements preceed your update, so by the time the update is read within table <Units> there is nothing for the update statement to match to. Nor is there anything else within the code to match to in the other tables because you've entirely deleted the Infantry unit from the database, and all Unit_Something tables reference back to the contents of table Units. This results in Invalid Reference errors in Database.log and other possible undesirable effects in-game. "Delete" literally deletes the row from the database, which is not what you want because this deletes the Infantry unit completely from table <Units>. You simply want an Update to table units.

Also, Gamedata is not correct. Always use GameData.

Code:
<GameData>
    <Units>
        <Update>
            <Set PrereqTech="TECH_COMBINED_ARMS" GoodyHutUpgradeUnitClass="NULL" ObsoleteTech="NULL"/>
            <Where Type="UNIT_INFANTRY" />
        </Update>
    </Units>
   
    <Unit_FreePromotions>
        <Row>
            <UnitType>UNIT_INFANTRY</UnitType>
            <PromotionType>PROMOTION_GRENADES</PromotionType>
        </Row>
    </Unit_FreePromotions>

    <Unit_ClassUpgrades>
        <Delete UnitType="UNIT_INFANTRY"/>
    </Unit_ClassUpgrades>
</GameData>
The Delete in table <Unit_ClassUpgrades> will not delete the Infantry Unit from the game, it will merely delete the row within that table that specifies what the Infantry Unit should upgrade to.
 
Is there any problem with codding redundancy? For example: one of my mods have this code:
Code:
<GameData>
    <UnitPromotions>
        <Update>
            <Where Type="PROMOTION_CAN_MOVE_AFTER_ATTACKING" />
            <Set LostWithUpgrade="true" />
        </Update>
        <Update>
            <Where Type="PROMOTION_CARGO_I" />
            <Set LostWithUpgrade="true" />
        </Update>
        <Update>
            <Where Type="PROMOTION_CARGO_II" />
            <Set LostWithUpgrade="true" />
        </Update>
        <Update>
            <Where Type="PROMOTION_CARGO_III" />
            <Set LostWithUpgrade="true" />
        </Update>
        <Update>
            <Where Type="PROMOTION_CARGO_IV" />
            <Set LostWithUpgrade="true" />
        </Update>
        <Update>
            <Where Type="PROMOTION_PARADROP" />
            <Set LostWithUpgrade="true" />
        </Update>
    </UnitPromotions>
</GameData>

Another of my mod has the same code. This generates any problem?
 
no. no problems will come from two or more mods making the same exact update to the same thing.

the only time a problem will occur is if two or more mods are making "opposing" update changes to the same thing. then the order the mods load will come into play, and the last to load will be the one whose code is used in the game. without a reference from one mod to the others, the order the mods load with respect to each other will be essentially random across all users of the mods because the mods will load in the order an individual user enabled them in the ingame mods menu. User 1 might have mod # 1 loading first whereas User # 2 might have mod # 2 loading first.
 
I've created a nat mod for Great Admirals usefullness. https://forums.civfanatics.com/threads/morius-great-admiral-discovery.637712/

It creates an island that can be traversed by land and sea units. Very cool, imo.

Now i whant to it to work like landmarks. If you create a landmark on a Minor Civ territory, you gain a boost in influence with this minor civ. If you create a landmark on a major civ territory, you gain a boost on the realtions with that civ. I want my mod to do the same thing with their islands discoveries.

No i mulled down on the landmarks, acheologists and acheology sites to figure out what causes it. Well, what causes it is in GlobalDefines and GlobalDiplomacyAIDefines. But the how to do this i think it can be found on a file named ChooseArcheologyPopup.lua

I tweaked it a little bit, but didn't achieved nothing (made a backup of it first).

Is it possible?
 
ChooseArcheaologyPopup is only used to drive the pop-up panel that occurs when an Archaeologist finishes a dig. It does not execute when an AI finishes a dig. All it does is recieve the click instructions from the human user and signal the game which choice was made. The internal game engine then handles the busy-work of making the influence and diplomacy-adjustment when a Landmark is chosen.

It might be possible to write an lua script to remove your custom improvement, add a landmark instead, and then remove the landmark and replace it with a second custom improvement that creates the normal effects of your great admiral's terrain improvement. But whether or not the landmark influence and diplomacy effects would be implemented by the game engine I have no idea.
 
Oh, ok, i think it's worthwhile!

Now, one quick clarifying about updates. When you update a table, like Unit_FreePromotions, you don't need to put <Set/> and <Where/> to include a new promotions. But the same didn't to seem to be the truth in some other tables, like Unit_Flavors (to include a new flavor) or Unit_AITypes (to icnlude a new AI type). Is this statement true?

Update: I've noticed that some mods even bother to change those two tables (Unit_Flavors and Unit_AITypes)
 
Last edited:
This piece of code is driving me nuts:
Code:
<GameData>
    <Civilization_UnitClassOverrides>
        <Update>
            <Where UnitType="UNIT_AZTEC_JAGUAR"/>
            <Set UnitClassType="UNITCLASS_HORSEMAN"/>
        </Update>
        <Update>
            <Where UnitType="UNIT_POLYNESIAN_MAORI_WARRIOR"/>
            <Set UnitClassType="UNITCLASS_HORSEMAN"/>
        </Update>
    </Civilization_UnitClassOverrides>
    <Units>
        <Update>
            <Where Type ="UNIT_AZTEC_JAGUAR" />
            <Set>
                <Class>UNITCLASS_HORSEMAN</Class>
                <Combat>12</Combat>
                <Cost>75</Cost>
                <FaithCost>150</FaithCost>
                <Moves>3</Moves>
                <ObsoleteTech>TECH_GUNPOWDER</ObsoleteTech>
                <GoodyHutUpgradeUnitClass>UNITCLASS_KNIGHT</GoodyHutUpgradeUnitClass>
            </Set>
        </Update>
        <Update>
            <Where Type ="UNIT_POLYNESIAN_MAORI_WARRIOR" />
            <Set>
                <Class>UNITCLASS_HORSEMAN</Class>
                <Combat>12</Combat>
                <Cost>75</Cost>
                <FaithCost>150</FaithCost>
                <Moves>3</Moves>
                <ObsoleteTech>TECH_GUNPOWDER</ObsoleteTech>
                <GoodyHutUpgradeUnitClass>UNITCLASS_KNIGHT</GoodyHutUpgradeUnitClass>
            </Set>
        </Update>
    </Units>

    <Unit_FreePromotions>
        <Update>
            <UnitType>UNIT_AZTEC_JAGUAR</UnitType>
            <PromotionType>PROMOTION_CAN_MOVE_AFTER_ATTACKING</PromotionType>
        </Update>
        <Update>
            <UnitType>UNIT_POLYNESIAN_MAORI_WARRIOR</UnitType>
            <PromotionType>PROMOTION_CAN_MOVE_AFTER_ATTACKING</PromotionType>
        </Update>
        <Update>
            <UnitType>UNIT_BARBARIAN_WARRIOR</UnitType>
            <PromotionType>PROMOTION_PILLAGE_HEAL</PromotionType>
        </Update>
    </Unit_FreePromotions>   
</GameData>

Database.log keeps babling about this:
[72732.484] Database::XMLSerializer (Warrior/Warriors.xml): <Update> element requires a child <Set> element.

What's is really wrong and why?
 
Code:
    <Unit_FreePromotions>
        <Update>
            <UnitType>UNIT_AZTEC_JAGUAR</UnitType>
            <PromotionType>PROMOTION_CAN_MOVE_AFTER_ATTACKING</PromotionType>
        </Update>
        <Update>
            <UnitType>UNIT_POLYNESIAN_MAORI_WARRIOR</UnitType>
            <PromotionType>PROMOTION_CAN_MOVE_AFTER_ATTACKING</PromotionType>
        </Update>
        <Update>
            <UnitType>UNIT_BARBARIAN_WARRIOR</UnitType>
            <PromotionType>PROMOTION_PILLAGE_HEAL</PromotionType>
        </Update>
    </Unit_FreePromotions>
1st: Do you see "Where" or "Set" anywhere in that part of your code ? <Update> statements require Set and also usually need Where in order to function as desired.

2nd: when you want to add a new row to a game table you don't use <Update>, you use <Row>. <Update> is only used to alter the data in existing rows within a game-table.
 
Last edited:
Ok, i see why the question seems to be stupid (my words), but look at this:

Code:
<GameData>
    <Unit_FreePromotions>
        <Row>
            <UnitType>UNIT_DANISH_SKI_INFANTRY</UnitType>
            <PromotionType>PROMOTION_BAYONET</PromotionType>
        </Row>
        <Row>
            <UnitType>UNIT_DANISH_SKI_INFANTRY</UnitType>
            <PromotionType>PROMOTION_EXTRA_STRENGTH</PromotionType>
        </Row>
    </Unit_FreePromotions>

    <Unit_AITypes>
        <Row>
            <UnitType>UNIT_DANISH_SKI_INFANTRY</UnitType>
            <UnitAIType>UNITAI_COUNTER</UnitAIType>
        </Row>
    </Unit_AITypes>

    <Language_en_US>
        <Update>
            <Where Tag="TXT_KEY_CIV5_DENMARK_SKI_INFANTRY_STRATEGY"/>
            <Set Text="Caroleans are the backbone of the early Industrial era Swedish army. They start with the March promotion that allows it to Heal every turn, even if it performs an action. They also have a bonus agains mounted units."/>
        </Update>
        <Update>
            <Where Tag="TXT_KEY_CIV5_DENMARK_SKI_INFANTRY_HELP"/>
            <Set Text="The Norwegian Ski Infantry is one of two Danish Unique Units, replacing the Skirmsher. This Unit moves through Snow, Tundra, or Hill at double speed. It also has a +25% combat bonus in Snow, Tundra or Hill terrain if neither Forest nor Jungle is present. hey also have a bonus agains mounted units. "/>
        </Update>
    </Language_en_US>
</GameData>

This code, worked, and i didn't set any Set/Where on the promotions table.

Code:
<GameData>
    <Unit_FreePromotions>
        <Row>
            <UnitType>UNIT_HELICOPTER_GUNSHIP</UnitType>
            <PromotionType>PROMOTION_CAN_MOVE_AFTER_ATTACKING</PromotionType>
        </Row>
        <Row>
            <UnitType>UNIT_HELICOPTER_GUNSHIP</UnitType>
            <PromotionType>PROMOTION_ONLY_DEFENSIVE</PromotionType>
        </Row>
    </Unit_FreePromotions>
</GameData>

This other code is from Better Helicopters mod, that works and is on steam for a while. https://steamcommunity.com/sharedfiles/filedetails/?id=7126837

And the Sky Infantry is not the first unit i wrrote free promotions without Where and Set, not even the fifth.


So, you know why my confusion.Better comply other to complain i think. But why is that? Why in the Ski Infantry and helicopter examples it worked without the where and set, but on the warriors didn't?

EDIT: HOW STUPID OF ME! In those examples there are NO Updates! This is result of codding distracted! Sorry for this mate!
 
Last edited:
All right, one more question: How do i change <UnitPromotions_UnitCombats> for others. For example:
AMBUSH_1 and AMBUSH_2 promotions are for UnitCombats Melee and Gun. I want to exchange those for UnitCombat Ranged, Unitcombat Armor and UnitCombat Helicopter, how do i do this?

Code:
<GameData>
  <UnitPromotions_UnitCombats>
     <Delete UnitCombatType="UNITCOMBAT_MELEE" PromotionType="PROMOTION_AMBUSH_1"/>
        <Row>
           <PromotionType>PROMOTION_AMBUSH_1</PromotionType>
           <UnitCombatType>UNITCOMBAT_HELICOPTER</UnitCombatType>
       </Row>
  </UnitPromotions_UnitCombats>
</GameData>

This would work?
 
Last edited:
It's probably better to delete everything from table <UnitPromotions_UnitCombats> related to PROMOTION_AMBUSH_1 and then re-build your needed rows:
Code:
<GameData>
  <UnitPromotions_UnitCombats>
     <Delete PromotionType="PROMOTION_AMBUSH_1"/>
        <Row>
           <PromotionType>PROMOTION_AMBUSH_1</PromotionType>
           <UnitCombatType>UNITCOMBAT_HELICOPTER</UnitCombatType>
       </Row>
       .... etc ....
  </UnitPromotions_UnitCombats>
</GameData>
This way you know no other mod has added a bunch of other stuff to table <UnitPromotions_UnitCombats> related to PROMOTION_AMBUSH_1.

Remember that everything is order-dependant in your code, and in the code executed by other mods. Some other mod could load after yours and essentially undo everything you just did in your mod, but that's the issue all mod-makers face where there can be an infinite number of mods active at the same time.

Just make sure your code does things in a logical order. You don't want to add new rows to the table and then do a delete -- you'd want to delete first and then add back in any needed rows including new ones that weren't there originally.

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

You can also accomplish the same effect you are after by using code as
Code:
<GameData>
  <UnitPromotions_UnitCombats>
	<Update>
		<Where PromotionType="PROMOTION_AMBUSH_1" UnitCombatType="UNITCOMBAT_MELEE" />
		<Set UnitCombatType="UNITCOMBAT_ARCHER" />
	</Update>
 	<Update>
		<Where PromotionType="PROMOTION_AMBUSH_1" UnitCombatType="UNITCOMBAT_GUN" />
		<Set UnitCombatType="UNITCOMBAT_ARMOR" />
	</Update>
       <Row>
           <PromotionType>PROMOTION_AMBUSH_1</PromotionType>
           <UnitCombatType>UNITCOMBAT_HELICOPTER</UnitCombatType>
       </Row>
  </UnitPromotions_UnitCombats>
</GameData>
 
Hello again!

Doing the ArtDefines when you don't need/don't want to vary the unit model between rows is easy, but when you do?

I've tried to do this without any success. There it is my code:

Code:
<GameData>
    <ArtDefine_UnitInfos>
        <Row>
            <Type>ART_DEF_UNIT_U_MUBARIZUN</Type>
            <DamageStates>1</DamageStates>
            <Formation>DefaultMelee</Formation>
        </Row>
    </ArtDefine_UnitInfos>
    <ArtDefine_UnitInfoMemberInfos>
        <Row>
            <UnitInfoType>ART_DEF_UNIT_U_MUBARIZUN</UnitInfoType>
            <UnitMemberInfoType>ART_DEF_UNIT_MEMBER_U_MUBARIZUN</UnitMemberInfoType>
            <NumMembers>4</NumMembers>
        </Row>
        <Row>
            <UnitInfoType>ART_DEF_UNIT_U_MUBARIZUN</UnitInfoType>
            <UnitMemberInfoType>ART_DEF_UNIT_MEMBER_U_MUBARIZUN_V2</UnitMemberInfoType>
            <NumMembers>2</NumMembers>
        </Row>
        <Row>
            <UnitInfoType>ART_DEF_UNIT_U_MUBARIZUN</UnitInfoType>
            <UnitMemberInfoType>ART_DEF_UNIT_MEMBER_U_MUBARIZUN_V3</UnitMemberInfoType>
            <NumMembers>6</NumMembers>
        </Row>
    </ArtDefine_UnitInfoMemberInfos>

    <ArtDefine_UnitMemberCombats>
        <Row>
            <UnitMemberType>ART_DEF_UNIT_MEMBER_U_MUBARIZUN</UnitMemberType>
            <EnableActions>Idle Attack RunCharge AttackCity Bombard Death BombardDefend Run Fortify CombatReady Walk AttackCharge</EnableActions>
            <ShortMoveRadius>12.0</ShortMoveRadius>
            <ShortMoveRate>0.35</ShortMoveRate>
            <TargetHeight>8.0</TargetHeight>
            <HasShortRangedAttack>1</HasShortRangedAttack>
            <HasRefaceAfterCombat>1</HasRefaceAfterCombat>
            <ReformBeforeCombat>1</ReformBeforeCombat>
        </Row>
        <Row>
            <UnitMemberType>ART_DEF_UNIT_MEMBER_U_MUBARIZUN_V2</UnitMemberType>
            <EnableActions>Idle Attack RunCharge AttackCity Bombard Death BombardDefend Run Fortify CombatReady Walk AttackCharge</EnableActions>
            <ShortMoveRadius>12.0</ShortMoveRadius>
            <ShortMoveRate>0.35</ShortMoveRate>
            <TargetHeight>8.0</TargetHeight>
            <HasShortRangedAttack>1</HasShortRangedAttack>
            <HasRefaceAfterCombat>1</HasRefaceAfterCombat>
            <ReformBeforeCombat>1</ReformBeforeCombat>
        </Row>
        <Row>
            <UnitMemberType>ART_DEF_UNIT_MEMBER_U_MUBARIZUN_V3</UnitMemberType>
            <EnableActions>Idle Attack RunCharge AttackCity Bombard Death BombardDefend Run Fortify CombatReady Walk AttackCharge</EnableActions>
            <ShortMoveRadius>12.0</ShortMoveRadius>
            <ShortMoveRate>0.35</ShortMoveRate>
            <TargetHeight>8.0</TargetHeight>
            <HasShortRangedAttack>1</HasShortRangedAttack>
            <HasRefaceAfterCombat>1</HasRefaceAfterCombat>
            <ReformBeforeCombat>1</ReformBeforeCombat>
        </Row>
    </ArtDefine_UnitMemberCombats>

<ArtDefine_UnitMemberInfos>
        <Row>
            <Type>ART_DEF_UNIT_MEMBER_U_MUBARIZUN</Type>
            <Scale>0.14</Scale>
            <Model>Swordsman_Arabia.fxsxml</Model>
            <MaterialTypeTag>ARMOR</MaterialTypeTag>
            <MaterialTypeSoundOverrideTag>ARMOR</MaterialTypeSoundOverrideTag>
        </Row>
        <Row>
            <Type>ART_DEF_UNIT_MEMBER_U_MUBARIZUN_V2</Type>
            <Scale>0.14</Scale>
            <Model>Swordsman_Arabia_v2.fxsxml</Model>
            <MaterialTypeTag>ARMOR</MaterialTypeTag>
            <MaterialTypeSoundOverrideTag>ARMOR</MaterialTypeSoundOverrideTag>
        </Row>
        <Row>
            <Type>ART_DEF_UNIT_MEMBER_U_MUBARIZUN_V3</Type>
            <Scale>0.14</Scale>
            <Model>Swordsman_Arabia_v3.fxsxml</Model>
            <MaterialTypeTag>ARMOR</MaterialTypeTag>
            <MaterialTypeSoundOverrideTag>ARMOR</MaterialTypeSoundOverrideTag>
        </Row>
    </ArtDefine_UnitMemberInfos>
    <ArtDefine_UnitMemberCombatWeapons>
        <Row>
            <UnitMemberType>ART_DEF_UNIT_MEMBER_U_MUBARIZUN</UnitMemberType>
            <Index>0</Index>
            <SubIndex>0</SubIndex>
            <WeaponTypeTag>METAL</WeaponTypeTag>
            <WeaponTypeSoundOverrideTag>SWORD</WeaponTypeSoundOverrideTag>
        </Row>
        <Row>
            <UnitMemberType>ART_DEF_UNIT_MEMBER_U_MUBARIZUN_V2</UnitMemberType>
            <Index>0</Index>
            <SubIndex>0</SubIndex>
            <WeaponTypeTag>METAL</WeaponTypeTag>
            <WeaponTypeSoundOverrideTag>SWORD</WeaponTypeSoundOverrideTag>
        </Row>
        <Row>
            <UnitMemberType>ART_DEF_UNIT_MEMBER_U_MUBARIZUN_V3</UnitMemberType>
            <Index>0</Index>
            <SubIndex>0</SubIndex>
            <WeaponTypeTag>METAL</WeaponTypeTag>
            <WeaponTypeSoundOverrideTag>SWORD</WeaponTypeSoundOverrideTag>
        </Row>
    </ArtDefine_UnitMemberCombatWeapons>
</GameData>
 
There is nothing wrong on it! I was working on a big mod, that i changed several units. Now i've started to work on a small one that changes only one unit, and i've forgot to tick the "Reload Unit System" on Mod Proprieties, just that! Problem solved!
 
Back
Top Bottom