HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How do you set a point on a unit?

02-02-2006, 09:57 AM#1
Moss
Why can't you set a point to equal a unit variable?! How the heck are you supposed to prevent leaking if you have to say "Position of u" all the time instead of setting p = position of u and then removing p when you are done using it???

EDIT: Sorry, this problem isn't universal but I have seen it sometimes. It seems the problem I am actually having right now is centering a region on a point. It just stays where it was placed on the map for some reason.
02-02-2006, 10:08 AM#2
Naakaloh
You can't set a variable of one type to point to an object of a different type, unless it's a derived type, but inheritence only really applies to handles with Warcraft. When using JASS, the name for a point is a location. So you'll want to use RemoveLocation(location whichLocation).

Edit: I think you need to post your trigger/script to get help on that one.
02-02-2006, 11:43 AM#3
Ant
When you preplace a region on the map, the region stays there, you can't move it for most purposes. You have to set the region as a variable and redefine it everytime. Of course this means you have to remove it every time as well.

As far as I know at least.
02-02-2006, 01:23 PM#4
Vexorian
no no no.

First of all there are 2 things in wc3 editing world that are kind of different : rects and regions. I'd like to thank blizzard for this confusion.

regions: Can have any shape / have enter/leave events.
rects: They are always rectangular shaped, you can pick all the units in a rect.

Problem is that what world editor calls regions are actually rects.

When you use the event A unit enters a region . It in fact is a unit enters a rect, as I said rects don't have enter/leave events.

So what blizzard did was to make the event registeror create a new region then add the current points of the rect to that region .

Problem is that the new region is never saved into any variable so you don't have access to it.

When you move a rect, it will just move the rect. But the region that was created for the event will stay there. And that's the problem
02-03-2006, 07:25 PM#5
Moss
Thanks Vex. Still kinda confused, but I guess that is the point. But I guess whatever you are saying explains why I have a periodic trigger creating floating text at the center of the region which is centered on my hero and that works fine, but the "unit enters a region" event doesn't fire unless my hero is standing where the region/rect was preplaced. Actually I have a bunch of regions, one for each potential hero in the game and I have an if statement to detect if the region being entered is the one associated with the unit entering, like so:
Trigger:
Drop Reinforcements Copy
Collapse Events
Unit - A unit enters DZ1 <gen>
Unit - A unit enters DZ2 <gen>
Unit - A unit enters DZ3 <gen>
Unit - A unit enters DZ4 <gen>
Unit - A unit enters DZ5 <gen>
Unit - A unit enters DZ6 <gen>
Unit - A unit enters DZ7 <gen>
Unit - A unit enters DZ8 <gen>
Unit - A unit enters DZ9 <gen>
Unit - A unit enters DZ10 <gen>
Unit - A unit enters DZ11 <gen>
Unit - A unit enters DZ12 <gen>
Collapse Conditions
(Unit-type of (Triggering unit)) Equal to Drop Ship
Collapse Actions
Set i = (Player number of (Owner of (Triggering unit)))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(DropZone[i] contains (Triggering unit)) Equal to True
Collapse Then - Actions
-------- Do Stuff --------
Else - Actions

But the if statement seems to always evaluate true, no matter what region it is entering. Anyway, how should I do this? I just want a trigger that drops a bunch of reinforcements by the hero when the Drop Ship actually gets near the hero. The heroes aren't preplaced so I can't use the "within range" event.
02-03-2006, 09:03 PM#6
Anitarf
Sure you can use the within range event, you just have to add it to your trigger when you create your heroes, there's an action for adding events to triggers.
02-04-2006, 12:16 AM#7
Mystic Prophet
Well, if you want to use it. WEU has a convert region to rect function and vice versa which should allow you to access regions, but this is an advanced trigger and thus will make your map unopenable in normal WE.
02-04-2006, 05:57 AM#8
Moss
Wow, thanks Anitarf. I didn't realize you could do that because when you add that event the usual way you can only choose "No Unit" or a preplaced unit.
02-04-2006, 02:18 PM#9
Starcraftfreak
Just for reference, andvanced WEs like my UMSWE or Pitzers WEU fix the region/rect confusion. Additionally they add general region support (real regions) including the corresponding cleanup functions.

As always, using Blizzards crap to write clean scripts with proper cleanup is kinda hard.