Jump to content

Would modders be interested...


plainab

Recommended Posts

I did a little playing around with weidu today and came up with a little idea. There have been a few posts at different forums talking about how difficult weidu is to learn. Maybe my little idea might help modders who would typically do an overwrite style mod to at the very least utilize weidu as an installer.

 

Weidu has a compare feature that will produce a series of WRITE_BYTEs to modify the existing file into the new file. It is true that these WRITE_BYTEs will only create a working file if the file being modified is identical to the file that was compared when the writes were first created. The only guaranteed identical state is a pure unmodified game.

 

That said, I've created a little tp2 file which will create a starting place tp2 complete with patches that include the aforementioned WRITE_BYTEs. Usages of this could vary.

 

1. A modder can create a set of files using any program they are comfortable with. When the mod is done and tested, this utility could be ran. The mod is then "weiduized" but still retains the requirement that it be installed as the very first mod. (Or with a specific set of mods installed in a specific order.)

 

2. A modder can follow #1, but afterwards pull out the IESDP in conjunction with NI and make any modifications to the patch that they wish to make. Changes that would allow for installation at any point in the mod list. For example: adding in a FOR loop to make sure that a value modified in an extended header or effect gets properly adjusted IF an earlier mod adds or subtracts a header or effect.

 

3. A player could run this to weiduize a favorite non-weidu mod that is always installed first.

 

4. A player could run this to weiduize a favorite non-weidu mod at some middle point in the mod list. The patches created would change any existing modified file as if it had been simply overwritten.

 

Numbers 1 and 2 would just need to run this code and manually backup the results. Then package up all necessary files and distribute.

 

Numbers 3 and 4 would be a multi part process.

1. Run this code and manually backup the results (uninstallation will remove needed files)

2. Then uninstall this code and run the newly created mod code retrieved from the backed up results.

 

Do note that I've tested the functions of this, but not any mod that was converted by this.

 

Anyone wishing to try this out may do so. The only requirements are:

1) A copy of weidu.exe is present in the main game directory.

2) That another copy of weidu.exe is renamed -- setup-ab_nwct.exe

3) and the below tp2 code be named -- setup-ab_nwct.tp2

 

Normally, I would not care about the naming, but this code is dependent upon the names being exactly as they are.

//plainab's Non-Weidu Conversion Tool
BACKUP ~ab_nwct\backup~
AUTHOR ~plainab~

BEGIN ~Convert a non-weidu mod into a patching weidu mod~
<<<<<<<< inlined/blank.tp2
//--- Non-Weidu Mod converted to weidu patch ---
>>>>>>>>
COPY ~inlined/blank.tp2~ ~override/ab_nwct_tp2_file.tp2~
COPY ~inlined/blank.tp2~ ~override/ab_nwct_new_file.log~
//make sprints blank for safety reasons
OUTER_SPRINT main_mod dir ~~
OUTER_SPRINT file_dir ~~
OUTER_SPRINT author ~~
OUTER_SPRINT new_mod_name ~~
//ask for location of mod to be converted
PRINT ~-------------------------------
Please enter the directory location of the mod you
wish to convert.

EXAMPLE:
If the mod was located at:
"C:\Program Files\Black Isle\Baldur's Gate\somemod"

You would enter:

somemod

Once you have entered the correct information,
please press ENTER to continue.
-------------------------------~
ACTION_READLN ~main_mod_dir~
//ask for location of files to be converted
PRINT ~-------------------------------
Please enter the directory location of the files
from the mod you wish to convert.

EXAMPLE:
If the mod was located at:
"C:\Program Files\Black Isle\Baldur's Gate\somemod"
and the files are located in the sub-directory of "files"

You would enter:

files

If the files are not located in a sub-directory,
do not enter anything just press ENTER.

Once you have entered the correct information,
please press ENTER to continue.
-------------------------------~
ACTION_READLN ~file_dir~
//ask for author's contact information
PRINT ~-------------------------------
Please enter the contact information for the mod.
I.E. an e-mail address or website where the author can be reached.

EXAMPLE:
someguy@somedomain.com

Once you have entered the correct information,
please press ENTER to continue.
-------------------------------~
ACTION_READLN ~author~
//ask for the new name of the weiduized mod
PRINT ~-------------------------------
Please enter the name you wish the weiduized mod to be called.

EXAMPLE:
If original mod was, Baldurdash AND your prefix is "ab"
Then you might want to use:

ab_B-dash_on_Weidu

NOTE: This will be used for the setup files.

Once you have entered the correct information,
please press ENTER to continue.
-------------------------------~
ACTION_READLN ~new_mod_name~
//make directory to put files to compare after they are yanked out of the biff
MKDIR ~ab_original_files~
//append the header information for the weiduized tp2 file
APPEND "ab_nwct_tp2_file.tp2" "BACKUP ~%main_mod_dir%\backup~"
APPEND "ab_nwct_tp2_file.tp2" "AUTHOR ~%author%~"
APPEND "ab_nwct_tp2_file.tp2" "//--- Component Start ---"
APPEND "ab_nwct_tp2_file.tp2" "BEGIN ~Converted Patches of Mod in the %main_mod_dir% directory~"
//copy the mods files to compare them to the original files
COPY ~%main_mod_dir%\%file_dir%~ ~override~
SPRINT filename_ext ~%SOURCE_FILE%~
SPRINT filename ~%SOURCE_RES%~
PATCH_PRINT ~Examining %main_mod_dir%\%file_dir%\%filename_ext%~
INNER_ACTION BEGIN
 ACTION_IF (FILE_EXISTS_IN_GAME ~%filename_ext%~) THEN BEGIN
  APPEND "ab_nwct_tp2_file.tp2" "COPY_EXISTING ~%filename_ext%~ ~override~"
  COPY ~override/ab_nwct_tp2_file.tp2~ ~ab_nwct_tp2_file.tp2~
  ACTION_IF (FILE_EXISTS ~override\%filename_ext%~) THEN BEGIN
PRINT ~%filename_ext% found in override -- Comparing against that version.~
COPY ~override\%filename_ext%~ ~ab_original_files\%filename_ext%~
  END ELSE BEGIN
PRINT ~%filename_ext% not found in override -- Getting BIFF version to compare.~
AT_NOW ~weidu --biff-get "%filename%" --out "ab_original_files"~
  END
  PRINT ~Comparing mod file %filename_ext% with existing version.~
  AT_NOW ~weidu --cmp-from "ab_original_files\%filename_ext%" --cmp-to "%main_mod_dir%\%file_dir%\%filename_ext%" --append "ab_nwct_tp2_file.tp2"~
  COPY ~ab_nwct_tp2_file.tp2~ ~override/ab_nwct_tp2_file.tp2~
  APPEND "ab_nwct_tp2_file.tp2" "BUT_ONLY_IF_IT_CHANGES"
 END ELSE BEGIN
  PRINT ~%filename_ext% not found in game at all -- this is a new file.~
  APPEND "ab_nwct_tp2_file.tp2" "//%main_mod_dir%\%file_dir%\%filename_ext% -- is a new file"
  APPEND "ab_nwct_tp2_file.tp2" "COPY ~%main_mod_dir%\%file_dir%\%filename_ext%~ ~override~"
  APPEND "ab_nwct_new_file.log" "--------------------------------------------------------------"
  APPEND "ab_nwct_new_file.log" "%main_mod_dir%\%file_dir%\%filename_ext%"
  APPEND "ab_nwct_new_file.log" "--------------------------------------------------------------"
  APPEND "ab_nwct_new_file.log" "Does not have a corresponding file in the existing game setup."
  APPEND "ab_nwct_new_file.log" "It is a new file, please make sure that you keep this file."
  APPEND "ab_nwct_new_file.log" "If you keep the original mod setup you can use the following,"
  APPEND "ab_nwct_new_file.log" "which is included in the tp2 file:"
  APPEND "ab_nwct_new_file.log" ""
  APPEND "ab_nwct_new_file.log" "COPY ~%main_mod_dir%\%file_dir%\%filename_ext%~ ~override~"
  APPEND "ab_nwct_new_file.log" "--------------------------------------------------------------"
 END
END
BUT_ONLY_IF_IT_CHANGES

COPY ~override/ab_nwct_tp2_file.tp2~ ~setup-%new_mod_name%.tp2~
PRINT ~New file -- setup-%new_mod_name%.tp2 -- is complete.
Find it in main game directory.~
COPY ~setup-ab_nwct.exe~ ~setup-%new_mod_name%.exe~
PRINT ~New file -- setup-%new_mod_name%.exe -- made.
Find it in main game directory.~
COPY ~override/ab_nwct_new_file.log~ ~ab_nwct_new_file.log~
PRINT ~Info file -- ab_nwct_new_file.log
-- lists those files not found within the current game setup.
Find it in the main game directory.~

PRINT ~-----------------------------------------------
Prior to uninstalling this converter,
Please backup the following files as the uninstallation process
will most likely delete them. You need these as they are important
to your new weiduized mod.

setup-%new_mod_name%.tp2
setup-%new_mod_name%.exe
ab_nwct_new_file.log

All are located in the the game's main directory.

Please press ENTER to acknowledge this message.
-----------------------------------------------~
ACTION_READLN ~ack_1~

NOTE: This was designed and tested on Redrake's IWD Fixpack available at Chosen of Mystra. That mod had everything in one central place, other mods might be different and could require moving files into one central place.

Also, the compare feature will create write bytes for any file that is in the designated folder and within the game even if it is a file not typically considered patchable with write bytes (i.e. bam, wav, 2da, ids). Special attention may be needed to ensure that these files do work correctly after the patch has been installed.

 

If this does prove to be a useful tool, I'd be willing to package it up complete with tra file, directory structure, exe file and of course the tp2.

 

Let your thoughts commence.

Should the moderators feel that this is better served in a different location, feel free to move it.

Link to comment

You can use NO_LOG_RECORD (after BEGIN mymod) and COPY - (for the files that are copied to the override and shouldn't be kept).

 

APPEND_OUTER ~somefile~ will append to ./somefile rather than ./override/somefile (to avoid leaving unrelevant files in the override).

 

   ACTION_IF (FILE_EXISTS ~override\%filename_ext%~) THEN BEGIN
PRINT ~%filename_ext% found in override -- Comparing against that version.~
COPY ~override\%filename_ext%~ ~ab_original_files\%filename_ext%~
  END ELSE BEGIN
PRINT ~%filename_ext% not found in override -- Getting BIFF version to compare.~
AT_NOW ~weidu --biff-get "%filename%" --out "ab_original_files"~
  END

--> Unless I'm missing something, simply use COPY_EXISTING ~%filename_ext%~ ab_original_files

 

The various --*cmp-from/to commands should receive an update in 209 (well, not --cmp-from/to, but --bcmp-from/to will decompile the file, --dcmp-from/to will work if the two files have different length, and --textcmp-from/to will be added for 2da and ids files), so you might want to call the correct one according to %SOURCE_EXT%.

 

Also, you might want to decompile new dlg and bcs files (so that new strings will be kept) and run --automate on both new and old itm, spl, cre... files (again, to preserve strings). --automate on old files would require some trickery to remove the COPY ~mymod/files/blah.itm~ and be kept in the same COPY command as the one from the --cmp-from/to patch.

Link to comment
You can use NO_LOG_RECORD (after BEGIN mymod) and COPY - (for the files that are copied to the override and shouldn't be kept).

When things are working right for all different file types, I'll certainly think about adding it in.

 

APPEND_OUTER ~somefile~ will append to ./somefile rather than ./override/somefile (to avoid leaving unrelevant files in the override).

Cool, that saves me some headache.

 

--> Unless I'm missing something, simply use COPY_EXISTING ~%filename_ext%~ ab_original_files

Yeah, I didn't think about that. I'd been needing to use copy everywhere else and sort just stuck with the habit.

 

The various --*cmp-from/to commands should receive an update in 209 (well, not --cmp-from/to, but --bcmp-from/to will decompile the file, --dcmp-from/to will work if the two files have different length, and --textcmp-from/to will be added for 2da and ids files), so you might want to call the correct one according to %SOURCE_EXT%.

Looking into this...

cmp should only do: are, cre, chr, itm, spl, & sto files correct?

bcmp is for bcs and bs script files. You say that in 209 they will be internally decompiled for the compare process. If so, that will help.

dcmp is for dlg files correct?

textcmp will be for 2da, ids and other text type files correct?

What about files like bam, wav and other game files? Is cmp okay to use or are those file types most likely best to just use a straight copy to replace any existing copy?

 

Also, you might want to decompile new dlg and bcs files (so that new strings will be kept) and run --automate on both new and old itm, spl, cre... files (again, to preserve strings). --automate on old files would require some trickery to remove the COPY ~mymod/files/blah.itm~ and be kept in the same COPY command as the one from the --cmp-from/to patch.

Are you saying that new dlg and bcs files that cannot be compared with existing game files should be decompiled by whomever wishes to convert a weidu mod for later compiling during install by a different user?

 

I tried automate and all it does is create a string of copy tp2 commands. There were no strings preserved at all. Perhaps I had needed to specify the dialog.tlk file that Redrake provides with his mod. I'll give that a try and see what happens.

When you say to automate both new and old files do you mean new mod files and mod files with existing game versions?

 

Is 209 available yet?

Link to comment
Looking into this...

cmp should only do: are, cre, chr, itm, spl, & sto files correct?

bcmp is for bcs and bs script files. You say that in 209 they will be internally decompiled for the compare process. If so, that will help.

dcmp is for dlg files correct?

textcmp will be for 2da, ids and other text type files correct?

This is all correct.

 

What about files like bam, wav and other game files? Is cmp okay to use or are those file types most likely best to just use a straight copy to replace any existing copy?

I'd simply replace the old one.

 

Are you saying that new dlg and bcs files that cannot be compared with existing game files should be decompiled by whomever wishes to convert a weidu mod for later compiling during install by a different user?

Yes.

 

I tried automate and all it does is create a string of copy tp2 commands. There were no strings preserved at all. Perhaps I had needed to specify the dialog.tlk file that Redrake provides with his mod. I'll give that a try and see what happens.

When you say to automate both new and old files do you mean new mod files and mod files with existing game versions?

automate only works on strings after #62169 (SoA string count).

Your definition of new and old is correct.

 

Is 209 available yet?

No, I fell asleep :p

Link to comment
automate only works on strings after #62169 (SoA string count).
Is it possible to get the current count of dialog.tlk strings on the users install? In other words if I can somehow read the file and get the total number of strings, I can then do the automate feature only when the dialog.tlk exceeds the given number.

Sounds like it's a useless feature for BG & IWD unless they have heavily modified dialog.tlk files.

 

Is 209 available yet?

No, I fell asleep :p

Ahh, that happens to the all of us at one point or another...
Link to comment
automate only works on strings after #62169 (SoA string count).
Is it possible to get the current count of dialog.tlk strings on the users install? In other words if I can somehow read the file and get the total number of strings, I can then do the automate feature only when the dialog.tlk exceeds the given number.

Sounds like it's a useless feature for BG & IWD unless they have heavily modified dialog.tlk files.

I guess I could figure out the original string count depending on the game 'behind the scenes'. Or you need to have current and old string count in tp2?

Link to comment
automate only works on strings after #62169 (SoA string count).
Is it possible to get the current count of dialog.tlk strings on the users install? In other words if I can somehow read the file and get the total number of strings, I can then do the automate feature only when the dialog.tlk exceeds the given number.

Sounds like it's a useless feature for BG & IWD unless they have heavily modified dialog.tlk files.

I guess I could figure out the original string count depending on the game 'behind the scenes'. Or you need to have current and old string count in tp2?

I don't really need the count of the mod added strings.

It would be nice if I could just do

COPY ~dialog.tlk~ ~dialog.tlk~
READ_LONG 0xa ~total_num_strings~
BUT_ONLY_IF_IT_CHANGES

I can then use the value of total_num_strings to call the --automate feature if and when the value is greater than the low limit of 62169

But due to weidu's file size limitations, I can not.

Is there a way that you can get the count?

I don't mind if it is a built in variable that can't be modified only accessed. Only way to update the count would be to use CLEAR_MEMORY. You could use a variable name like: TOTAL_NUM_TLK_STRINGS

Link to comment
If you need it only for --automate, it's easier to have WeiDU correctly figure it out from the game type rather than forcing you to correctly --automate-min.

Okay, how do we have weidu figure it out from the game type?

Link to comment

Doesn't it do it automatically?

 

If not, you could check for files, something like

PATCH_IF FILE_EXISTS bgmain.exe BEGIN //BG series
PATCH_IF FILE_EXISTS_IN_GAME sarevo.cre BEGIN //bg1
 game = "bg1"
END
ELSE
game = "bg2"
END
PATCH_IF FILE_EXISTS torment.exe BEGIN //PST
game = "pst"
END
//whatever is for iwd...

 

Or, if IWD uses bgmain.exe or something similar, you could compare itm files and all that.

 

Icen

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...