Detect waygate ability and apply teleport effect using triggers

Not a fully working solution, but hopefully looking at what I've tried might help.

AFAIK there is no way to directly detect the Waygate ability being used.
Here's a set of triggers that uses regions and unit groups to monitor for units teleporting between waygate regions. It feels a little inelegant but it's what I was able to come up with.

When a unit enters a waygate region, it's added to a unitgroup for that region. When it leaves the region, it remains in the group for a short delay before being removed. If the unit entering a region is, at the moment of entry, a member of one of these buffered unit groups, then the trigger can assume it must have teleported via the waygate because there's no practical way it could have moved that far so quickly.

For ease of debugging, I made it so that a different effect plays at the two locations. Thunderclap should play at the position from which the teleport is leaving, and Holy Light should play on the unit at its destination. For some reason, Holy Light only works in one direction of travel. Absolutely no idea what's wrong with it.

  • EnterGate1
    • Events
      • Unit - A unit enters Gate1 <gen>
    • Conditions
    • Actions
      • Game - Display to (All players) for 10.00 seconds the text: Entered Gate1
      • -------- unit can only practically be in a group if it was in the other waygate region within the last 0.1 seconds --------
      • -------- nothing can walk that fast, so we use this to guess that the unit teleported via waygate --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is in grp_array_waygate[2]) Equal to True
        • Then - Actions
          • Game - Display to (All players) for 10.00 seconds the text: Gate1 FX
          • Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
      • Unit Group - Add (Triggering unit) to grp_array_waygate[1]
  • LeaveGate1
    • Events
      • Unit - A unit leaves Gate1 <gen>
    • Conditions
    • Actions
      • -------- tiny wait to ensure the unit has time to complete teleportation, if it is indeed teleporting --------
      • Wait 0.01 seconds
      • -------- check if leaving unit is near this waygate's destination (in this case Gate2) --------
      • -------- if so, we assume the unit teleported via waygate --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Gate2 <gen> contains (Triggering unit)) Equal to True
        • Then - Actions
          • Set loc_temp = (Center of Gate1 <gen>)
          • Special Effect - Create a special effect at loc_temp using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_loc_temp)
        • Else - Actions
      • -------- unit remains buffered in group for a moment so that entry trigger on the other end... --------
      • -------- can infer whether the entering unit teleported or not --------
      • Wait 0.40 seconds
      • Game - Display to (All players) for 10.00 seconds the text: Removed from Grp1
      • Unit Group - Remove (Triggering unit) from grp_array_waygate[1]
Near-identical triggers exist for the inverse direction of travel.
The regions are set up as pictured, each one centered on the position of one of the two Waygates.
Test map file attached.
WaygateRegions.jpg


I hope this helps you figure this out, good luck! :wink:
 

Attachments

Back
Top