Author Topic: BUT_ONLY trouble for .dlgs  (Read 12923 times)

Offline Galactygon

  • Modding since 2002
  • Planewalker
  • *****
  • Posts: 378
  • Gender: Male
  • Creator of spells
Re: BUT_ONLY trouble for .dlgs
« Reply #25 on: July 28, 2010, 10:03:51 AM »
I'm in a hurry, so I'll post this. The installer fails when its reading the last entry of the first row, with the PATCH_PRINT below not happening.
Code: [Select]
FOR ( loops = 6; loops < 10; loops += 1 ) BEGIN
READ_2DA_ENTRY_FORMER ~r2en_race_immunity~ row loops read_effect_parameters
PATCH_PRINT "%read_effect_parameters%, number %how_many_effects_to_add%"
...
It happens when loops = 10, yet changing the line to
Quote
READ_2DA_ENTRY_FORMER ~r2en_race_immunity~ row 10 read_effect_parameters
Reads the line, and causes the installer to fail at a later stage, at the very end of the file.

Columns 6, 7, 8, 9, and 10 (counting 0 as a column) are supposed to give parameters of the effects I will add for the valid races covered by earlier parts of the code. All of those effects use opcode 177, but I want to specify the rest. Also, I might need more than one effect per race.ids entry - which is why I have more than one column. For example, a save-for-half damage requires at least two embedded effects, with the .spl calling on .effs with two different resources. So I'd need to call in the second effect for each race/class/whatever.

I'm storing the effect list in an array $effect_parameters(~%effect_number%~ ~%parameter_number%~). variable %effect_number% is set based on how many effects I'd like to add per race/class/whatever entry, and %parameter_number% is just an index to the parameters of each effect.

Near the end of your code, right before the line
Code: [Select]
SPRINT ids_file ~%restriction_type%~
I've added this:
Code: [Select]
SET how_many_effects_to_add = 0
    SPRINT read_effect_parameters ""
    FOR ( loops = 6; loops < 10; loops += 1 ) BEGIN
      READ_2DA_ENTRY_FORMER ~r2en_race_immunity~ row loops read_effect_parameters
      PATCH_PRINT "%read_effect_parameters%, number %how_many_effects_to_add%"
      PATCH_IF ( "%read_effect_parameters%" STRING_COMPARE_CASE "****" = 1 ) BEGIN
        // Default values, in case we didn't specify the parameters
        SPRINT resource ""
        SET resisttype = 0
        SET timing = 0
        SET duration = 0
        INNER_PATCH ~%read_effect_parameters%~ BEGIN
          REPLACE_EVALUATE ~RESOURCE=\([^_]+\)~ BEGIN
            SPRINT resource "%MATCH1%"
          END ~RESOURCE=%MATCH1%~
          REPLACE_EVALUATE ~RESISTTYPE=\([0-9]+\)~ BEGIN
            SET resisttype = MATCH1
          END ~RESISTTYPE=%MATCH1%~
          REPLACE_EVALUATE ~TIMING=\([0-9]+\)~ BEGIN
            SET timing = MATCH1
          END ~TIMING=%MATCH1%~
          REPLACE_EVALUATE ~DURATION=\([0-9]+\)~ BEGIN
            SET duration = MATCH1
          END ~DURATION=%MATCH1%~
        END
        PATCH_IF (VARIABLE_IS_SET resource && VARIABLE_IS_SET resisttype) BEGIN
          SPRINT $effect_parameters(~%how_many_effects_to_add%~ ~0~) "%resource%"
          SET $effect_parameters(~%how_many_effects_to_add%~ ~1~) = resisttype
        END
        SET how_many_effects_to_add += 1
      END
    END
    FOR ( a = 0; a < how_many_effects_to_add; a += 1 ) BEGIN
      SPRINT p0 $effect_parameters(~%how_many_effects_to_add%~ ~0~)
      SET p1 = $effect_parameters(~%how_many_effects_to_add%~ ~1~)
      PATCH_PRINT "Resource %p0%, resisttype %p1%"
    END
My RACE_IMMUNITY.2da.
Quote
AND(2)        ****      ****       ****              ****      ****      ****                    ****      ****      ****      ****
SPWI402.spl   1-50      ****       OPCODE=146_EFFECT=5       CLASSSIZE      L            RESOURCE=PROPC206_RESISTTYPE=3      ****            ****            ****            ****
SPWI402.spl   1-50      ****       OPCODE=146_EFFECT=5       CLASSFLY       Y            RESOURCE=PROPC206_RESISTTYPE=3      ****            ****            ****            ****
AND(4)        ****      ****       ****              ****      ****      ****                    ****      ****      ****      ****
SPWI504.spl   1-5       Y          OPCODE=146_EFFECT=5       RACEMAKE      I            RESOURCE=PROPC206_RESISTTYPE=3      ****            ****            ****            ****
SPWI504.spl   1-5       ****       OPCODE=146_EFFECT=5       RACEFLY       Y            RESOURCE=PROPC206_RESISTTYPE=3      ****            ****            ****            ****
SPWI812.spl   1-50      ****       EFFECT=1                  GENERAL       3          RESOURCE=PRSPLVL8_RESISTTYPE=0      RESOURCE=FOOL_RESISTTYPE=2            RESOURCE=YEAHBABY_RESISTTYPE=1            RESOURCE=NOOBER_RESISTTYPE=1            ****
SPWI812.spl   1-50      ****       EFFECT=1                  RACEMAKE      B_N_I_M      RESOURCE=PRSPLVL8_RESISTTYPE=0      RESOURCE=FOOL_RESISTTYPE=2            RESOURCE=YEAHBABY_RESISTTYPE=1            RESOURCE=NOOBER_RESISTTYPE=1            RESOURCE=NEEBER_RESISTTYPE=0

The second to the last row means I'd like to add 2 effects to extended headers 1-50 for SPWI812.spl, affecting only undead. Both effects use opcode 177 as opcode type, the first one calls in effect "PRSPLVL8", and affects creatures regardless of magic resistance/not dispellable. The second effect calls in "FOOL", and cannot be dispelled/does not bypass magic resistance.

The rest of the stuff I will do in a modified version of Gort's patch macro, ADD_SPELL_EFFECT, and macros I've written FIND_SPELL_EFFECT. I'm giving you the bigger picture.

-Galactygon

Offline Galactygon

  • Modding since 2002
  • Planewalker
  • *****
  • Posts: 378
  • Gender: Male
  • Creator of spells
Re: BUT_ONLY trouble for .dlgs
« Reply #26 on: July 28, 2010, 11:40:18 AM »
Never mind, I found the root of the problem.

This was supposed to be this
Quote
FOR ( a = 0; a < how_many_effects_to_add; a += 1 ) BEGIN
      SPRINT pa $effect_parameters(~%a%~ ~0~)
      SET pb = $effect_parameters(~%a%~ ~1~)
      PATCH_PRINT "Resource %pa%, resisttype %pb%"
    END
instead of this
Quote
FOR ( a = 0; a < how_many_effects_to_add; a += 1 ) BEGIN
      SPRINT pa $effect_parameters(~%how_many_effects_to_add%~ ~0~)
      SET pb = $effect_parameters(~%how_many_effects_to_add%~ ~1~)
      PATCH_PRINT "Resource %pa%, resisttype %pb%"
    END

-Galactygon

Offline Galactygon

  • Modding since 2002
  • Planewalker
  • *****
  • Posts: 378
  • Gender: Male
  • Creator of spells
Re: BUT_ONLY trouble for .dlgs
« Reply #27 on: July 28, 2010, 01:36:06 PM »
I finally got this baby working to spew effects into extension headers like Firkragg does to fire. It now takes me a few seconds to do sweeping changes to spells that would notmally have taken me a day (literally) with less consistency and more human error.

It still has a few missing frills I'd like to get to, but the backbone is there and working. I'll be back in a week with requests and questions.

-Galactygon

Offline Galactygon

  • Modding since 2002
  • Planewalker
  • *****
  • Posts: 378
  • Gender: Male
  • Creator of spells
Re: BUT_ONLY trouble for .dlgs
« Reply #28 on: August 11, 2010, 01:04:04 AM »
I'd like to ask some advice on sound files and multi-component installs. Right now, I have a required component that copies & de-.ogg-s the .ogg files, and deletes the .wav files at uninstall.

Getting rid of this component would mean I have to break down the list of sounds into individual components. But what makes this really hard are the overlaps - some sounds are used by more than one component, and uninstalling one component would cause issues - like the Uninstall.bat deleting the .wav file in the override when the other component is still using it.

What solutions are there to this? I have right now 183 .ogg files in the main component, and this is expected to grow. The easiest solution I thought of is a simple ACTION_IF at the beginning of all components that installs all sound files, but I don't feel good about this.

-Galactygon

Offline Mike1072

  • Planewalker
  • *****
  • Posts: 298
  • Gender: Male
Re: BUT_ONLY trouble for .dlgs
« Reply #29 on: August 11, 2010, 01:45:15 AM »
If I had to decompress files, I'd convert them via script, but let WeiDU handle copying them into the override.  That would avoid the need for an uninstall script.

Alternatively, you could just use .wavc files instead of .oggs.

Offline Galactygon

  • Modding since 2002
  • Planewalker
  • *****
  • Posts: 378
  • Gender: Male
  • Creator of spells
Re: BUT_ONLY trouble for .dlgs
« Reply #30 on: August 11, 2010, 02:06:31 AM »
.oggs are a necessity; IIRC they saved roughly 50mB worth of download size. I don't know to what degree are .wavc better than .oggs. We are talking of hundreds of audio files.

I'm interested about the script you are mentioning. Would it allow easy maintaining/updating per-component lists of sound files, with entries across components overlapping?

-Galactygon

Offline Galactygon

  • Modding since 2002
  • Planewalker
  • *****
  • Posts: 378
  • Gender: Male
  • Creator of spells
Re: BUT_ONLY trouble for .dlgs
« Reply #31 on: August 14, 2010, 04:05:18 AM »
Bump. SpellPack is close to being released, I'm still looking for a better way than placing the same ACTION_IFs in front of each component.

-Galactygon

Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1424
  • Gender: Male
  • Searcher of Bugs
Re: BUT_ONLY trouble for .dlgs
« Reply #32 on: August 14, 2010, 11:38:07 AM »
I think your best bet is to avoid the hassle and do what you are doing now - one component drops all .wav into override at install, removes all at uninstall. But there are some alternatives, too -

The simplest way would be what Mike1072 suggested. Set up scripts for each individual component that covers just those particular sounds - for the overlap, if you are careful about component install order you might even be able to avoid having weidu uninstall the ones you want.

the way to make this possible might be to simply decompress / convert all .oggs (suggest doing this in the source folder  - the bigg, Mike1072, and Miloch had good posts awhile back on how to do this) up front as a resource file filled with .wavs. Then, in each component, use WeiDU's COPY to place the necessary soundfile in override. It leaves the original .wav there, so installing components can continue to copy everything needed - the "downstream" problem is taken care of by weidu itself, isn't it, if you copy each resurce needed in each component it is used in, and let WeiDu handle the removal from override (I can see A uninstalled a.wav, and B then reinstalls a.wav as weidu rolls everything back on uninstall and then moves forward again: it might take a test, but if each component uses COPY or [god help you, and someone else needs to clean up this brainstorm to workable code]

ACTION_FOR_EACH ~%mysoundfile.wav%~  IN ~list_of_files~ BEGIN

A_I !F_E ~override/%mysoundfile.wav%~ THEN BEGIN
COPY ~mymod/%mysoundfile.wav%~ override

END

)

Alternatives might include what I did for BG1NPC MusicPack - I set up each original component as a subcomponent, so:

.tp2
Code: [Select]
BACKUP ~bg1npcmusic/backup~

AUTHOR ~http://forums.gibberlings3.net/index.php?showforum=45~

//MODDER

README ~bg1npcmusic/readme-bg1npc_music.html~

VERSION ~v5~

BEGIN ~Install All Audio~
  SUBCOMPONENT ~The BG1 NPC Project Music Pack~
  UNINSTALL ~SETUP-MBG1NPC.TP2~ ~0~

MKDIR ~music/blank~
COPY ~bg1npcmusic/blank.mus~ ~music~
     ~bg1npcmusic/blank.acm~ ~music/blank/blanka.acm~

COPY_EXISTING ~songlist.2da~ ~override~
  SET_2DA_ENTRY 0 0 2 ~2DA_V1.0~
  SET_2DA_ENTRY 0 1 2 ~~
  SET_2DA_ENTRY 0 0 2 ~IDOBEK Name~
  SET_2DA_ENTRY 1 2 3 ~BLANK.MUS~
  SET_2DA_ENTRY 0 0 3 ~~
  REPLACE_TEXTUALLY CASE_INSENSITIVE ~2DA_V1.0~ ~2DA V1.0~

COPY_EXISTING ~sw1h01.itm~ ~override/bg1npcmusic.g3~

PRINT ~PLEASE do not close this window until music decompression is complete.~

// scripts to compress/decompress sounds
ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~win32~) THEN BEGIN
  AT_NOW                   ~bg1npcmusic/batchfiles/allaudio_win.bat~
  AT_INTERACTIVE_UNINSTALL ~bg1npcmusic/batchfiles/allaudio_win.bat~
END ELSE BEGIN
  ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~osx~) THEN BEGIN
    AT_NOW                   ~sh bg1npcmusic/batchfiles/allaudio_osx.sh~
    AT_INTERACTIVE_UNINSTALL ~sh bg1npcmusic/batchfiles/uninstall_allaudio_osx.sh~
  END ELSE BEGIN
    AT_NOW                   ~bash bg1npcmusic/batchfiles/allaudio_lin.sh~
    AT_INTERACTIVE_UNINSTALL ~bash bg1npcmusic/batchfiles/uninstall_allaudio_lin.sh~
  END
END

BEGIN ~Install Regular Audio Only~
  SUBCOMPONENT ~The BG1 NPC Project Music Pack~
  UNINSTALL ~SETUP-MBG1NPC.TP2~ ~0~

MKDIR ~music/blank~
COPY ~bg1npcmusic/blank.mus~ ~music~
     ~bg1npcmusic/blank.acm~ ~music/blank/blanka.acm~

COPY_EXISTING ~songlist.2da~ ~override~
  SET_2DA_ENTRY 0 0 2 ~2DA_V1.0~
  SET_2DA_ENTRY 0 1 2 ~~
  SET_2DA_ENTRY 0 0 2 ~IDOBEK Name~
  SET_2DA_ENTRY 1 2 3 ~BLANK.MUS~
  SET_2DA_ENTRY 0 0 3 ~~
  REPLACE_TEXTUALLY CASE_INSENSITIVE ~2DA_V1.0~ ~2DA V1.0~

COPY_EXISTING ~sw1h01.itm~ ~override/bg1npcmusic.g3~

PRINT ~PLEASE do not close this window until music decompression is complete.~

// scripts to compress/decompress sounds
ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~win32~) THEN BEGIN
  AT_NOW                   ~bg1npcmusic/batchfiles/regularaudio_win.bat~
  AT_INTERACTIVE_UNINSTALL ~bg1npcmusic/batchfiles/regularaudio_win.bat~
END ELSE BEGIN
  ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~osx~) THEN BEGIN
    AT_NOW                   ~sh bg1npcmusic/batchfiles/regularaudio_osx.sh~
    AT_INTERACTIVE_UNINSTALL ~sh bg1npcmusic/batchfiles/uninstall_regularaudio_osx.sh~
  END ELSE BEGIN
    AT_NOW                   ~bash bg1npcmusic/batchfiles/regularaudio_lin.sh~
    AT_INTERACTIVE_UNINSTALL ~bash bg1npcmusic/batchfiles/uninstall_regularaudio_lin.sh~
  END
END

BEGIN ~Install Romance Audio Only~
  SUBCOMPONENT ~The BG1 NPC Project Music Pack~
  UNINSTALL ~SETUP-MBG1NPC.TP2~ ~0~

MKDIR ~music/blank~
COPY ~bg1npcmusic/blank.mus~ ~music~
     ~bg1npcmusic/blank.acm~ ~music/blank/blanka.acm~
and had a batch file with just the list of files.

Another way would be to preserve current components, and use something that works like Fixpack's READLN to set up the lists, but that seems like just as much work (and user error might creep in). The idea here is creating a flag file or check for each component, and at the end of install read those flags like Fixpack reads the "romance tweaks". Just like PIDs have to go last, you can set up a final component that runs at the end of each install/uninstall (using DESIGNATED with INSTALL_BY_DEFAULT or some such combo), but you could also set up something with a straight

MOD_IS_INSTALLED modTp2Name modComponent

looking for what components are already installed (it should work, just like REQUIRE_COMPONENT
...

hey. Why not just use a set of components at the end of the install, like this:

BEGIN ~Audio for Component 1~
DESIGNATED ~2000~
REQUIRE_COMPONENT "setup-spellpack.tp2" "1" "Skipping audio for component one, as it is not installed"

stuff

BEGIN ~Audio for Component 2~
DESIGNATED ~2001~
REQUIRE_COMPONENT "setup-spellpack.tp2" "2" "Skipping audio for component two, as it is not installed"
stuff


OK, my head hurts. But that was fun. Now, what was the problem with shortcutting this with a simple ALWAYS that does a check for a designated .wav and if it doesn't see it does a full  blanket install of the audio? BWP folks are going to biff anyways, and non-BWP could be warned that they may need the bigg's generalized biffing Mod if you want to suggest that in the readme.


The last means one list, all audio files, no problems with maintaining a list.
« Last Edit: August 14, 2010, 11:41:19 AM by cmorgan »

Offline Mike1072

  • Planewalker
  • *****
  • Posts: 298
  • Gender: Male
Re: BUT_ONLY trouble for .dlgs
« Reply #33 on: August 14, 2010, 05:56:12 PM »
Bump. SpellPack is close to being released, I'm still looking for a better way than placing the same ACTION_IFs in front of each component.

-Galactygon
Sorry, somehow I missed your reply completely.

I came up with this as the easiest way I can think of to bulk convert and install all .ogg files in a folder.  Here's what the Windows script would look like:
Code: (convert.bat) [Select]
@echo off
cd your_mod\audio
oggdec.exe *.ogg
This is the standard "convert ogg to wav" install script, minus the part that moves them into the override.

In your mod:
Code: (.tp2) [Select]
AT_NOW ~your_mod/audio/convert.bat~ // insert OS checks here to run the correct script

ACTION_BASH_FOR ~your_mod/audio~ ~^.+\.wav$~ BEGIN
  COPY ~%BASH_FOR_FILESPEC%~ ~override~
END

Since you only want to copy over specific sounds in each component and some are duplicated, you'd need something a little different to prevent WeiDU from filling your mod's backup folders with lots of unnecessary .wavs.
Code: (convert.bat) [Select]
@echo off
cd your_mod\audio
The oggdec.exe lines have been removed, as we will add them later.

Code: (.tp2) [Select]
ACTION_CLEAR_ARRAY  ~sounds~
ACTION_DEFINE_ARRAY ~sounds~ BEGIN // these are your sound files, they should be the only thing you need to modify when copy/pasting this code (other than the file paths)
  ~misnd03~
  ~misnd04~
  ~misnd07~
END

// you could probably move all the generic stuff below into a separate file and include it after specifying your sounds

COPY ~your_mod/audio/convert.bat~ ~your_mod/audio/component%COMPONENT_NUMBER%.bat~ // create script specifically for this component

ACTION_PHP_EACH ~sounds~ AS ~index~ => ~sound~ BEGIN
  ACTION_IF (NOT FILE_EXISTS ~your_mod/audio/%sound%.wav~) BEGIN
    // insert OS checks here to append to different scripts
    APPEND_OUTER ~your_mod/audio/component%COMPONENT_NUMBER%.bat~ ~oggdec.exe "%sound%.ogg"~ // add line to script to convert this .ogg if it hasn't already been converted
  END
END

AT_NOW ~"your_mod\audio\component%COMPONENT_NUMBER%.bat"~ // run the script and convert the .oggs

ACTION_PHP_EACH ~sounds~ AS ~index~ => ~sound~ BEGIN
  ACTION_IF (NOT FILE_EXISTS_IN_GAME ~%sound%.wav~) BEGIN
    COPY ~your_mod/audio/%sound%.wav~ ~override~ // copy the resulting .wav files into the game if they're not there already
  END
END
« Last Edit: August 14, 2010, 06:57:12 PM by Mike1072 »

Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1424
  • Gender: Male
  • Searcher of Bugs
Re: BUT_ONLY trouble for .dlgs
« Reply #34 on: August 15, 2010, 08:31:31 AM »
Nice !

Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1424
  • Gender: Male
  • Searcher of Bugs
Re: BUT_ONLY trouble for .dlgs
« Reply #35 on: August 15, 2010, 12:49:05 PM »
With added OS checks, it seems a bit tougher - how close am I, please? (sorry for the semi-hijack, as I am not sure you are supporting anything other than Windows, Galactygon, but I am interested in seeing how close to a "universal" solution I can. And of course the easiest is just to use wavc, but most mods don't).

contents of aranw/audio/convert_win.bat
Code: [Select]
@echo Decompressing Audio Files


contents of aranw/audio/convert_lin.sh
Code: [Select]
#!/bin/sh


contents of aranw/audio/convert_osx.sh
Code: [Select]
#!/bin/sh

ogg_files="


in setup-aranw.tp2
Code: [Select]

BEGIN ~My Component Number One~

/* set up what sounds need to be installed for this component to be covered */
ACTION_CLEAR_ARRAY  ~sounds~
ACTION_DEFINE_ARRAY ~sounds~ BEGIN
  ~c-aran01~ // SELECT_COMMON1
  ~c-aranft~ // friendtalk
  ~c-aranlt~ // lovetalk
  ~c-aranat~ // angry
END

/* set up the decompression shell script for the OS being used */
ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~win32~) THEN BEGIN
  COPY ~aranw/audio/convert_win.bat~ ~aranw/audio/component%COMPONENT_NUMBER%.bat~
END ELSE BEGIN
  ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~osx~) THEN BEGIN
    COPY ~aranw/audio/convert_osx.sh~ ~aranw/audio/component%COMPONENT_NUMBER%.sh~
  END ELSE BEGIN
    COPY ~aranw/audio/convert_lin.sh~ ~aranw/audio/component%COMPONENT_NUMBER%.sh~
  END
END

/* check for a sound and see if it already has been decompressed. If not, add it to the list. */
ACTION_PHP_EACH ~sounds~ AS ~index~ => ~sound~ BEGIN
  ACTION_IF (NOT FILE_EXISTS ~aranw/audio/%sound%.wav~) BEGIN
  PRINT ~Adding %sound%.wav~
    ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~win32~) THEN BEGIN
        APPEND_OUTER ~aranw/audio/component%COMPONENT_NUMBER%.bat~ ~oggdec "%sound%.ogg"~
    END ELSE BEGIN
    ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~osx~) THEN BEGIN
        APPEND_OUTER ~aranw/audio/component%COMPONENT_NUMBER%.sh~ ~"%sound%.ogg"~
    END ELSE BEGIN
        APPEND_OUTER ~aranw/audio/component%COMPONENT_NUMBER%.sh~ ~oggdec "%sound%.ogg"~
    END
  END
END

/* When all that has been done, add the rest of the commands to the OSX shell script if it is being used */
ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~osx~) THEN BEGIN
    APPEND_OUTER ~aranw/audio/component%COMPONENT_NUMBER%.sh~
~
"
for file in $ogg_files; do
  echo Converting $file
  bg1npcmusic/ogg/sox bg1npcmusic/ogg/$file override/${file%.ogg}.wav
done
~
END

/* run the resulting .ogg conversion files */
ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~win32~) THEN BEGIN
  AT_NOW ~"aranw\audio\component%COMPONENT_NUMBER%.bat"~
END ELSE BEGIN
  ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~osx~) THEN BEGIN
    AT_NOW ~"sh aranw\audio\component%COMPONENT_NUMBER%.sh"~
  END ELSE BEGIN
    AT_NOW ~"bash aranw\audio\component%COMPONENT_NUMBER%.sh"~
  END
END

/* look for the resulting .wav files and copy them into the game - could also save space with MOVE */
ACTION_PHP_EACH ~sounds~ AS ~index~ => ~sound~ BEGIN
  ACTION_IF (NOT FILE_EXISTS_IN_GAME ~%sound%.wav~) BEGIN
    COPY ~aranw/audio/%sound%.wav~ ~override~
  END
END

Or is there a much easier way to create a simple inner patch that creates the required .bat/.sh/.sh using inlined files?

Offline Mike1072

  • Planewalker
  • *****
  • Posts: 298
  • Gender: Male
Re: BUT_ONLY trouble for .dlgs
« Reply #36 on: August 15, 2010, 02:41:46 PM »
With added OS checks, it seems a bit tougher - how close am I, please? (sorry for the semi-hijack, as I am not sure you are supporting anything other than Windows, Galactygon, but I am interested in seeing how close to a "universal" solution I can. And of course the easiest is just to use wavc, but most mods don't).
I only posted Windows info because I can't test the others.  I can post what I think would work, but it should really be tested.

For normal mods that just need to install audio in one go:

Code: (convert_win.bat) [Select]
cd aranw\audio
oggdec.exe *.ogg

Code: (convert_osx.sh) [Select]
#!/bin/sh

ogg_files=`cd aranw/audio/; ls *.ogg;`

for file in $ogg_files; do
  echo Converting $file
  aranw/audio/sox  aranw/audio/$file aranw/audio/${file%.ogg}.wav
done

Code: (convert_lin.sh) [Select]
#!/bin/sh
oggdec aranw/audio/*.ogg

Code: (.tp2) [Select]
ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~win32~) THEN BEGIN
  AT_NOW ~aranw\audio\convert_win.bat~
END
ELSE ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~osx~) THEN BEGIN
  AT_NOW ~sh aranw/audio/convert_osx.sh~
END
ELSE BEGIN
  AT_NOW ~bash aranw/audio/convert_lin.sh~
END

ACTION_BASH_FOR ~your_mod/audio~ ~^.+\.wav$~ BEGIN
  MOVE ~%BASH_FOR_FILESPEC%~ ~override~
END

Changing the COPY commands to MOVEs was a good idea, and it seems to function correctly.


For Galactygon:

Code: (convert_win.bat) [Select]
@echo Decompressing Audio Files
cd your_mod\audio

Code: (convert_lin.sh) [Select]
#!/bin/sh

Code: (convert_osx.sh) [Select]
#!/bin/sh

Code: (.tp2) [Select]
BEGIN ~My Component Number One~

/* set up what sounds need to be installed for this component to be covered */
ACTION_CLEAR_ARRAY  ~sounds~
ACTION_DEFINE_ARRAY ~sounds~ BEGIN
  ~misnd03~
  ~misnd04~
  ~misnd07~
END

/* set up the decompression shell scripts */
COPY ~your_mod/audio/convert_win.bat~ ~your_mod/audio/win%COMPONENT_NUMBER%.bat~
COPY ~your_mod/audio/convert_osx.sh~ ~your_mod/audio/osx%COMPONENT_NUMBER%.sh~
COPY ~your_mod/audio/convert_lin.sh~ ~your_mod/audio/lin%COMPONENT_NUMBER%.sh~

/* check for a sound and see if it already has been decompressed. If not, add it to the list. */
ACTION_PHP_EACH ~sounds~ AS ~index~ => ~sound~ BEGIN
  ACTION_IF (NOT FILE_EXISTS ~your_mod/audio/%sound%.wav~) BEGIN
    APPEND_OUTER ~your_mod/audio/win%COMPONENT_NUMBER%.bat~ ~oggdec "%sound%.ogg"~
    APPEND_OUTER ~your_mod/audio/osx%COMPONENT_NUMBER%.sh~ ~your_mod/audio/sox "your_mod/audio/%sound%.ogg" "your_mod/audio/%sound%.wav"~
    APPEND_OUTER ~your_mod/audio/lin%COMPONENT_NUMBER%.sh~ ~oggdec "your_mod/audio/%sound%.ogg"~
  END
END

/* run the resulting .ogg conversion files */
ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~win32~) THEN BEGIN
  AT_NOW ~"your_mod\audio\win%COMPONENT_NUMBER%.bat"~
END
ELSE ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~osx~) THEN BEGIN
  AT_NOW ~"sh your_mod/audio/osx%COMPONENT_NUMBER%.sh"~
END
ELSE BEGIN
  AT_NOW ~"bash your_mod/audio/lin%COMPONENT_NUMBER%.sh"~
END

/* look for the resulting .wav files and copy them into the game */
ACTION_PHP_EACH ~sounds~ AS ~index~ => ~sound~ BEGIN
  ACTION_IF (NOT FILE_EXISTS_IN_GAME ~%sound%.wav~) BEGIN
    COPY ~your_mod/audio/%sound%.wav~ ~override~
  END
END
If you use MOVE, you'll save disk space, but COPY will save installation time since it won't have to convert the same files multiple times.
« Last Edit: August 15, 2010, 07:25:47 PM by Mike1072 »

Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1424
  • Gender: Male
  • Searcher of Bugs
Re: BUT_ONLY trouble for .dlgs
« Reply #37 on: August 15, 2010, 02:48:19 PM »
I see - just create all three OS-related scripts... cool!

Offline Galactygon

  • Modding since 2002
  • Planewalker
  • *****
  • Posts: 378
  • Gender: Male
  • Creator of spells
Re: BUT_ONLY trouble for .dlgs
« Reply #38 on: August 17, 2010, 02:49:21 PM »
Got around trying this; I'm impressed and the code isn't that long either.

I have a few questions:
Code: [Select]
  ACTION_IF (NOT FILE_EXISTS_IN_GAME ~%sound%.wav~) BEGIN
    COPY ~LCTests/Audio/%sound%.wav~ ~override~
  END
This part is supposed to prevent duplicates from being copied for overlapping components. But I might feel like I want to override a sound file left by an earlier mod (such as mine). Woudln't it be sensible to do a FILE_CONTAINS_EVALUATED (~your_mod/audio/win%COMPONENT_NUMBER%.bat~ ~%sound%.ogg~) instead for each sound file?

Another thing I noticed, at uninstalls the .wav files are not deleted. From an end-user's POV, wouldn't it be a waste of space? Especially for mods with hundreds of .wavs, which can take a few hundred megs.

-Galactygon

Offline Mike1072

  • Planewalker
  • *****
  • Posts: 298
  • Gender: Male
Re: BUT_ONLY trouble for .dlgs
« Reply #39 on: August 17, 2010, 06:44:20 PM »
I have a few questions:
Code: [Select]
  ACTION_IF (NOT FILE_EXISTS_IN_GAME ~%sound%.wav~) BEGIN
    COPY ~LCTests/Audio/%sound%.wav~ ~override~
  END
This part is supposed to prevent duplicates from being copied for overlapping components. But I might feel like I want to override a sound file left by an earlier mod (such as mine). Woudln't it be sensible to do a FILE_CONTAINS_EVALUATED (~your_mod/audio/win%COMPONENT_NUMBER%.bat~ ~%sound%.ogg~) instead for each sound file?
I might leave this the way it is, then add in extra lines after this is run to cover the sounds that you want to ensure get copied over.

Quote
Another thing I noticed, at uninstalls the .wav files are not deleted. From an end-user's POV, wouldn't it be a waste of space? Especially for mods with hundreds of .wavs, which can take a few hundred megs.
You can use MOVE instead of COPY, but that will clean up the .wavs after each component, so you won't be able to save time if later components use the same .oggs - they'll have to be converted again.  It's up to you which trade-off is more important for your mod.
« Last Edit: August 17, 2010, 07:02:49 PM by Mike1072 »

Offline Galactygon

  • Modding since 2002
  • Planewalker
  • *****
  • Posts: 378
  • Gender: Male
  • Creator of spells
Re: BUT_ONLY trouble for .dlgs
« Reply #40 on: August 18, 2010, 12:03:24 AM »
I have this (untested) idea to have a 0 kb .wav that gets copied for each sound before being overridden by the real sound at decompression, so this way WeiDU can handle the uninstalls.
Code: [Select]
ACTION_PHP_EACH ~sounds~ AS ~index~ => ~sound~ BEGIN
  ACTION_IF (NOT FILE_EXISTS ~SpellPackB5/Audio/%sound%.wav~) BEGIN
    COPY ~SpellPackB5/Audio/null.wav~ ~SpellPackB5/Audio/%sound%.wav~
    APPEND_OUTER ~SpellPackB5/Audio/win%COMPONENT_NUMBER%.bat~ ~oggdec %sound%.ogg~
    APPEND_OUTER ~SpellPackB5/Audio/osx%COMPONENT_NUMBER%.sh~ ~SpellPackB5/Audio/sox SpellPackB5/Audio/%sound%.ogg SpellPackB5/Audio/%sound%.wav~
    APPEND_OUTER ~SpellPackB5/Audio/lin%COMPONENT_NUMBER%.sh~ ~oggdec SpellPackB5/Audio/%sound%.ogg~
  END
END

-Galactygon

Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1424
  • Gender: Male
  • Searcher of Bugs
Re: BUT_ONLY trouble for .dlgs
« Reply #41 on: August 18, 2010, 07:50:37 AM »
If you use MOVE, the files are not a problem, and if you want to clean up you could also just run a shell script on exit that deleted *.wav in the audio subdirectory... I am not understanding the implementation of the blank sound file above.



Offline Galactygon

  • Modding since 2002
  • Planewalker
  • *****
  • Posts: 378
  • Gender: Male
  • Creator of spells
Re: BUT_ONLY trouble for .dlgs
« Reply #42 on: August 18, 2010, 08:05:20 AM »
When the .ogg files are decoded in .wavs, they are done by another program, so WeiDU does not know about them. That means at uninstall, the .wav files will be left in the Audio folder.

I'm thinking of using WeiDU to copy dummy .wav files before being overriden by the .bat file so that WeiDU will delete them at uninstall.

-Galactygon

Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1424
  • Gender: Male
  • Searcher of Bugs
Re: BUT_ONLY trouble for .dlgs
« Reply #43 on: August 18, 2010, 11:59:39 AM »
But after they are decoded in a shell program, Mike1072's code uses the WeiDU

Code: [Select]
/* look for the resulting .wav files and copy them into the game */
ACTION_PHP_EACH ~sounds~ AS ~index~ => ~sound~ BEGIN
  ACTION_IF (NOT FILE_EXISTS_IN_GAME ~%sound%.wav~) BEGIN
    COPY ~your_mod/audio/%sound%.wav~ ~override~
  END
END

copying them into override, so they should remove when uninstalled - either COPY or MOVE leverages weidu for the uninstall. Hold on - let me go test...

Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1424
  • Gender: Male
  • Searcher of Bugs
Re: BUT_ONLY trouble for .dlgs
« Reply #44 on: August 18, 2010, 01:05:01 PM »
yep. Just tested. With either MOVE or COPY, the override is populated/cleared via WeiDU on uninstall. As Mike1072 indicated above, the MOVE command does not leave a .wav file in the ./audio subdirectory, moving it into override, and then moving it back. COPY just left the originals.


So there is no problem with .wavs in override. The only thing that is bloating is the .wav's in the audio subdirectory, if someone installs and then uninstalls the mod. I think the residual .wav's cleanup would have to be a shell script run AT_INTERACTIVE_EXIT or some such, with cleanup.ext shell scripts of

(Someone needs to help with grep on linux and OSX - basically, all that has to be done is delete all .wav files from the audio subdirectory)

windows .bat
Code: [Select]
cd bg1npcmusic\ogg

del *.wav

osx NOT CORRECT ON GREP .sh
Code: [Select]
#!/bin/sh

rm subdirectory/*.wav

lin NOT CORRECT ON GREP .sh
Code: [Select]
#!/bin/sh

rm -f subdirectory/*.wav

I don't think you even have to change your target, as this

/* look for the resulting .wav files and copy them into the game */
ACTION_PHP_EACH ~sounds~ AS ~index~ => ~sound~ BEGIN
  ACTION_IF (NOT FILE_EXISTS_IN_GAME ~%sound%.wav~) BEGIN

checks to see if it is present in the game, so installing component 0, 3, and 7 will work, and uninstalling 3 from the mix will still work, as far as I can see...

The working code (as tested) follows:

Code: [Select]
VERSION ~vINTERNAL_1~

BEGIN ~Install All Audio~
  SUBCOMPONENT ~The BG1 NPC Project Music Pack~
  UNINSTALL ~SETUP-MBG1NPC.TP2~ ~0~    /* removes the oldest version if present; like DEPRECIATED */

MKDIR ~music/blank~
COPY ~bg1npcmusic/blank.mus~ ~music~
     ~bg1npcmusic/blank.acm~ ~music/blank/blanka.acm~

COPY_EXISTING ~songlist.2da~ ~override~
  SET_2DA_ENTRY 0 0 2 ~2DA_V1.0~
  SET_2DA_ENTRY 0 1 2 ~~
  SET_2DA_ENTRY 0 0 2 ~IDOBEK Name~
  SET_2DA_ENTRY 1 2 3 ~BLANK.MUS~
  SET_2DA_ENTRY 0 0 3 ~~
  REPLACE_TEXTUALLY CASE_INSENSITIVE ~2DA_V1.0~ ~2DA V1.0~

COPY_EXISTING ~sw1h01.itm~ ~override/bg1npcmusic.g3~

/* set up what sounds need to be installed for this component to be covered */
ACTION_CLEAR_ARRAY  ~sounds~
ACTION_DEFINE_ARRAY ~sounds~ BEGIN
~ajrom~
~xanro1~
~xarom~
~brar1~
~brar2~
~brrom~
~coranb~
~coranf~
~corang~
~corann~
~dyrom1~
~dyrom2~
~shrar~
~ajant99~
~alora99~
~branw99~
~coran99~
~dynah99~
~edwin99~
~eldot99~
~faldo99~
~garri99~
~imoen99~
~jahei99~
~kagain99~
~khali99~
~kivan99~
~minsc99~
~monta99~
~quayl99~
~safana99~
~shart99~
~skie99~
~tiax99~
~vicon99~
~xannn99~
~xzar99~
~yesli99~
END

/* set up the decompression shell scripts */
COPY ~bg1npcmusic/batchfiles/convert_win.bat~ ~bg1npcmusic/ogg/win%COMPONENT_NUMBER%.bat~
COPY ~bg1npcmusic/batchfiles/convert_osx.sh~ ~bg1npcmusic/ogg/osx%COMPONENT_NUMBER%.sh~
COPY ~bg1npcmusic/batchfiles/convert_lin.sh~ ~bg1npcmusic/ogg/lin%COMPONENT_NUMBER%.sh~

/* check for a sound and see if it already has been decompressed. If not, add it to the list. */
ACTION_PHP_EACH ~sounds~ AS ~index~ => ~sound~ BEGIN
  ACTION_IF (NOT FILE_EXISTS ~bg1npcmusic/ogg/%sound%.wav~) BEGIN
    APPEND_OUTER ~bg1npcmusic/ogg/win%COMPONENT_NUMBER%.bat~ ~oggdec "%sound%.ogg"~
    APPEND_OUTER ~bg1npcmusic/ogg/osx%COMPONENT_NUMBER%.sh~ ~bg1npcmusic/ogg/sox "bg1npcmusic/ogg/%sound%.ogg" "bg1npcmusic/ogg/%sound%.wav"~
    APPEND_OUTER ~bg1npcmusic/ogg/lin%COMPONENT_NUMBER%.sh~ ~oggdec "bg1npcmusic/ogg/%sound%.ogg"~
  END
END

/* run the resulting .ogg conversion files */
ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~win32~) THEN BEGIN
  AT_NOW ~"bg1npcmusic/ogg/win%COMPONENT_NUMBER%.bat"~
END ELSE ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~osx~) THEN BEGIN
    AT_NOW ~"sh bg1npcmusic/ogg/osx%COMPONENT_NUMBER%.sh"~
END ELSE BEGIN
      AT_NOW ~"bash bg1npcmusic/ogg/lin%COMPONENT_NUMBER%.sh"~
END

/* look for the resulting .wav files and copy them into the game */
ACTION_PHP_EACH ~sounds~ AS ~index~ => ~sound~ BEGIN
  ACTION_IF (NOT FILE_EXISTS_IN_GAME ~%sound%.wav~) BEGIN
    MOVE ~bg1npcmusic/ogg/%sound%.wav~ ~override~
  END
END


BEGIN ~Install Regular Audio Only~
  SUBCOMPONENT ~The BG1 NPC Project Music Pack~
  UNINSTALL ~SETUP-MBG1NPC.TP2~ ~0~

MKDIR ~music/blank~
COPY ~bg1npcmusic/blank.mus~ ~music~
     ~bg1npcmusic/blank.acm~ ~music/blank/blanka.acm~

COPY_EXISTING ~songlist.2da~ ~override~
  SET_2DA_ENTRY 0 0 2 ~2DA_V1.0~
  SET_2DA_ENTRY 0 1 2 ~~
  SET_2DA_ENTRY 0 0 2 ~IDOBEK Name~
  SET_2DA_ENTRY 1 2 3 ~BLANK.MUS~
  SET_2DA_ENTRY 0 0 3 ~~
  REPLACE_TEXTUALLY CASE_INSENSITIVE ~2DA_V1.0~ ~2DA V1.0~

COPY_EXISTING ~sw1h01.itm~ ~override/bg1npcmusic.g3~

/* set up what sounds need to be installed for this component to be covered */
ACTION_CLEAR_ARRAY  ~sounds~
ACTION_DEFINE_ARRAY ~sounds~ BEGIN
~ajant99~
~alora99~
~branw99~
~coran99~
~dynah99~
~edwin99~
~eldot99~
~faldo99~
~garri99~
~imoen99~
~jahei99~
~kagain99~
~khali99~
~kivan99~
~minsc99~
~monta99~
~quayl99~
~safana99~
~shart99~
~skie99~
~tiax99~
~vicon99~
~xannn99~
~xzar99~
~yesli99~
END

/* set up the decompression shell scripts */
COPY ~bg1npcmusic/batchfiles/convert_win.bat~ ~bg1npcmusic/ogg/win%COMPONENT_NUMBER%.bat~
COPY ~bg1npcmusic/batchfiles/convert_osx.sh~ ~bg1npcmusic/ogg/osx%COMPONENT_NUMBER%.sh~
COPY ~bg1npcmusic/batchfiles/convert_lin.sh~ ~bg1npcmusic/ogg/lin%COMPONENT_NUMBER%.sh~

/* check for a sound and see if it already has been decompressed. If not, add it to the list. */
ACTION_PHP_EACH ~sounds~ AS ~index~ => ~sound~ BEGIN
  ACTION_IF (NOT FILE_EXISTS ~bg1npcmusic/ogg/%sound%.wav~) BEGIN
    APPEND_OUTER ~bg1npcmusic/ogg/win%COMPONENT_NUMBER%.bat~ ~oggdec "%sound%.ogg"~
    APPEND_OUTER ~bg1npcmusic/ogg/osx%COMPONENT_NUMBER%.sh~ ~bg1npcmusic/ogg/sox "bg1npcmusic/ogg/%sound%.ogg" "bg1npcmusic/ogg/%sound%.wav"~
    APPEND_OUTER ~bg1npcmusic/ogg/lin%COMPONENT_NUMBER%.sh~ ~oggdec "bg1npcmusic/ogg/%sound%.ogg"~
  END
END

/* run the resulting .ogg conversion files */
ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~win32~) THEN BEGIN
  AT_NOW ~"bg1npcmusic/ogg/win%COMPONENT_NUMBER%.bat"~
END ELSE ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~osx~) THEN BEGIN
    AT_NOW ~"sh bg1npcmusic/ogg/osx%COMPONENT_NUMBER%.sh"~
    END ELSE BEGIN
      AT_NOW ~"bash bg1npcmusic/ogg/lin%COMPONENT_NUMBER%.sh"~
END

/* look for the resulting .wav files and copy them into the game */
ACTION_PHP_EACH ~sounds~ AS ~index~ => ~sound~ BEGIN
  ACTION_IF (NOT FILE_EXISTS_IN_GAME ~%sound%.wav~) BEGIN
    MOVE ~bg1npcmusic/ogg/%sound%.wav~ ~override~
  END
END

BEGIN ~Install Romance Audio Only~
  SUBCOMPONENT ~The BG1 NPC Project Music Pack~
  UNINSTALL ~SETUP-MBG1NPC.TP2~ ~0~

MKDIR ~music/blank~
COPY ~bg1npcmusic/blank.mus~ ~music~
     ~bg1npcmusic/blank.acm~ ~music/blank/blanka.acm~

COPY_EXISTING ~songlist.2da~ ~override~
  SET_2DA_ENTRY 0 0 2 ~2DA_V1.0~
  SET_2DA_ENTRY 0 1 2 ~~
  SET_2DA_ENTRY 0 0 2 ~IDOBEK Name~
  SET_2DA_ENTRY 1 2 3 ~BLANK.MUS~
  SET_2DA_ENTRY 0 0 3 ~~
  REPLACE_TEXTUALLY CASE_INSENSITIVE ~2DA_V1.0~ ~2DA V1.0~

COPY_EXISTING ~sw1h01.itm~ ~override/bg1npcmusic.g3~

/* set up what sounds need to be installed for this component to be covered */
ACTION_CLEAR_ARRAY  ~sounds~
ACTION_DEFINE_ARRAY ~sounds~ BEGIN
~ajrom~
~xanro1~
~xarom~
~brar1~
~brar2~
~brrom~
~coranb~
~coranf~
~corang~
~corann~
~dyrom1~
~dyrom2~
~shrar~
END

/* set up the decompression shell scripts */
COPY ~bg1npcmusic/batchfiles/convert_win.bat~ ~bg1npcmusic/ogg/win%COMPONENT_NUMBER%.bat~
COPY ~bg1npcmusic/batchfiles/convert_osx.sh~ ~bg1npcmusic/ogg/osx%COMPONENT_NUMBER%.sh~
COPY ~bg1npcmusic/batchfiles/convert_lin.sh~ ~bg1npcmusic/ogg/lin%COMPONENT_NUMBER%.sh~

/* check for a sound and see if it already has been decompressed. If not, add it to the list. */
ACTION_PHP_EACH ~sounds~ AS ~index~ => ~sound~ BEGIN
  ACTION_IF (NOT FILE_EXISTS ~bg1npcmusic/ogg/%sound%.wav~) BEGIN
    APPEND_OUTER ~bg1npcmusic/ogg/win%COMPONENT_NUMBER%.bat~ ~oggdec "%sound%.ogg"~
    APPEND_OUTER ~bg1npcmusic/ogg/osx%COMPONENT_NUMBER%.sh~ ~bg1npcmusic/ogg/sox "bg1npcmusic/ogg/%sound%.ogg" "bg1npcmusic/ogg/%sound%.wav"~
    APPEND_OUTER ~bg1npcmusic/ogg/lin%COMPONENT_NUMBER%.sh~ ~oggdec "bg1npcmusic/ogg/%sound%.ogg"~
  END
END

/* run the resulting .ogg conversion files */
ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~win32~) THEN BEGIN
  AT_NOW ~"bg1npcmusic/ogg/win%COMPONENT_NUMBER%.bat"~
END ELSE ACTION_IF (~%WEIDU_OS%~ STRING_EQUAL_CASE ~osx~) THEN BEGIN
    AT_NOW ~"sh bg1npcmusic/ogg/osx%COMPONENT_NUMBER%.sh"~
    END ELSE BEGIN
      AT_NOW ~"bash bg1npcmusic/ogg/lin%COMPONENT_NUMBER%.sh"~
END


/* look for the resulting .wav files and copy them into the game */
ACTION_PHP_EACH ~sounds~ AS ~index~ => ~sound~ BEGIN
  ACTION_IF (NOT FILE_EXISTS_IN_GAME ~%sound%.wav~) BEGIN
    MOVE ~bg1npcmusic/ogg/%sound%.wav~ ~override~
  END
END



So basically, a universal "audio install on the fly by .tp2 list" is as close as it has ever been!




« Last Edit: August 18, 2010, 01:06:48 PM by cmorgan »

Offline Galactygon

  • Modding since 2002
  • Planewalker
  • *****
  • Posts: 378
  • Gender: Male
  • Creator of spells
Re: BUT_ONLY trouble for .dlgs
« Reply #45 on: August 18, 2010, 03:31:06 PM »
Switching to a different topic a bit, I'm having serious trouble with a laughable code. Nothing is printed.

Code: [Select]
COPY_EXISTING ~SPPR302.spl~ ~override~
        SPRINT gh "CLERIC_CHANT"
        PATCH_IF (FILE_CONTAINS_EVALUATED (~LCLIST_SPELLS.2da~ ~%gh%~)) BEGIN
                PATCH_PRINT "Chanting..."
        END
        PATCH_IF (FILE_CONTAINS_EVALUATED (~LCLIST_SPELLS.2da~ ~CLERIC_CHANT~)) BEGIN
                PATCH_PRINT "Chanting..."
        END
        PATCH_IF (FILE_CONTAINS ~LCLIST_SPELLS.2da~ ~CLERIC_CHANT~) BEGIN
                PATCH_PRINT "Chanting..."
        END
        BUT_ONLY
Contents of LCLIST_SPELLS.2da, which is appended at each component:
Code: [Select]
2DA V1.0
****
1105  CLERIC_ENTANGLE       SPPR105.spl  PLANT  ****
1106  CLERIC_MAGICAL_STONE  SPPR106.spl  PLANT  ****
1109  CLERIC_SANCTUARY      SPPR109.spl  PLANT  ****
1146  CLERIC_SUNSCORCH      SPPR146.spl  PLANT  ****
1116  CLERIC_BATTLEFATE       SPPR116.spl  PLANT  ****
1118  CLERIC_CALL_UPON_FAITH  SPPR118.spl  PLANT  ****
1113  CLERIC_DOOM             SPPR113.spl  PLANT  ****
1129  CLERIC_FAERIE_FIRE      SPPR129.spl  PLANT  ****
1110  CLERIC_SHILLELAGH       SPPR110.spl  PLANT  ****
1216  CLERIC_ALICORN_LANCE     SPPR216.spl  PLANT  ****
1219  CLERIC_BEAST_CLAW        SPPR219.spl  PLANT  ****
1203  CLERIC_CHANT             SPPR203.spl  PLANT  ****
1206  CLERIC_FLAME_BLADE       SPPR206.spl  ELEMENTALFIRE  ****
1231  CLERIC_MOON_MOTES        SPPR231.spl  PLANT  ****
1233  CLERIC_PRODUCE_FLAME     SPPR233.spl  PLANT  ****
1213  CLERIC_SPIRITUAL_HAMMER  SPPR213.spl  PLANT  ****
1211  CLERIC_SILENCE_15_FOOT   SPPR211.spl  PLANT  ****
1230  CLERIC_MOMENT            SPPR230.spl  PLANT  ****
1236  CLERIC_SEEKING           SPPR236.spl  PLANT  ****
1309  CLERIC_INVISIBILITY_PURGE SPPR309.spl  PLANT  ****
1302  CLERIC_CALL_LIGHTNING     SPPR302.spl  PLANT  ****
1333  CLERIC_ELYSIUMS_TEARS     SPPR333.spl  PLANT  ****
1310  CLERIC_MISCAST_MAGIC      SPPR310.spl  PLANT  ****
1339  CLERIC_MOON_BLADE         SPPR339.spl  PLANT  ****
1341  CLERIC_PRAYER             SPPR341.spl  PLANT  ****
1342  CLERIC_RANDOM_CASUALTY    SPPR342.spl  PLANT  ****
1343  CLERIC_SPIKE_GROWTH       SPPR343.spl  PLANT  ****
1344  CLERIC_STORM_SHELL        SPPR344.spl  PLANT  ****

This works:
Code: [Select]
COPY_EXISTING ~SPPR302.spl~ ~override~
        PATCH_IF (FILE_CONTAINS_EVALUATED (~GENERAL.ids~ ~UNDEAD~)) BEGIN
                PATCH_PRINT "Undead..."
        END
        BUT_ONLY
And this causes the installer to bail out
Code: [Select]
COPY_EXISTING ~SPPR302.spl~ ~override~
        PATCH_IF (FILE_CONTAINS ~GENERAL.ids~ ~UNDEAD~) BEGIN
                PATCH_PRINT "Undead..."
        END
        BUT_ONLY
But this works:
Code: [Select]
ACTION_IF (FILE_CONTAINS ~baldur.ini~ ~3D Acceleration=1~) BEGIN
COPY_EXISTING ~LC_WEBA1.vvc~ ~override~
                      ~LC_WEBA2.vvc~ ~override~
                      ~LC_WEBA3.vvc~ ~override~
                      ~LC_WEBA4.vvc~ ~override~
READ_BYTE   0x18 display_flags1
                WRITE_BYTE  0x18 (display_flags1 BAND 0b11111101) // Disables 50% transparency
                READ_BYTE   0x19 display_flags2
                WRITE_BYTE  0x19 (display_flags2 BOR 0b00000010)  // Enables this nice-looking blend
                READ_BYTE   0x1a colour_flags1
                WRITE_BYTE  0x1a (colour_flags1 BAND 0b11111100)  // Disables bit 0 (use area lighting) and bit 1 (use own light mask)
                READ_BYTE   0x1a colour_flags1
                WRITE_BYTE  0x1a (colour_flags1 BOR 0b00100000)   // Enables "own brightness"
BUT_ONLY_IF_IT_CHANGES
END

-Galactygon

Offline Mike1072

  • Planewalker
  • *****
  • Posts: 298
  • Gender: Male
Re: BUT_ONLY trouble for .dlgs
« Reply #46 on: August 18, 2010, 08:59:31 PM »
So there is no problem with .wavs in override. The only thing that is bloating is the .wav's in the audio subdirectory, if someone installs and then uninstalls the mod.
His code should get rid of the files left over after uninstall.  By copying a blank file in place of the .wav before converting it, WeiDU registers that it added that file to the folder, so when it uninstalls the component, it will delete the file.


I haven't used FILE_CONTAINS or FILE_CONTAINS_EVALUATED before, but they seem to behave as follows.

FILE_CONTAINS accepts only paths to actual files.  If the file doesn't exist, it spits out an error.

With FILE_CONTAINS_EVALUATED,

If you specify a filename:
  1) If the file exists in the main directory (e.g. baldur.ini), check it.
  2) Else if the file exists in the override directory, check it.
  3) Else if the file exists in the game biffs, check it.
  4) Else return 0.

If you specify a path to a file:
  1) If the file exists, check it.
  2) Else return 0.

Maybe bigg can clarify if this is true.
« Last Edit: August 18, 2010, 09:01:14 PM by Mike1072 »

Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1424
  • Gender: Male
  • Searcher of Bugs
Re: BUT_ONLY trouble for .dlgs
« Reply #47 on: August 18, 2010, 09:25:03 PM »
Quote
His code should get rid of the files left over after uninstall.  By copying a blank file in place of the .wav before converting it, WeiDU registers that it added that file to the folder, so when it uninstalls the component, it will delete the file.

AH! Now I understand. I failed my saving throw against intelligence. So that means no need to create a cleanup script. I will test tomorrow (about 12 hours from now), with MOVE and the above - I am excited about this idea in general.

Offline Galactygon

  • Modding since 2002
  • Planewalker
  • *****
  • Posts: 378
  • Gender: Male
  • Creator of spells
Re: BUT_ONLY trouble for .dlgs
« Reply #48 on: August 19, 2010, 12:48:55 AM »
Thanks Mike, the directory part was the problem. All 3 of these work:

Quote
COPY_EXISTING ~SPPR302.spl~ ~override~
        SPRINT gh "CLERIC_CHANT"
        PATCH_IF (FILE_CONTAINS_EVALUATED (~override/LCLIST_SPELLS.2da~ ~%gh%~)) BEGIN
                PATCH_PRINT "Chanting..."
        END
        PATCH_IF (FILE_CONTAINS_EVALUATED (~override/LCLIST_SPELLS.2da~ ~CLERIC_CHANT~)) BEGIN
                PATCH_PRINT "Chanting..."
        END
        PATCH_IF (FILE_CONTAINS ~override/LCLIST_SPELLS.2da~ ~CLERIC_CHANT~) BEGIN
                PATCH_PRINT "Chanting..."
        END
        BUT_ONLY

But now for some more WeiDU wierdness. This does not work.
Code: [Select]
COPY_EXISTING ~SPPR302.spl~ ~override~
        SPRINT gh "CLERIC_CHANT"
        PATCH_IF (FILE_CONTAINS_EVALUATED (~LCLIST_SPELLS.2da~ ~%gh%~)) BEGIN
                PATCH_PRINT "Chanting..."
        END
        PATCH_IF (FILE_CONTAINS_EVALUATED (~LCLIST_SPELLS.2da~ ~CLERIC_CHANT~)) BEGIN
                PATCH_PRINT "Chanting..."
        END

But I had a macro that starts with
Code: [Select]
PATCH_IF (SOURCE_SIZE > 0x71 AND !(FILE_CONTAINS_EVALUATED (~LCLIST_PATCHIGNORE_TELEPORT.2da~ ~%SOURCE_FILE%~)))
which always worked for me.

The_bigg, maybe you could help us out and explain what is happening.

-Galactygon

Offline Mike1072

  • Planewalker
  • *****
  • Posts: 298
  • Gender: Male
Re: BUT_ONLY trouble for .dlgs
« Reply #49 on: August 19, 2010, 01:28:38 AM »
Code: [Select]
COPY ~TestMod/LCLIST_SPELLS.2da~ ~override~

COPY_EXISTING ~SPPR302.spl~ ~override~
  SPRINT gh "CLERIC_CHANT"
  PATCH_IF (FILE_CONTAINS_EVALUATED (~LCLIST_SPELLS.2da~ ~%gh%~)) BEGIN
    PATCH_PRINT "Chanting..."
  END
  PATCH_IF (FILE_CONTAINS_EVALUATED (~LCLIST_SPELLS.2da~ ~CLERIC_CHANT~)) BEGIN
    PATCH_PRINT "Chanting..."
  END
  BUT_ONLY
It prints out both for me just fine.

 

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.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

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)?: