• 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] Checking Region

Status
Not open for further replies.
Level 12
Joined
Aug 12, 2008
Messages
350
How do I check whether the region enters by a unit?
  • Group Changing
    • Events
      • Unit - A unit enters Point1 <gen>
      • Unit - A unit enters Point2 <gen>
      • Unit - A unit enters Point3 <gen>
      • Unit - A unit enters Point4 <gen>
    • Conditions
      • <<some condition>>
    • Actions
So, in this action, I want to check the region entered by the unit. If region enter by the unit is Point1, then I add this unit into unit group 1 whereby if the unit enter Point2, I add this unit into unit group 2 and so on.
I found only this condition: "All units are in region..." but don't have the condition when a single unit of the particular group enters a region.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
The solution ruleofiron99 gave you is a good one, but it can fail at times.

When "a unit enters region" event triggers, "unit is in region" can still return false.

Here's a system that sets the triggering region into a variable, just in case you need it:


  • Init Copy
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: local region r
      • -------- ---------------------------------------------- --------
      • Hashtable - Create a hashtable
      • Set RectHash = (Last created hashtable)
      • -------- ---------------------------------------------- --------
      • Set Trig = Enter Copy <gen>
      • -------- ---------------------------------------------- --------
      • Set RectEnter[0] = Region 003 <gen>
      • Set RectEnter[1] = Region 003 Copy <gen>
      • Set RectEnter[2] = Region 003 Copy 2 <gen>
      • -------- ---------------------------------------------- --------
      • For each (Integer A) from 0 to 2, do (Actions)
        • Loop - Actions
          • Custom script: set r = CreateRegion()
          • Custom script: call RegionAddRect(r, udg_RectEnter[bj_forLoopAIndex])
          • Custom script: call TriggerRegisterEnterRegion(udg_Trig, r, null)
          • Custom script: call SaveRectHandle(udg_RectHash , GetHandleId(r), 0, udg_RectEnter[bj_forLoopAIndex] )
      • -------- ---------------------------------------------- --------
      • Custom script: set r = null
  • Enter Copy
    • Events
    • Conditions
    • Actions
      • Custom script: set udg_Rect = LoadRectHandle(udg_RectHash , GetHandleId(GetTriggeringRegion()) , 0)
      • Special Effect - Create a special effect at (Center of Rect) using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
      • Special Effect - Destroy (Last created special effect)
 

Attachments

  • Enter_Region.w3x
    17.4 KB · Views: 58
Status
Not open for further replies.
Top