Im trying to make a dota 2 like spell of mk which is called tree dance. I based the spell to the sentinel spell. It works when i jump from the ground to a tree but whenever im on a tree and jumps to another one, the jump still starts from the ground when it should be from the tree. Can somebody help me? Here is the code:
JASS:
function TD takes unit mk, real range, real angle returns nothing
set udg_tdcaster = mk
set udg_tdrange = range
set udg_tddistanceTravelled = 0.00
set udg_tdangle = angle
endfunction
function unperch takes nothing returns boolean
if (GetIssuedOrderId() == OrderId("smart") or GetIssuedOrderId() == OrderId("attack") or GetIssuedOrderId() == OrderId("patrol") ) then
call SetUnitFlyHeight(GetOrderedUnit(), 0, 0)
call SetUnitPathing(GetOrderedUnit(), true)
set udg_TreeDance_isPerched[GetUnitUserData(GetOrderedUnit())] = false
call DisableTrigger(GetTriggeringTrigger())
return true
endif
return false
endfunction
function ParabolaZ takes real h, real d, real x returns real
return (4 * h / d) * (d - x) * (x / d)
endfunction
function periodic takes nothing returns nothing
local timer t=GetExpiredTimer()
local real casterX = GetUnitX(udg_tdcaster)
local real casterY = GetUnitY(udg_tdcaster)
local real dx = casterX + 7.50 * Cos(udg_tdangle * bj_DEGTORAD)
local real dy = casterY + 7.50 * Sin(udg_tdangle * bj_DEGTORAD)
local real bonusHeight = 0.00
call SetUnitX(udg_tdcaster, dx)
call SetUnitY(udg_tdcaster, dy)
set udg_tddistanceTravelled = udg_tddistanceTravelled + 7.5
if (udg_tddistanceTravelled >= udg_tdrange / 2 and GetUnitFlyHeight(udg_tdcaster) <= 300) then
call PauseTimer(t)
call DestroyTimer(t)
set udg_TreeDance_isUnPerched = CreateTrigger()
call TriggerRegisterUnitEvent(udg_TreeDance_isUnPerched, udg_tdcaster, EVENT_UNIT_ISSUED_POINT_ORDER)
call TriggerRegisterUnitEvent(udg_TreeDance_isUnPerched, udg_tdcaster, EVENT_UNIT_ISSUED_TARGET_ORDER)
call TriggerAddCondition(udg_TreeDance_isUnPerched, Condition(function unperch))
set udg_TreeDance_isPerched[GetUnitUserData(udg_tdcaster)] = true
else
if udg_TreeDance_isPerched[GetUnitUserData(udg_tdcaster)] == false then
set bonusHeight = 300.00
endif
call SetUnitFlyHeight(udg_tdcaster, ParabolaZ(400,udg_tdrange,udg_tddistanceTravelled) + bonusHeight, 0.00)
endif
endfunction
function Trig_Climb_Tree_Actions takes nothing returns nothing
local real angle = AngleBetweenPoints(GetUnitLoc(GetTriggerUnit()), GetDestructableLoc(GetSpellTargetDestructable()))
local real dist = DistanceBetweenPoints(GetUnitLoc(GetTriggerUnit()), GetDestructableLoc(GetSpellTargetDestructable()))
local real bonusDist = dist * 300/1000
local timer t
local real x = GetSpellTargetX()
local real y = GetSpellTargetY()
if GetSpellAbilityId() == 'A000' then
if udg_TreeDance_isPerched[GetUnitUserData(GetTriggerUnit())] == false then
set bonusDist = 0.00
endif
call TD(GetTriggerUnit(), dist + bonusDist, angle)
if (UnitAddAbility(udg_tdcaster, 'Amrf')) then
call UnitRemoveAbility(udg_tdcaster, 'Amrf')
endif
set t = CreateTimer()
call SetUnitPathing(udg_tdcaster, false)
call TimerStart(t, 0.01, true, function periodic)
set bj_lastCreatedUnit = CreateUnit(GetTriggerPlayer(), 'h000', x, y, bj_UNIT_FACING)
call UnitApplyTimedLife(bj_lastCreatedUnit, 'BTLF', 0.5)
call UnitAddAbility(bj_lastCreatedUnit, 'Adcn')
call IssuePointOrderById(bj_lastCreatedUnit, 852057, x, y)
endif
endfunction
//===========================================================================
function InitTrig_Climb_Tree takes nothing returns nothing
local trigger gg_trg_Climb_Tree = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Climb_Tree, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(gg_trg_Climb_Tree, function Trig_Climb_Tree_Actions)
endfunction
Last edited: