View Single Post
 10-03-2007, 11:03 AM #15 Toink User   Join Date: Oct 2006 Posts: 1,086 Submissions (3) Another issue about that is when you destroy some structs, which would then leave an empty space in the whole list. Imagine there's 10 books piled up, these books represent each instances of a unit being knocked back. When a unit is done being knocked back, that book is removed. [Book 10] [Book 9] [Book 8] [Book 7] [Book 6] and so on.. [Book 10] [Book 9] [Book 8] [Book 7] <---- This is done, it will be removed. [Book 6] [Book 10] [Book 9] [Book 8] <---- empty space, your timer will loop through it, not to mention reducing the TOTAL index counter, which means that you will somehow lose track of Book 10 [Book 6] [Null Book 10] <-- You set TOTAL = TOTAL - 1 [Book 9] [Book 8] [Book 6] So to avoid those problems, you'd have to find a way of reorganizing the order of the structs. Fortunately, I have done a method like that along time ago and I'm gonna post it here. Insert this BEFORE you set TOTAL = TOTAL - 1 JASS:``` loop set total = TOTAL set counter = kd set counter = counter + 1 exitwhen counter > TOTAL set data = knockbackdata(counter) //a struct variable //Now we transfer the members of the next struct to the struct destroyed set kd.u = data.u set kd.a = data.a //And so on.. after you transfer all of the members.. call knockbackdata.destroy(data) //Destroy the next struct, the iteration ends, the next iteration will transfer data from the other struct to the struct we just destroyed endloop ``` In other words, we would bring down Book 8, 9 and 10 to fill in the hole caused by the destruction of Book 7.