Staredit Network > Forums > SC1 Mapping Tools > Topic: Oreo Triggers
Oreo Triggers
Jun 2 2012, 9:22 am
By: Kaias
Pages: 1 2 35 >
 

Jun 2 2012, 9:22 am Kaias Post #1





Oreo triggers is an SCMDraft trigger preprocessor that runs on php. More than a macro-triggerer, it adds modularity, intuitive triggering, EUD and Deathcounter support, helps you manage your resources and allows for custom built actions and conditions.

( It doesn't let you do anything you couldn't already do in Scmdraft, it just helps you do it more easily. )

Note about php:
If I had started with what this project ended up being in mind (and if I had planned to release it to people) I wouldn't've used php. As it happens, I originally started this as a simple preprocessor for Wormer's Macrotriggers (to add another layer of abstraction), which, at that level php was a natural choice. As it stands, however, php is great for people just being introduced to programming as it is a loosely typed language. To use Oreo triggers, you'll have to familiarize yourself with the php syntax (or at least, how it's used in Oreo triggers).

Just so you have a better idea of what this is before I go on, here's an example of what triggers might look like using Oreo triggers:

Example
Its Result


Installation and Usage
1. Install/Setup Oreos package
  • Install a local php server (I use Zend Server CE)
  • Download the Oreos Package (link below)
  • Unzip and place the Oreos folder in either your htdocs (windows) or public_html (linux) server folder (for Zend Server CE on Windows it should be ProgramFiles/Zend/Apache2/htdocs)
2. Create a your Oreo trigger projects in the same directory as the Oreos folder (but not in the Oreos folder).
  • Oreo projects are just php files that have:
    <?php require_once('Oreos/initialize.php');
    at the beginning and:
    ?>
    at the end. The actual oreo code you write will be in-between. You can edit .php files with any text editor, although it is best to use a programming environment that supports php.
3. Actually write your oreo triggers (using the oreo functions and classes. How to do this is explained in sections below).
4. Visit your project in a web browser to generate the triggers
  • Visiting your php file in a browser causes the php script to execute (and thus generate your map's triggers).
  • If you created your project in your web root (public_html or htdocs folder) then the url to visit the project will be:
    localhost/projectname.php
5. Copy and paste the generated triggers into the SCMDraft Textual Trig Editor


Using Mint
After some collaboration with yoonkwun (thanks yoonkwun), we developed an extension called 'Mint', which lets you write triggers to your map merely by compiling. With Mint enabled, you no longer have to copy/paste the generated text into Scmdraft, the triggers are added for you. This also gives you the ability to generate units and locations to your map within Oreo trigs. (Mint is not a separate download, its included in the Oreos package, and is completely optional).
To use mint, you must provide a path to your input file and an output file path to the Mint() function. Ex:

Mint takes your input map file and adds the triggers Oreo generates to it. Your input map should not have the triggers in it. There are few reasons we do it this way instead of overwriting the triggers onto the original file- it protects your map from the off chance that it gets corrupted, it keeps the triggers units and locations (made by OT) from being added to your map multiple times, and it makes it so that you don't have to reload the map in Scmdraft after compiling.
Your typical work flow would go like this- keep the original/input map open in Scmdraft (for making physical changes to the map, like terran, units, sprites) and oreo triggers in whatever IDE your using (for making changes to the triggers). Whenever you make a change to the map in either Scmdraft or in Oreo Trigs, you recompile OT and the changes will appear in the output map. When you test in Starcraft, you test with your output map file (where all the physical map and triggers are combined).

To create a preplaced unit or location to the map using Mint Oreos, simply use these functions:



Download
Latest: http://www.mediafire.com/download/ycdjj5qn6s6k8x6/Oreo_Triggers_1.0.1.rar (1.0.1)

http://www.mediafire.com/?g7gg4is0zynm69k (0.9.6)
http://www.mediafire.com/?krvtr5chehnigyh (0.9.5)
http://www.mediafire.com/?ip3vukvy2v49dkn (0.9.4)
http://www.mediafire.com/?s9ff64op5c9dbjl (0.9.3)
http://www.mediafire.com/?5f52tuh0okxau39 (0.9.2)
http://www.mediafire.com/?8ku895s94z745t2 (0.9.1)
http://www.mediafire.com/?314bqvc3dww5mle (0.9.0)
http://www.mediafire.com/?i2ge65z9fpa8lof (0.8.5)
http://www.mediafire.com/?6w1uk4idger78ex (0.8.4)
http://www.mediafire.com/?ybhdc5xcspu2bgz (0.8.3)
http://www.mediafire.com/?e8do8gta41kud7e (0.8.2)
http://www.mediafire.com/?z82q778izt50i4s (0.8.1)
http://www.mediafire.com/?06kqb8050gk1458 (0.8)


Creating triggers
Every oreo trigger begins with a player object which must be defined before the trigger. Player objects can hold any number of players.
Example of creating new Player object (we're naming ours $Players):
	$Players = new Player("Player 1", "Player 2", "Player 3");

Any trigger created with the player object you define will be owned by the players you specified when you created it.

There are 4 ways to start a trigger:
$Players->always( actions )
$Players->justonce( actions )
$Players->never( actions )
$Players->_if( conditions )->then( actions )



Version History
  • 09/05/13 Lots of changes, see post notes (1.0.1)
  • 11/08/12 Deathcounters can be used in Display Text. ->enter and ->exit for UnitGroups. Update checking (0.9.6)
  • 09/24/12 Fixes mint bug with Dark Swarm Nuclear Missile becoming the wrong units, fixes bug with complex conditions and more (0.9.5)
  • 08/23/12 A lot of changes, see notes (0.9.4)
  • 07/12/12 Added Leaderboard functions, fixed centerview for mint, added ModifyHangar, and more bug fixes (0.9.3)
  • 07/07/12 Added ForemostPlayer() function, Event and PlayerSwitch classes, fixed deathcounter division functions and other bug fixes. (0.9.2)
  • 06/30/12 Added repeat() and MintMapRevealers() functions. Fixed a bug where it wasn't removing extraneous triggers, and a bug when using the Order action with Mint. (0.9.1)
  • 06/26/12 Added support for all vanilla Conditions. Mint Extension released. Some bug fixes, a few more functions. LeaderBoard condition renamed to LeaderBoardPoints. (0.9.0)
  • 06/17/12 Added Switch statements, and more UnitGroup, IndexedUnit and Deathcounter functions as well as some minor bugfixes (0.8.5)
  • 06/08/12 Fixed create unit properties bug (0.8.4)
  • 06/08/12 Player objects in conditions support, Create unit with properties support, orGroups (0.8.3)
  • 06/07/12 Minor bug fix, Player in actions support, Comments moved to end of trigger (0.8.2)
  • 06/02/12 Fixed a bug in deathcounter multiply functions (0.8.1)
  • 06/02/12 Oreo Triggers Released (0.8)


Other Remarks
There are more classes I haven't touched and much more to tell, but it's late I'm tired of writing and I'm eager to release. Special thanks to Lethal Illusion for volunteering to do the Deathcounter math functions, the EUD classes and helping me test. More thanks: Roy, Yoonkwun, Farty1Billion for EUD work, Wormer for Macrotriggers documentation, and R1SKED911 for ever existing.

Remember, it's still in beta stage. Feel free to rifle through the code and change things to your liking (I recommend putting any additions you might make to a separate document and then just including them onto the proper page). Also feel free to contribute and make this thing even better.

Post has been edited 21 time(s), last time on Sep 6 2013, 2:02 am by Kaias.



None.

Jun 2 2012, 9:24 am Kaias Post #2



Documentation
CONDITIONS
ACTIONS
Deathcounters
Switches
KeyStroke
UnitGroup



I'll probably continue writing the documentation tomorrow. I haven't even touched on the EPD, IndexedUnit, or Location classes.

Post has been edited 6 time(s), last time on Jun 16 2012, 11:02 pm by Kaias.



None.

Jun 2 2012, 10:15 am Jack Post #3

>be faceless void >mfw I have no face

Very nice, I'll have to try this out and see if I can get the hang of it in time for the 1 week contest.



Red classic.

"In short, their absurdities are so extreme that it is painful even to quote them."

Jun 2 2012, 2:56 pm Sacrieur Post #4

Still Napping

High five!



None.

Jun 2 2012, 7:02 pm Kaias Post #5



It's intended for making all of your map's the triggers with, not just generating a few triggers and pasting it into your project (though you could certainly do that). Ideally you'll never have to open the Classic Trigger Editor.

This should be useful even in making little dinky maps.



None.

Jun 2 2012, 8:44 pm Jack Post #6

>be faceless void >mfw I have no face

With the deathcounters, does it automatically assign DCs? It seems so from your example code, but that would presumably interfere with any pre-selected DCs you might have in an existing map if you were copying and pasting just one trigger system, for example.



Red classic.

"In short, their absurdities are so extreme that it is painful even to quote them."

Jun 2 2012, 11:29 pm Lethal_Illusion Post #7



Quote from Jack
With the deathcounters, does it automatically assign DCs? It seems so from your example code, but that would presumably interfere with any pre-selected DCs you might have in an existing map if you were copying and pasting just one trigger system, for example.

Yeah, it automatically assigns DCs, but you can tell the compiler which DCs are available and which aren't. Same goes for switches.



None.

Jun 3 2012, 1:29 am Jack Post #8

>be faceless void >mfw I have no face

What is the empty value at the end of each trigger?
Code
'');


EDIT
On your tutorial, you may want to add that you need to be running the server executable to be able to run the .php script. And that you need to hit the Compile button in SCMDraft. Most people will work that out anyway but it's worth noting.



Red classic.

"In short, their absurdities are so extreme that it is painful even to quote them."

Jun 3 2012, 3:34 am Kaias Post #9



Quote from Jack
What is the empty value at the end of each trigger?
Code
'');
That's just a blank parameter I put at the end of triggers so that all of my actions can end in a comma. It isn't at all necessary.



None.

Jun 3 2012, 10:00 pm samsizzle Post #10



Code
<?php require_once("Oreo/initialize.php");

    $P1 = new Player("Player 1");
    $spawntimer = new Deathcounter();

    $P1->_if( $spawntimer->exactly(0) )->then(
        Display('Spawn timer set to 10 seconds'),
        $spawntimer->setTo(120),
    '');

    $P1->always(
        $spawntimer->subtract(1),
    '');

?>


Why doesn't this compile? I tried other files in the same directory as this and they work fine.



None.

Jun 3 2012, 10:34 pm Kaias Post #11



If you're using 'require_once("Oreo/initialize.php");' to initialize the oreos package then your project file needs to be in the same directory as the Oreo folder (but not in the Oreo folder). If you want to put your projects in a different folder you'll need to change the path to find it properly.

"Oreo/initialize.php" is a relative path. You can make an absolute path like this:
require_once($_SERVER['DOCUMENT_ROOT']."/Oreo/initialize.php");
which would point to htdocs/Oreo/initialize.php. You'd then be able to put your project anywhere in htdocs.



None.

Jun 5 2012, 2:10 am samsizzle Post #12



At first it didn't work so I tried changing it to require_once($_SERVER['DOCUMENT_ROOT']."/oreotriggers/Oreo/initialize.php"); and it worked fine.



None.

Jun 8 2012, 2:11 am Kaias Post #13



New Update 0.8.2:
  • You can now pass Player objects into actions and it will create the action for each player in the Player object
  • Autocomments moved to end of action list (so manual ones take priority)
  • Bugfix for deathcounter quotientOf and roundedQuotientOf functions
  • Added create() function to UnitGroup class
  • For efficient deathcounter allocation, you can now create Deathcounters for specific player slots by passing in a Player object on declaration. EX:
    $players = new Player(P2, P3);
    $dc = new Deathcounter($players, 500); // Creates a deathcounter with slots for P2 and P3 only reserved with a max of 500

    Using the deathcounter will use a player name of "Current Player", so its your responsibility to use $dc only in triggers owned by the players you set it for (in this case Player 2 and 3). That or you can player cast (e.g. $dc->P3->setTo(0) to set the deathcounter for player 3 to 0 )

Download Link:
http://www.mediafire.com/?e8do8gta41kud7e

Next:
After gathering some opinions I'm going to make it so using Player objects in conditions treats it as though it were a force. For instance:
Bring( $players, 'Terran Marine', AtLeast, 1, 'Anywhere' )
(Where $players is a player object) will act like this: "If any of the players in $players bring at least 1 Marine to Anywhere then..." as opposed to "If all of the players in $players bring at least 1 Marine to Anywhere then..."

Post has been edited 1 time(s), last time on Jun 8 2012, 2:21 am by Kaias.



None.

Jun 8 2012, 4:47 am LoveLess Post #14

Let me show you how to hump without making love.

Handy.



None.

Jun 8 2012, 10:24 pm Kaias Post #15



New Update 0.8.3 0.8.4:
  • You can now pass Player objects into conditions. By default it will act like a force would, where if any of the players meet the condition the actions are executed. EX:
    $humans = new Player(P1, P2, P3);
    Bring($humans, 'Terran Marine', AtLeast, 1, 'Anywhere')
    Will have a result to the effect of "Player 1, 2, or 3 bring at least 1 Marine to Anywhere". Using $humans->any or $humans->or in place of $humans will have the same effect. If you use $humans->all, $humans->each or $humans->and it will require all the players to meet the condition. EX:
    $humans = new Player(P1, P2, P3);
    Bring($humans->each, 'Terran Marine', AtLeast, 1, 'Anywhere')
    Will have a result to the effect of "Player 1, 2, AND 3 bring at least 1 Marine to Anywhere".

  • Create Unit with Properties now works. To use it, create an array of the property settings you want like so (order doesn't matter):
    $properties = array(Invincible, LiftedOff, Cloaked, Hallucinated, Burrowed, Shields => 99, Health => 90, Resources => 500, Hangar => 10, Energy => 30);
    CreateUnitWithProperties(P1, 'Terran Marine', 1, 'SpawnLocation', $properties)
    If you pass in only a single flag instead of an array it will work as you'd expect. Example:
    CreateUnitWithProperties(P1, 'Zerg Hydralisk', 1, 'SpawnLocation', Burrowed)
    Which will create a burrowed hydralisk at 'SpawnLocation' for Player 1

  • Added function orGroup(). Any conditions you pass into it will be "Or'd". Example:
    $Player->_if( $switch1->is_set(), orGroup( $QKey->pressed(), $EKey->pressed() ) )->then(
    Display('Q or E was pressed!')
    );
    In common programming syntax the conditions would translate to:
    if( $switch1->is_set() && ( $QKey->pressed() || $EKey->pressed() ) ) then..

  • Moved generated triggers into a scrollable

Download Link:
http://www.mediafire.com/?6w1uk4idger78ex

Post has been edited 1 time(s), last time on Jun 9 2012, 7:27 am by Kaias.



None.

Jun 10 2012, 12:42 am samsizzle Post #16



I'd just like to say its taken me a while to get into the syntax of Oreo, but its definitely more fun and intuitive once you get used to it.



None.

Jun 13 2012, 1:48 am Kaias Post #17



@Jack
It's a capitalization issue

Change
location('_p1Range');
to be
Location('_p1Range');

It seems that my version of PHP is less picky than yours (it didn't mind the capitalization issue).

By the way, I use PhpStorm as an IDE. I didn't like it at first because of how certain things worked and how ugly it was, but it is extremely configurable so I've been able to fix all my reservations (including the ugliness) and its better for Php than anything else I've used.



None.

Jun 13 2012, 1:52 am Jack Post #18

>be faceless void >mfw I have no face

Excellent, that worked. Thanks for your help!

I'm using Notepad++ at the moment, it's nice and minimalist, and quick to load.



Red classic.

"In short, their absurdities are so extreme that it is painful even to quote them."

Jun 13 2012, 2:33 am Kaias Post #19



Quote from Jack
Excellent, that worked. Thanks for your help!

I'm using Notepad++ at the moment, it's nice and minimalist, and quick to load.
I prefer PhpStorm primarily because it has good code hinting and error detection. So when you forget a comma or a parenthesis you know right away and when you want to use the Bring function it tells you exactly what its expecting. Using Notepad++ is indeed a great minimalist environment, however.

By the way, a location name like "_p1Range" screams poor triggering practice. Instead of dedicating a _p1Range location to the hero, I would use a general purpose location that's the same size and just center it on the hero when needed (assuming you're using the way I think you are).



None.

Jun 13 2012, 2:36 am Jack Post #20

>be faceless void >mfw I have no face

Quote from Kaias
Quote from Jack
Excellent, that worked. Thanks for your help!

I'm using Notepad++ at the moment, it's nice and minimalist, and quick to load.
I prefer PhpStorm primarily because it has good code hinting and error detection. So when you forget a comma or a parenthesis you know right away and when you want to use the Bring function it tells you exactly what its expecting. Using Notepad++ is indeed a great minimalist environment, however.

By the way, a location name like "_p1Range" screams poor triggering practice. Instead of dedicating a _p1Range location to the hero, I would use a general purpose location that's the same size and just center it on the hero when needed (assuming you're using the way I think you are).
Yeah I was just making a quick map to see how well Oreo works, I wasn't worried about location reuse and such. In a proper map I would be.

Also, http://templesiege.com/test1.php was generated via Oreo Triggers, it works pretty well :D might be a few errors in it but I'm happy with how quick it is and how it works. Thanks very much for making this Kaias.



Red classic.

"In short, their absurdities are so extreme that it is painful even to quote them."

Options
Pages: 1 2 35 >
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[04:47 pm]
Dem0n -- then again w/e
[04:46 pm]
Dem0n -- It's hardly even a SEN server honestly. Just mostly the same 10 people saying dumb shit LMAO
[04:46 pm]
Dem0n -- NudeRaider
NudeRaider shouted: Voyager7456 there should probably be a place more obvious that gives the link to the discord server. I'd say we're past trial stage by now.
no tbh. Lots of dumb people that shouldn't be on it.
[04:45 pm]
Suicidal Insanity -- Naw, somebody just redefined what one standard moose is
[04:39 pm]
Dem0n -- Our Moosey's all grown up C|:'^ )
[04:36 pm]
Dem0n -- O__________________________________________________________O
[04:17 pm]
jjf28 -- moose is no longer a mini O.O
[10:41 am]
NudeRaider -- NudeRaider
NudeRaider shouted: Voyager7456 there should probably be a place more obvious that gives the link to the discord server. I'd say we're past trial stage by now.
In the menu. Probably an item under Site, or preferably next to Wiki
[10:40 am]
NudeRaider -- Voyager7456
Voyager7456 shouted: You download Discord and join the SEN server :P
there should probably be a place more obvious that gives the link to the discord server. I'd say we're past trial stage by now.
[08:53 pm]
O)FaRTy1billion[MM] -- I'm pretty sure you can use the web one on phone too
Please log in to shout.


Members Online: Roy, Smithjaq2, UEDCommander, jun3hong