• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

A simple indexing question

Status
Not open for further replies.
Level 13
Joined
Mar 24, 2013
Messages
1,105
They are the exact same. DIMF has a basic and generic showing of it, PnF has a more in-depth tutorial but they are both showing the same method. The only thing maybe slightly different is in Ch 12 it does a periodic check every 1 second I would probably advise a more frequent check so things are happening more precisely.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
They are the exact same. DIMF has a basic and generic showing of it, PnF has a more in-depth tutorial but they are both showing the same method. The only thing maybe slightly different is in Ch 12 it does a periodic check every 1 second I would probably advise a more frequent check so things are happening more precisely.

In the explanation I do say that a 0.03 should be used. Dynamic Indexing is also different. Indexed arrays don't keep there order. While dynamic indexing does.

There are slight differences and indexed arrays are slightly faster. They are also cleaner to code IMO.
 
The dynamic indexing I show in my tutorial doesn't maintain order either. It does the same thing.

Although, perhaps Hanky's implementation is different. I don't quite remember.

But anyway, the names are overall arbitrary (link). All that matters is the implementation. In the end, the speed difference is likely to be negligible (unless you use a really bad algorithm), so don't worry about it too much.

Most of the "indexing" for spells is done relatively the same way: you increment a counter, assign some arrays (sometimes they start at 0, sometimes at 1), and then you start a timer. In the timer trigger, you loop through the indexes. When a spell is done, it'll remove the index from the list (which varies: in most indexing it will just shift the last element to the current position, and then decrease the loop integer and instance count). And that is usually all there is to it.
 
So for something that requires order like for example a spinning spell which moves in a circle is something Indexed arrays can't do?

That doesn't require order. Spells that require "ordered" instances are very rare. One example could be two units doing periodic damage to each other if the caster is alive. Let's say they are both about to die from a final tick of the periodic damage. In the tick before, some other miscellaneous unit finished his DoT, and that moved the unit B's instance before unit A. Originally, unit A should've had his tick deal damage first, but unit B's instance got moved ahead of it in the looping order, so unit A will die and unit B won't (assuming that the spell checks if the caster is alive before dealing damage).

But that is a really specific, really rare case. We don't worry about that too much.

In your case, indexed arrays/dynamic indexing/anything would be fine. If you are using multiple dummy units for the "spinning", then you can just use a unit group. If you need to attach effects to them, then you may want to use a hashtable to save the effects under the key of each dummy unit, or you can use a unit indexer, or w/e.
 
Status
Not open for further replies.
Top