Adding an event to a trigger

AgentPaper

From the depths, I come.
Reaction score
107
Is this just not possible anymore? It's not in the GUI, but can you use custom script and/or Galaxy code to do it? My problem is that I have a trigger that creates a hex grid of regions, and I want a trigger to run whenever a unit enters one of them, but I can't seem to figure out how to make that work without pre-placing the regions, which I do NOT want to do.
 

Yoshii

New Member
Reaction score
74
Is this just not possible anymore? It's not in the GUI, but can you use custom script and/or Galaxy code to do it? My problem is that I have a trigger that creates a hex grid of regions, and I want a trigger to run whenever a unit enters one of them, but I can't seem to figure out how to make that work without pre-placing the regions, which I do NOT want to do.

why not just save the created hex grid of region in a variable and have the event run?

I see what you mean though for the event part
 

AgentPaper

From the depths, I come.
Reaction score
107
I'm...not sure what you mean. Do you mean have the trigger just run constantly and check if units are in the regions? Because that's not going to work even a little bit.
 

Yoshii

New Member
Reaction score
74
I'm...not sure what you mean. Do you mean have the trigger just run constantly and check if units are in the regions? Because that's not going to work even a little bit.
I dont see the issue based on your first post; you mentioned you have a trigger creating region and being unable to call upon them because they are not "pre placed" .

Why not just to save those created region in a region variable or array then turn on the other trigger and call upon them by checking if any unit enter those variable as event.I had to do something like this in wc3 in a situation that look exactly like the one you described

unless there are some info im missing from your map.
 

AgentPaper

From the depths, I come.
Reaction score
107
That's exactly what I want to do. The trigger creates all of the region, assigns them to a variable, (an array of regions) and then I want that trigger to add an event to a different trigger, such that whenever a unit enters one of the regions, the trigger will run.

In WC3, this would have been as simple as using the "Add Event to Trigger" action, but that doesn't seem to exist in SC2 for whatever reason. What I'm asking is whether there's any way to do this with custom script or Galaxy code, since GUI doesn't support it at the moment.
 

Yoshii

New Member
Reaction score
74
That's exactly what I want to do. The trigger creates all of the region, assigns them to a variable, (an array of regions) and then I want that trigger to add an event to a different trigger, such that whenever a unit enters one of the regions, the trigger will run.

In WC3, this would have been as simple as using the "Add Event to Trigger" action, but that doesn't seem to exist in SC2 for whatever reason. What I'm asking is whether there's any way to do this with custom script or Galaxy code, since GUI doesn't support it at the moment.

why not create such trigger and have them turned off when game start and turn them once the region are created; you can assign the enter region event to your variable/array of your turned off trigger until it get a value

I doubt galaxy will support it in the way you want to do it, we can only hope.
 

AgentPaper

From the depths, I come.
Reaction score
107
How would having the trigger off at the start help in any way whatsoever? The problem is that I can't add the event to the trigger, and I can't have it at the beginning because you can't assign an event with a variable like that.
 

Arkless

New Member
Reaction score
31
custom script would be:

TriggerAddEventUnitRegion (trigger t, unitref u, region r, bool state);

triggernames are: gt_NAME
unitref has to be -1 for any unit (at least i think so, might be wrong)
global variables got the prefix gv_ and locals lv_ (for the region)
region/range events - true = entered, false = exited
 

AgentPaper

From the depths, I come.
Reaction score
107
custom script would be:

TriggerAddEventUnitRegion (trigger t, unitref u, region r, bool state);

triggernames are: gt_NAME
unitref has to be -1 for any unit (at least i think so, might be wrong)
global variables got the prefix gv_ and locals lv_ (for the region)
region/range events - true = entered, false = exited

Thank you very much. That's exactly what I was looking for. So, just to see if I have this right, the custom script would be:

TriggerAddEventUnitRegion (trigger gt_EnterHex, unitref -1, region gv_hex[lv_num], bool true);

This would add the event: Unit enters (Hex[Num]) to the trigger "Enter Hex"

Edit: Not working. Says I have a syntax error.

Edit: Edit: Also tried "TriggerAddEventUnitRegion (gt_EnterHex, -1, gv_hex[lv_num], true);" which gives: "Script failed to compile: Parameter type does not match the function definition"
 

Arkless

New Member
Reaction score
31
awh, sry, any unit = null (not -1)
looked it up now, yesterday I wrote everything from my memory >.< sry again

just to tell you how I got the -1, it's for any player in player events
 

AgentPaper

From the depths, I come.
Reaction score
107
awh, sry, any unit = null (not -1)
looked it up now, yesterday I wrote everything from my memory >.< sry again

just to tell you how I got the -1, it's for any player in player events

Thank you very much, it works perfectly!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top