Author Topic: Patching SPL files to use different VFX and SFX  (Read 73 times)

Offline Andrea C.

  • Planewalker
  • *****
  • Posts: 80
  • Gender: Male
Patching SPL files to use different VFX and SFX
« on: November 13, 2017, 12:38:02 PM »
Hello.

I would like to patch the Dimension Door spell to use the BG1 VFX and new SFX made available by chimeric on the Beamdog boards, but I'm having some trouble figuring out the code that will let me do that.

Let's start from the basics:

Code: [Select]
ACTION_FOR_EACH spell IN ~[list of file names that pertain to Dimension Door spells]~

ACTION_IF (FILE_EXISTS_IN_GAME ~%spell%.spl~) THEN BEGIN
    COPY_EXISTING ~%spell%.spl~ ~override~
       READ_SHORT 0x72 ability

All Dimension Door spells appear to only have one Spell Ability field, so I should be safe reading 0x72 directly, which is its offset. At this point, however, I'm not sure how to continue.

Let's start with SFX. The sound effect played by the spell is the second effect (EFFECT 01) in 0x72, which is found at 0xca—but how do I instruct WeiDU to read offsets inside 0x72? I will then need to patch offset 0xde (RESOURCE) inside 0xca.

From this previous thread, I seem to understand the following code does something similar:

Code: [Select]
COPY_EXISTING_REGEXP GLOB ~.*\.cre~ ~override~
  SET validslot = 0
  READ_LONG 0x2bc itemsoffset
  READ_LONG 0x2b8 itemslot
  READ_LONG 0x2c0 itemnumber
  READ_SSHORT (itemslot + 0x04) shieldslot
  PATCH_IF (shieldslot > "0") BEGIN
   READ_ASCII ((LONG_AT 0x2bc) + %shieldslot% * 0x14) itemname

I reckon the last bit that sets variable itemname is doing exactly that—reading a specific offset within another offset, but I don't have a good understanding of how it works and, therefore, of how to adapt it to different scenarios.


As for VFX, the spell appears to play an effect called Hit Door but I can't seem to find any reference to a BAM or VVC in the SPL structure. Now, obviously there's a DDOORH.VVC file that is probably what I want to target, so I suppose I could just rename the VVC and BAM I have to DDOORH and put them in the override. But what if I wanted to add this VFX to the game without overriding the existing one? Which fields of the SPL should I be patching?

Thanks in advance!

Offline CamDawg

  • Infidel
  • Planewalker
  • *****
  • Posts: 798
    • The Gibberlings Three
Re: Patching SPL files to use different VFX and SFX
« Reply #1 on: November 13, 2017, 12:52:53 PM »
This is a great place to use macros, specifically ALTER_EFFECT.

Code: [Select]
ACTION_FOR_EACH spell IN ~[list of file names that pertain to Dimension Door spells]~

  COPY_EXISTING ~%spell%.spl~ ~override~
   LPF ALTER_EFFECT INT_VAR match_opcode = 174 STR_VAR match_resource = old resource = new END
    BUT_ONLY IF_EXISTS

END

This basically says if you find any effect that uses opcode 174 and plays old sound, change it to play new sound. You can do the same with visual effects my changing match_opcode = 215.
The Gibberlings Three - Home of IE Mods

The BG2 Fixpack - All the fixes of Baldurdash, plus a few hundred more. Now available, with more fixes being added in every release.

Offline Andrea C.

  • Planewalker
  • *****
  • Posts: 80
  • Gender: Male
Re: Patching SPL files to use different VFX and SFX
« Reply #2 on: November 13, 2017, 01:18:35 PM »
So for the VFX I would change DDOORH.VVC to, say, NEWDOOR.VVC and dump NEWDOOR.VVC in the override?

That's pretty sleek!

Offline CamDawg

  • Infidel
  • Planewalker
  • *****
  • Posts: 798
    • The Gibberlings Three
Re: Patching SPL files to use different VFX and SFX
« Reply #3 on: November 13, 2017, 01:39:37 PM »
Yes, but don't use the file extensions, e.g. use DDOORH, not DDOORH.vvc, in the ALTER_EFFECT macro.
The Gibberlings Three - Home of IE Mods

The BG2 Fixpack - All the fixes of Baldurdash, plus a few hundred more. Now available, with more fixes being added in every release.

Offline Andrea C.

  • Planewalker
  • *****
  • Posts: 80
  • Gender: Male
Re: Patching SPL files to use different VFX and SFX
« Reply #4 on: November 13, 2017, 02:11:56 PM »
I tried this:

Code: [Select]
ACTION_FOR_EACH spell IN ~bddoorx.spl~ ~ohnddoor.spl~ ~spin565.spl~ ~spwi402.spl~ ~spwi926.spl~ ~spwi982.spl~ ~spwi994.spl~ ~spwi995.spl~ BEGIN

COPY_EXISTING ~%spell%.spl~ ~override~
LPF ALTER_EFFECT INT_VAR match_opcode = 174 STR_VAR match_resource = EFF_M09 resource = DMDOOR END
LPF ALTER_EFFECT INT_VAR match_opcode = 215 STR_VAR match_resource = DDOORH resource = BGDOOR END
BUT_ONLY IF_EXISTS

END

When I run this code, it installs successfully but WeiDU says it's patching 0 files—and indeed there is no change in the spell at all.

I tried swapping opcode 215 to 141, which is what the spell is using according to NI, but I'm still getting nothing. Do both conditions need to be satisfied for the patching to be successful (i.e. opcode 174 must be found as being EFF_M09 and 215 must be found as being DDOORH)? I'm pretty sure the SFX part should work otherwise.

Opcode 141 is referencing an effect called "Hit Door" as opposed to a VVC called DDOORH. I tried playing DDOORH.BAM and it seems to be a different VFX from what I expected (possibly from IWD?). Not sure which resource is the VFX for the Dimension Door spell then  ???

Perhaps I should wipe 141 clean and replace it with 215? Can this macro do that?
« Last Edit: November 13, 2017, 02:14:34 PM by Andrea C. »

Offline CamDawg

  • Infidel
  • Planewalker
  • *****
  • Posts: 798
    • The Gibberlings Three
Re: Patching SPL files to use different VFX and SFX
« Reply #5 on: November 13, 2017, 02:45:45 PM »
You've got the file extension, .spl, specified in both the file list and the C_E. Essentially, that patch is trying to patch bddoorx.spl.spl, ohnddoor.spl.spl, spin655.spl.spl, etc. and not finding any of those, of course. Drop the .spl from the C_E and make that line COPY_EXISTING ~%spell%~ ~override~
The Gibberlings Three - Home of IE Mods

The BG2 Fixpack - All the fixes of Baldurdash, plus a few hundred more. Now available, with more fixes being added in every release.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: