• 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] Get Entered Region?

Status
Not open for further replies.
Level 16
Joined
Oct 12, 2008
Messages
1,570
Hello people,,

Is there any way of checking Which region is entered?
I got a trigger that uses (now only 15 but is going to use) about 500 events (whenever you enter a house, but there are loads of houses over the map)
Is there any way of checking which region was entered? Without using a variable array that i have to set manually, cause i have done that so far, but it is annoying -.-

Anyone knows? Jass or GUI, doesnt matter
Thanks!:grin:

-Yixx,,-
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Yeah but i mean:
I got a trigger that has 2 events(for example):
  • EnterHouse
    • Events
      • Unit - Unit enters House1
      • Unit - Unit enters House2
    • Conditions
    • Actions
      • My actions
How do i know which region it entered? Cause if it entered House1 i need to do some actions, if House2 it needs to do other actions
Any way? Jass is also accepted, Even a long long code, as long as there is an explanation how to use,,
 
Level 15
Joined
Aug 18, 2007
Messages
1,390
I think he understands, but sadl, there aint much 8of a way out.

Unless you could do a "pick every unit in region" and then if the picked unit was the triggering unit, you would know wich region he entered.

  • EnterHouse
  • Events
    • Unit - Unit enters House1
    • Unit - Unit enters House2
  • Conditions
  • Actions
    • For each interger (A) from 1 to (House_count) do actions:
      • Actions - loop
        • Unit Group - Pick every unit in (House_entrance(For loop integer A)
          • Actions - Loop
            • If / then / else - If (picked unit) equal to (triggering unit)
              • Then - actions
                • Unit - Move triggering unit instantly to center of (House_Arrival(For loop interger a)
                • Else - actions
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Well, in fact, i used that sort of trigger already, but i will get really tired of setting about 500 region variables,, so i thought maybe some other way,,
But as you guys say, not possible,,
Thanks anywayz,,
 
Level 8
Joined
Aug 6, 2008
Messages
451
JASS:
constant native GetTriggeringRegion takes nothing returns region

I found this one. I havent really used regions, so I dont know if it is rect what you need or a region, but I hope this helps.
 
Level 2
Joined
Feb 22, 2009
Messages
24
There is a little trick to get the coordinates faster: get jasscraft, or any programm where you can open/extract the .j file out of your map...

There the coordinates are listed for the globals ... helps a bit with many regions (copy-paste)

The problem is:
the corespondending event to GetTriggeringRegion() is: EVENT_GAME_ENTER_REGION
but you usually dont use that event, but call TriggerRegisterEnterRectSimple( trigger, region )

-> you only get the unit of that event... and there is no real (Is that the event rect)-function


I actually uses this solution: But u need all regions in an array!

I maybe public the full code of the triggers later... actually working on them

JASS:
  local integer i = 0
  local integer triggeringRectId = 0
  local unit triggeringUnit = GetTriggerUnit()

  //Wait untill unit is really in - Bugs without, when entering from top...no clue why ;)
  call TriggerSleepAction(GetUnitMoveSpeed(triggeringUnit)/2000)

  //Get triggeringRectId
  set i = 0
  loop  
    exitwhen i>3 
      if ([B]RectContainsUnit[/B](udg_zRegion[i],triggeringUnit)) then
        set triggeringRectId = i
      endif
    set i = i+1
  endloop
 
Level 2
Joined
Feb 22, 2009
Messages
24
Basically i haven't found any direct solution to get the region entered.

Problem:
That what in the World Editor is a region is in the Jass code a rect. They check if a unit enters a rect, they check if the unit is in the rect! That is why there are no jass functions for eventhanling a region.

The funtion the WE uses for "unit enters region" is:
JASS:
function TriggerRegisterEnterRegionSimple takes trigger trig, region whichRegion returns event
    return TriggerRegisterEnterRegion(trig, whichRegion, null)
endfunction
The WE registers a region...dont know why he can, cause the variable is as rect defined...

As far as i have seen the regions (in jass) are collection of many rects...which may can be used for some purposes, but im not that informed about that. There are some functions for that:
JASS:
native RegionAddRect            takes region whichRegion, rect r returns nothing
native RegionClearRect          takes region whichRegion, rect r returns nothing

native RegionAddCell           takes region whichRegion, real x, real y returns nothing
native RegionClearCell         takes region whichRegion, real x, real y returns nothing

native IsUnitInRegion               takes region whichRegion, unit whichUnit returns boolean
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
I think i got a better solution =)
What i need it for:
When you enter a house, i need to know which house, so you dont get in one house, and exit some other,,
I thought: Set it into a variable and move it to that region when exiting,,
But why dont i set the position of the unit in a variable and move it to that point when exiting? =D,,
Well, i thank you all for replying!
+rep!:grin:

Still too bad there is no 'GetTriggeringRect' =(
 
Status
Not open for further replies.
Top