• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

Can you help with getting a new unit mod to work?

MtB

Chieftain
Joined
Apr 19, 2009
Messages
18
Hello,
I would like to create and release a new unit for Civilization VI, but I need to ask for a volunteer or two to help out on completing the mod - that is, getting it to work.

I have got part of it done. It shows up in the Civilopedia and the unit is buildable (currently using the builder model) within the game (see pictures).

The mod however does not work as intended, and this is why I would like someone to read through what I've got and fix and clean up the (.xml, ArtDefs) code, and if possible build a new unit model. Also, tell me what I did wrong.

Supplied with the zipped mod are all the .xml, .dep, and artdef files I'm using. To preview or playtest it, download the mod, unzip it, put it in your Mods folder, and activate it prior to play game. It's called M*A*S*H.



The Mod...

Proposed Unit: Mobile Army Surgical Hospital (M*A*S*H)

Upgraded from: Medic

Ability: Heal all units within three tiles - This ability is not working ingame...

Requires: Flight and Barracks

Usage: By utilizing the highly manoeuvrable helicopter (not shown in game), injured soldiers are swiftly extracted from the combat zone to nearby field hospitals where surgeons are ready to perform 'meatball' surgery, that is, temporarily patching wounds so that the most serious wounded can then be sent on to proper medical facilities and those with less serious wounds can be returned to the front line.

Model Wanted: Nothing overly complicated is needed. It doesn't need animation. All that is needed is a big green tent with a white circle on it with a red cross in the circle. See Mash 3 - Unit In Play.jpg for idea.


Notes:

To quickly playtest the MASH unit, the mod has itself been modded so that it can be built without barracks and upon the discovery of Mining, and with a low build cost.


UnitAbilities.xml
I guess this is where the problem lies. This file is a copy of the original game file with everything stripped out that didn't contain the word MEDIC or HEAL. The word MEDIC was then changed to MASH in the assumption that would work. I also assumed changing the MinDistance of the <RequirementId>ADJACENT_UNIT_REQUIREMENT from 0 to 3 would increase the distance of the healing ability - but no. Something is missing or incorrect.


If something like this has been created already, please let me know where I can get it.

Thanks,
MtB
Mash 1 - Civilopedia.jpg
Mash 2 - Build List.jpg
Mash 3 - Unit In Play.jpg
 

Attachments

  1. File UnitAbilities.xml is not being loaded into the game database, therefore nothing in that file will be implemented
  2. The game already has a requirement called ADJACENT_UNIT_REQUIREMENT, so this part of your code will cause the game to stop reading anything in the file even if you add it to an UpdateDatabase action:
    Code:
    <Requirements>
      <Row>
        <RequirementId>ADJACENT_UNIT_REQUIREMENT</RequirementId>
        <RequirementType>REQUIREMENT_PLOT_ADJACENT_TO_OWNER</RequirementType>
      </Row>
    </Requirements>
    Every "RequirementId" name added by a new row must be unique and cannot repeat anything already added by the base game, any DLC, and any other mods that have already loaded their code into the game's database.
  3. Setting this to a value of "3" from the original value of "0" would not work, I would not think:
    Code:
    <RequirementArguments>
      <Row>
        <RequirementId>ADJACENT_UNIT_REQUIREMENT</RequirementId>
        <Name>MinDistance</Name>
        <Value>3</Value>
      </Row>
    </RequirementArguments>
    'MinDistance' is a Minimum Distance, so making the minimum distance "3" would I think require the unit to be 3 plots away rather than be 3 plots or less away.
  4. After altering the name of your requirement so it does not violate the uniqueness rule, try as:
    Code:
    <RequirementArguments>
      <Row>
        <RequirementId>SOME_NEW_REQUIREMENT</RequirementId>
        <Name>MinDistance</Name>
        <Value>0</Value>
      </Row>
      <Row>
        <RequirementId>SOME_NEW_REQUIREMENT</RequirementId>
        <Name>MaxDistance</Name>
        <Value>3</Value>
      </Row>
    </RequirementArguments>
    I am not sure a <RequirementType> of REQUIREMENT_PLOT_ADJACENT_TO_OWNER will understand a 'MaxDistance' but this approach would seem to be more logical.
  5. Neither table <BaseGameText> nor table <LocalizedText> is valid for an UpdateDatabase type of action. In order to use LOC_ABILITY_MASH_HEAL_NAME, etc., you need your action to be of type UpdateText.
 
  • Like
Reactions: MtB
You've also not defined a unit-portrait, which is why you are seeing the Stonehenge portrait in the Production Qeue. Running a test on the mod wihout any other mods enabled I also see the same thing.
Code:
<Row Name="ICON_UNIT_MEDIC_PORTRAIT"                        Atlas="ICON_ATLAS_UNIT_PORTRAITS"   Index="63"/>

For unit flags there are also
Code:
		<Row Name="ICON_UNIT_MEDIC_WHITE" Index="65" Atlas="ICON_ATLAS_UNIT_FLAG_SYMBOLS_WHITE"/>
		<Row Name="ICON_UNIT_MEDIC_BLACK" Index="65" Atlas="ICON_ATLAS_UNIT_FLAG_SYMBOLS_BLACK"/>
But I am not sure these cannot get overriden by what is in the artdef or blp files for a new unit. The fact tht these unit-flag definitions exist under table <IconDefinitions> reaches the limit of my knowledge re adding new unit art to the game.

When your mod is not functioning as expected, the first thing to do is to check the contents of Database.log for error-messages related to your mod.
The second thing to do is to double-check you have no unecessary mods also running, and disable all other mods that are not 100% needed in order for your mod to function.
 
  • Like
Reactions: MtB
LeeS,
Thanks for responding to this thread. I knew some of the coding in the UnitAbilities.xml was incorrect. When it comes to modding .xml files, it's pretty much complete guesswork as I have no formal, or informal training. Maybe I should look in to learning.

I tried your suggestions for the MinDistance and MaxDistance but as of yet I still cannot get the mod to work properly. I have extensively edited the abilities code, trying all sorts of things but nothing has worked, and I think I know the problem.

As you said, "File UnitAbilities.xml is not being loaded into the game database." This was probably due to it not being listed in the .modinfo file, which it now is, I believe.

<InGameActions>
<UpdateDatabase id="MashAbilities">
<File>UnitAbilities.xml</File>
</UpdateDatabase>
</InGameActions>

<Files>
<File>UnitAbilities.xml</File>
</Files>

I even tried renaming the file UnitAbilities_Abilities. Even so, I still think the file is not being loaded because I can completely remove the UnitAbilities.xml from the mod, and when playing the game, the MASH unit can still heal an additional 20hp from one tile away, so it must be linked to the medic somehow.

The only thing I can see for that to happen are two listings for Tag="CLASS_MEDIC". If I change them to CLASS_MASH I lose the +20hp bonus, and the game reverts to the basic healing points.

Even emptying the Cache and Logs folders did nothing.

You made mention of checking the Database.log for errors. I looked at it and none of it meant anything to me.

No matter.

Thanks again for the code examples. I don't see why it should not work. I'll persevere for a bit longer with it and see what happens.

First things first, how to get the file to load in to the game...

MtB
 
Back
Top Bottom