Author Topic: Triggers Script Editor  (Read 591 times)

Offline Qver

  • Peon
  • **
  • Posts: 4
    • View Profile
Triggers Script Editor
« on: May 14, 2025, 02:23:27 PM »
Hello!

When I was making some maps with triggers I found it really boring making some uniform triggers (like giving each player 20 gold and 10 forest per sheep, etc) using Mistral's Triggers Editor. Idk how Mistral made some maps like Desert Strike (which has about a thousand triggers). So I made this program called Triggers Script Editor that allows you to write code that can be compiled into Mistral's triggers. Maybe I have put more efforts to do this program than just making triggers by mouse, but anyway, I made it.

Last development of it was, like, in December, and for some reason I didn't released it than. I'm not sure, but this version can still be very buggy. So dont forget to backup your sources). Program saves them automatically every 2 second when in foreground so in case of crush your sources should be safe. And I added very many asserts so now file should not be erased as it happens in earlier versions.

Now about program itselves.


Spoiler
UI:
Build button: compiles program in manual mode.
Push button: save result of your program to PUD selected in bottom right corner. Warning: it does not build your program automatically, so if you selected "Disable compilation" mode you need to build your program by using button above
Reset colors button: make all text in editor black, and then restyle it again. Can be usefull if styling broke down.
Editor & compiler mode:
Disable compilation: disabling auto compilation and colorizing of code.
Only color mode: enable auto compilation and colorizing of code.
Color & Completition: same as above, plus replacing compiler log with completition list. Assumed to work as Visual Studio one. To switch between this and above mode you can use F2 hotkey.
Compiler toolset: can be used to see internal structure of compiler. Used to debug this program. Hint: OK button can be used to see full compiler log if it doesn't fit in right pane.

Script language:
#? - display tiny help
It has c-style preprocessor that support #define #undef #ifdef #ifndef #endif
#message and #message8 - insert text in binary output. First - with unsigned short length, second with unsigned char length. Should be used to implement triggers
#asm - insert numbers in binary output. support @16 and @32 modificators to change length of bits of number in output. Default is 8 bits
#foreach X - equal to #foreach X 0..7
#foreach X a..b - repeats code between #foreach and #endeach (b-a+1) times, defining X all values from a to b
fun function_name int constant_integer int* variable auto anything - declare function. It must ends with end keyword. Function can be overrided only by number of arguments, but not its types
#import file_name - adding file to compilation. Works like #include in C, except you dont need quotes.
#pragma
  message X - display message to user
  error X - display message to user in red
  description - disaply all previos comments to user
  debug - Debugging method
  trace - Debugging method
if statement.
Code: [Select]
if a < 2
// do something
else
// do something else
done
You probably will use implemented functions for triggers. You can see the whole list in Compiler Toolset and in stdlib file.


Btw, you can see some examples of scripts: https://raw.githubusercontent.com/sindev666/olymp-libs/refs/heads/WarCraft2/WC2/1/My%20puds/2035.pud.txt https://github.com/sindev666/olymp-libs/blob/WarCraft2/WC2/1/Chalton%20-%20%20from%20slave%20to%20the%20king/D4_THE_BORDER.pud.txt

Almost all defines from stdlib were found in Mistral's war2mod source code. This is internal reason of using c-style preprocessor.

If someone will be insteresting about it I can give more detailed description of what is inside and how it works

Download: https://github.com/sindev666/olymp-libs/raw/refs/heads/WarCraft2/WC2/TSE/Trigger%20Script%20Editor%201.0.zip
Virustotal: https://www.virustotal.com/gui/url/8a23df6b8e51303b10f64de32ccc18babff8d795a2fea48de445dd5960809fa9/detection

If you meet some bugs - you can write about them here. But this is just fan project, that I posting in hope that it can be usefull for someone, so dont except bugs to be fixed quickly.

Offline Mistral

  • Administrator
  • Axe Thrower
  • *****
  • Posts: 449
    • View Profile
Re: Triggers Script Editor
« Reply #1 on: May 14, 2025, 04:14:56 PM »
wow man
very cool stuff
 :newthumbsup: