IPB

Welcome Guest ( Log In | Register )

2 Pages V   1 2 >  
Reply to this topicStart new topic
> 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 +
bajadulce    Santa Cruz, California
Jan 10 2010, 10:51 PM    Post #2
I'm not much of a mapper, but I do know that building triggers in map editors can be really cumbersome! And so this is really slick.

For fun I converted the current PEAI trigs to be compatible with this new program to help test for any bugs. At first it was really slow going as I had to check back and forth with the references.txt as to the proper syntax. I sort of went all out using Unit ID's which is really fantastic for a modder like myself who practically knows the damn unit ID's by heart now. laugh.gif

So here's some questions:
* What's the benefit of this program vs. PyTrg?
* How do I import this into PyTrg to convert to a stripped melee.trg?
* In my trigs I am using the default strings for leaderboard and so I left that string as ""?
* Is Player12 = to neutral? I just discovered that "neutral players" and "neutral" are 2 different things.
* Take a peek and see if there were things that could have been simplified/made use of special coding

Next, I'll double check this by comparing it to a saved SCMDraft .txt file side by side.

One things for certain. I prob won't be bothering with map editors to build trigs whether it be this program or PyTrg. smile.gif


 
Go to the top of the page +
poiuy_qwert    Canada
Jan 10 2010, 11:47 PM    Post #3
QUOTE(bajadulce @ Jan 11 2010, 01:51 AM) *
I'm not much of a mapper, but I do know that building triggers in map editors can be really cumbersome! And so this is really slick.

I agree.

QUOTE(bajadulce @ Jan 11 2010, 01:51 AM) *
For fun I converted the current PEAI trigs to be compatible with this new program to help test for any bugs. At first it was really slow going as I had to check back and forth with the references.txt as to the proper syntax. I sort of went all out using Unit ID's which is really fantastic for a modder like myself who practically knows the damn unit ID's by heart now. laugh.gif

It makes it a bit easier to follow using the built in globals like SetTo and Marine for example tongue.gif I should have included a list of them in the reference, but I forgot. If you got or get the source version you can look in Globals.py and see all of them. Also, if you were to use Notepad++ to edit your ProTRG files you can have autocomplete for Trigger, condtions, actions, and all the globals. But yeah, being able to use unit ids is nice.

QUOTE(bajadulce @ Jan 11 2010, 01:51 AM) *
So here's some questions:
1) What's the benefit of this program vs. PyTrg?
2) How do I import this into PyTrg to convert to a stripped melee.trg?
3) In my trigs I am using the default strings for leaderboard and so I left that string as ""?
4) Is Player12 = to neutral? I just discovered that "neutral players" and "neutral" are 2 different things.
5) Take a peek and see if there were things that could have been simplified/made use of special coding

1) PyTRG is like SCMDraft triggers just with different syntax, they are made to define every trigger in a static way. ProTRG is meant to generate triggers, as well as define static triggers if the need should arise.
2) ProTRG is mostly meant for mappers using SCMDraft, which means atm its not the best for doing the job you want (though I already have the base code all set up to be able to save to trg files in the future, its not done). You'll have to create/open a map in SCMDraft, put the generated triggers in and save the map, then open the map in StarEdit/XtraEdit and export the trg. You can then open that in PyTRG and save it stripped.
3) Ah thats not mentioned in the reference heh. You use the number 0 for default string. There is also supposed the be the global DefaultString but its commented out in the current release :S If you have the source version you can open Globals.py to uncomment it if you want.
4) SCMDrafts "Neutral" is Player 12, so yeah 12 or Player12 will work
5) Well a lot of the triggers can be generated. For example your tax salary triggers could be condensed into:
CODE
tax_salary = (
    (1000,    500),
    (900,    500),
    (850,    500),
    (800,    475),
    (800,   475),
    (700,    450),
    (675,    450),
    (650,    425),
    (600,    400),
    (550,    375),
    (500,    350),
    (450,    325),
    (400,    300),
    (350,    275),
    (300,    250),
    (250,    225),
    (200,    200),
    (175,    175),
    (150,    150),
    (125,    125),
    (100,    100),
)    
for tax,(gold,ferillium) in enumerate(tax_salary):
    Trigger(17)
    ElapsedTime(0, 90)
    Deaths(13, 222, 0, 1)
    Deaths(13, 188, 10, tax)
    CountdownTimer(1, 1)
    Wait(1000)
    SetResources(13, 8, gold, 0)
    SetResources(13, 8, ferillium, 1)
    PreserveTrigger()
    Comment("0 tax salary = %sg %sf" % (gold,ferillium))

If there was an easy way to calculate the gold and ferillium from the tax then you could just do the math in the for instead of defining the amounts beforehand. Your triggers to calculate the tax could be generated in the same way. Your hyper triggers could be done this way (minimal code):
CODE
for a in range(3):
    Trigger(17)
    Always()
    for b in range(62):
        Wait(0)
    PreserveTrigger()
    Comment("hypers")

And for the way thats a bit longer, but more memory efficient when generating the triggers:
CODE
trig = Trigger(17)
trig.addTrigger()
trig.addTrigger()
Always()
wait = Wait(0)
for b in range(62):
    trig.add(wait)
PreserveTrigger()
Comment("hypers")


 
Go to the top of the page +
bajadulce    Santa Cruz, California
Jan 11 2010, 12:04 AM    Post #4
The idea that trigs can be generated such as the payout array you've shown is really powerful. Unlike myself, mappers that use complex trigs can definitely benefit from something like this.

EDIT:
Well I finally figured out why I couldn't seem to import trigs into SCMDraft. It seems you have to hit the "check" button first and make sure there are no errors. For some reason as mentioned in the shoutbox, SCMDraft doesn't like the "clear" state for ComputerLeaderBoard(state)

After deleting this leaderboard action from my trigs and then hitting "save" SCMDraft reports every single comment string as being "corrupt? something like:
String corruption detected in line XXXX, file .\windows\CMainGui.cpp.. blah blah blah. But I don't see any difference in the comment format generated by ProTRG and the comments generated from SCMDraft. ??


 
Go to the top of the page +
poiuy_qwert    Canada
Jan 11 2010, 06:13 PM    Post #5
Oh man i didn't even think of how fun it will be to debug ProTRG and ProTRG+SCMDraft synergy with my lack of Windows CPU accessibility tongue.gif Well I'll look into the comment thing asap.


 
Go to the top of the page +
bajadulce    Santa Cruz, California
Jan 11 2010, 06:20 PM    Post #6
Here's the scoop with the comment errors as I was able to reproduce the messages. The .txt file that I uploaded has 2 errors. One is a line break error as noted in the shoutbox and the other is the leaderboard(state).

LeaderboardComputerPlayers(5) which compiles to:
Leaderboard Computer Players(clear);

And SCMDraft is reporting something wrong with "clear"?

As far as the other error with the line break:
Comment("Initiate resources and remove restrictions.\r\nPlayer has selected a race and is human") which compiles as:
CODE
    Comment("Initiate resources and remove restrictions.

Player has selected a race and is human");
}
This line break error can however be fixed/edited in SCMDraft's Trigger Editor without busting it and getting those comment errors.

.. go figure.


 
Go to the top of the page +
poiuy_qwert    Canada
Jan 11 2010, 10:28 PM    Post #7
Ah. I could have sworn I put in the code to handle line breaks for strings (convert them to TBL constants that SCMDraft accepts) but evidently I didn't. Anyway, if you have the source version, below are the fixes for both bugs.

For the LeaderboardComputerPlayers action fix, go to line 850 which should be:
CODE
    definition = [(SETSWITCHSTATE,8)]

and replace it with:
CODE
    definition = [(SETOTHERSTATE,8)]

Note: This does not change the parameter hints in Notepad++ and the reference.txt, wait for an update for total integration of the change.

For the string bug you encountered with comments, go to line 258 which should be:
CODE
        return '"%s"' % val

and replace it with:
CODE
        return '"%s"' % val.replace('\r\n','<0D><0A>').replace('\r','<0D><0A>').replace('\n','<0D><0A>')


Edit: Fixed the fixed code :S


 
Go to the top of the page +
bajadulce    Santa Cruz, California
Jan 25 2010, 11:59 AM    Post #8
I managed to get my mod transferred back to ProTRG and am now going through the last of the compiler messages.

So far I have these to report:

Errors:
CreateUnit(CurrentPlayer, Marine, 3, 0)
SetSwitch(11, Set)

Fixes:
CreateUnit(CurrentPlayer, Marine, 3, "Location 0")
SetSwitch(11, Enabled)

1. You can't use "0" as a location. Tho your compiler explicitly says "between 1 and 255" so this isn't an issue, but might be something to note in reference.txt for Location 0.

2. The compiler does not seem to like "Set" for the SetSwitch action and you must use "Enabled" or "4" for this action?

Ok.. I'll prob have some more to add as I go along. Haven't imported any of this into SCMDraft yet. ohmy.gif


 
Go to the top of the page +
poiuy_qwert    Canada
Jan 25 2010, 12:32 PM    Post #9
1. Ah yes this confusing thing again. There is no such thing as location 0, yet the editors start the names of the locations at "Location 0". I'll change it to be 0 to 254 instead of 1 to 255.
2. Actually they are the same thing. If you look in Globals.py they are declared like so:
CODE
Set = Enabled = 4
Cleared = Disabled = 5


 
Go to the top of the page +
bajadulce    Santa Cruz, California
Jan 25 2010, 12:36 PM    Post #10
QUOTE(poiuy_qwert @ Jan 25 2010, 12:32 PM) *
Actually they are the same thing. If you look in Globals.py they are declared like so:
CODE
Set = Enabled = 4
Yes, I see that and I am reporting that "Set" Does not compile only Enabled and 4 do. Sorry for not being too clear.


 
Go to the top of the page +
poiuy_qwert    Canada
Jan 25 2010, 12:47 PM    Post #11
It works for me, its used in the example triggers.protrg included with ProTRG. How does it "not compile"? Is there an error in the generated file or in stdeo.txt?


 
Go to the top of the page +
bajadulce    Santa Cruz, California
Jan 25 2010, 02:01 PM    Post #12
Damnit! .. I swear I even looked at the reference in triggers.protrg before reporting this, but somehow I must have screwed up. Sorry for the false alarm.. User error or just being tired.

Good news:
I finally managed to update all the formatting/syntax for my Trigs transferred from PyTrg to ProTrg and got a compile! smile.gif yeah... now to test in SCMDraft ohmy.gif

EDIT:
My first problem seems to involve the MoveLocation Action. For whatever reason SCMDraft keeps giving me an error with the following:
CODE
Trigger(AllPlayers)
Switch(1, IsSet)
MoveLocation(CurrentPlayer, CommandCenter, Anywhere, 1) # gives error in SCMDraft compiler


Which compiles as:
CODE
Move Location("Current Player", "Terran Command Center", "Anywhere", "Location 1");


Oddly enough when I build this trigger manually in SCMDraft and then look at the trig editor to see how it might differ, it appears identical?
Here is what SCMDraft's Trig Editor reports for the same trig built manually:
CODE
Move Location("Current Player", "Terran Command Center", "Anywhere", "Location 1");


????? looks identical to the line compiled by ProTrg?


 
Go to the top of the page +
bajadulce    Santa Cruz, California
Jan 26 2010, 09:04 AM    Post #13
QUOTE(bajadulce @ Jan 25 2010, 02:01 PM) *
For whatever reason SCMDraft keeps giving me an error with the following:
CODE
MoveLocation(CurrentPlayer, CommandCenter, Anywhere, 1) # gives error in SCMDraft compiler

Which compiles as:
CODE
Move Location("Current Player", "Terran Command Center", "Anywhere", "Location 1");

Oddly enough when I rebuild this trigger manually in SCMDraft and then look at the trig editor to see how it might differ, it appears identical?
Try rebuilding the trigger in the SAME map you're importing to Asshole! smile.gif Funny what a new day and a fresh mind can see.

THE FIX:
It appears that the particular map I was trying to import these compiled triggers uses "Location 63" to represent "Anywhere", whereas the map I manually rebuilt the trigger in to compare, used "Anywhere".

CODE
MoveLocation(CurrentPlayer, CommandCenter, 63, 1)
Now works and compiles to:
CODE
Move Location("Current Player", "Terran Command Center", "Location 63", "Location 1");

Can anything be done to account for this in Global.py? Such as Anywhere = 63 = "Anywhere"
"Anywhere" will not work for all maps, but does location 63 work in all? Need to test as I am not that familiar w/ mapping.


 
Go to the top of the page +
poiuy_qwert    Canada
Jan 27 2010, 02:59 PM    Post #14
No location will have the same name in every map. The Anywhere global and being able to use a number id to reference the locations is just a convenience if your map has the "Anywhere" location and locations named in the format "Location #". For most cases people will have custom location names in their map, so they'll have to use those in ProTRG. You can also always redefine Anywhere in your code.


 
Go to the top of the page +
bajadulce    Santa Cruz, California
Jan 27 2010, 07:11 PM    Post #15
Well this is all obvious now that the problem has been resolved, but for ppl who aren't as familiar with mapping and unaware of the "location 63" thing, it can be really confusing as to why SCMDraft would give such an error with code that looks perfectly fine.

Using the "replace" feature in notepad, I am able to change the code for importing into different maps. I still don't understand why some maps use "Anywhere" and others "location 63". And I don't see a way to change this in the map editor. So this is just something ppl will have to keep an eye out for. Tho I imagine most experienced mappers would recognize this without even thinking about it.


 
Go to the top of the page +
poiuy_qwert    Canada
Jan 28 2010, 12:07 PM    Post #16
QUOTE(bajadulce @ Jan 27 2010, 10:11 PM) *
Well this is all obvious now that the problem has been resolved, but for ppl who aren't as familiar with mapping and unaware of the "location 63" thing, it can be really confusing as to why SCMDraft would give such an error with code that looks perfectly fine.

ProTRG knows nothing about the maps the triggers are designed for, its up to the mapper to know which locations he has, there is nothing ProTRG can do about that. The Anywhere location is probably the only location that will give problems like this (since people assume Anywhere is always Anywhere, when its really just any other location), and SCMDraft's crappy error reporting doesn't help the situation.

QUOTE(bajadulce @ Jan 27 2010, 10:11 PM) *
Using the "replace" feature in notepad, I am able to change the code for importing into different maps. I still don't understand why some maps use "Anywhere" and others "location 63". And I don't see a way to change this in the map editor. So this is just something ppl will have to keep an eye out for. Tho I imagine most experienced mappers would recognize this without even thinking about it.

I don't believe StarEdit let you change the Anywhere location, but SCMDraft does. Thats why not all maps have location 63 automatically named "Anywhere". You can change a locations name by double clicking the location or pressing enter when the location is selected.


 
Go to the top of the page +
bajadulce    Santa Cruz, California
Jan 28 2010, 12:59 PM    Post #17
Thnx poiuy for all the responses. This fantastic tool is so handy for creating, importing, as well as editing trigs into all of my maps. smile.gif

QUOTE(poiuy_qwert @ Jan 28 2010, 12:07 PM) *
I don't believe StarEdit let you change the Anywhere location, but SCMDraft does.
How do you do this? I'd like to always use the same string for this location for all of my maps. I don't see how to change this as it isn't a "physical" location on the map. There some other menu tab or something that lets you edit location names other than "clicking" on the location itself? Kinda a mapping question, sorry.


 
Go to the top of the page +
poiuy_qwert    Canada
Jan 28 2010, 01:46 PM    Post #18
Np, and thanks smile.gif

QUOTE(bajadulce @ Jan 28 2010, 03:59 PM) *
QUOTE(poiuy_qwert @ Jan 28 2010, 12:07 PM) *
I don't believe StarEdit let you change the Anywhere location, but SCMDraft does.
How do you do this? I'd like to always use the same string for this location for all of my maps. I don't see how to change this as it isn't a "physical" location on the map. There some other menu tab or something that lets you edit location names other than "clicking" on the location itself? Kinda a mapping question, sorry.

You have to create 64 locations, the 64th location is the Anywhere location (its "Location 63" since SCMDraft uses 0 based names). Until you do that the Anywhere location will be hidden, be the size of the map, and have the name "Anywhere".


 
Go to the top of the page +
bajadulce    Santa Cruz, California
Mar 9 2010, 11:46 AM    Post #19
Been using the program a lot over the past few weeks and have a question:

I'd like to display the following text message
CODE
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\x006TRANSCENDENT PATH INITIATED HERE!");


I tried this in protrg as:
CODE
DisplayTextMessage(SubtitleDisplay, "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nTRANSCENDENT PATH INITIATED HERE!")

NOTE: I replaced line 258 in source with the said fix you described in earlier post btw.

But am getting this?
CODE
    Display Text Message(Don't Always Display, "<13><10><13><10><13><10><13><10><13><10><13><10><13><10><13><10><13><10><13><10>TRANSCENDENT PATH INITIATED HERE!");
    Preserve Trigger();


And if I try
CODE
DisplayTextMessage(SubtitleDisplay, "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\x013\x006TRANSCENDENT PATH INITIATED HERE!")

I get:
CODE
    Display Text Message(Don't Always Display, "<13><10><13><10><13><10><13><10><13><10><13><10><13><10><13><10><13><10><13><10>SOH3NUL6TRANSCENDENT PATH INITIATED HERE!");

So I must be doing something terribly wrong.

Also note that SubtitleDisplay is compiling as "Don't Always Display". Is that correct and what command do I need to use for Always Display? Maybe I'm just missing something in your trigger.protrg sample.

One other question, what does the 2nd value "0" in the following represent?
CODE
PlayWAV("sound\\Misc\\Buzz.wav", 0)


Also Protrg is compiling the above as:
CODE
Play WAV("sound\Misc\Buzz.wav", 0);

and SCMDraft is reporting an error. Seems SCMDraft wants the double slash.


 
Go to the top of the page +
poiuy_qwert    Canada
Mar 10 2010, 06:15 AM    Post #20
QUOTE(bajadulce @ Mar 9 2010, 02:46 PM) *
Been using the program a lot over the past few weeks and have a question:

I'd like to display the following text message
CODE
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\x006TRANSCENDENT PATH INITIATED HERE!");


I tried this in protrg as:
CODE
DisplayTextMessage(SubtitleDisplay, "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nTRANSCENDENT PATH INITIATED HERE!")

NOTE: I replaced line 258 in source with the said fix you described in earlier post btw.

But am getting this?
CODE
    Display Text Message(Don't Always Display, "<13><10><13><10><13><10><13><10><13><10><13><10><13><10><13><10><13><10><13><10>TRANSCENDENT PATH INITIATED HERE!");
    Preserve Trigger();


And if I try
CODE
DisplayTextMessage(SubtitleDisplay, "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\x013\x006TRANSCENDENT PATH INITIATED HERE!")

I get:
CODE
    Display Text Message(Don't Always Display, "<13><10><13><10><13><10><13><10><13><10><13><10><13><10><13><10><13><10><13><10>SOH3NUL6TRANSCENDENT PATH INITIATED HERE!");

So I must be doing something terribly wrong.

Hmm, I didn't know SCMDraft supported \r\n, do the <13><10>
s work correct (should if SCMDraft supports TBL formatting like it should)? The only problem I see is \x013 and \x006. I dunno why SCMDrafts supports more but the \x## format only takes two digits after the x, so you are creating \x01 3 \x00 6, which turns out to be "SOH" 3 "NULL" 6. It should be either \x13\x06 or <13><06>.

QUOTE(bajadulce @ Mar 9 2010, 02:46 PM) *
Also note that SubtitleDisplay is compiling as "Don't Always Display". Is that correct and what command do I need to use for Always Display? Maybe I'm just missing something in your trigger.protrg sample.

Yeah "Don't Always Display" is correct, the other value should be AlwaysDisplay, but check the reference/supply an obviously invalid value to get an error to see what values are correct.

QUOTE(bajadulce @ Mar 9 2010, 02:46 PM) *
One other question, what does the 2nd value "0" in the following represent?
CODE
PlayWAV("sound\\Misc\\Buzz.wav", 0)


Also Protrg is compiling the above as:
CODE
Play WAV("sound\Misc\Buzz.wav", 0);

and SCMDraft is reporting an error. Seems SCMDraft wants the double slash.

I'm pretty sure its "length of WAV", but I don't think its used.


 
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: 31st July 2010 - 09:21 PM