HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Region Offsets

03-20-2008, 01:36 PM#1
BoO-
Collapse JASS:
________________
|               |
|               |
|               |
|               |
|               |
|               | 
|               |
|               |
|_______________|
Thats about the size of the region I am using (in-game).
What I want to do, is create a gravestone around a unit so they can't move much, but I don't know much about offsets. I just played around with them and I am pretty sure it can make it so a gravestone spawns around all of the edges of that region. I have to go to sleep now so I'll check this in the morning.

If anyone knows how I can do this, please post.

Thanks.
03-20-2008, 08:50 PM#2
Castlemaster
Offsets require a grasp of cartesian coordinate system. lets say you wanted the box dimensions to be 500 x 500. This essentially means that the north edge gravestones all have the same Y coordinates, so you just need to find the Y coordinate of the center.

Take the Y coordinate of the center and add (or offset if you will) by 250. All gravestones on the north side will have this Y coordinate, but differing X coordinates. So if I created a gravestone at every 50 distance, I would place them at origin location offset by (-250,+250), (-200,+250), (-150,+250), (-100,+250)...(0,+250), (+50,+250)...and (+250,+250). For the south edge I would repeat this with the X offset, but instead of offsetting the Y by +250, I would offset it by -250.

For the east and west edges, the X remains the same while the Y changes. So in this case, the offset would look like this (+250,-250), (+250,-200), (+250,-150)...(+250,0), (+250,+50), (+250,+100)...(+250,+250). Once the opposite side would use -250 for the X offset instead of +250.

Hopefully that gives you an idea of what you were asking.
03-20-2008, 10:59 PM#3
BoO-
That gives me a better idea, yes. But how do I find out exactly how big the region is?
03-20-2008, 11:32 PM#4
Salbrismind
Quote:
Originally Posted by BoO-
That gives me a better idea, yes. But how do I find out exactly how big the region is?

In gui you can set a real variable to the proper values, min and max of both x and y. Which will give you what you need.
03-21-2008, 01:12 AM#5
BoO-
Ok I made a region variable, I have this code:
Trigger:
Enprisonment
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Enprisonment
Collapse Actions
Set RVariable = (Region centered at (Position of (Target unit of ability being cast)) with size (100.00, 100.00))
Unit - Create 1 Gravestone for Player 11 (Dark Green) at ((Center of RVariable) offset by (-100.00, 100.00)) facing Default building facing degrees
Unit - Create 1 Gravestone for Player 11 (Dark Green) at ((Center of RVariable) offset by (-50.00, 100.00)) facing Default building facing degrees
Unit - Create 1 Gravestone for Player 11 (Dark Green) at ((Center of RVariable) offset by (0.00, 100.00)) facing Default building facing degrees
Unit - Create 1 Gravestone for Player 11 (Dark Green) at ((Center of RVariable) offset by (50.00, 100.00)) facing Default building facing degrees
Unit - Create 1 Gravestone for Player 11 (Dark Green) at ((Center of RVariable) offset by (100.00, 100.00)) facing Default building facing degrees

And it makes them like this:
Collapse JASS:
           +
+ +       
      + +
     X
Where X is the target, and the +'s are the gravestones.
Why is that??
03-21-2008, 03:50 AM#6
Castlemaster
I'm not sure why it's doing that, but instead of using regions, try using locations. If you are needing regions to know when units are entering a location, you can just as easily use coordinates

just set RVariable = Target Point of Ability Being Cast and use that as your location instead of center of region.
03-21-2008, 04:28 AM#7
BoO-
I changed the variable to a point, and it does the same thing..
03-21-2008, 08:39 AM#8
Spec
Quote:
Originally Posted by BoO-
Where X is the target, and the +'s are the gravestones.
Why is that??
It happens due to collision of units. Just set physical size of graveyard unit to 0 (field "collision" in OE) and enjoy.
03-21-2008, 10:08 AM#9
BoO-
Trigger:
Enprisonment
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Enprisonment
Collapse Actions
Set RPoint = (Position of (Target unit of ability being cast))
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (-100.00, 100.00)) facing Default building facing degrees
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (-50.00, 100.00)) facing Default building facing degrees
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (0.00, 100.00)) facing Default building facing degrees
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (50.00, 100.00)) facing Default building facing degrees
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (100.00, 100.00)) facing Default building facing degrees
-------- Break --------
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (100.00, 50.00)) facing Default building facing degrees
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (100.00, 0.00)) facing Default building facing degrees
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (100.00, -50.00)) facing Default building facing degrees
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (100.00, -100.00)) facing Default building facing degrees
-------- Break --------
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (50.00, -100.00)) facing Default building facing degrees
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (0.00, -100.00)) facing Default building facing degrees
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (-50.00, -100.00)) facing Default building facing degrees
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (-100.00, -100.00)) facing Default building facing degrees
-------- Break --------
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (-100.00, -50.00)) facing Default building facing degrees
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (-100.00, 0.00)) facing Default building facing degrees
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (-100.00, 50.00)) facing Default building facing degrees
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (-100.00, 100.00)) facing Default building facing degrees

K so thats what I got, and its massive, it lags for about 2 seconds when cast.


Two problems:
The lag, I need to make it so it doesn't lag as much, how can I do this?

I set the spell so I can cast it on my allies, it stuns them, and I cannot walk through the gravestones.
But when I cast it on an enemy, and they attack me, and I run away, they can run right through them and get me... How can I fix these problems?

Thank you.
03-22-2008, 08:03 AM#10
Pyrogasm
Loops are your friends:
Trigger:
Enprisonment
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Enprisonment
Collapse Actions
Set RPoint = (Position of (Target unit of ability being cast))
Collapse For each (Integer A) from 1 to 2 do (Actions)
Collapse Loop - Actions
If ((Integer A) equal to 1) then do (Set Offset = 100.00) else do (Set Offset = -100.00)
Collapse For each (Integer B) from 1 to 4 do (Actions)
Collapse Loop - Actions
Set TempPoint = (RPoint offset by ((-150.00 + (Real(Integer B) x 50.00)), Offset))
Unit - Create 1 Gravestone for Player 11 (Dark Green) at TempPoint facing Default building facing degrees
Custom script: call RemoveLocation(udg_TempPoint)
Collapse For each (Integer A) from 1 to 2 do (Actions)
Collapse Loop - Actions
If ((Integer A) equal to 1) then do (Set Offset = 100.00) else do (Set Offset = -100.00)
Collapse For each (Integer B) from 1 to 4 do (Actions)
Collapse Loop - Actions
Set TempPoint = (RPoint offset by (Offset, (-150.00 + (Real(Integer B) x 50.00))))
Unit - Create 1 Gravestone for Player 11 (Dark Green) at TempPoint facing Default building facing degrees
Custom script: call RemoveLocation(udg_TempPoint)
Custom script: call RemoveLocation(udg_RPoint)
That also fixes your location (point) leaks. "TempPoint" is a point-type variable; "Offset" is a real-type variable.

The problem with running through them is that in order to create the units at the proper spot the units need to not have collision, but then they can be walked through. The only solution is to give the gravestones back their collision and then use some Custom Scripts:
Trigger:
Enprisonment
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Enprisonment
Collapse Actions
Set RPoint = (Position of (Target unit of ability being cast))
Collapse For each (Integer A) from 1 to 2 do (Actions)
Collapse Loop - Actions
If ((Integer A) equal to 1) then do (Set Offset = 100.00) else do (Set Offset = -100.00)
Collapse For each (Integer B) from 1 to 4 do (Actions)
Collapse Loop - Actions
Set TempPoint = (RPoint offset by ((-150.00 + (Real(Integer B) x 50.00)), Offset))
Unit - Create 1 Gravestone for Player 11 (Dark Green) at TempPoint facing Default building facing degrees
Custom script: call SetUnitX(bj_lastCreatedUnit, GetLocationX(udg_TempPoint))
Custom script: call SetUnitY(bj_lastCreatedUnit, GetLocationY(udg_TempPoint))
Custom script: call RemoveLocation(udg_TempPoint)
Collapse For each (Integer A) from 1 to 2 do (Actions)
Collapse Loop - Actions
If ((Integer A) equal to 1) then do (Set Offset = 100.00) else do (Set Offset = -100.00)
Collapse For each (Integer B) from 1 to 4 do (Actions)
Collapse Loop - Actions
Set TempPoint = (RPoint offset by (Offset, (-150.00 + (Real(Integer B) x 50.00))))
Unit - Create 1 Gravestone for Player 11 (Dark Green) at TempPoint facing Default building facing degrees
Custom script: call SetUnitX(bj_lastCreatedUnit, GetLocationX(udg_TempPoint))
Custom script: call SetUnitY(bj_lastCreatedUnit, GetLocationY(udg_TempPoint))
Custom script: call RemoveLocation(udg_TempPoint)
Custom script: call RemoveLocation(udg_RPoint)
03-22-2008, 04:37 PM#11
Salbrismind
Your lag is the unfortunate side effect of using gui. It is inefficient if you haven't already try learning jass because you can do this very easy, organized and with little to no delay.

Use Pyro's answer it should work!
03-23-2008, 12:36 AM#12
BoO-
I get this error with 'jasshelper':
Cannot convert rect to location

On this line:
call SetUnitX(bj_lastCreatedUnit , GetLocationX(udg_TempPoint))

here is my code...:
Trigger:
Enprisonment
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Enprisonment
Collapse Actions
Set RPoint = (Position of (Target unit of ability being cast))
Collapse For each (Integer A) from 1 to 2, do (Actions)
Collapse Loop - Actions
If ((Integer A) Equal to 1) then do (Set Offset = 100.00) else do (Set Offset = -100.00)
Collapse For each (Integer B) from 1 to 4, do (Actions)
Collapse Loop - Actions
Set TempPoint = (RVariable offset by ((-150.00 + ((Real((Integer B))) x 50.00)), Offset))
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (-100.00, 100.00)) facing Default building facing degrees
Custom script: call SetUnitX(bj_lastCreatedUnit, GetLocationX(udg_TempPoint))
Custom script: call SetUnitY(bj_lastCreatedUnit, GetLocationY(udg_TempPoint))
Custom script: call RemoveLocation(udg_TempPoint)
Collapse For each (Integer A) from 1 to 2, do (Actions)
Collapse Loop - Actions
If ((Integer A) Equal to 1) then do (Set Offset = 100.00) else do (Set Offset = -100.00)
Collapse For each (Integer B) from 1 to 4, do (Actions)
Collapse Loop - Actions
Set TempPoint = (RVariable offset by ((-150.00 + ((Real((Integer B))) x 50.00)), Offset))
Unit - Create 1 Gravestone for Player 11 (Dark Green) at (RPoint offset by (-100.00, 100.00)) facing Default building facing degrees
Custom script: call SetUnitX(bj_lastCreatedUnit, GetLocationX(udg_TempPoint))
Custom script: call SetUnitY(bj_lastCreatedUnit, GetLocationY(udg_TempPoint))
Custom script: call RemoveLocation(udg_TempPoint)
Custom script: call RemoveLocation(udg_RPoint)
03-23-2008, 05:06 AM#13
Pyrogasm
That's an odd error.... I can't see why that would occur. Unless "TempPoint" isn't defined as a point variable in the variable editor. I think this line needs to be changed:
Trigger:
Set TempPoint = (RVariable offset by ((-150.00 + ((Real((Integer B))) x 50.00)), Offset))
To this:
Trigger:
Set TempPoint = (RPoint offset by ((-150.00 + ((Real((Integer B))) x 50.00)), Offset))

Also, you've mixed up a line; your line for creating the GreaveStones should look like this:
Trigger:
Unit - Create 1 Gravestone for Player 11 (Dark Green) at TempPoint facing Default building facing degrees
03-23-2008, 07:10 AM#14
BoO-
Ugh ok I changed some confusing variables; It semi-works. It creates 3 at the location but they are a bit messed up, and then it makes the rest at the center of the map..
Trigger:
Enprisonment
Collapse Events
Unit - A unit Starts the effect of an ability
Collapse Conditions
(Ability being cast) Equal to Enprisonment
Collapse Actions
Set RPoint = (Position of (Target unit of ability being cast))
Collapse For each (Integer A) from 1 to 2, do (Actions)
Collapse Loop - Actions
If ((Integer A) Equal to 1) then do (Set Offset = 100.00) else do (Set Offset = -100.00)
Collapse For each (Integer B) from 1 to 4, do (Actions)
Collapse Loop - Actions
Set TPoint = (RPoint offset by ((-150.00 + ((Real((Integer B))) x 50.00)), Offset))
Unit - Create 1 Gravestone for Player 11 (Dark Green) at TPoint facing Default building facing degrees
Custom script: call SetUnitX(bj_lastCreatedUnit, GetLocationX(udg_TPoint))
Custom script: call SetUnitY(bj_lastCreatedUnit, GetLocationY(udg_TPoint))
Custom script: call RemoveLocation(udg_TPoint)
Collapse For each (Integer A) from 1 to 2, do (Actions)
Collapse Loop - Actions
If ((Integer A) Equal to 1) then do (Set Offset = 100.00) else do (Set Offset = -100.00)
Collapse For each (Integer B) from 1 to 4, do (Actions)
Collapse Loop - Actions
Set TPoint = (RPoint offset by ((-150.00 + ((Real((Integer B))) x 50.00)), Offset))
Unit - Create 1 Gravestone for Player 11 (Dark Green) at TPoint facing Default building facing degrees
Custom script: call SetUnitX(bj_lastCreatedUnit, GetLocationX(udg_TPoint))
Custom script: call SetUnitY(bj_lastCreatedUnit, GetLocationY(udg_TPoint))
Custom script: call RemoveLocation(udg_TPoint)
Custom script: call RemoveLocation(udg_RPoint)
03-24-2008, 02:30 AM#15
Pyrogasm
This line should be the last of the trigger, not inside the loops:
Trigger:
Custom script: call RemoveLocation(udg_RPoint)