Staredit Network > Forums > SC1 Mapping Tools > Topic: Tool to extract triggers from .scx file and then reinsert them
Tool to extract triggers from .scx file and then reinsert them
Dec 5 2018, 12:45 am
By: sethmachine  

Dec 5 2018, 12:45 am sethmachine Post #1



Hi,

I have used this open source project for Warcraft 3 files (.w3x): https://github.com/ladislav-zezula/StormLib

It treats a .w3x as an archive which is made up of other files. Namely there is a war3map.j file, which contains all the triggers for that map.

What is the equivalent for an .scx file? I want a way to programmatically rebuild a .scx file with updated triggers, so I don't have to use the SCMDraft GUI to copy and paste whole new triggers, etc.

The API should look something like below. I know this is 100% possible, because I have this exact setup/API for Warcraft 3 maps (see: https://github.com/sethmachine/pyw3x) using an external DLL. Can someone point me to what I need to look at to get started?

python
infile = '/path/to/map.scx'
# extract the triggers data (in human readable format)
with open_archive(infile, 'r') as archive:
  archive.extract_triggers('triggers.txt')

# create new triggers or whatever
new_trigs = create_new_trigs()

# update the map's triggers data
with open_archive(infile, 'w') as archive:
 archive.write_triggers(new_trigs)
 archive.compact()




None.

Dec 5 2018, 7:15 am poiuy_qwert Post #2

PyMS and ProTRG developer

Hey sethmachine,

StarCraft maps (.scm and .scx files) are also archives like .w3x files. They are all just MPQ files (or MoPaQ files) with different extensions, so can be opened/edited with any of the various MPQ editing programs/libraries.

The first problem for editing StarCraft maps in the way you are looking for is that most of their "parts" are not stored in separate files in the mpq (only custom sound files are stored separately). Everything else is placed together into one binary scenario.chk file inside the mpq. The second issue is that your triggers are not stored in the chk file as "code", but as a "compiled" version of the triggers (though unless you are using a trigger generator, no information is lost in the compiling, it can be decompiled to its original source). The third and probably most complex/hardest issue is that all of the strings used for the map (scenario text, custom unit/switch/location names, trigger text, sound file paths, etc.), are stored and intermingle in a single section and only referenced from the other sections by an ID, so its very hard to manage the strings.

There are various tools that have been made to do trigger generation using higher level languages (including Python), you can find a bunch of them on the main page in this forum, and i'm pretty sure there are more. Most of them generate SCMDraft triggers that can be pasted into SCMDraft (or .trg files which can be imported into a map or used in mods), but I think there might be a couple that can inject them directly into maps. Also most, if not all, of these tools don't extract triggers from the map. Usually you would keep your "code" outside the map, update the code, regenerate the triggers, and update the map with those new triggers. Here is just a small list of the tools off the top of my head that you could look into (there are plenty of great tools around):
- LangUMS
- LIT (Lua)
- ProTRG (Python)
- TriGen (Python)
- Oreo Triggers (PHP)
- MacroTriggers

Another option is to go even lower level. I have written a suite of modding tools in Python called PyMS, which are built on top of custom libraries to read/edit most of the StarCraft files, including CHK and MPQ files (MPQ editing is a wrapper around ShadowFlare's SFmpq.dll). It may not be super user friendly, but if you know your way around python/programming, it can accomplish everything you are asking and will provide total control over everything. ProTRG could also probably be tweaked to interface with PyMS for even more power. I can also try and give some help/direction if this is the route you would like to take.

There is a lot of information here, I hope it all makes sense and gives you some idea where you want to go. If you have any questions I would be happy to clarify/elaborate.

Have fun!

Post has been edited 1 time(s), last time on Dec 8 2018, 5:44 pm by poiuy_qwert.




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[08:55 pm]
Vrael -- not really two-party-system specific but it was kinda a big deal when those old guys wrote about "unalienable rights" and that stuff
[08:54 pm]
Vrael -- Oh_Man
Oh_Man shouted: basically i'm saying two party systems sap the violence out of a population by giving them the illusion of choice, instead of feeling the need to rebel, they just say "well i'm not voting for you next time"
you kinda missed those minor details about how fundamental rights are baked into democratic systems so you actually have power to change the system (to whatever degree you wanna argue), whereas in other systems your only option is "no u", aka it's not an illusion of choice
[08:52 pm]
Ultraviolet -- what are you trying to accomplish here?
[08:51 pm]
sraw531 -- similar to how people farm scarabs.
[08:50 pm]
sraw531 -- was toying with the thought of trying to get a computer to continuously make nexi in the corner of the map and have triggers remove it occasionally, but I honestly don't know how to do that.
[08:48 pm]
Ultraviolet -- sraw531
sraw531 shouted: is there a way to create using triggers a building that is under construction? (Especially protoss, for multiple reasons)
afaik this is not possible
[08:46 pm]
sraw531 -- though ~3400 units on map is also an improvement considering reavers are 11 and carriers are 9 units.
[08:45 pm]
sraw531 -- GGmano
GGmano shouted: Yea see it describet as ccmu fix
I think my favorite part about ccmu fix is probably the 400 weapon limit. 100 is so low, considering 10 valks is 80 of that.
[08:41 pm]
Ultraviolet -- Suicidal Insanity
Suicidal Insanity shouted: Ultraviolet The devs are fairly good about backwards compatibility, just sometimes takes time
Fair enough, random crashes are always scary though :P
[07:36 pm]
Suicidal Insanity -- Ultraviolet
Ultraviolet shouted: martosss So you've had issues with maps that were previously playable having issues with the latest patch as well? I was play testing one of my creations a couple days ago and it crashed the game, something it has never done before. Has me feeling kind of concerned about playability of custom content going forward :/
The devs are fairly good about backwards compatibility, just sometimes takes time
Please log in to shout.


Members Online: Roy, hamlet337017, Gladishse10, yxekow