| 06-28-2004, 07:59 PM | #1 |
is there any way to get the rect (global) a unit stands in, like if a unit is ordered to cast an ability, then you wanna know which region the unit is in. ( without using a loop ) to get a unit, you can use, get random unit in unitgroup, and then use a matching condition to get that specific unit your after, I would need a function like that, but to get the random rect matching blabla. |
| 06-28-2004, 09:35 PM | #2 |
Whats wrong with a loop? but i guess you could make a trigger (in your function) then have it use the event Unit Enters Region then you could make a dummy unit right next to the caster and then with your new trigger use return EnteredRegion. |
| 06-28-2004, 09:49 PM | #3 | |
Quote:
I Got 2700 regions, that's whats wrong with a loop... And I don't think it's possible to Do it the way you though off.. I also tried to create 2700 triggers with a unit is in region[ gethandle blabla] condition. But it lagged as much as it did when I used a loop. guess it runs all 2700 triggers at the same time , checking the conditions and then picks the single one that is right and do the actions. What I need is a function that returns the rect the unit stands in, but then the unit could stand in 2 or more regions, maybe that's why there is no function like that. :( |
| 06-29-2004, 02:43 AM | #4 |
What do you need all those regions for? Do they form some kind of grid or something? |
| 06-29-2004, 03:30 AM | #5 |
check when the unit enters a region then set the region to a var. if you have 2 regions it would be hard. and multiple units.. bleh buggy but best thing i could think of. |
| 06-29-2004, 05:08 AM | #6 |
Would help if you told a bit more what the locations are for. If you're using these for a grid, then I suggest you take a different approach. For grids it's a whole lot easier to just use some sequential math stuff. That way you can get a point as an offset for which block of the grid a unit is in based on that units location and use that to make a region to do stuff with and destroy it when you're done. Hell, you wouldn't even need to use sequential math stuff really, not unless you wanted the cells of the grid to be dynamic based on the size of each cell, or unless you wanted to be able to 'apply' that grid in its current state and the state of things on it to a different part of the map. |
| 06-29-2004, 10:29 AM | #7 |
Yeah, the regions form a grid all over the map. But I've already started to remake the grid using the X, Y locations, like Wargiant proposed. Checking the position of a unit with a periodic timer, and having an array that tells witch square the unit is in. There will be at most 120 units that would have to be checked every second, 4 players, 30 in each team, making the trigger check the diffrent players units at diffrent time wont cause any lag. (btw thanks to RodofNod who helped me out with this). And for you who wounders, Im making a map like the game Dungeon Keeper. Where every square is controlled by a diffrent player, and you can only build rooms, cast spells, make traps and such on your own "soil". thx. |
| 06-29-2004, 07:33 PM | #8 |
Hmm I was thinking of making my starforce map better then it is, one of my ideas was generating all the locations at map init. Then I start the unit at an index and manipulate the indexes so you do not have to always create/destroy 'random locations'. |
| 06-29-2004, 11:35 PM | #9 |
Ok, now Im using both regions and a x - y grid, I have the regions to check when a unit enters and takes controll of a square, and I have the x - y grid that calculates the location of a unit, (which square it is in). Now the only loops I need is the one that creates the 2703 trigger with the "enter region event" and the one that creates the 2703 regions. After those have run, all works perfect without the slightest lag. :D |
