Jump to content


Photo

Pitfalls of mod conversion


No replies to this topic

#1 DavidW

DavidW
  • Gibberlings
  • 4149 posts
  • Gender:Male

Posted 06 October 2010 - 01:52 AM

Some notes about converting an IWD mod to IWD-in-BG2 (mostly aimed at Kulyok for the moment).

Most of it is reasonably obvious. Creature files need to be redone completely, since the IWD and BG2 versions are differently structured. (I have code that does this automatically, but unless you have dozens of creatures it's probably quicker just to do it manually.

Custom spells and items may or may not be okay, depending on whether you've used IWD-specific resources, projectiles and opcodes. If not, you're fine. If so, you'll need to convert them. Again, I have code; again, it'll be easier to do it manually unless there are horrendous numbers of them. (See below if you're using IWD WAV or BAM files.)

Stores need converting, but here the conversion really is simple, and might as well be done by code (which I can provide if desired).

IWD resources are mostly still available under their IWD names. In particular, items, scripts, dialogs, creatures, areas have the same names as in IWD, so you can refer to them in the original way. Death variables are also unchanged: any death variable that picks out a particular actor in IWD will pick out the same actor in IWD-in-BG2.

A small number of IWD spells aren't available in IWD-in-BG2 at all (Wall of Moonlight, Smashing Wave, Seven Eyes, Soul Eater, Mordenkainen's Force Missiles, (Great) Shout, Spiritual Wrath, Whirlwind), so if you've used them (or magic items that use them) you'll need to change them. More importantly, any IWD spell which isn't also in BG2 is likely to have had its resource name (SPPR123 or whatever) changed. This is because I want to avoid overwriting BG2 spells that aren't in IWD, as I think quite a few people will want them available and it's easier to hide unwanted spells than reintroduce overwritten ones.

I suspect the simplest way to handle this is to write some WEIDU code to read in SPELL.IDS so that you have some array $spell_res which associates a spell resource name to each spell descriptor (so that $spell_res(~WIZARD_CATS_GRACE~) gets assigned sprwi214, say). Then add any spells you need at install time via ADD_SPELL, using $spell_res to set the filename of the spell to add. Alternatively, the converter outputs a file that tells you the new filename of each old filename, so you could just read that in and do a REPLACE_TEXTUALLY. (I can probably provide code for anyone whose WEIDU isn't up to this.)

(When the converter is stable, it would probably be simpler to just use the BGT/TUTU dual coding trick. But that relies on the new names of the spells being stable, and they won't be for a little while - basically until I manage to convert and/or permanently give up on the unconverted spells.)

(Scroll files still exist under their old names.)

Scripts and dialogs should basically be fine provided that your IWD mod doesn't use any scripting that doesn't work in BG2. Variables are also unchanged, with one crucial exception: any variable of the form SOMETHING_DEAD now has the form SPRITE_IS_DEADSOMETHING. This is basically forced by hardcoded differences between the variables that IWD and BG2 set when an actor is killed. Given that many variables of this form need renaming, it's much safer and more bug-resistant to rename all of them (not doing this led to a significant fraction of the death-variable-related bugs reported in v4).

The simplest way (I think) to handle this in your code, if you want it to work both in IWD and in BG2, is

(i) get your code to check if it's installing on IWD or IWD-in-BG2 (e.g. by detecting BGMAIN). If it's on IWD, do

OUTER_SPRINT ~SPRITE_IS_DEAD~ ~~
OUTER_SPRINT ~_DEAD~ ~_DEAD~

If it's on IWD-in-BG2, do
OUTER_SPRINT ~SPRITE_IS_DEAD~ ~SPRITE_IS_DEAD~
OUTER_SPRINT ~_DEAD~ ~~

Then, whenever you want to refer to one of these variables (say ORC_DEAD), just put it into your code as ~%SPRITE_IS_DEAD%ORC%_DEAD%~ and compile using EVALUATE_BUFFER. That will compile to the correct value, whatever version you're playing.

(Note that this only applies to things of the form XYZ_DEAD, not XYZDEAD. TALONITESDEAD, for instance, is unchanged.)



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users