I would look into using the Data Editor for this. You could give the turn pads a behavior (e.g. Look at the Science Vessel's "Irradiated" behavior) which searches for any units in range and performs a given action on that unit. Then, create a trigger which detects this action and checks for the desired conditions (i.e. unit type, unit is moving towards turn pad, etc.).
This might be a better method anyway; there seems to be an "Effect Used" event and a corresponding "Triggering Effect Unit" function which I've not tested but maybe they work like you want. The event doesn't have grammar text and has a mysterious integer parameter though so maybe it's not yet implemented or who knows
I always end up doing things the hard way but by jove does it work
ok looks like I was PMed to this thread cause I did something similar in raynor party
there's no easy way to do it that I know of, with triggers anyway - maybe effects or behaviours in the data editor can alter unit facing like that? I've not looked. if it's possible, you can then use a behaviour with a periodic search area effect to grab units who come close and set their facing
as you've discovered, you can't use the unit enters range of unit event as-is, because trigger events aren't dynamic like that: the event is "added" to the trigger on map initialization and the parameters evaluated there-and-then as with any other function, so if you try to use a variable there you'll just end up with whatever the initial value of the variable is as the unit
but there are some more complicated ways
the method I use in raynor party is pretty good, but it can only support a finite number of trap units at once. if the players can potentially create an unlimited number of traps you'll run into additional complications. the general idea is we pre-make a bunch of regions and move them during the game play when traps are created, and then use unit enters region on all these regions
SO!!
create a bunch of regions big enough to cover the trap unit-type anywhere on the map, call them TrapRegion00 to TrapRegion99 or whatever. you need enough regions to have one for every trap that can exist simultaeneously. make a region array variable with enough entries and set each entry to one of these regions (on map initialization). so Regions[0] = TrapRegion00, Regions[1] = TrapRegion01, and so on. Make a trigger and add a "unit enters region" event for all of these regions. You gotta do most of this manually so it's a giant pain in the arse if you need a lot of simultaeneous traps
THEN!!
You also need a unit array variable of the same size as the regions array, call it Units. Have an integer variable like RegionsUsed, initially zero. Whenever someone creates a trap, move Regions[RegionsUsed] to the position of the trap, set Units[RegionsUsed] to the trap unit and increment RegionsUsed. Then in the trigger with all the "enters region" events, loop through the regions array using some index variable i and check whether the triggering region is equal to Regions[i]. You only need to check values of i less than the current value of RegionsUsed. If it is, you know the triggering unit stepped on Units[i] and you can do what you like
UH OH!!
you need a separate region for each potential simultaeneously-existing trap, so obviously this won't work for an arbitrary number of traps. you can theoretically have 8192 regions in a big array but uh, you probably don't want to manually create 8192 regions, assign them to the array, and add an event with them... SO You can either limit the number of traps somehow, or destroy old traps if there's too many, or whatnot. if traps can be destroyed, you need to do some extra stuff too. you can keep a boolean array of IsRegionUsed[] in this case instead of using a RegionsUsed variable. When a trap is created, loop through to find the first unused region and use that. When it's destroyed, loop through the units array to find the index and set IsRegionUsed[i] to false. blah blah blah
THE OTHER METHOD :(
this works for an arbitrary number of traps but it's less straightforward. you need to create a trigger with no events as the "stepped on a trap" trigger. when a trap is created, you dynamically add a new event to the trigger. this gets around the problem mentioned earlier. you can only dynamically add events with custom script. for unit enters range of unit, the script you need is TriggerAddEventUnitRange(gt_NameOfYourTrigger, null, TRAP_UNIT, RANGE, true); Fill in the capitals with whatever. The trap unit will be Created Unit or some local variable or whatever, hit Ctrl+D to look at things and figure out what you need. Now you've got a trigger that, although it has no events, will fire whenever a unit enters range of one of your created traps. Triggering Unit will give you the unit that stepped on the trap. The problem now is that you don't know which trap was stepped on. You gotta come up with a way to get round this. Maybe check every trap on the map and see if the triggering unit is close enough to it; alternatively, you could duplicate the entire system for each distinct type of trap if knowing the type is enough.
WARNING I haven't actually tried this method but I'm pretty sure it should work, and it worked in war3. probably gonna change raynor party to use this sometime
i'm pretty much rambling here and it's a rough outline but hopefully you can figure out a decent system
EDIT i've been told there might actually be custom script for programatically creating regions at run-time which would simplify the first method a lot. haven't looked to see what it is. was possible in war3 but first I looked star2 stored regions as XML, but someone said only the editor uses that
0
This might be a better method anyway; there seems to be an "Effect Used" event and a corresponding "Triggering Effect Unit" function which I've not tested but maybe they work like you want. The event doesn't have grammar text and has a mysterious integer parameter though so maybe it's not yet implemented or who knows
I always end up doing things the hard way but by jove does it work
0
@FIRETRUCKEU:
EventUnitProgressUnit()
0
ok looks like I was PMed to this thread cause I did something similar in raynor party
there's no easy way to do it that I know of, with triggers anyway - maybe effects or behaviours in the data editor can alter unit facing like that? I've not looked. if it's possible, you can then use a behaviour with a periodic search area effect to grab units who come close and set their facing
as you've discovered, you can't use the unit enters range of unit event as-is, because trigger events aren't dynamic like that: the event is "added" to the trigger on map initialization and the parameters evaluated there-and-then as with any other function, so if you try to use a variable there you'll just end up with whatever the initial value of the variable is as the unit
but there are some more complicated ways
the method I use in raynor party is pretty good, but it can only support a finite number of trap units at once. if the players can potentially create an unlimited number of traps you'll run into additional complications. the general idea is we pre-make a bunch of regions and move them during the game play when traps are created, and then use unit enters region on all these regions
SO!!
create a bunch of regions big enough to cover the trap unit-type anywhere on the map, call them TrapRegion00 to TrapRegion99 or whatever. you need enough regions to have one for every trap that can exist simultaeneously. make a region array variable with enough entries and set each entry to one of these regions (on map initialization). so Regions[0] = TrapRegion00, Regions[1] = TrapRegion01, and so on. Make a trigger and add a "unit enters region" event for all of these regions. You gotta do most of this manually so it's a giant pain in the arse if you need a lot of simultaeneous traps
THEN!!
You also need a unit array variable of the same size as the regions array, call it Units. Have an integer variable like RegionsUsed, initially zero. Whenever someone creates a trap, move Regions[RegionsUsed] to the position of the trap, set Units[RegionsUsed] to the trap unit and increment RegionsUsed. Then in the trigger with all the "enters region" events, loop through the regions array using some index variable i and check whether the triggering region is equal to Regions[i]. You only need to check values of i less than the current value of RegionsUsed. If it is, you know the triggering unit stepped on Units[i] and you can do what you like
UH OH!!
you need a separate region for each potential simultaeneously-existing trap, so obviously this won't work for an arbitrary number of traps. you can theoretically have 8192 regions in a big array but uh, you probably don't want to manually create 8192 regions, assign them to the array, and add an event with them... SO You can either limit the number of traps somehow, or destroy old traps if there's too many, or whatnot. if traps can be destroyed, you need to do some extra stuff too. you can keep a boolean array of IsRegionUsed[] in this case instead of using a RegionsUsed variable. When a trap is created, loop through to find the first unused region and use that. When it's destroyed, loop through the units array to find the index and set IsRegionUsed[i] to false. blah blah blah
THE OTHER METHOD :(
this works for an arbitrary number of traps but it's less straightforward. you need to create a trigger with no events as the "stepped on a trap" trigger. when a trap is created, you dynamically add a new event to the trigger. this gets around the problem mentioned earlier. you can only dynamically add events with custom script. for unit enters range of unit, the script you need is TriggerAddEventUnitRange(gt_NameOfYourTrigger, null, TRAP_UNIT, RANGE, true); Fill in the capitals with whatever. The trap unit will be Created Unit or some local variable or whatever, hit Ctrl+D to look at things and figure out what you need. Now you've got a trigger that, although it has no events, will fire whenever a unit enters range of one of your created traps. Triggering Unit will give you the unit that stepped on the trap. The problem now is that you don't know which trap was stepped on. You gotta come up with a way to get round this. Maybe check every trap on the map and see if the triggering unit is close enough to it; alternatively, you could duplicate the entire system for each distinct type of trap if knowing the type is enough.
WARNING I haven't actually tried this method but I'm pretty sure it should work, and it worked in war3. probably gonna change raynor party to use this sometime
i'm pretty much rambling here and it's a rough outline but hopefully you can figure out a decent system
EDIT i've been told there might actually be custom script for programatically creating regions at run-time which would simplify the first method a lot. haven't looked to see what it is. was possible in war3 but first I looked star2 stored regions as XML, but someone said only the editor uses that