• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

GetTriggeringRegion for Unit-A unit enters Region

Status
Not open for further replies.
Level 8
Joined
Jan 8, 2010
Messages
493
what i need is basically this, a unit enters a region, and a trigger that saves the region being entered to to a variable, and spawn some units there. i searched the forum and found something like this:

  • Custom script: set udg_RegionSpawn=GetTriggeringRegion()
i tried it, but when i save it (i used JNGP) it says that it is a syntax error.. or something like that. i'm not at home, so i'm not sure about the error, but i'm very sure that it doesn't save so it must be incorrect.
i also tried using "==" and it is also an error.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
The issue is that rects are actually called regions in GUI.

GetTriggeringRegion is a valid function and it works.

However, your variable is actually a rect, not a region. There is not region type variables in GUI.

A rect (rectangle) is an area defined by four points. A region can consist of one or more rects.

You could use locals,

Custom script: local region r = GetTriggerRegion

However I don't know what you need the region for so I can't say more.
 
because GUI regions are RECTS in JASS, meaning since you udg_RegionSpawn is a GUI region, its actually a rect in jass so you cannot equate it to a region...

Oh, Maker posted earlier...

So to equate the TriggeringRegion into the udg_Variable, you need to create a rect from the region (which is what GUI region actions do)
 
Level 8
Joined
Oct 3, 2008
Messages
367
This is the kind of thing that rectwraps was invented for. Unfortunately it's a vJass system and not suited at all for GUI usage.

If you want to stick to GUI I guess you could attach the rect to the region with a hashtable. Is that even possible in GUI? Does doing anything with hashtable rects still crash the editor? So many limitations.
 
Level 8
Joined
Jan 8, 2010
Messages
493
i was just searching the functions list at JNGP and it has Rects

@mckill2009
what's going to be in the parameter of YOURRECT? :eek:

@Maker
this is a trigger that i'll be using it for.
  • Events
    • Unit - A unit enters Region01
    • Unit - A unit enters Region02
    • Unit - A unit enters Region03
  • .
  • .
  • .
    • Actions
      • Set Region = GetTriggeringRegion <-- it is supposed to set the triggering region to a variable
      • For each (Integer A) from 1 to (Random number between 3 and 5), do (Actions)
        • Loop - Actions
          • Set Point = (Random point in Region)
          • Unit - Create 1 Kobold for Neutral Hostile at Point facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_Point)
 
Level 8
Joined
Jan 8, 2010
Messages
493
at this moment they are separated into different triggers (26 in all XD), then found that GetTriggeringRegion function while browsing functions lists (also found SaveGameCache there, which i intended to ask here too but worked fine anyways) and thought maybe it would work so i can have only 3 triggers for those 26 regions, since they basically spawn the same creeps.
 
you can do if-then-elses or a CS loop which will filter out in which rect the unit entered...

  • Custom script: if RectContainsUnit(udg_Region001, GetTriggerUnit()) then
  • Do actions here
  • Custom script: endif
but take note that RectContainsUnit is a BJ function which calls another BJ function...

you can also just save the Rects (your GUI regions) into a rect array, then just use a loop in order to minimize the code written...

  • Set Region[1] = Region001
  • blahblah
  • For each integer A from 1 to MaxRect do
    • Custom script: if RectContainsUnit(udg_Region[bj_forLoopAIndex], GetTriggerUnit()) then
    • Do actions here
    • Custom script: endif
but if you want efficiency, the BJ function which the RectContainsUnit BJ calls just checks if the unit's coordinates are within the bounds of the rect (just look it up on TESH)
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
The reason why I did "RegionAddRect", coz you really cant use the GUI region directly to jass...
The "TriggerRegisterEnterRegion" native is called from "TriggerRegisterEnterRectSimple"

which is in this form...
JASS:
local region rectRegion = CreateRegion()
call RegionAddRect(rectRegion, r)
return TriggerRegisterEnterRegion(trig, rectRegion, null)

region in GUI is rect in jass, like Maker said...
 
yeah, but what he needed was a way to filter out which rect the unit entered, which is doable even without using jass regions... anyway, I guess its already solved...

but ofc he can also use jass regions, and it will be better that way too coz it won't involve if-then elses to check which region the unit entered... but that would be either pure jass or lots of CS in GUI... which I don't think he likes to do...
 
Level 37
Joined
Mar 6, 2006
Messages
9,240

  • 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)
^Yeah, leaks Center of region


http://www.hiveworkshop.com/forums/pastebin.php?id=ik4af9
 
Status
Not open for further replies.
Top