Jump to content


Photo

How to resurrect an old mod


  • Please log in to reply
4 replies to this topic

#1 hlidskialf

hlidskialf

    Incarnation of the Eternal Ale Warrior

  • Modder
  • 2510 posts

Posted 11 September 2005 - 11:33 AM

Mod Resurrection Tutorial
- Making new from old.

Having rebuilt a few old mods into new weidu versions, and having been asked a time or 3 on how to do it, I thought I'd make an attempt to throw a tutorial together on how it's done. Perhaps it'll inspire someone else to dust off that old mod they found under a rock and bring it back into the light of day. ;)

Pre-Resurrection Preparation:

This is the most important step for me. When you start juggling old/new/and partial files it's easy to fubar things up if you don't plan well.

Step 1)
It's a good idea to either have a clean game install for referencing, or enough modding experience to know the difference between original and modified files. Now, you'll need a directory for where you can do your work without corrupting original game files. I have a directory I use for this called my "Cauldron". (Funky 'eh?) You'll also need a copy of Weidu, Near Infinity and/or DLTCEP.

Step 2)
Once you've created this folder, you'll need to stock it. Create an empty Override folder in this new directory. (I'll just call it the Cauldron from now on.) Add to the Cauldron a clean dialog.tlk and chitin.key of the game you're planning to mod.

Step 3)
Now add the contents of a clean weidu folder. (This will include the weidu.exe, src folder, etc...) The reason you place one here is to make life easy while working. Weidu first looks into it's current directory for game files, then to the default BG2 installation. We don't want to corrupt original files, and we won't always be working with BG2 so this bit of space saves endless game targeting headaches when running the weidu.exe.

Step 4)
Finally, it's handy to set up a profile in DLTCEP or set the game directory of the game type you want to import into in IEEP to point at the Cauldron for your BG2 installation. This way importing IAP or TBG files will wind up here instead of your game directory. Time to put on your Indiana Jones hat and go hunting ancient websites and archives for an old mod to play with!

Deciding What to Work With

Step 5)
Now let's install that old mod. If IAP or TBG format, use your above configured DLTCEP or IEEP. If you have an SFX.exe, then browse to your Cauldron to install it. When done, you'll have some new files in your Cauldron's override, and new strref (if applicable) in your .tlk file. Goodie! Reward yourself with a pint of ale, you've earned it.

Step 6)
Now go look and see what's in your override. These are the mod files, likely some new creations, and some modified regular game files. You'll need to place these into an installation package, if you do this now you can also easily build most of your .tp2 code using weidu's --automate function. Easy and time saving are things I appreciate so we'll do this now.
Create a new folder in your Cauldron. It'll be your final package's name so come up with something you like. For example, when I did this for Freedom's Reign and Reign of Virtue (Some big item mods created by Deano during the early days of modding. Staple mods for many.) I called the folder FR_ROV. For ease of tutorialness (A new word!) we'll use the everpopular, "MyMod" name.
Inside your new MyMod folder, you'll need some other folders. To start, you'll need one called "backup". (This is where weidu will put backup files, strangely enough.) You can organize as much as you like at this point, I like to keep it pretty organized, with subfolders for most file types. Other people like to just stuff everything in the MyMod folder and leave them loose in there. The final decision is yours, but I'm going to detail my way for now. Create a folder for "Areas", "Items", "Spells", "Stores", "Dlg", "DFiles", "Scripts", "Bafs", "Dump", "Snip" and "Misc", etc... as applicable. (I find it handy actually to have a blank folder of every file type in a folder called "NewFolders" in my Cauldron directory. This way I can just grab copies when I make a new package instead of recreating them all. )
Inside each of these folders, place all the specific file types you found in the override. The Item folder gets the .itm files, etc... If you're not sure, throw them in the misc folder.

Step 7)
You'll need to decompile and rebuild the dialog and script files. Using the weidu.exe, either through doubleclick or command window, type in:

weidu.exe MyMod/Dlg/*.dlg --text

This will convert all your .dlg files into .D files. The "--text" command causes the actual strings to be exported into the .D file instead of the strref number. Since you're referencing strref numbers that don't match the end user's, this is a good way to do it. The .D files will now be in your Cauldron folder, move them into the DFiles folder of your installation pack. Now you can delete your Dlg folder, as it's served it's purpose.
Now you have to decompile the bcs files. I find it easiest actually to use the NI dropbox to mass decompile the scripts. It's easy and quick. You'll need NI for a bunch of other things (or DLTCEP) so it's also handy to have open. To ensure you get the right strref added by the mod, I move my virgin .tlk file somewhere and temporarily replace it with the modded one. Decompile the scripts, then move everything back. It's not clean, but modding never is! :P Place the newly aquired .baf into the "Baf" folder. If any .baf file is one already used in the game, move it to the "snip" folder. Why? Because these are scripts that will need to have the old content removed, and the coding in the .tp2 used to extend them to the regular game scripts. Open each one of those existing .baf reference scripts in your snip folder. Delete all the old content and save the file. You now have a .baf file with the changes made by the mod for that particular script. I usually rename these scripts to show they are a snip and prevent confusion during coding. (For example, adding a script block to AR0700.bcs I'd rename the snip file to sAR0700.baf. ) Make sense? No? Have another ale, it'll start coming together. */
Now, go through the code of the full baf and snip baf files and make sure that any strrefs that are referenced by the scripts, are changed from strref numbers to a functional weidu code string. An example from NEJ:

ActionOverride(Player1,DisplayStringHead(Myself,83111)) //Suddenly, you have a feeling that this portal leads nowhere and there may be no way back. Perhaps it would be better to leave this portal for now and investigate the rest of the dungeon, while you still have a choice.

You need to convert this to:
ActionOverride(Player1,DisplayStringHead(Myself,~Suddenly, you have a feeling that this portal leads nowhere and there may be no way back. Perhaps it would be better to leave this portal for now and investigate the rest of the dungeon, while you still have a choice.~))

Otherwise the end user will get gibberish from displaying an invalid strref. You don't have to use tildes (~~) but I prefer to code with them, and if desired, to later convert to a .tra format. (See the weidu readme for the auto-tra functions. I'm not going to detail them here.) As you may imagine, this can be a royale pain in the ass when converting larger mods. Fortify yourself with more ale, and click away.

Step 8)
This is the part that truely is time consuming and tedious. Deciding what's new or changed, and what those changes are. Work through, folder, by folder. You've already done the work on the dlg and script files, now you must examine each to see if they are new and unique to the mod, or modified regular game files. Unique files are easy, they will be copied into the game folder when the mod installs, using code from step 9.
Modified standard game files will suck the life from you as you search each file for changes made by the mod, and determine code that will modify, instead of replacing the file on the end user's system. It's handy to keep two editors open side, by side, one open to your virgin install, one open with the modified file. NI is a good choice for this as it even handily displays the hex locations the majority of .tp2 files will require. You may find that it's quite the game of hide and seek when snipping out portions of .baf or .d files. Scripts are quite easy to extend with weidu. Dialogs are as well, although it requires more knowledge of possible coding options. There's several great tutorials out there already on how to do these, so I'll be lame and skip over it.
Once the file has been modified, make sure to delete it from your mod directory! If you leave it in there, it'll be added to the .tp2 in step 9, and overwrite files instead of patching them. Which would kinda make redundant the whole point of weiduing this mod and sufferring through this step!
Let's check out an example from FR_ROV. The desire here is to add an item to Ribald's store in the Adventurer's Mart:
//Patch Existing Stores
///////////////////////

//Adventurer's Mart - Ribald Barterman
COPY_EXISTING ~ribald.sto~ ~override/ribald.sto~
   ADD_STORE_ITEM + ~DeITM072~ #0 #0 #0 ~IDENTIFIED&UNSTEALABLE~ #1 // Valiant Blade

Note, the handy notes I've left for myself to remind me what section is what. Anything after the double slash '//' is ignored by weidu. Thus I know DeITMO72 is actually the Valiant Blade, and is added to Ribald's store. This is insanely handy when the inevitable bugfixes need to be done.

At this point, you've probably ingested a large amount of ale. Perhaps a coffee is in order.

Step 9)
Time to build some code. This is where we use the --automate function for Items, Spells, Stores, and Areas, and where putting all the files into individual folders first comes in handy. This will spit out some .tp2 files in the Cauldron directory, I like to ID them by file type. For areas type this:
--automate MyMod/Areas --textapp Area.tp2
This will spit out an Area.tp2 in your Cauldron folder. If an area has any assigned strref (Such as for signs or triggers, etc...) This will copy the file over and place in the strref. Easy 'eh?
Now repeat for Items, Stores, and Spells. Referencing the correct folder and naming of final .tp2.

Step 10)
Time to start building the .tp2. Have another ale. You might have to restock your chair's fridge at this point, do this before your legs get as wobbly as this whole tutorial has made your mind. Use your original .tp2 file. (The one you set up with the modified file code.) Add the introductory code:

BACKUP ~MyMod/backup~ // So you designate where the backup files go when the mod installs.
AUTHOR ~Your name, perhaps an email or forum address where you can be tracked down.~

BEGIN ~MyMod~

After that, just start adding the code you've generated. It's a good idea to group changes by file type. eg) Copy/Paste the --automate generated code for areas into your .tp2. Then add any of the area modification code you made. (if any) Next do creatures, etc... Once your .tp2 is built, add a closing out command that'll nicely display the mod's readme if you desire. eg)
//End of Reign of Virtue
////////////////////////

AT_INTERACTIVE_EXIT ~VIEW FR_ROV/ReadMe-FR_ROV.txt~

Step 11)
Here comes the fun part. Create a copy of weidu, and rename it to Setup-MyMod.exe. Rename your main .tp2 file to Setup-MyMod.tp2. Drop both of them, and a copy of your new mod folder into a game directory. Run it, and prepare to fix the errors you made which is preventing it from installing. (Murphy's law and all that, 'eh?) Debug, package and ship it out! I hope this tutorial helped more than it hindered. If nothing else I'm hoping you've developed a finer appreciation for ale!

Edited by vilkacis, 13 December 2009 - 02:02 PM.

The great wolf Fenrir gapes ever at the dwelling of the gods.


#2 AnnabelleRose

AnnabelleRose

    The great pretender... of modding!

  • Modder
  • 2083 posts

Posted 30 October 2005 - 04:01 PM

Wow, I had not seen this till Shed linked to it.

Hlid, you kick ass. :cheers:

- The transitioned former modder once known as MTS.


#3 Carinna

Carinna
  • Member
  • 19 posts

Posted 13 December 2009 - 11:16 AM

I just want to point out that the link to DLTCEP in the original post now leads to a porn site. Haven't checked the other 2 links.

#4 Hoppy

Hoppy

    Mage Hunter

  • Member
  • 2107 posts

Posted 13 December 2009 - 12:58 PM

It seems all dragonlance links are now porn sites. I saw some at Black Wyrm Lair, too
?May God defend me from my friends; I can defend myself from my enemies.? - Voltaire

"If you think that a size of the mod indicates an amount of bugs that it introduces and their severity you're totally wrong...
Try not to use next time a load of shitty "super-mega-improving-tweaking-revising" small mods that you have installed and try to meet Wulfgar once again."
- King Diamond


Posted Image The Definitive Guide to Trolls

"Finding food and a place to sleep is your own business. I imagine Paul the Cat should have some fun with you, too" - Potencius in The Darkest Day
"You have been warned, little bastard!" -Khelben to a young <CHARNAME>in Check the Bodies
There are those who will snivel, and offer nothing in return except criticism, meanwhile never lifting a finger to do other than to cut other peoples labor down simply for the fact that they lack the capability to put anything of their own together. -erebusant

#5 vilkacis

vilkacis

    Rashemen REPRESENT! Word to yo hamsta!

  • Modder
  • 1571 posts

Posted 13 December 2009 - 02:00 PM

I just want to point out that the link to DLTCEP in the original post now leads to a porn site.

That's... bad.

Pointing it to the DLTCEP section on the G3 boards. The WeiDU and NearInfinity links are still fine.

[edit: also fixed the b0rken html.]

Edited by vilkacis, 13 December 2009 - 02:02 PM.