• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Region contains 2 hero doesn't recognize them

Level 12
Joined
Jul 5, 2014
Messages
551
There supposed to be a teleportation if two heroes are in the particular region but nothing happens. "SingleUsePoint" is the target location which runs as soon as the map starts.

  • Escape Teleport2
    • Events
      • Unit - A unit enters Wrong Destination2 <gen>
    • Conditions
      • ((Entering unit) is A Hero) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (Wrong Destination2 <gen> contains Hero1) Equal to True
              • (Wrong Destination2 <gen> contains Hero2) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Camera - Pan camera for Player 2 (Blue) to SingleUsePoint1 over 0.00 seconds
          • Special Effect - Create a special effect at SingleUsePoint1 using Abilities\Spells\Human\MassTeleport\MassTeleportCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 2 (Blue)) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Picked unit)) Not equal to Arcane Box
                  • (Unit-type of (Picked unit)) Not equal to Defend must be inactive
                  • (Unit-type of (Picked unit)) Not equal to Night time
                • Then - Actions
                  • Unit - Move (Picked unit) instantly to SingleUsePoint1
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Because of some nuance about the edges of rects, unit coordinates, and collision size it's possible that a unit entering a region from an edge will subsequently fail a 'region contains that unit' check. There are two options:
  • Build better logic into your check so it only checks the other unit to see that it's also in the region and doesn't check the unit that you know just entered.
  • Delay the trigger's execution with a wait.
Solution 2 is obviously simpler: put a 0 second wait as the first action in the trigger and make sure it doesn't mess up any event responses the trigger uses. Solution 1 looks like this:
  • If (All conditions are true) then do (Then actions) else do (Else actions)
    • If - Conditions
      • Or - Either Condition is true
        • Conditions
          • ((Triggering Unit) equal to Hero1) AND ((Wrong Destination2 <gen> contains Hero2) equal to True) //can use multi-line AND if you want
          • ((Triggering Unit) equal to Hero2) AND ((Wrong Destination2 <gen> contains Hero1) equal to True)
 
Level 12
Joined
Jul 5, 2014
Messages
551
Because of some nuance about the edges of rects, unit coordinates, and collision size it's possible that a unit entering a region from an edge will subsequently fail a 'region contains that unit' check. There are two options:
  • Build better logic into your check so it only checks the other unit to see that it's also in the region and doesn't check the unit that you know just entered.
  • Delay the trigger's execution with a wait.
Solution 2 is obviously simpler: put a 0 second wait as the first action in the trigger and make sure it doesn't mess up any event responses the trigger uses. Solution 1 looks like this:
  • If (All conditions are true) then do (Then actions) else do (Else actions)
    • If - Conditions
      • Or - Either Condition is true
        • Conditions
          • ((Triggering Unit) equal to Hero1) AND ((Wrong Destination2 <gen> contains Hero2) equal to True) //can use multi-line AND if you want
          • ((Triggering Unit) equal to Hero2) AND ((Wrong Destination2 <gen> contains Hero1) equal to True)
Thanks, solution 1 solved the issue. Kinda strange to me though because "entering unit is a hero" should have achieved a similar result.
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
No.

Entering Unit returns fine so the check to see that the unit that ran the event is a hero still proceeds properly. The issue is that the unit's coordinate origin is not within the edges of the region because the units collision size edge is what trips the Enters event. So when you check if it's in the region it says "no".
 
Level 12
Joined
Jul 5, 2014
Messages
551
No.

Entering Unit returns fine so the check to see that the unit that ran the event is a hero still proceeds properly. The issue is that the unit's coordinate origin is not within the edges of the region because the units collision size edge is what trips the Enters event. So when you check if it's in the region it says "no".
So, you're saying that "entering region" is not "region contains"?
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Yes, the enter region event fires before the unit's origin (the center of where the unit is located) is actually inside the region. The Region Contains... check to see if a unit is inside the region will then fail because it only checks the coordinates of the unit's origin, which as established aren't inside the region when the event fires.
 
Level 12
Joined
Jul 5, 2014
Messages
551
Yes, the enter region event fires before the unit's origin (the center of where the unit is located) is actually inside the region. The Region Contains... check to see if a unit is inside the region will then fail because it only checks the coordinates of the unit's origin, which as established aren't inside the region when the event fires.
Gotcha. Kinda wacky, one would think entering the region means they're inside, not just caressing it from a distance.
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
As I said it's a nuance with unit collision sizes. Collision size determines things like a unit being 'in' or 'out' of a default spell AoE (like Silence): if the edge of the unit's collision circle overlaps the targeted area it will be hit by the spell even if the origin is outside the area (shown by the target being highlighted in the pre-cast ui). A different unit with a very small collision size located at the same XY coordinates would not be hit by the spell.

Custom spells that use an AoE search also would not find such units to be inside their search area because GroupEnumUnitsInRange ("units within RANGE of POINT" in GUI) also works the same way and doesn't consider collision size. For this reason many manual AoE-search and range-check functions/systems/code increases its search radius by 1/2 of the maximum collision size of any unit on the map, in order to mimic Wc3's actual spellcast behavior.
 
Top