| 03-10-2006, 11:29 PM | #1 |
Does anyone know a trick for creating units at a random point in a rect, but ensuring that the point is pathable? This may seem easy, but I have a special restriction: This has to work in Reign of Chaos (sorry to annoy everyone with that). That means no IsTerrainPathable checks for the point. The way it works now, I can create units in deep water, boundary areas, cliff faces, etc. Looks odd. I wouldn't even worry about it too much, except that I have found killing these "illegally" placed units causes a server split 100% of the time (at least, within the context of my map script). I have tried creating a tower first--hoping the tower, as a building with extra pathing requirements, would be displaced, letting me create the desired unit at the tower's position--but the tower can be placed in unpathable areas too... or even on top of itself. I'm sure this problem is as old as time. But I've just never encountered it in my maps before. I only hope someone has figured a way around it in RoC. And I hope that way isn't "draw regions over pathing-safe (or unsafe) areas". |
| 03-10-2006, 11:33 PM | #2 |
i remember vexorian had some functions that use submerge to detect water and to detect pathing he made an item at a point, and then measured the distance between the item and the point, if it was very far it means point was unpathable. |
| 03-11-2006, 12:33 AM | #3 |
Not so sure about submerge. I have thought about using a unit that summons, and attempting to summon at the random point.... if IssuePointOrder returns false, it's unpathable. That would be a more complete solution I think. Two issues are: 1. I wonder if I would be able to issue orders for every unit creation using a single unit, or if I would need to create a new unit for each order. The latter would be less good. 2. I think this would only work for unpathable terrain, but would not stop me from creating units at the same spot as a building. Though maybe Inferno might work, since you can set valid targets... hmm. EDIT: This concern is needless, since buildings ALREADY displace units when creating them. Forgot that. As for Vex's function using items... it sounds like it might work. Very promising! Do you have a link? (I'll look for it myself in the meantime.) |
| 03-11-2006, 03:07 PM | #4 |
I found Vex's function. It has a weird (to me, at least) step that uses a TFT-only function call (EnumItemsInRect). However, the rest looks great, and is terribly simple. Basically, the function suggests that items can not be created in unpathable positions; they are displaced to the nearest pathable location when created. I tested this out, and it's true. I won't end up using Vex's script, but the main premise of that function solves everything. At map init, when placing units, I will simply create an item at the random location, then create the unit at the position of the item. My tests show that it works, and it's even pretty clean (for a workaround). Thanks shadow (and Vex)! I'll post more if it doesn't work, but otherwise, assume the problem is solved. |
| 03-11-2006, 11:17 PM | #5 |
Guest | I think wc3 got some functions to detect pathing you should look in gui, later on blizzard.j |
