ProTRG v1.1

Help - Resources - Discussion
User avatar
poiuy_qwert
Posts: 548
Joined: Sun Jan 13, 2008 2:14 am

ProTRG v1.1

Postby poiuy_qwert » Sun Jan 10, 2010 11:06 pm

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
User avatar
poiuy_qwert
Posts: 548
Joined: Sun Jan 13, 2008 2:14 am

Postby poiuy_qwert » Mon Jan 11, 2010 7:47 am

[quote name='bajadulce' post='8950' date='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.[/quote]
I agree.

[quote name='bajadulce' post='8950' date='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. :lol:[/quote]
It makes it a bit easier to follow using the built in globals like SetTo and Marine for example :P 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 name='bajadulce' post='8950' date='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[/quote]
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: Select all

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: Select all

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: Select all

trig = Trigger(17)
trig.addTrigger()
trig.addTrigger()
Always()
wait = Wait(0)
for b in range(62):
   trig.add(wait)
PreserveTrigger()
Comment("hypers")
User avatar
poiuy_qwert
Posts: 548
Joined: Sun Jan 13, 2008 2:14 am

Postby poiuy_qwert » Tue Jan 12, 2010 2:13 am

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 :P Well I'll look into the comment thing asap.
User avatar
poiuy_qwert
Posts: 548
Joined: Sun Jan 13, 2008 2:14 am

Postby poiuy_qwert » Tue Jan 12, 2010 6:28 am

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: Select all

   definition = [(SETSWITCHSTATE,8)]

and replace it with:

Code: Select all

   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: Select all

      return '"%s"' % val

and replace it with:

Code: Select all

      return '"%s"' % val.replace('rn','<0D><0A>').replace('r','<0D><0A>').replace('n','<0D><0A>')


Edit: Fixed the fixed code :S
User avatar
poiuy_qwert
Posts: 548
Joined: Sun Jan 13, 2008 2:14 am

Postby poiuy_qwert » Mon Jan 25, 2010 8:32 pm

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: Select all

Set = Enabled = 4
Cleared = Disabled = 5

Return to “PyMS (poiuy_qwert's complete modding suite)”

Who is online

Users browsing this forum: No registered users and 1 guest