IPB

Welcome Guest ( Log In | Register )

> ProTRG v1.1, Quickly and efficiently generate masses of triggers!
poiuy_qwert    Canada
Jan 10 2010, 03:06 PM    Post #1
ProTRG v1.1 by poiuy_qwert
Download Windows EXE: ProTRG v1.1 (1.7mb)
Download the Source: ProTRG v1.1 (49kb, requires Python)

ProTRG is an advanced trigger creation language (like MacroTriggers) built on top of Python that is very useful for generating lots of SCMDraft triggers (and now even .trg files!) in an easy and efficient way. ProTRG is a command line "compiler" which runs the code in a plain text file and outputs SCMDraft triggers (or a .trg) to another file. It also comes with Notepad++ support, in fact its meant to be used with Notepad++ for a much easier experience.

Changes
ProTRG v1.1:
* Updated readme
* Fixed LeaderboardComputerPlayers (changed parameter from SETSWITCHSTATE to SETOTHERSTATE)
* Fixed the default trigger file from "triggers.txt" to "triggers.protrg"
* Fixed the convenience global ACTIONS so it's set to True
* Fixed some TUNIT vs UNIT inconsistancies, and the definitions for conditions/actions with the PERCENT parameter type
* Fixed multilines and slashes in string conversion
* Fixed potential problem with script filenames starting with "protrg" (without quotes)
* Fixed switches to be numbered the same as SCMDraft switches (1-256 instead of 0-255)
* Fixed many unit names
* Added support for compiling straight to .trg's, including GOT compatible .trg's (Note: StarEdit has problems loading recycled strings)
* Added an optional mechanism to have stronger typed values for parameters (Explained more in the Coding section)
* Added support for Extended Unit Deaths (EUD's) using the new stronger type mechanism (using EXTENDEDUNIT type)
* Added DefaultString, which is set to an empty string (""), and all default AI scripts as Globals
* Added @include preprocessor to iclude ProTRG files in others
* Added better command line support
* Added better support for Properties
* Added the keyword argument "disabled" for conditions/actions
* Added the possibility to collapse code in Notepad++ using #> and #< for the start and end
* Added a list of the Globals and their values to reference.txt
* All conditions and actions now inherit from the Condition and Action classes instead of directly from Raw
* LOCATION id's are now 0 to 254 instead of 1 to 255 to conform with map editors default location names
* If an error happens in your script it will now print all the current triggers in the Trigger list (if any) after printing the error traceback
ProTRG v1:
* First public release


 
Go to the top of the page +
2 Pages V  < 1 2  
Start new topic
Replies (20 - 30)
bajadulce    Santa Cruz, California
Mar 10 2010, 10:03 AM    Post #21
Thnx for the quick response poiuy. I guess <10> threw me off because SCMDraft reports this as displaying the color purple in its trig editor.


Couple things to report now after experimenting with what you commented on.

First, I made a simple map manually in SCMDraft that can be easily screwed around with to check some of this stuff:
Attached File  Trigtest2.scm ( 38.63K ) Number of downloads: 35


The map plays a virtual wav and then centers some display text. I used <13><10> as well as blank carriage returns in the editor as seen in pic above. Blank carriage returns are a bit easier when doing this manually as you can see when you are on the 11th line etc as I'm sure this is standard for most ppl doing this manually. But "manually" isn't a concern here.
Here's what SCMDraft's TrigEditor shows with the above map:
CODE
Trigger("Player 1"){
Conditions:
    Always();

Actions:
    Play WAV("sound\\misc\\buzz.wav", 0);
    Display Text Message(Always Display, "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\x013\x007Message 1.");
    Wait(10000);
    Preserve Trigger();
}

//-----------------------------------------------------------------//

Trigger("Player 1"){
Conditions:
    Elapsed Time(At least, 5);

Actions:
    Play WAV("sound\\Misc\\Buzz.wav", 0);
    Display Text Message(Always Display, "\x013\x010\x013\x010\x013\x010\x013\x010\x013\x010\x013\x010\x013\x010\x013\x010\x013\x010\x013\x010\x013\x006Message 2.");
    Wait(10000);
    Preserve Trigger();
}

//-----------------------------------------------------------------//
  • Everything works fine except that the second message isn't centered with this setup? I tried various things such as adding another <13> just before the text, but without any luck. Not sure what to do to center text as is done in the first message?
  • I experimented with removing the added digit in \x013\x010 to just \x13\x10 and SCMDraft's compiler didn't seem to have a problem with that. If you open the trigs again tho, they have the extra digit. So just something weird that SCMDraft does, but at least that clears that up.
  • Notice the sound file has 2 backslashes. If you remove one, you'll get the following compiler error.
    Error at lineXX: unknown escape sequence
    Error at lineXX: "," expected
    So another strange format that SCMDraft uses.
  • Don't Always Display and Always Display don't seem to do anything different? Not sure what that little checkbox does but both display in my tests.
Here is a sample trig I wrote in ProTrg:
CODE
# ProTrg WAV and Text Display test

Trigger(AllPlayers)
Always()
PlayWAV("sound\\Misc\\Buzz.wav", 0)
DisplayTextMessage(SubtitleDisplay, "<13><10><13><10><13><10><13><10><13><10><13><10><13><10><13><10><13><10><13><10><13><06>Message 2")
Wait(5000)
PreserveTrigger()
Everything is fine except for the extra backslash after compiling (weird why this has to be in SCMDraft) and not being able to center. Is there something I can add to the source files so it will compile with double slashes?

One funny thing to note. I tend to archive all of my files in lowercase in my MPQ's rather than the standard format used by a lot of Blizzard files. So something like sound\misc\buzz.wav (which would work in SCMDraft's trig compiler) is what you'd see in my mpq if it had been modified. However:
CODE
PlayWAV("sound\misc\buzz.wav", 0)
and the "\b" gives problems! laugh.gif

Ok sorry for such a long post as usual. The only issue that is preventing me from importing my compiled ProTrg triggers is the double backslashes after all of this. The center text is only a cosmetic thing (and there's probably a way to do this with <13> in a different configuration anyways).


 
Go to the top of the page +
poiuy_qwert    Canada
Mar 10 2010, 07:22 PM    Post #22
Ohhh SCMDraft uses hexadecimal in the TBL formatting but I had used decimal (<13> and <10> should be <0D> and <0A>)! Since we have to change this we'll make it SCMDraft's preferred way with \r\n. Here is a fix for that and also includes the fix for the slash problem you are having. Go to line 258 which should be:
CODE
        return '"%s"' % val.replace('\r\n','<13><10>).replace('\r','<13><10>').replace('\n','<13><10>')l

and replace it with:
CODE
        return '"%s"' % val.replace('\r\n','\\r\\n').replace('\r','\\r\\n').replace('\n','\\r\\n').replace('\\','\\\\')


Also, SubtitleDisplay (Don't Always Display in SCMDraft) only shows the text when the user has the option "Show Subtitles" selected from the options menu. And then AlwaysDisplay is pretty straight forwards tongue.gif


 
Go to the top of the page +
bajadulce    Santa Cruz, California
Mar 11 2010, 12:19 AM    Post #23
the sound files now compile correctly as:
CODE
    Play WAV("sound\\Misc\\Buzz.wav", 0);
    Display Text Message(Don't Always Display, "\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n<13><06>Message 2");
but those double slashes in "\r\n" while seem to compile fine in SCMDraft, they aren't displaying correctly. Looks like we just need "\r\n" to compile as "\r\n". Can this be changed, but still keep the double slashes in the "\" and "\\" formatting?

Sorry I haven't been able to use this program to its fullest with all the macros etc, but it has been a huge help making the trigs for my mod as I don't like the way SCMDraft's trig editor is formated. And that MacroTrig program that I've read about seems really odd. Thnx so much for putting up with all of this.


 
Go to the top of the page +
poiuy_qwert    Canada
Mar 11 2010, 07:00 AM    Post #24
QUOTE(bajadulce @ Mar 11 2010, 03:19 AM) *
the sound files now compile correctly as:
CODE
    Play WAV("sound\\Misc\\Buzz.wav", 0);
    Display Text Message(Don't Always Display, "\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n<13><06>Message 2");
but those double slashes in "\r\n" while seem to compile fine in SCMDraft, they aren't displaying correctly. Looks like we just need "\r\n" to compile as "\r\n". Can this be changed, but still keep the double slashes in the "\" and "\\" formatting?

Ah my mistake again, didn't think about the \r\n when doing the slashes part. Go to line 258 which should be:
CODE
        return '"%s"' % val.replace('\r\n','\\r\\n').replace('\r','\\r\\n').replace('\n','\\r\\n').replace('\\','\\\\')

and move the replace on the end to the beginning:
CODE
        return '"%s"' % val.replace('\\','\\\\').replace('\r\n','\\r\\n').replace('\r','\\r\\n').replace('\n','\\r\\n')


QUOTE(bajadulce @ Mar 11 2010, 03:19 AM) *
Sorry I haven't been able to use this program to its fullest with all the macros etc, but it has been a huge help making the trigs for my mod as I don't like the way SCMDraft's trig editor is formated. And that MacroTrig program that I've read about seems really odd. Thnx so much for putting up with all of this.

I agree. And no problem, my pleasure.


 
Go to the top of the page +
bajadulce    Santa Cruz, California
Mar 11 2010, 10:14 AM    Post #25
All works great! I'll keep you posted if I come across anything else.

Edit:
Not sure If I screwed up my version of global.py as this seems to have come up before in an earlier post, but Unit#26 Eduke Turret (Siege Mode) is compiling as "Duke Turret type 1" which seems to be Unit24 in SCMDraft or the (Tank Mode type1). SCMDraft isn't too helpful spotting this either as a lot of units share the same string! wtf?

CODE
Command(CurrentPlayer, 26, AtLeast, 1)
compiles as:
CODE
Command("Current Player", "Duke Turret type 1", At least, 1);

So seems like unit26 needs to be "type 2" for SCMDraft. What file assigns strings to Unit ID's?

For now I did this to Global.py to get around this, but this is sort of a hack:
CODE
DukeTurret = "Duke Turret type 2"
EdmundDuke_SiegeMode = "Edmund Duke (Siege Mode)"
DukeTurret_SiegeMode = "Duke Turret type 1"


 
Go to the top of the page +
bajadulce    Santa Cruz, California
Mar 11 2010, 07:09 PM    Post #26
Well sorry to bring bad news again. sad.gif

There seems to be more problems with Unit ID's as I couldn't understand why the gambling trigs that I created manually in SCMDraft are not working after carefully rebuilding them in ProTRG. Here's what's happening:

CODE
SetDeaths(CurrentPlayer, 191, SetTo, 1)
SetDeaths(CurrentPlayer, 192, SetTo, 1)
SetDeaths(CurrentPlayer, 193, SetTo, 1)
SetDeaths(CurrentPlayer, 194, SetTo, 1)
SetDeaths(CurrentPlayer, 195, SetTo, 1)
SetDeaths(CurrentPlayer, 196, SetTo, 1)
SetDeaths(CurrentPlayer, 197, SetTo, 1)
SetDeaths(CurrentPlayer, 198, SetTo, 1)
SetDeaths(CurrentPlayer, 199, SetTo, 1)


Is compiling as:

CODE
    Set Deaths("Current Player", "Protoss Marker", Set To, 1);
    Set Deaths("Current Player", "Protoss Marker", Set To, 1);
    Set Deaths("Current Player", "Protoss Marker", Set To, 1);
    Set Deaths("Current Player", "Protoss Beacon", Set To, 1);
    Set Deaths("Current Player", "Protoss Beacon", Set To, 1);
    Set Deaths("Current Player", "Protoss Beacon", Set To, 1);
    Set Deaths("Current Player", "Protoss Flag Beacon", Set To, 1);
    Set Deaths("Current Player", "Protoss Flag Beacon", Set To, 1);
    Set Deaths("Current Player", "Protoss Flag Beacon", Set To, 1);


So I guess I will have to use the full names until this can be straightened out. I absolutely love using unit ID's tho as I can keep track of them easier.


 
Go to the top of the page +
poiuy_qwert    Canada
Mar 11 2010, 08:07 PM    Post #27
Ah, its hard getting all the names correct since SCMDraft has weird names for some things and no reference list, so I generated my list with a little script and a few problems slipped through. Open Globals.py and go to lines 292-300 which should be:
CODE
Marker = "Zerg Marker"
Marker = "Terran Marker"
Marker = "Protoss Marker"
Beacon = "Zerg Beacon"
Beacon = "Terran Beacon"
Beacon = "Protoss Beacon"
FlagBeacon = "Zerg Flag Beacon"
FlagBeacon = "Terran Flag Beacon"
FlagBeacon = "Protoss Flag Beacon"

and replace it with:
CODE
ZergMarker = "Zerg Marker"
TerranMarker = "Terran Marker"
ProtossMarker = "Protoss Marker"
ZergBeacon = "Zerg Beacon"
TerranBeacon = "Terran Beacon"
ProtossBeacon = "Protoss Beacon"
ZergFlagBeacon = "Zerg Flag Beacon"
TerranFlagBeacon = "Terran Flag Beacon"
ProtossFlagBeacon = "Protoss Flag Beacon"

then go to lines 527-535 which should be:
CODE
    Marker,
    Marker,
    Marker,
    Beacon,
    Beacon,
    Beacon,
    FlagBeacon,
    FlagBeacon,
    FlagBeacon,

and replace it with:
CODE
    ZergMarker,
    TerranMarker,
    ProtossMarker,
    ZergBeacon,
    TerranBeacon,
    ProtossBeacon,
    ZergFlagBeacon,
    TerranFlagBeacon,
    ProtossFlagBeacon,


QUOTE(bajadulce @ Mar 11 2010, 01:14 PM) *
Not sure If I screwed up my version of global.py as this seems to have come up before in an earlier post, but Unit#26 Eduke Turret (Siege Mode) is compiling as "Duke Turret type 1" which seems to be Unit24 in SCMDraft or the (Tank Mode type1). SCMDraft isn't too helpful spotting this either as a lot of units share the same string! wtf?

CODE
Command(CurrentPlayer, 26, AtLeast, 1)
compiles as:
CODE
Command("Current Player", "Duke Turret type 1", At least, 1);

So seems like unit26 needs to be "type 2" for SCMDraft. What file assigns strings to Unit ID's?

For now I did this to Global.py to get around this, but this is sort of a hack:
CODE
DukeTurret = "Duke Turret type 2"
EdmundDuke_SiegeMode = "Edmund Duke (Siege Mode)"
DukeTurret_SiegeMode = "Duke Turret type 1"

Hmm, looks like SCMDraft decided to name the Duke Turret that comes first "type 2", told you it can be screwy tongue.gif Anyway, that is actually exactly how to fix it.


 
Go to the top of the page +
bajadulce    Santa Cruz, California
Mar 13 2010, 10:47 PM    Post #28
Boo! smile.gif Nothing to report.


 
Go to the top of the page +
poiuy_qwert    Canada
Mar 27 2010, 06:41 AM    Post #29
ProTRG v1.1 released
Download Windows EXE: ProTRG v1.1 (1.7mb)
Download the Source: ProTRG v1.1 (49kb, requires Python)

Changes:
* Updated readme
* Fixed LeaderboardComputerPlayers (changed parameter from SETSWITCHSTATE to SETOTHERSTATE)
* Fixed the default trigger file from "triggers.txt" to "triggers.protrg"
* Fixed the convenience global ACTIONS so it's set to True
* Fixed some TUNIT vs UNIT inconsistancies, and the definitions for conditions/actions with the PERCENT parameter type
* Fixed multilines and slashes in string conversion
* Fixed potential problem with script filenames starting with "protrg" (without quotes)
* Fixed switches to be numbered the same as SCMDraft switches (1-256 instead of 0-255)
* Fixed many unit names
* Added support for compiling straight to .trg's, including GOT compatible .trg's (Note: StarEdit has problems loading recycled strings)
* Added an optional mechanism to have stronger typed values for parameters (Explained more in the Coding section)
* Added support for Extended Unit Deaths (EUD's) using the new stronger type mechanism (using EXTENDEDUNIT type)
* Added DefaultString, which is set to an empty string (""), and all default AI scripts as Globals
* Added @include preprocessor to iclude ProTRG files in others
* Added better command line support
* Added better support for Properties
* Added the keyword argument "disabled" for conditions/actions
* Added the possibility to collapse code in Notepad++ using #> and #< for the start and end
* Added a list of the Globals and their values to reference.txt
* All conditions and actions now inherit from the Condition and Action classes instead of directly from Raw
* LOCATION id's are now 0 to 254 instead of 1 to 255 to conform with map editors default location names
* If an error happens in your script it will now print all the current triggers in the Trigger list (if any) after printing the error traceback


 
Go to the top of the page +
Apr 5 2010, 01:44 AM    Post #30
Hello there.

I was wondering if you could add in the memory condition, which is a newer condition for Scmdraft used to make EUD conditions.

Here is a memory condition in standard scmdraft text format:

Memory(x, Comparison, y);

x needs to be able to be negative, and I don't think y will ever need to be. Of course, you don't really do too much low level data manipulation in Python anyways, so I guess it doesn't matter. x and y need to both be integers as well. The comparison is the usual At Least, At Most, Exactly.

The next paragraph goes into explaining the differences between the old EUD conditions and the new ones -- you can probably just not read it and still add in the memory condition to ProTrg just fine.

The traditional EUD condition, done in StarForge, had a general formula of: Address = Offset + (4*(player )) + (48*(unit:id)). The memory condition uses deaths of Terran Marine, which has a unit:id of 0, so the formula becomes a bit simpler where the only variable to solve for becomes player; here is the memory condition formula: Address = Offset + 4*Player + 48*0. So to solve for player, you pretty much just subtract your address from the death table minimum value (which is 5808996) then divide by (4*player#).

If you need anymore info let me know, though, I can't see why you would need anything other than the standard scmdraft text format for the condition tongue.gif

Thanks!


 
Go to the top of the page +
poiuy_qwert    Canada
Apr 7 2010, 07:32 AM    Post #31
QUOTE(CecilSunkure @ Apr 5 2010, 05:44 AM) *
I was wondering if you could add in the memory condition, which is a newer condition for Scmdraft used to make EUD conditions.

Yep.


 
Go to the top of the page +

2 Pages V  < 1 2
Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 7th September 2010 - 07:37 PM