Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: How exactly to extract .wav files from .scx file?
How exactly to extract .wav files from .scx file?
Mar 9 2019, 7:27 pm
By: sethmachine  

Mar 9 2019, 7:27 pm sethmachine Post #1



Hi,

I have an MPQ library that lets me pull the .chk file out with no problem:

Code
def extract_chk(infile, outfile=None):
   """Extracts the .chk file from a .scx/.scm.  File paths must be absolute.

   :param infile: absolute path to a .scx/.scm Starcraft scenario map file
   :param outfile: output .chk file; if None, uses the basename of the infile plus the .chk extension
   :return:
   """
   if not outfile:
       outdir = os.path.dirname(infile)
       bn = os.path.basename(infile)
       name, ext = os.path.splitext(bn)
       outfile = os.path.join(outdir, name + '.chk')
   with pyw3x.archive.open_archive(infile, 'r') as a:
       a.extract_file('staredit\\scenario.chk', outfile)


But where are the .wav files stored? I need to know the path to extract them. For example, .chk file is stored under "staredit\\scenario.chk".

Thanks!



None.

Mar 11 2019, 7:45 pm poiuy_qwert Post #2

PyMS and ProTRG developer

The wav files are stored with any path, they are not static. When you import a wav, the path is stored in the maps string section, and the trigger references that string by ID. If you want to extract all wav's, you can generally just extract all files from the MPQ (for most standard maps, there is only the .chk and .wav files) and ignore the .chk. If you want to get the .wav files that are actually used by the triggers, you must loop over all the triggers, then loop over all their actions to find actions which use sounds, lookup the string they are referencing in the string section by the ID in the action, then extract the file with that path.




Mar 11 2019, 10:10 pm jjf28 Post #3

Cartography Artisan

Note that there are two kinds of WAVs, a regular WAV which gets added in your map file similar to scenario.chk, and a virtual WAV which resides in the StarCraft MPQ files (patch_rt.mpq, broodat.mpq, stardat.mpq).

Both as poiuy said are just map strings, all of the data in the WAV section is not technically required (but it can help keep track of WAVs not used in triggers yet) - just take the wavStringId from triggers, get the string at that index in the STR section, and extract the file from your map using that string as the path (or check it against the list of virtual WAVs).

Here's my copy of the virtual WAV list: https://github.com/jjf28/Chkdraft/blob/feature/fundamental-refactoring/MappingCoreLib/Basics.cpp#L482



Rs_yes-im4real - Clan Aura - jjf28.net84.net

Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.

Mar 11 2019, 11:24 pm Suicidal Insanity Post #4

I see you !

Out of curiosity: Is that list different than just parsing the sound table file directly?




Mar 11 2019, 11:39 pm jjf28 Post #5

Cartography Artisan

Out of curiosity: Is that list different than just parsing the sound table file directly?

It shouldn't be any different, I don't remember exactly how I generated it tbh; the reason it was hardcoded was because of older architecture decisions that would have made it a hindrance to developing code in MappingCore (e.g. can't validate against the virtual wav list in the Scenario or MapFile class's add wav methods) which at this point I now have the tools (abstracted/extensible platform-independent file browsers and default parameters for instance) to get around - so I'll eventually have the code load it from the SC data files or use the hardcoded version as a backup.



Rs_yes-im4real - Clan Aura - jjf28.net84.net

Reached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.

Mar 11 2019, 11:44 pm Suicidal Insanity Post #6

I see you !

Ok, just was wondering whether I was missing any files.

I don't validate in the mapping level - the UI validates the text / allows explicit override, and the UI has access to the game data.

On the flip side, my list of AI scripts is hardcoded, instead of parsing the tables. That was just laziness + adding user friendly names xD




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[02:24 am]
razorback9423 -- Immortal Hardened Shields (idk how to recreate them, maybe weapon_damage.cpp)
[02:24 am]
razorback9423 -- Let shields regenerate first before health
[02:23 am]
razorback9423 -- Increase armor while burrowed
[02:23 am]
razorback9423 -- Here are some GPTP ideas
[11:05 pm]
Suicidal Insanity -- NudeRaider
NudeRaider shouted: Suicidal Insanity so it is true, but still silly
You still have not explained why not dropping support for mac users is silly
[06:57 pm]
Ultraviolet -- Sometimes we need reminders of our childhood wisdom ;)
[05:00 pm]
KrayZee -- Ultraviolet
Ultraviolet shouted: KrayZee Seems like you already know the answer. Don't feed the trolls
Funny that you write that. Someone just told me the exact same thing but about another person in that same forum who is acting pretty dumb. :bleh:
[04:32 pm]
Ultraviolet -- KrayZee
KrayZee shouted: How does one deal with a narcissist who is making things up, exaggerates their statements using words like "worst experience in my life" as to put emphasis in declaring trivial things, can't admit they are wrong and likes to escalate a situation that wasn't even a problem in the first place? I'm already at the point of just straight up ignoring this person and reporting em to forum moderators.
Seems like you already know the answer. Don't feed the trolls
[04:20 pm]
NudeRaider -- Suicidal Insanity
Suicidal Insanity shouted: There was a blue post to that effect, why would it be silly?
so it is true, but still silly
[04:20 pm]
NudeRaider -- Suicidal Insanity
Suicidal Insanity shouted: There was a blue post to that effect, why would it be silly?
not sure if there's a misunderstanding, because obviously blue posts can be silly as well.
Please log in to shout.


Members Online: Roy, razorback9423, lelumpolelum277190