| 02-21-2006, 09:28 PM | #1 |
Any idea why this doesn't work? Trigger: Actions![]() Set p2 = (Position of (Random unit from ug))![]() Custom script: call SetHandleHandle(udg_u, "dest", udg_p2)![]() Unit - Order u to Attack-Move To p2 JASS:
set udg_p2 = GetUnitLoc(GroupPickRandomUnit(udg_ug))
call SetHandleHandle(udg_u, "dest", udg_p2)
call IssuePointOrderLocBJ( udg_u, "attack", udg_p2 )
The ordering to attack part seems to work fine. The problem is handle part. I attach the point to the unit so that if the unit is distracted by some order I have another trigger to re-order it to keep going to it's destination. I also have a debug trigger so when I select a unit it will ping where its "dest" variable is set to. And it turns out that when I have this happening to multiple units they get all scrambled up so some units clearly have "dest"'s that should have gone on other units and sometimes the "dest" is set to 0, 0 so it seems they never actually got a dest variable attached to them. ![]() |
| 02-22-2006, 01:33 AM | #2 |
when exactly are you assigning the u variable? |
| 02-22-2006, 03:17 AM | #3 |
In another trigger, units are created, then u is set to the last created unit and immediately the trigger with this code is called. Also whenever the units reach their destination u is set to the triggering unit (the unit entering a region) and this trigger is called again. Basically I am being cheap and instead of making functions that pass variables I am setting the global variable u and then immediately running a trigger. This shouldn't be a problem if there are no waits right? All that happens is u is set to a unit just created or just entering a region, this trigger is called and then there is a bit of code I didn't bother showing which creates the unit group ug by selecting valid units within range of u. I am pretty sure that u is fine because for the most part units correctly go from one point to the next. The problem is that if I select the unit and order it to go somewhere else, instead of it continuing where it is supposed to (with the triggers below), it either goes to some crazy place it has no business going, because it has the dest of another unit or it does nothing because it doesn't really have a dest. Trigger: Re move
Trigger: If I am using handle vars correctly then I guess it must be something else that is screwing stuff up, but I can't imagine what. |
| 02-22-2006, 06:20 AM | #4 |
You destroy your location in the Do Move trigger, so the unit can only be ordered to it's destination once before you destroy it. |
| 02-22-2006, 07:03 AM | #5 |
Actually I just added that RemoveLocation part in before I posted, it was still bugging before that. So I don't want to destroy p? I'm a little confused with handles and variables and pointers etc, I gotta admit. From what you are saying it seems that when I create the point in the first place and make it the dest variable on my unit, dest is just a pointer to a location that would be universally accessible if I "caught" it by assigning it to any other variables when it is created, like a regular global. And since I am setting p to the units dest in the Do Move trigger and then removing p I am actually removing dest? So....perhaps I should mention another part I didn't show on my first trigger. After I do Trigger: Actions![]() Set p2 = (Position of (Random unit from ug))![]() Custom script: call SetHandleHandle(udg_u, "dest", udg_p2)![]() Unit Group - Remove u from Units![]() Unit - Order u to Attack-Move To p2![]() Unit Group - Add u to UnitsTrigger: Custom script: call RemoveLocation(udg_p2)EDIT: I turned off all the actions that remove locations but it didn't fix anything. The units still act the same in-game. EDIT2: I turned off all the actions that remove locations for real this time and it works perfectly! Thanks for the hint Anitarf. Live and learn I guess. |
