Creating rect in front of unit

bowser499

Member
Reaction score
1
See the image.
0howtodo.jpg
 

skyblader

You're living only because it's illegal killing.
Reaction score
159
Note this works only if it's facing exactly 0, 90, 180 or 270 degrees, because you can't make a rectangular region diagonally. Let's say you want a region 200 distance towards the North of the unit, and the region size being 600 x 400. Simply set a point, which is the position of the unit offset by 600 towards 90 degrees. And create a region centered at the point set with length 600 and breadth 400.
 

bowser499

Member
Reaction score
1
I just want to put all enemies in front of unit in a group. Unit can face diagonally... =(
 

skyblader

You're living only because it's illegal killing.
Reaction score
159
Then you can't use regions. You'll need to pick units in range of the unit, and then change the facing angle. Let's say facing angle of unit is 200. Just set the angle from the unit to the picked unit and check if the angle is +50 -50.
 

Sajin

User title under construction.
Reaction score
56
like a region? or a visual thing?
I think for sure you'll need

Unit_Position - Point
x_Rect = Real
y_Rect = Real
y_RectOFFSET = Real
RECT = Region

Where
x_Rect is the width of the rectangle
y_Rect is the Height of the rectangle
y_RectOFFSET is y_Rect / 2
and RECT is your final region

and the trigger would be something like
(im excluding events / conditions)
Code:
Actions - 
   set Unit_Position = Position of Triggering Unit
   set x_Rect = 600
   set y_Rect = 300
   set y_RectOFFSET = y_Rect / 2
   Create Region at Unit_Position with size (x_Rect, y_Rect) offset by y_RectOFFSET towards Facing of Triggering Unit
   set Rect = Last Created Region


EDIT for unit group why not...
add UNIT_Group = Unitgroup variable

Code:
Actions - 
   set Unit_Position = Position of Triggering Unit
   set x_Rect = 600
   set y_Rect = 300
   set y_RectOFFSET = y_Rect / 2
   Create Region at Unit_Position with size (x_Rect, y_Rect) offset by y_RectOFFSET towards Facing of Triggering Unit
   set Rect = Last Created Region
   Pick all units in RECT and
        Actions:
            Add Picked Unit to UNIT_Group
            //
            // Do your actions and what not
            //
   call RemoveLocation (udg_Unit_Position)
   call DestroyGroup (udg_UNIT_Group)
   // the code to destroy regions?



Edit again: to Sky
you might be able to use them

you would just have to offset the region and it would look like this
Code:
SW------------S-----------SE
---------------------------
---------------------------
W--------------------------E
---------------------------
---------------------------
NW------------N------------NE


where the directions(SE, NW, Etc) is the facing angle of the unit
you would just need different offset values and a formula to calculate it
 

skyblader

You're living only because it's illegal killing.
Reaction score
159
You can't create diagonal regions as far as I know...
 

Sajin

User title under construction.
Reaction score
56
Locals can only be used in jass i believe :p so if you know it go for it ;)
 

skyblader

You're living only because it's illegal killing.
Reaction score
159
no you cant, but you can offset them to make it work i edited my post above to show

I saw it.. but... where's the O? And still I can't see how you can make a region in front of a unit diagonally, without the use of more than 1 region.
 

Sajin

User title under construction.
Reaction score
56
sorry i re re did it to show it better ^_^' but your not making a region diagonally, its still a square, its just off center from where he wants it

think of it as a coordinate plane
when the units facing north he wants the unit to be at 0,0 and the regions coordinates are (-3, 3)(-3, 0)(3, 3)(3, 0) making the square in front of him but say he faces north west. then the unit will be placed at (3, 0)
 

skyblader

You're living only because it's illegal killing.
Reaction score
159
Oh I get it. But it wouldn't be too accurate right? since it's like a diamond infront of the unit?
 

Sajin

User title under construction.
Reaction score
56
Probably not, especially not at angles other then 90, 180, etc But if hes determined to use regions then it is possible, This is one of the easier ways to detect damage to units only in front of the unit as well (i know its possible other ways but i've never bothered to try it)
 

bowser499

Member
Reaction score
1
I want to put the units in circle segment (a-45;a+45) where a is facing angle, or what angles shall I use?
 

skyblader

You're living only because it's illegal killing.
Reaction score
159
It's up to you really, depending on how wide infront the unit you want targeted. a-180;a+180 would make something like a rectangle infront of the unit. (Actually a semicircle)
 

Sajin

User title under construction.
Reaction score
56
if you want a circle then use pick all units within range and create a dummy in front of the unit by alittle shorter then the range of the selection
for example
spell pick all enemies 500 range in front of caster

Code:
E
  unit starts effect of ability
C
  Ability = your ability
A
  Create 1 castdummy at position of caster offset by 480 towards facing angle of casting unit
  pick all units within 500 of last created unit
    cause last created unit to damage picked unit

makeing it shorter reduces the chances of creating and blind spots where the circle arches away from the casting unit
 

Sajin

User title under construction.
Reaction score
56
The absolute best you can get in GUI (easily anyhow) is something close to this
18967770.jpg


Uploaded with ImageShack.us
Keep in mind, to do it like this, first you must create a dummy unit 500 away and then pick the enemy units within 500 of it and add those to a unit group. THEN you need to also pick the units within 500 of your caster And create a new unit group with the units that are in both of the created unit groups, if there only in 1 then they get booted
 

xPass

All aboard the xPass Express!
Reaction score
26
Wait guys wait, actually you all missed one thing. Do you by chance know of an action that goes like this?

Region - Move Region

:D Never tried before, but I think it'll work...
 

bowser499

Member
Reaction score
1
I've done this with dummy (rep to Sajin) but another solution exist.
Just check angle between points < facing + 50. or > facing - 50.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top