scope WowFly initializer Init
private function Action takes nothing returns nothing
local unit u = GetTriggerUnit()
local real dx = PolarProjectionX(GetUnitX(u), 1250, GetUnitFacing(u))
local real dy = PolarProjectionY(GetUnitY(u), 1250, GetUnitFacing(u))
local unit mount = CreateUnit(Player(15), 'hgry', GetUnitX(u), GetUnitY(u), 270)
local effect e = AddSpecialEffectTarget("units\\human\\HeroMountainKing\\HeroMountainKing", mount, "overhead")
call IssuePointOrder(mount, "move", dx, dy)
call ShowUnit(u, false)
call SetPlayerAlliance(Player(15), GetOwningPlayer(u), ALLIANCE_SHARED_VISION, true)
call SelectUnitForPlayerSingle(mount, GetOwningPlayer(u))
call SetCameraTargetControllerNoZForPlayer( GetOwningPlayer(u), mount, 0, 0, false )
// The next line leaks, was done quickly. Fix it. Should also use a timer here instead.
call TriggerSleepAction( DistanceBetweenPoints(Location(GetUnitX(u),GetUnitY(u)),Location(dx, dy))/GetUnitMoveSpeed(mount) )
call ShowUnit(u, true)
call SetPlayerAlliance(Player(15), GetOwningPlayer(u), ALLIANCE_SHARED_VISION, FALSE)
call SetUnitPosition(u, dx, dy)
call DestroyEffect(e)
call RemoveUnit(mount)
call SelectUnitForPlayerSingle(u, GetOwningPlayer(u))
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'AHtc'
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition(t, Condition(function Conditions))
call TriggerAddAction(t, function Action)
endfunction
endscope