Spell Spectral Dagger

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.


JASS:
function SpectralDagger_Jass_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A002' 
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,'A002')
	local real qx = GetHandleReal(tx,"qx")
	local real qy = GetHandleReal(tx,"qy")
		
	set x = CreateUnit(GetOwningPlayer(u),'h000',qx,qy,0)
	call SetUnitAbilityLevel(x,'A000',i)
        call SetUnitAbilityLevel(x,'A001',i)
	call UnitApplyTimedLife(x,'BTLF',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),'h000',GetLocationX(dl),GetLocationY(dl),bj_UNIT_FACING)
        call SetUnitAbilityLevel(x,'A000',GetUnitAbilityLevel(u,'A002'))
        call SetUnitAbilityLevel(x,'A001',GetUnitAbilityLevel(u,'A002'))
        call UnitApplyTimedLifeBJ( 12.00, 'BTLF',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),'h000',GetLocationX(dl),GetLocationY(dl),bj_UNIT_FACING)
        call SetUnitAbilityLevel(x,'A000',GetUnitAbilityLevel(u,'A002'))
        call SetUnitAbilityLevel(x,'A001',GetUnitAbilityLevel(u,'A002'))
        call UnitApplyTimedLifeBJ( 12.00, 'BTLF',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,'A002')) )
    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),'h001',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),'h001',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.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
You are not using vjass function?

You could greatly optimize your code by using struct...
 

NetherHawk

New Member
Reaction score
26
dunno how 2 use struct =[

i just learnt how 2 use handle vars. Gals~ you know the constant function thing. can i apply it here? can you teach me whats a constant function too? =D
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>whats a constant function too?
It is just like normal function.
But why are we using constant function?
Is to let people know where they can edit and where they can't.

We usually put something like Damage, Slide Speed, Duration into constant functions.
 

NetherHawk

New Member
Reaction score
26
oh okay =D

Gals~ did you understand the trigger?=D i wanna aks you something. i want to turn pathing on after all the h000 units are gone. But even when i do it in gui or jass, the pathing nvr get turn on. you know where i can put it?
 

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
JASS:
call UnitApplyTimedLifeBJ( 12.00, 'BTLF',x)

=>
JASS:
call UnitApplyTimedLife(x, 'BTLF' 12.00)


Anyway (I haven't tested the map yet) does the spell leave the shadow path like in DotA? And if yes, then how did you do it? o_O
I haven't learned how to use Handle Variables so what is their purpose? You need them to use functions in other triggers or what?
 

NetherHawk

New Member
Reaction score
26
YA I KNOW HAHAHA. IT ROCKS IF THE UNIT RUNS AWAY FROM YOU, AN INSANELY LONG PATH HAHAHA.

erm cr4xzZz , local handle variables allows you to carry local variables from 1 function to another. you know like in gui, you're dream coil. it has 2 seperate triggers right? it allows you to make local variables like ' global ' ones so you can use the same variable you set in the first function for the 2nd function. Go download dota's spiritbreaker from dota imdex by emjlr3, i learnt local handle variables from that map. Anyway, alot of people criticise local handle variables as rusty o.o structs is better, but heck, i dont understand any of it.

well if you understood the local handle variables, you would understand the hero path thing. Its something like creating a local timer for each hero that the dagger 'hits'. and after the timing reaches a cap of 8 seconds, destroy the timer. So every 0.12 sec in my trigger, create the 'shadow' at the position of the hero. This is not the best yet. There is a function like SafeX and SafeY, i havent learnt them yet. Basically to check whether to location is 'safe' before moving or creating units.
 

waaaks!

Zinctified
Reaction score
256
really great spells youve made...but the bad thing is...its from dota
while now im out of jass spells ideas, thats why im looking forward for those cool jass enhanced spells

+rep anyway
 

NetherHawk

New Member
Reaction score
26
thanks =D im not realli a creative person thats why =[ i do have a spell in mind.. haha based on the anime Claymore if you know =D i just wanna further improve my jass skills first =D dota spells are an easy way of doing it rather than thinking of your own.. for me at least =] thanks again. =D
 

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
Uh, I'll check that ^^ That struct system u were talking about.. I saw it in a tutorial, but I can't understand anything in the code. If u know sth tell me, 'cuz I wanna know it too X_X
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top