| 08-02-2004, 08:58 PM | #1 |
Yet another fun fact about the workings of warcraft triggers. This has probably already been discovered a long time ago, but anyway: You would think that, when the "unit enters region" event fires, the unit just got in region, so the region now contains the unit? Guess again! We are dealing with edge conditions here, and on such occasions, wierd things happen: Code:
unit enters from above
- unit is not in region
__________________
unit | | unit enters from this side
enters | | - again not in region
from this | this here is |
side - | our region |
unit is | |
in region | |
|_________________| unit enters from below, but only crosses
the bottom right corner of the region -
unit enters from below unit is, in this case, not in region, despite
- unit is in region entering from below (same goes for top left corner)Code:
Test
Events
Unit - A unit enters Region 000 <gen>
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Region 000 <gen> contains (Entering unit)) Equal to True
Then - Actions
Game - Display to (All players) the text: Contains unit.
Else - Actions
Game - Display to (All players) the text: No unit. |
| 08-02-2004, 09:41 PM | #2 |
I've had this problem before also, I paused (Units) then sent moved them to random location in (Region X) and then Unpaused all units in (Region X) but sometimes they stayed paused because they were on the edge or corner... |
| 08-03-2004, 01:53 AM | #3 |
Hmm i think this example just explained what is going wrong somtimes in my map... I have it where a unit enters region, make unit move to random point in another region and so on but sometimes a unit enters and doesnt keep going to the next region..... I think this just explained what happens because it seems to happen where you said it at on corners and stuff... so how do you fix it? |
| 08-03-2004, 04:40 PM | #4 |
Well, one possibility is to have a seperate trigger for each region. That way, when a trigger runs, you know at which region the entering unit is, so you don't have to check. For example, for an AoS or TD map, just have a seperate trigger for each waypoint, and in each trigger, you can order the unit to the next waypoint, you don't have to check first which the next waypoint is by checking, in which region the unit is. Another possibility is to have a dual set of regions; one smaller and one larger; the smaller region is for "unit enters region" events, and the larger is for "unit in region" check that determines which region was entered. This, of course, is not usefull if you have regions one right next to the other, like I do when I discovered this. One last solution would be to, whenever the unit enters region, move it by 1 or something similarly unnoticably small forward if it's facing angle was pointing downwards or left. This is not perfect, because the unit can still enter the region from the left side (where region detection is correct) and at the same time be facing slightly to the South (which would mean that it is possible that the unit is entering the region from above, so it must be moved forward), so, if the unit entered the very bottom-left edge of the region, it could be, when pushed forward, be pushed out of the region again; but we are talking a very very small miss chance here, the unit would already have to be so close to the corner of the region that it wouldn't really look wierd that the unit missed it. Edit: I just tested the "move unit a bit forward when it enters a region so it will be certainly in that region" and the "move unit instantly" was acting a bit erratic; maybe it was just the doodad (the foot switch) getting in the way, or something else, but it didn't move the unit forward, but... well, it didn'talways move it into the region, plus the units orders got erased, so it looked really wierd, anyway, this is not a functional method, I guess (unless it really was the foot switch's fault and it would work on a region that is placed on regular terrain). Guess I'll have to do an individual trigger for every region, or a periodic looper (not very nice code in either case). |
