call BJDebugMsg(I2S(ModuloInteger(10, 2)))
call BJDebugMsg(I2S(ModuloInteger(10, 3)))
If you do use mine as an example for any reason (if you do choose to go from cache to single timer), don't use a massive block of global arrays. Use a struct array instead (I didn't have a clue how to use global struct arrays at the time )(Cohadar's TT, Flare's Custom Auras)
There's nothing different with using global struct array.
struct[x].variable = value
is the first Knockback System with Group Knocking!
From your title.... Doesn't Emijlr3 had a group knockback? Or was that Tinki3?
A nice spell though.... +rep
I thought structs were MUI. Why do they need to be arrays then?
I don't think you are understanding structs. Structs contain multiple objects, but there are different ways to attach structs. One way is to attach it using the GC, in which case it does not have to be an array. Another way is to store each Struct as it is created in an array, using a system that stores reference numbers for units, timers, or even handles in general. The the struct is retrieved by getting the struct[object'sArrayNumber].
PUI (Perfect Unit Indexing) is an example of a system that stores numbers for units.
I thought structs were MUI. Why do they need to be arrays then?
struct StructData
integer ticks = 0
integer maxticks
endstruct
globals
private integer CurrentInstances
private StructData array data
private timer LoopTimer = CreateTimer ()
private constant real TimerFreq = 0.03125
endglobals
function LoopFunc takes nothing returns nothing
local integer i = CurrentInstances
local StructData a //Leave it uninitialized, it's gonna be used in the loop
loop
exitwhen i <= 0
set a = data<i> //That's just for simplicity, since a is much shorter to type than data<i>
set a.ticks = a.ticks + 1
if a.ticks >= a.maxticks then //When the instance should be finished
call a.destroy ()
set data<i> = data[CurrentInstances]//Moving the last struct in the list to the newly freed slot
set CurrentInstances = CurrentInstances - 1 //And reducing the number of structs we must loop through <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" />
if CurrentInstances == 0 then
call PauseTimer (LoopTimer)
endif
endif
set i = i - 1
endloop
endfunction
//And we've done everything we need with every struct in the loop
//And now, for adding new stuff to the loop
function AddToLoop takes integer maxticks returns nothing
local StructData a
set CurrentInstances = CurrentInstances + 1
set data[CurrentInstances] = StructData.create ()
set a = data[CurrentInstances]
set a.maxticks = maxticks
//And any other arguments you may need
if CurrentInstances == 1 then
call TimerStart (LoopTimer, TimerFreq, true, function LoopFunc)
endif
endfunction</i></i></i>
And I do not store structs with GC in my code. I store locals.
In the code Flare posted above, you would need to position the globals-block beneath the struct.
Use a "keyword" with the same name as your struct and you are able to have the global block above the struct.