Results 1 to 4 of 4

Thread: How to merge 2 mods

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Ralendil's Avatar Semisalis
    Join Date
    Oct 2005
    Location
    France
    Posts
    426

    Default How to merge 2 mods

    As I had several PMs about that, I have preferred opening a thread about that instead of answering a lot of PMs (nota, use the forum to ask questions)

    This tutorial should only be used by people that have already started to mod. If you know nothing about modding the game, give up now...

    1./ The programs you will need:

    To format the modeldb file:
    http://www.twcenter.net/forums/downl...o=file&id=1180

    To merge 2 files in 1:
    http://winmerge.org/
    Nota: there are a lot of programs to do that, I put this one here cause it is a freeware (GNU license) and it can do the work. Additionally, it is the program I will use in this tutorial.

    2./ How to merge:

    First, you need to know how what you want to merge, is working.
    Exemple: if you want to merge a new faction in your own modifications, then you need to know how to add a new faction, or you will miss parts of the changes that are needed.

    You need also to test the changes one by one. But do not be blocked on 1 file. If the changes you merged don't work, then try an another file. Several files are linked between them.
    Exemple: If you want to merge a new faction, and don't begin by adding the changes in descr_sm_factions.txt, you will surely obtain a crash cause the game won't find the faction name that you want to introduce.
    Doing the changes one by one, can save you from a headache. If you have done a lot of changes and obtain a CTD, don't complain you don't know where is the error.

    Sometimes, introducing changes won't require you that you merge 2 "txt" files.
    Exemples: If you want to use a modified texture for an unit, if you want to use a new texture for the blood, if you want to use a new banner for a faction, if you want to introduce a mod that is changing the interface of the game etc... (for this kind of changes, you will need to work with a program like photoshop, and this is not the purpose of this tutorial to learn you that, or I would spend too much time at writing this tutorial)

    3./ Merging 2 "txt" files by using Winmerge:

    The program permits you to merge files with the extensions: ".txt" ".modeldb" ".cfg" ".xml". In fact, this program permits you to merge all the files that have text inside.

    How can we use this program?
    I take here the exemple of the Orders mod. Let's see how we can merge the changes of the descr_banners_new.xml. The exemple is not really good, as few mods modify this file, and so if the file is unmodified, you don't need to do what I will describe here. You would simply need to put the modified file in your mod folder. However, if you want to merge 2 mods that have modified a same file, what I describe here is needed. Anyways, we need an exemple...

    1. Do a save of the file you will modify.
    2. Open WinMerge
    3. Click "Open" (CTRL + O)
    4. You will see 2 lines, 1 named "left" and one named "right".
    In the left or right (as you wish) put the adress of the file you want to be modified (we will call this file "the destination"). In the left or right (here use the one you have not used to put the adress of the file you want to be modified) put the adress of the file that contains the changes you want to merge (we will call this file "the source").
    You can use the browse function of the program to find the files you want to be compared.
    When it is done, click "OK"
    5.You will see this:


    In the side bar you will see the changes. The colors used are easy to understand:
    White: no change
    Yellow: changes
    Grey: Something missed in the other file (so when there's a part in grey, the corresponding part of the other file is in... yellow)

    Here you can see that there are parts modified, and parts added.
    If you check it carefully, you will see that the parts added are 3 sections called "special_unit_infantry" "special_unit_cavalry" and "special_unit_missile".
    To add them to the file you want to be modified simply right click on the yellow part and select copy to left (or right depends where is the file you want to be modified).

    In the exemple below, you can see that my "source" is on the left and the file I want to be modified is on the right. So I use the command "Copy to Right".

    Nota: If you use the undo command, the part that has been removed from the file you had modified will appear in red in the source file.

    Nota 2: You could also have merged the first changes at the beginning of the file. These changes concern the display of the banners.
    It is interresting to talk about that here, as this is not an addition to the file, but a change. So you may notice that the 2 columns of the sidebar show this part in yellow, as the two parts of the file differ totally.

    Nota 3: The button "refresh" (F5) is interresting when you do several changes to the file as it permits you to resynchronise the 2 files. Like that you can see again what are the changes not integrated. Also this is needed if you modify by hands one file. Then the files are no more synchronised and the program need you to resynchronise the 2 files to be able to use the "copy to left" and "copy to right" commands.

    Let's finish this exemple by checking the export_descr_unit.txt file. I will again take a vanilla file as the destination file (the file we want to modify). However, here I will show how to introduce the changes of the banners WITHOUT adding the new units provided by the mod.
    So execute the instructions 1 to 4.
    When it will be time to merge it you should see a file with few yellow in the sidebars.
    You should constat that there are several sections that are not in the source file and are presents in the destination. Why? cause the author (me) deleted them to concentrate all the changes at the end of the file.
    Well, we could delete the entries that are in the destination file and after adding the entries modified of the source file, however... the mod adds several new mounts and we don't want these new mounts (remember we only want the banners).
    If you compare the entries you will see a change about the banner line.
    So copy this line to the destination (copy and paste, don't use the copy to right command...)
    So find in your destination file this line:
    Code:
    banner faction   main_cavalry
    And change it to:
    Code:
    banner faction   special_unit_cavalry
    Now, let's introduce the banners for the Janissaries. Synchronise again the files (F5)
    You should see few yellow lines in the sidebar. If you go to them you will see that these changes concern the entries: Janissary Archers, Janissary Musketeers and Janissary Heavy Inf
    You will see that only one line is modified, the line we have seen also modified for the templars, hospitallers etc.... (see below what you should see, assuming that you put the source on the left and the destination on the right)


    Change it by copying from the source to the destination.

    Congrats, you added to your modifications the banners of the orders mod.

    4./ Modeldb

    The file battle_models.modeldb is really special. You should find a formatted version of this file in nearly all mods you will download that add units to the game.
    So first you need to format it. Use the file I linked in the first paragraph.
    Look at the readme inside the archive (it is not the purpose of this tutorial to explain how to use this tool) and format your modeldb file.

    Nota: If you really merge 2 mods, you should find 2 files that have been already formatted, I just put this comment above to avoid the questions like "I don't understand my modeldb file is not looking like yours".

    Ok, now we have our 2 files ready.
    Open them in Winmerge (see in the last paragraph for this, you should know now how to do it)
    Then here it is the same thing, you just need to know how the modeldb is working (see my sig for an explanation of this file).

    So, before playing with this file, be sure, that you understand how this file works... this file is the one that can lead to crash really fast.


    As I said, you need to learn perfectly how to mod something to be able to merge 2 mods... If you try to merge 1 faction used in one mod into an another mod and don't know how to add a faction, you will fail. There's no doubt about that...

    _______________________________________________________________
    An explanation of the file battle_models.modeldb | Starting to mod
    Downloads:
    MTW2 Interface (interface, menus, icons) - Version 1.1
    Orders Mod- Version 1.2



    Last edited by Ralendil; April 20, 2011 at 01:05 PM. Reason: adding my old sig to permit users to retrieve infos
    Kill one man, and you are a murderer. Kill millions of men, and you are a conqueror. Kill them all, and you are a god.
    Jean Rostand

    Current Mod for S2TW: Sengoku Unit Cards

  2. #2
    Trajan's Avatar Capodecina
    Join Date
    Oct 2004
    Location
    USA
    Posts
    10,934

    Default Re: How to merge 2 mods

    Thanks Ralendil for spreading the word about WinMerge. I was using ExamDiff before and compared to WinMerge, it was a pain in the ass merging specific lines in the EDU.txt.

  3. #3
    Ralendil's Avatar Semisalis
    Join Date
    Oct 2005
    Location
    France
    Posts
    426

    Default Re: How to merge 2 mods

    Quote Originally Posted by Trajan View Post
    Thanks Ralendil for spreading the word about WinMerge. I was using ExamDiff before and compared to WinMerge, it was a pain in the ass merging specific lines in the EDU.txt.
    You're welcome
    Kill one man, and you are a murderer. Kill millions of men, and you are a conqueror. Kill them all, and you are a god.
    Jean Rostand

    Current Mod for S2TW: Sengoku Unit Cards

  4. #4

    Default Re: How to merge 2 mods

    Great program, +Rep.
    Reap the promised end to the struggle. Reap every point on our linear path.
    Reap the smiles in time we borrow, every harvest relies on the last.
    Reap the promising song of the sparrow, that they learned from the birth of sea.
    Silenced by the threnody of the crows. Reap the fallen fruit of the dogwood tree.
    But I witnessed in all this silence one soul's definition of beauty. and a backlit smile so temporary.
    A facade so rich with evil history. Cast in direct opposition set to overwhelm this moment to shine and sleep.
    came out on top of what was borrowed, and found all that beauty to be still...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •