• 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.

Why does this vJass script doesnt work?

Status
Not open for further replies.
Level 3
Joined
Jan 31, 2009
Messages
8
Im learning vJass now and made some spells, but when i try to make sells with static methods...they will not work (there are no errors). Here is my Testspell, I didnt remove leaks usw... its just for test now...
could any skilled vJasser (dynasti, dark dragon, or something else...) help me by correcting this script?

JASS:
scope Chidori initializer Init

    private struct Data
        unit caster
        unit target
        real angle
        real distance
        
        static method Loop takes nothing returns nothing
            local Data dat
            local real x1
            local real y1
            local integer index = Total
            loop
                set index = index - 1
                exitwhen index < 0
                set dat = Dats[index]
                set x1 = GetUnitX(dat.caster)
                set y1 = GetUnitY(dat.caster)
                call SetUnitPosition(dat.caster, x1 + 30 * Cos(dat.angle), y1 + 30 * Sin(dat.angle))
                if SquareRoot((GetUnitX(dat.target) - x1) * (GetUnitX(dat.target) - x1) + (GetUnitY(dat.target) - y1) * (GetUnitY(dat.target) - y1)) < 128 then
                    call dat.destroy()
                    set Total = Total - 1
                    set Dats[index] = Dats[Total]
                    if Total == 0 then
                        call PauseTimer(Tim)
                    endif
                endif
            endloop
        endmethod
        
        static method Start takes unit caster, unit target returns nothing
            local Data dat = Data.create()
            local real x1
            local real y1
            local real x2
            local real y2
            set dat.caster = caster
            set dat.target = target
            set x1 = GetUnitX(dat.caster)
            set y1 = GetUnitY(dat.caster)
            set x2 = GetUnitX(dat.target)
            set y2 = GetUnitY(dat.target)
            set dat.angle = Atan2(y2 - y1, x2 - x1)
            set dat.distance = SquareRoot((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
            if Total == 0 then
                call TimerStart(Tim, 0.03, true, function Data.Loop)
            endif
            set Dats[Total] = dat
            set Total = Total + 1
        endmethod
    endstruct
    
    globals
        private Data array Dats
        private integer Total = 0
        private timer Tim = CreateTimer()
    endglobals
    
    private constant function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A002'
    endfunction
    
    private function Actions takes nothing returns nothing
        local unit caster = GetTriggerUnit()
        local unit target = GetSpellTargetUnit()
        call Data.Start(caster, target)
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger trg = CreateTrigger()
        local integer index = 0
        loop
            call TriggerRegisterPlayerUnitEvent(trg, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
            set index = index + 1
            exitwhen index == bj_MAX_PLAYER_SLOTS
        endloop
        call TriggerAddCondition(trg, Condition(function Conditions))
        call TriggerAddAction(trg, function Actions)
        set trg = null
    endfunction

endscope
 
Status
Not open for further replies.
Top