NetherHawk
New Member
- Reaction score
- 26
MUI, Jass
er leaks: im not too sure
uses local handle variables
hurls a spectral dagger to the target unit or point, if the target is a point, the dagger will travel for the max distance.
if the target is a unit, it will stop once hitting the unit.
hero's hit by the dagger will create a spectral path as they move. enemy units near the path will be slowed while the caster has a speed buff.
i dont know when to set the pathing to false, anyone wanna help? thats the only remaining issue.
please tell me if im leaking anywhere in the trigger.
er leaks: im not too sure
uses local handle variables
hurls a spectral dagger to the target unit or point, if the target is a point, the dagger will travel for the max distance.
if the target is a unit, it will stop once hitting the unit.
hero's hit by the dagger will create a spectral path as they move. enemy units near the path will be slowed while the caster has a speed buff.
JASS:
function SpectralDagger_Jass_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 039;A002039;
endfunction
function SpectralDagger_Damage_Conditions takes nothing returns boolean
local timer t = GetExpiredTimer()
local group dg = GetHandleGroup(t,"damagedgroup")
local boolean b1 = IsUnitAliveBJ(GetFilterUnit()) == true
local boolean b2 = IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetHandleUnit(t,"caster"))) == true
local boolean b3 = IsUnitInGroup(GetFilterUnit(), dg) == false
local boolean b4 = IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false
local boolean b5 = IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false
return b1 and b2 and b3 and b4 and b5
endfunction
function SpectralDagger_TrailHero takes nothing returns nothing
local timer tx = GetExpiredTimer()
local unit q = GetHandleUnit(tx,"hero")
local unit u = GetHandleUnit(tx,"caster")
local unit x
local real s = GetHandleReal(tx,"duration")
local integer i = GetUnitAbilityLevel(u,039;A002039;)
local real qx = GetHandleReal(tx,"qx")
local real qy = GetHandleReal(tx,"qy")
set x = CreateUnit(GetOwningPlayer(u),039;h000039;,qx,qy,0)
call SetUnitAbilityLevel(x,039;A000039;,i)
call SetUnitAbilityLevel(x,039;A001039;,i)
call UnitApplyTimedLife(x,039;BTLF039;,8)
call SetHandleReal(tx,"qx",GetUnitX(q))
call SetHandleReal(tx,"qy",GetUnitY(q))
set s = s + 0.2
call SetHandleReal(tx,"Duration",s)
if s > 7 or GetUnitState(q,UNIT_STATE_LIFE)<1 then
call PauseTimer(tx)
call FlushHandleLocals(tx)
set q = null
set u = null
endif
set x = null
endfunction
function SpectralDagger_Point_Movement takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer i = GetHandleInt(t,"counter")
local real a = GetHandleReal(t,"angle")
local unit u = GetHandleUnit(t,"caster")
local real r = GetHandleReal(t,"damage")
local unit d = GetHandleUnit(t,"dagger")
local location dl = GetUnitLoc(d)
local location dnl = PolarProjectionBJ(dl, 16.00, a)
local unit x
local group g
local group dg = GetHandleGroup(t,"damagedgroup")
local unit p
local timer tx
local unit q
local real s = 0
if i < 100 then
set i = i + 1
set x = CreateUnit(GetOwningPlayer(u),039;h000039;,GetLocationX(dl),GetLocationY(dl),bj_UNIT_FACING)
call SetUnitAbilityLevel(x,039;A000039;,GetUnitAbilityLevel(u,039;A002039;))
call SetUnitAbilityLevel(x,039;A001039;,GetUnitAbilityLevel(u,039;A002039;))
call UnitApplyTimedLifeBJ( 12.00, 039;BTLF039;,x)
call SetUnitPositionLocFacingBJ(d,dnl,a)
set g = GetUnitsInRangeOfLocMatching(150.00,dnl, Condition(function SpectralDagger_Damage_Conditions))
loop
set p = FirstOfGroup(g)
exitwhen p == null
call GroupAddUnit(dg,p)
call UnitDamageTarget(u,p,r,true,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
if IsUnitType(p, UNIT_TYPE_HERO) == true then
set tx = CreateTimer()
set q = p
call SetHandleHandle(tx,"hero",q)
call SetHandleHandle(tx,"caster",u)
call SetHandleReal(tx,"qx",GetUnitX(q))
call SetHandleReal(tx,"qy",GetUnitY(q))
call SetHandleReal(tx,"duration",s)
call TimerStart(tx,.12,true,function SpectralDagger_TrailHero)
endif
call GroupRemoveUnit(g,p)
endloop
call SetHandleInt(t,"counter",i)
call RemoveLocation(dl)
call RemoveLocation(dnl)
call DestroyGroup(g)
set dl = null
set dnl = null
set x = null
else
call KillUnit(d)
call RemoveUnit(d)
call GroupClear(dg)
call DestroyGroup(dg)
call PauseTimer(t)
call FlushHandleLocals(t)
call DestroyTimer(t)
set t = null
set u = null
set d = null
set x = null
endif
endfunction
function SpectralDagger_Unit_Movement takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer i = GetHandleInt(t,"counter")
local unit u = GetHandleUnit(t,"caster")
local unit ux = GetHandleUnit(t,"target")
local location uxl = GetUnitLoc(ux)
local real r = GetHandleReal(t,"damage")
local unit d = GetHandleUnit(t,"dagger")
local location dl = GetUnitLoc(d)
local real a = AngleBetweenPoints(dl,uxl)
local location dnl = PolarProjectionBJ(dl, 16.00, a)
local real c = DistanceBetweenPoints(dl,uxl)
local unit x
local group g
local group dg = GetHandleGroup(t,"damagedgroup")
local unit p
local timer tx
local unit q
local real s = 0
if c >= 17.00 then
set x = CreateUnit(GetOwningPlayer(u),039;h000039;,GetLocationX(dl),GetLocationY(dl),bj_UNIT_FACING)
call SetUnitAbilityLevel(x,039;A000039;,GetUnitAbilityLevel(u,039;A002039;))
call SetUnitAbilityLevel(x,039;A001039;,GetUnitAbilityLevel(u,039;A002039;))
call UnitApplyTimedLifeBJ( 12.00, 039;BTLF039;,x)
call SetUnitPositionLocFacingBJ(d,dnl,a)
set g = GetUnitsInRangeOfLocMatching(150.00,dnl, Condition(function SpectralDagger_Damage_Conditions))
loop
set p = FirstOfGroup(g)
exitwhen p == null
call GroupAddUnit(dg,p)
call UnitDamageTarget(u,p,r,true,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
if IsUnitType(p, UNIT_TYPE_HERO) == true then
set tx = CreateTimer()
set q = p
call SetHandleHandle(tx,"hero",q)
call SetHandleHandle(tx,"caster",u)
call SetHandleReal(tx,"qx",GetUnitX(q))
call SetHandleReal(tx,"qy",GetUnitY(q))
call SetHandleReal(tx,"duration",s)
call TimerStart(tx,.12,true,function SpectralDagger_TrailHero)
endif
call GroupRemoveUnit(g,p)
endloop
call RemoveLocation(dl)
call RemoveLocation(dnl)
call RemoveLocation(uxl)
call DestroyGroup(g)
set dl = null
set dnl = null
set uxl = null
set x = null
else
call KillUnit(d)
call RemoveUnit(d)
call PauseTimer(t)
call GroupClear(dg)
call DestroyGroup(dg)
call FlushHandleLocals(t)
call DestroyTimer(t)
set t = null
set u = null
set d = null
set x = null
endif
endfunction
function SpectralDagger_Jass_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local location ul = GetUnitLoc(u)
local real r = ( 50.00 * I2R(GetUnitAbilityLevel(u,039;A002039;)) )
local unit ux
local location uxl
local unit d
local real a
local timer t = CreateTimer()
local integer i = 0
local group dg = CreateGroup()
call SetUnitPathing(u,false)
if GetSpellTargetUnit() == null then
set uxl = GetSpellTargetLoc()
set a = AngleBetweenPoints(ul, uxl)
set d = CreateUnit(GetOwningPlayer(u),039;h001039;,GetLocationX(ul),GetLocationY(ul),a)
call SetHandleHandle(t,"caster",u)
call SetHandleReal(t,"angle",a)
call SetHandleReal(t,"damage",r)
call SetHandleInt(t,"counter",i)
call SetHandleHandle(t,"dagger",d)
call SetHandleHandle(t,"damagedgroup",dg)
call TimerStart(t,0.04,true,function SpectralDagger_Point_Movement)
else
set ux = GetSpellTargetUnit()
set uxl = GetUnitLoc(ux)
set a = AngleBetweenPoints(ul, uxl)
set d = CreateUnit(GetOwningPlayer(u),039;h001039;,GetLocationX(ul),GetLocationY(ul),a)
call SetHandleHandle(t,"caster",u)
call SetHandleHandle(t,"target",ux)
call SetHandleReal(t,"angle",a)
call SetHandleReal(t,"damage",r)
call SetHandleHandle(t,"dagger",d)
call SetHandleHandle(t,"damagedgroup",dg)
call TimerStart(t,0.04,true,function SpectralDagger_Unit_Movement)
endif
call RemoveLocation(uxl)
set uxl = null
endfunction
//===========================================================================
function InitTrig_Spectral_Dagger_Jass takes nothing returns nothing
set gg_trg_Spectral_Dagger_Jass = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Spectral_Dagger_Jass, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Spectral_Dagger_Jass, Condition( function SpectralDagger_Jass_Conditions ) )
call TriggerAddAction( gg_trg_Spectral_Dagger_Jass, function SpectralDagger_Jass_Actions )
endfunction
i dont know when to set the pathing to false, anyone wanna help? thats the only remaining issue.
please tell me if im leaking anywhere in the trigger.