System Knockback System

Tukki

is Skeleton Pirate.
Reaction score
29
Okey, some suggestions.

1: Add constant global for the Timer Interval.
2: You SHOULD consider switching to structs, an array-loop method would be faster than GC.
3: You are creating/destroying effects every 0.03 second which is really bad performance-wise.

Modulo thing: A modulo call returns the rest of a devision. Example:
JASS:

Would display 0 as the rest is 0, while:
JASS:

Would display 1 as the rest is 1.

Test yourself and see.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
But seriously you could use a single global timer and a struct array for this and you would remove the requirement of any additional system. Check out any system that runs on a single timer to figure out how to deal with it (Cohadar's TT, Flare's Custom Auras).
 
Reaction score
456
There's nothing different with using global struct array.

struct[x].variable = value
 

Flare

Stops copies me!
Reaction score
662
There's nothing different with using global struct array.

struct[x].variable = value

There's nothing different between struct arrays and what? A series of normal global arrays?

If that's what you meant, I was talking more in the sense of "Alot of global arrays can get messy" (since I was using 1 bundle of arrays for auras, and another for bonus skills, when I could've just used 2 structs which probably would've been more organised)
 
Reaction score
456
Sorry. I misread. I thought you said "I don't have clue how to use global struct arrays".

No need to reply.<3
 

Atreyu

One Last Breath.
Reaction score
49
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
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
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.
 

Vestras

Retired
Reaction score
248
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 do understant structs. But I've never done as you are saying.. I have always used ABC or something like that to get structs. And I do not store structs with GC in my code. I store locals. Uhm..
 

Flare

Stops copies me!
Reaction score
662
I thought structs were MUI. Why do they need to be arrays then?

They are MUI, but using a global array makes it easier to loop through the current instances i.e.

JASS:
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&#039;s gonna be used in the loop
  loop
  exitwhen i &lt;= 0
     set a = data<i> //That&#039;s just for simplicity, since a is much shorter to type than data<i>
     set a.ticks = a.ticks + 1
     if a.ticks &gt;= 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&#039;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.

All you have to do is attach an integer to GC, and retrieve it when it's needed (I think that's what Vexorian said you had to do in his introduction to structs)
 

Tukki

is Skeleton Pirate.
Reaction score
29
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.
Example:
JASS:

private keyword MyStruct

globals
   private integer COUNTER = 0
   private MyStruct array KBDatas
endglobals

struct MyStruct
// your stuff here
endstruct
 

Flare

Stops copies me!
Reaction score
662
In the code Flare posted above, you would need to position the globals-block beneath the struct.

I know that. I just assumed that MCR-ELSKER would know how to declare the struct, and about where to position things to avoid errors

Use a "keyword" with the same name as your struct and you are able to have the global block above the struct.

Never really knew about keywords :p
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
IMO, a good knockback system requires ease of use, little configuration, many options, commonly used systems (ABC or HSAS instead of attached vars for example) and efficient coding.

Nice effort I guess, but as said before: there are too many knockback systems out there already to make me go "wow" all of the sudden :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top