BlueMirage
Trust, but doubt.
- Reaction score
- 39
The spell does the following: You'll need to use a subskill called Set Destination. When using Travel, your hero will move towards the destination you previously set with extra movespeed and no collision. Travel is based on Berserk, and provides the extra movespeed and a fluent way of casting the spell. You lose these bonuses when you've traveled 35% of the distance (Assuming the terrain has no cliffs), or when you either give the unit any order while Travel is in effect.
The spell works almost flawlessly. It'll cancel correctly if the timer runs out, but if you activate the function TravelStop through giving the unit an order, the game crashes.
The spell works almost flawlessly. It'll cancel correctly if the timer runs out, but if you activate the function TravelStop through giving the unit an order, the game crashes.
JASS:
function TravelStop takes nothing returns nothing
local unit u
local timer tim = GetExpiredTimer()
local trigger t
local integer i
if tim == null then //You gave the unit an order
set t = GetTriggeringTrigger()
set u = GetTriggerUnit()
set tim = LoadTimerHandle(udg_Hashtable, GetHandleId(t), 0)
call FlushChildHashtable(udg_Hashtable, GetHandleId(tim))
else //You did not give the unit an order. Timer expired
set i = GetHandleId(tim)
set u = LoadUnitHandle(udg_Hashtable, i, 0)
set t = LoadTriggerHandle(udg_Hashtable, i, 1)
call FlushChildHashtable(udg_Hashtable, i)
endif
call FlushChildHashtable(udg_Hashtable, GetHandleId(t))
call EndTimer(tim) //Custom function that pauses and destroys a timer, nothing else.
call TriggerClearActions(t)
call DestroyTrigger(t)
call UnitRemoveAbility(u, 039;B00G039;) //Movespeed buff
call SetUnitPathing(u, true)
set u = null
set t = null
set tim = null
endfunction
function WandererCast takes nothing returns boolean
local integer i = GetSpellAbilityId()
local trigger t
local unit u
local timer tim
local real x
local real y
if i == 039;A014039; then //Set Destination
set i = GetHandleId(GetTriggerUnit())
call SaveReal(udg_Hashtable, i, StringHash("TravelX"), GetSpellTargetX())
call SaveReal(udg_Hashtable, i, StringHash("TravelY"), GetSpellTargetY())
elseif i == 039;A015039; then //Travel
set u = GetTriggerUnit()
set i = GetHandleId(u)
set x = LoadReal(udg_Hashtable, i, StringHash("TravelX"))
set y = LoadReal(udg_Hashtable, i, StringHash("TravelY"))
call IssuePointOrder(u, "move", x, y)
call SetUnitPathing(u, false)
set tim = CreateTimer()
set t = CreateTrigger()
set i = GetHandleId(tim)
call SaveUnitHandle(udg_Hashtable, i, 0, u)
call SaveTriggerHandle(udg_Hashtable, i, 1, t)
//Save handles so that they can be destroyed
//Note that the timer and the trigger runs the same function, TravelStop.
call TimerStart(tim, (0.35 * Distance(x, y, GetUnitX(u), GetUnitY(u)) / GetUnitMoveSpeed(u)) / 1.4, false, function TravelStop)
call SaveTimerHandle(udg_Hashtable, GetHandleId(t), 0, tim)
call TriggerRegisterUnitEvent(t, u, EVENT_UNIT_ISSUED_TARGET_ORDER)
call TriggerRegisterUnitEvent(t, u, EVENT_UNIT_ISSUED_POINT_ORDER)
call TriggerRegisterUnitEvent(t, u, EVENT_UNIT_ISSUED_ORDER)
call TriggerAddAction(t, function TravelStop) //It'll run TravelStop if the unit is given an order
set u = null
set t = null
set tim = null
endif
return false
endfunction