• 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] help me vith my code pls

Status
Not open for further replies.
Level 17
Joined
Jul 17, 2011
Messages
1,863
ok so here is my problem that i cant figure out.
JASS:
function  ApplyDotEffect takes unit damager , unit target , real damg , real duration , real interval, integer attacktypeindex, integer ability_id, boolean refresh , boolean stack   returns nothing
 local real  instance =  (duration / interval )
local integer id = doitRecycler[0]
local integer l = doitNext[0] 
local integer j = doitNext[0] 
local boolean crNew = false 
local boolean crNew1 = false 
   
 
     loop 
		exitwhen l ==0 
			 if target ==doitTarget[l] then //can ve stack or refresh the same instance ?? ? ?? if true , yes 
            
                   if stack == true then //ok but can ve do it does the function call allov us .. if yes.. proceed
                         loop 
                            exitwhen j == 0 
                                if ability_id == doitAbiId[j] then // is it the same ability id ?? if yes proceed  
                                        set doitDamage[j] = (damg + doitTDamage[j] ) / instance 
                                        set doitTDamage[j] = (damg + doitTDamage[j] )
                                       endif 
                                set j= doitNext[j] 
                            endloop 
                            endif  //endif for stack 
                    set j  = doitNext[0]      
             
                    if refresh == true then 
                        loop 
                        exitwhen j == 0 
                            if ability_id == doitAbiId[j] then 
                                    set doitTci[j] = 0 // refresh the number of iterations to 0 so that you can start all over again :D 
                            endif 
                        set j= doitNext[j] 
                        endloop 
                     endif  //endif for refresh 
                     
                     else //if not units in the variables match your new unit then create new instance 
                             call TimerStart(doitTimer, 0.031250000, true , function DoitLoop )
            if  id == 0 then
                set doitCounting[0] = doitCounting[0]  + 1
                set id = doitCounting[0]
            else
                set doitRecycler[0]  = doitRecycler[id] 
            endif
            set doitNext[id] = 0			
            set doitPrev[id] = doitPrev[0]		
            set doitNext[doitPrev[0]] = id		
            set doitPrev[0] = id				
            set  doitDamager[ id] = damager
            set  doitTarget[ id] = target
            set doitIterations[id] = R2I(interval / 0.03125)
            set totalCurrentDoitIterations[id] = R2I(instance)
            set  doitDamage[id] = damg /instance
            set doitInstanceIndex[id] = attacktypeindex 
            set doitAbiId[id ] = ability_id 
            set doitTDamage[id ]  = damg 

            endif 

             
                   set l = doitNext[l] 
                endloop 
                   

endfunction

Ok so this code above is first supposed to check if the current unit variable is equal to any unit stored in the array.

if it is then the system proceeds to check if the function call enables any of the conditions: stack and refresh.

if either is enabled then the system performs another loop to see if ability that triggered the function call is also used to identify one of the instances, this id is also stored in an array.

if this condition returns true then the system merged any old damage with new or refreshes the instance's duration dont worry about that it works fine.

however if the very first condition returns false then the system creates a new instance.



THE PROBLEM IS: how do i arrange these conditions so that:

if condition stack == true then stack the damage
if condition refresh == true then refresh/reset the instance
skip the new instance creation
endif
endif

if stack and refresh are false then
create new instance
endif

basically i can simply put the stack and refresh conditions one after the other but then after both of them are checked and instances are refreshed or stacked a new instance is created.....

currently this just creates a shitzload of instances and lags very bad i have no idea why i know that you people who know more than me can help and sorry for bad indenting
 
Status
Not open for further replies.
Top