| 07-30-2007, 01:48 PM | #1 |
Hello, I need to prevent unit from moving for unspecified period of time (it should be released by triggers). I was thinking of casting some dummy spell (ensare, roots...) on it, but I would have or remove all buffs when releasing it, it also won't affect magic immune units. Then I thougt of periodic trigger repeating each 0.1 seconds which would return it to the location where it should be, but it needlessly could drain CPU power. Is here another...easier way how to do it? PS: I can't use pauseunit because it should be able to cast abilities. |
| 07-30-2007, 01:55 PM | #2 |
Set movement speed to 0 maybe? |
| 07-30-2007, 03:03 PM | #3 |
I havent tried it in jass, but i have struggled with it some time ago in object editor. The unit was still slowly, butnoticeably moving unless its movement type was set to "none". |
| 07-30-2007, 03:27 PM | #4 |
u cant set movement speed to 0. It will just be 1 then. What u can do is to pause it, or just make triggers to prevent movement orders |
| 07-30-2007, 04:01 PM | #5 |
As I said I can't pause it, but the second idea may work, I will try it. |
| 07-30-2007, 04:52 PM | #6 |
If that's too difficult, another idea would be to surround the unit with pathing blockers or some other invisible unit for your duration of time. Could be some minor bugs to work out depending on how you're using it though. |
| 07-30-2007, 05:53 PM | #7 |
I seem to have problem with blocking the order. I have this Trigger: Catch Orders
It doesn't block smart, move and attack. Only patrol and blink seem to be okay (I haven't tried any other orders). |
| 07-30-2007, 06:07 PM | #8 |
You can't order a unit to stop on the event the unit is issued a certain order, it will not cancel the order. The current order can override it on alot of circumstances. You have to slightly delay the stop order, by 0.00 seconds. Use a timer, or one of the many Timer related libraries out there (TimeLib for example) for this effect. If you are not into JASS much, you could probably just set a global variable to OrderedUnit, create a timer that expires in 0.00 seconds and when it expires simply order the global variable unit to stop. Id assume it wouldn't be a problem unless of course 2 or more units are ordered to do something at the same exact time and both are prohibited from doing so. In this case you could easily setup a global array of units that should be ordered to stop, and the timer should order every unit in the array to stop, then of course clear the array. |
| 07-30-2007, 06:17 PM | #9 |
Ummm. Trigger that's like Unit issued orer targeting point Order = move Order Ordered unit to Stop. |
| 07-30-2007, 06:24 PM | #10 |
Cast a dummy ensnare on the unit? *Shrugs* |
| 07-30-2007, 06:28 PM | #11 |
Thanks rain! Works perfectly. JASS:function stop_body takes nothing returns nothing call IssueImmediateOrder( udg_stopunit, "stop" ) call PauseUnit( udg_stopunit, false ) call DestroyTimer(GetExpiredTimer()) endfunction function Trig_Catch_Orders_Actions takes nothing returns nothing local timer t=CreateTimer() set udg_stopunit = GetOrderedUnit() call PauseUnit( udg_stopunit, true) call TimerStart(t,0.,false,function stop_body) set t=null endfunction //=========================================================================== function InitTrig_Catch_Orders takes nothing returns nothing set gg_trg_Catch_Orders = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Catch_Orders, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Catch_Orders, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER ) call TriggerAddAction( gg_trg_Catch_Orders, function Trig_Catch_Orders_Actions ) endfunction +Rep |
| 07-31-2007, 08:33 AM | #12 |
You should pause the timer before destroying it... and the same thing might be able to be achieved with ExecuteFunc() instead of a timer. |
| 07-31-2007, 09:05 AM | #13 |
I thought only periodic timers need to be paused first...ok, I will fix it. And what do you mean with the executefunc? |
| 07-31-2007, 10:04 AM | #14 |
D'oh. I didn't think about the fact that that wasn't periodic... but I think it'd be safe to do it anyway. And what I meant by ExecuteFunc was this: JASS:function stop_body takes nothing returns nothing call IssueImmediateOrder( udg_stopunit, "stop" ) call PauseUnit( udg_stopunit, false ) endfunction function Trig_Catch_Orders_Actions takes nothing returns nothing set udg_stopunit = GetOrderedUnit() call PauseUnit( udg_stopunit, true) call ExecuteFunc("stop_body") endfunction //=========================================================================== function InitTrig_Catch_Orders takes nothing returns nothing set gg_trg_Catch_Orders = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Catch_Orders, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Catch_Orders, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER ) call TriggerAddAction( gg_trg_Catch_Orders, function Trig_Catch_Orders_Actions ) endfunction |
