• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] why dont this work:o

Status
Not open for further replies.
Level 11
Joined
Apr 6, 2008
Messages
760
why dont this work? made lots of spell like this but can get this to work. i ahve checked stuff over and over again(including rawcodes)!

JASS:
scope HookSpell initializer Init

globals
    private constant integer Abil_id = 'A00F'
    private constant integer Dum_id = 'e005'
    private constant real Dist = 200
    private constant real Time = 1.5
endglobals

private struct Data
unit c
unit t
unit dum

real movedist
real dist
real angle

boolean out

player play

lightning lig

timer time

    static method create takes nothing returns Data
        local Data d = Data.allocate()
        local location loc = GetSpellTargetLoc()
        local real tx = GetLocationX(loc)
        local real ty = GetLocationY(loc)
        local real x
        local real y
        
        set d.c = GetTriggerUnit()
        set d.time = CreateTimer()
        set d.movedist = ((800*(Dist+GetUnitAbilityLevel(d.c,Abil_id)))/Time)/(1./.035)
        set x = GetUnitX(d.c)
        set x = GetUnitY(d.c)
        set d.angle = Atan2(ty-y,tx-x)
        set d.play = GetOwningPlayer(d.c)
        set d.dum = CreateUnit(d.play,Dum_id,x+50*Cos(d.angle),y+50*Sin(d.angle),d.angle*(180/3.14169))
        set d.out = true
        set d.lig = AddLightningEx("BD",true,x,y,50,x+50*Cos(d.angle),y+50*Sin(d.angle),50)
        
        call BJDebugMsg("hay")
        
        call SetCSData(d.time,d)
        call TimerStart(d.time,.035,true,function Data.Loop)
        
        return d
    endmethod
    
    static method Loop takes nothing returns nothing
        local Data d = GetCSData(GetExpiredTimer())
        local real x
        local real y
        local group g
        
        if d.t == null then
            set g = CreateGroup()
            call GroupEnumUnitsInRange(g,x,y,75,Filter(function Data.filter))
            set d.t = FirstOfGroup(g)
            if d.t != null then
                set d.out = false
            endif
            call DestroyGroup(g)
        endif
        
        if d.out then
            set x = GetUnitX(d.dum)+d.movedist*Cos(d.angle)
            set y = GetUnitY(d.dum)+d.movedist*Sin(d.angle)
                call MoveLightningEx(d.lig,true,GetUnitX(d.c),GetUnitY(d.c),50,x,y,50)
                call SetUnitX(d.dum,x)
                call SetUnitY(d.dum,y)
                set d.dist = d.dist + d.movedist
                if d.dist >= Dist then
                    set d.out = false
                endif
        else
            if d.dist <= 50. then
                set x = GetUnitX(d.dum)-d.movedist*Cos(d.angle)
                set y = GetUnitY(d.dum)-d.movedist*Sin(d.angle)
                set d.angle = Atan2(y-GetUnitY(d.c),x-GetUnitX(d.c))
                if d.t != null then
                    call SetUnitX(d.t,x)
                    call SetUnitX(d.t,y)
                endif
                call MoveLightningEx(d.lig,true,GetUnitX(d.c),GetUnitY(d.c),50,x,y,50)
                call SetUnitX(d.t,x-d.movedist*Cos(d.angle))
                call SetUnitX(d.t,y-d.movedist*Sin(d.angle))
                set d.dist = d.dist - d.movedist
            else
                call d.destroy()
            endif
        endif
    endmethod
    
    static method filter takes nothing returns boolean
        local Data d = GetTimerStructA(GetExpiredTimer())
        local unit f = GetFilterUnit()
        local boolean ok = GetWidgetLife(f) > .405 and IsUnitEnemy(f,d.play)
        set f = null
        return ok
    endmethod
    
    method onDestroy takes nothing returns nothing
        call PauseTimer(.time)
        call DestroyTimer(.time)
        call KillUnit(.dum)
    endmethod
    
endstruct

private function Conds takes nothing returns boolean
    local Data d
    
    if GetSpellAbilityId()==Abil_id then
        set d = Data.create()
    endif
    
    return false
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer index = 0

    loop
        call TriggerRegisterPlayerUnitEvent(t,Player(index),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)

        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    
    call TriggerAddCondition(t,Filter(function Conds))
    
    set t = null
endfunction
    
endscope
 
Status
Not open for further replies.
Top