"Wait" help.

cleeezzz

The Undead Ranger.
Reaction score
268
JASS:
call CAS_SA('h00J',u,cx,cy,tx,ty,0.03,33,MaxDist(i),Damage(i),false,0,null,0,0,null)
    call CAS_SA('h00K',u,cx,cy,tx,ty,0.03,33,MaxDist(i),Damage(i),true,'A00A',"flamestrike",i,250.00,"Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl")


CAS_SA creates an arrow that goes straight, but i want the 2nd function to happen about .03 seconds after the first one, right now, they're instant so they overlap each other, whats the best way to do this
 
Reaction score
456
With so low periods, you have to use a timer.

If you're using vJass, you can do it easily by using a struct:
JASS:
struct Data
    timer t = CreateTimer()

    //add your stuff here
endstruct

globals
    Data array Data_ar
    integer counter = 0
endglobals

function SomeFunction_handler takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer loopA = 0
    
    loop
        exitwhen loopA >= counter
        if Data_ar[loopA].t = t then
        
            //launch the second arrow
            
            call PauseTimer(t)
            call DestroyTimer(t)
            call Data_ar[counter].destroy()
            set counter = counter - 1
        endif
        set loopA = loopA + 1
    endloop
endfunction

function SomeFunction takes nothing returns boolean
    local Data dat = Data.create()

    //set some data for the struct
    
    //launch first arrow
    
    call TimerStart(dat.t, 0.03, false, function SomeFunction_handler)
    
    set Data_ar[counter] = dat
    set counter = counter + 1
endfunction

If you don't know vJass, you're not getting anywhere with that code.

With TT:
JASS:
struct Data
    //add your stuff here
endstruct

function SomeFunction_handler takes nothing returns nothing
    local Data dat = TT_GetData()
    
    //launch second arrow
    
    call dat.destroy()

    return true
endfunction

function SomeFunction takes nothing returns nothing
    local Data dat = Data.create()

    //set some data for the struct
    
    //launch first arrow
    
    call TT_Start(function SomeFunction_handler, dat)
endfunction


Correct me if I am wrong. I don't have wc3/newgen or anything.
 

Hatebreeder

So many apples
Reaction score
381
Create a Timer that runs just once.
Simple, efficient and proberbly acurate =)
Problem is, you will proberbly need a Attachment System.
Also, if you are doing stuff like this, I recomend you use something like TT by Cohadar, since you will have to create + destroy the Timer >.<
 
Reaction score
456
The Data_ar is array of Data structs, and counter is counting how many "things" (can't figure out a word for it now) there are in the Data_ar. In the handler function we are looping each through the Data_ar.
 

cleeezzz

The Undead Ranger.
Reaction score
268
hmm

JASS:
function SomeFunction_handler takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer loopA = 0
    
    loop
        exitwhen loopA &gt;= counter
        if Data_ar[loopA].t = t then
        
            //launch the second arrow
            
            call PauseTimer(t)
            call DestroyTimer(t)
            call Data_ar[counter].destroy()
            set counter = counter - 1
        endif
        set loopA = loopA + 1
    endloop
endfunction


but i cant launch the arrow in a separate function unless i load the struct right?

heres what i got so far.

JASS:
scope HA initializer Init

private function Damage takes integer i returns real
    return 350.00+(100.00*i)
endfunction

private function Damage2 takes integer i returns real
    return 100.00*i
endfunction

private function MaxDist takes integer i returns real
    return 1500.00+(500.00*i)
endfunction

private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == &#039;A006&#039;
endfunction

private struct Data
    timer t = NewTimer()
    unit u
    real cx
    real cy
    real tx
    real ty
    integer i
endstruct

    

private function Shockwave takes nothing returns nothing //i know this doesn&#039;t work yet

    call CAS_SA(&#039;h00K&#039;,u,cx,cy,tx,ty,0.03,33,MaxDist(i),Damage(i),true,&#039;A00A&#039;,&quot;flamestrike&quot;,i,250.00,&quot;Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl&quot;)

endfunction

private function Actions takes nothing returns nothin
    local Data d = Data.create()
    local l = GetSpellTargetLoc()
    set d.u = GetTriggerUnit()
    set i = GetUnitAbilityLevel(d.u,GetSpellAbilityId())
    set d.cx = GetUnitX(d.u)
    set d.cy = GetUnitY(d.u)
    set d.tx = GetLocationX(l)
    set d.ty = GetLocationY(l)
    
    call CAS_SA(&#039;h00J&#039;,d.u,d.cx,d.cy,d.tx,d.ty,0.03,33,MaxDist(i),Damage(i),false,0,null,0,0,null)
    call TimerStart(d.t,0.05,false,function Shockwave)
    
    call RemoveLocation(l)
endfunction


//===========================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( trig, Condition( function Conditions ) )
    call TriggerAddAction( trig, function Actions)
endfunction
   
endscope
 
Reaction score
456
JASS:
scope HA initializer Init

private function Damage takes integer i returns real
    return 350.00+(100.00*i)
endfunction

private function Damage2 takes integer i returns real
    return 100.00*i
endfunction

private function MaxDist takes integer i returns real
    return 1500.00+(500.00*i)
endfunction

private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == &#039;A006&#039;
endfunction

private struct Data
    timer t = NewTimer()
    unit u
    real cx
    real cy
    real tx
    real ty
    integer i
endstruct

globals
    private Data array Data_ar
    private integer counter = 0
endglobals
    
private function Shockwave takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer loopA = 0
    
    loop
        exitwhen loopA &gt;= counter
        if Data_ar[loopA].t = t then
        
            call CAS_SA(&#039;h00K&#039;,Data_ar[loopA].u,Data_ar[loopA].cx,Data_ar[loopA].cy,Data_ar[loopA].tx,Data_ar[loopA].ty,0.03,33,MaxDist(i),Damage(i),true,&#039;A00A&#039;,&quot;flamestrike&quot;,i,250.00,&quot;Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl&quot;)
            
            call PauseTimer(t)
            call DestroyTimer(t)
            call Data_ar[counter].destroy()
            set counter = counter - 1
        endif
        set loopA = loopA + 1
    endloop
endfunction

private function Actions takes nothing returns nothin
    local Data d = Data.create()
    local l = GetSpellTargetLoc()
    set d.u = GetTriggerUnit()
    set i = GetUnitAbilityLevel(d.u,GetSpellAbilityId())
    set d.cx = GetUnitX(d.u)
    set d.cy = GetUnitY(d.u)
    set d.tx = GetLocationX(l)
    set d.ty = GetLocationY(l)
    
    call CAS_SA(&#039;h00J&#039;,d.u,d.cx,d.cy,d.tx,d.ty,0.03,33,MaxDist(i),Damage(i),false,0,null,0,0,null)
    call TimerStart(d.t,0.05,false,function Shockwave)
    
    set Data_ar[counter] = d
    set counter = counter + 1
    
    call RemoveLocation(l)
endfunction


//===========================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( trig, Condition( function Conditions ) )
    call TriggerAddAction( trig, function Actions)
endfunction
   
endscope

I used the struct array and counter method in that. Oh, you should also store the i variable it seems.
 

cleeezzz

The Undead Ranger.
Reaction score
268
Solved

JASS:
scope HA initializer Init

private function Damage takes integer i returns real
    return 350.00+(100.00*i)
endfunction

private function Damage2 takes integer i returns real
    return 100.00*i
endfunction

private function MaxDist takes integer i returns real
    return 1500.00+(500.00*i)
endfunction

private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == &#039;A006&#039;
endfunction

private struct Data
    timer t = NewTimer()
    unit u
    real cx
    real cy
    real tx
    real ty
    integer i
    private method onDestroy takes nothing returns nothing
        set .u = null
        call ReleaseTimer(.t)
    endmethod
endstruct

globals
    private Data array Array
    private integer c = 0
endglobals

    

private function Shockwave takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer l = 0
    
    loop
        exitwhen l &gt;= c
        if Array[l].t = t then     //syntax error
            call CAS_SA(&#039;h00K&#039;,Array[l].u,Array[l].cx,Array[l].cy,Array[l].tx,Array[l].ty,0.03,33,MaxDist(Array[l].i),Damage(Array[l].i),true,&#039;A00A&#039;,&quot;flamestrike&quot;,Array[l].i,250.00,&quot;Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl&quot;)
            call d.destroy()
            return
        endif
        set l = l + 1
    endloop
endfunction

private function Actions takes nothing returns nothing
    local Data d = Data.create()
    local location l = GetSpellTargetLoc()
    set d.i = GetUnitAbilityLevel(d.u,GetSpellAbilityId())
    set d.u = GetTriggerUnit()
    set d.cx = GetUnitX(d.u)
    set d.cy = GetUnitY(d.u)
    set d.tx = GetLocationX(l)
    set d.ty = GetLocationY(l)
    
    call CAS_SA(&#039;h00J&#039;,d.u,d.cx,d.cy,d.tx,d.ty,0.03,33,MaxDist(d.i),Damage(d.i),false,0,null,0,0,null)
    call TimerStart(d.t,0.05,false,function Shockwave)
    
    set Array[c] = d
    set c = c + 1


    
    call RemoveLocation(l)
endfunction


//===========================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( trig, Condition( function Conditions ) )
    call TriggerAddAction( trig, function Actions)
endfunction
   
endscope
theres a comment in the code



edit: solved it with attachment.
which way is better, this way? or attachment systems?
 
Reaction score
456
Syntax error is caused by single =. It should be ==. Sorry, I've been working with other languages.

Also, I have to say I am sorry for giving you the wrong solution, this should fix it:

JASS:
private function Shockwave takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer l = 0
    
    loop
        exitwhen l &gt;= c
        if Array[l].t == t then
            call CAS_SA(&#039;h00K&#039;,Array[l].u,Array[l].cx,Array[l].cy,Array[l].tx,Array[l].ty,0.03,33,MaxDist(Array[l].i),Damage(Array[l].i),true,&#039;A00A&#039;,&quot;flamestrike&quot;,Array[l].i,250.00,&quot;Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl&quot;)
            set Array[c] = Array[l]
            set c = c - 1
            set l = l - 1
            call d.destroy()
            return
        endif
        set l = l + 1
    endloop
endfunction
 

cleeezzz

The Undead Ranger.
Reaction score
268
JASS:
scope HA initializer Init

private function Damage takes integer i returns real
    return 350.00+(100.00*i)
endfunction

private function Damage2 takes integer i returns real
    return 100.00*i
endfunction

private function MaxDist takes integer i returns real
    return 1500.00+(500.00*i)
endfunction

private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == &#039;A006&#039;
endfunction

private struct Data
    timer t
    unit u
    real cx
    real cy
    real tx
    real ty
    integer i
    private method onDestroy takes nothing returns nothing
        set .u = null
        call ReleaseTimer(.t)
    endmethod
endstruct

    

private function Shockwave takes nothing returns nothing
    local Data d = GetCSData(GetExpiredTimer())
    call CAS_SA(&#039;h00K&#039;,d.u,d.cx,d.cy,d.tx,d.ty,0.03,150,33,MaxDist(d.i),Damage2(d.i),true,&#039;A00A&#039;,&quot;flamestrike&quot;,d.i,250.00,&quot;Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl&quot;)
    call d.destroy()
endfunction

private function Actions takes nothing returns nothing
    local Data d = Data.create()
    local location l = GetSpellTargetLoc()
    set d.t = NewTimer()
    set d.u = GetTriggerUnit()
    set d.i = GetUnitAbilityLevel(d.u,GetSpellAbilityId())
    set d.cx = GetUnitX(d.u)
    set d.cy = GetUnitY(d.u)
    set d.tx = GetLocationX(l)
    set d.ty = GetLocationY(l)
    
    call CAS_SA(&#039;h00J&#039;,d.u,d.cx,d.cy,d.tx,d.ty,0.03,75,33,MaxDist(d.i),Damage(d.i),false,0,null,0,0,null)
    call TimerStart(d.t,0.08,false,function Shockwave)

    call SetCSData(d.t, d)
    call RemoveLocation(l)
endfunction


//===========================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( trig, Condition( function Conditions ) )
    call TriggerAddAction( trig, function Actions)
endfunction
   
endscope


lol i just wanted to make it work, so this attachment way works

but, which way is "better"? ill change it if it makes a difference.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top