• 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.

Indexing Problem/new way of indexing does not work

Status
Not open for further replies.
How it should work:
everytime a slot becomes empty the last value of the array will be copyed to it

I made and uploaded some system using this way of indexing:
http://www.hiveworkshop.com/forums/spells-569/lightning-system-by-d4rk_g4nd4lf-version-0-1d-142234/
I didn't find any bugs while testing but I did not test all cases...
however people told me about fatal errors and I was like: :cry: DAMN IT! I FAILED!!!!111

after thinking about everything I decided to recode the problem at its simplest form and here it is:

it should work but it does not
must be some extreme case I think because it only happenes sporadically
I'm looking for either a way to fix this or an even better indexing system
don't think anything can beat this by its simplicity and efficiency though

Code:
  • Events
    • Time - Every 0.10 seconds of game time
  • Conditions
  • Actions
    • Set Number = (Number + 1)
    • Set Duration[Number] = 0.00
    • Set DurationMax[Number] = (Random real number between 0.00 and 2.00)
    • Set loc = (Center of (Playable map area))
    • Set loc2 = (loc offset by 256.00 towards (Real(Number)) degrees)
    • Lightning - Create a Drain Life lightning effect from source loc to target loc2
    • Set Lightning[Number] = (Last created lightning effect)
    • Custom script: call RemoveLocation( udg_loc )
    • Custom script: call RemoveLocation( udg_loc2 )
    • Visibility - Disable fog of war
    • Visibility - Disable black mask
  • Events
    • Time - Every 0.03 seconds of game time
  • Conditions
  • Actions
    • For each (Integer A) from 1 to Number, do (Actions)
      • Loop - Actions
        • Game - Display to (All players) the text: (Number: + (String(Number)))
        • Game - Display to (All players) the text: (A: + (String((Integer A))))
        • Game - Display to (All players) the text: (Duration: + (String(Duration[(Integer A)])))
        • Game - Display to (All players) the text: (Max Duration: + (String(DurationMax[(Integer A)])))
        • Set Duration[(Integer A)] = (Duration[(Integer A)] + 0.03)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Duration[(Integer A)] Less than DurationMax[(Integer A)]
          • Then - Actions
            • Set loc = (Center of (Playable map area))
            • Set loc2 = (loc offset by 256.00 towards (Real((Integer A))) degrees)
            • Lightning - Move Lightning[(Integer A)] to source loc and target loc2
            • Custom script: call RemoveLocation( udg_loc )
            • Custom script: call RemoveLocation( udg_loc2 )
          • Else - Actions
            • Lightning - Destroy Lightning[(Integer A)]
            • Set Duration[(Integer A)] = Duration[Number]
            • Set Lightning[(Integer A)] = Lightning[Number]
            • Set Number = (Number - 1)
edit: I uploaded a modified version with a little text and so on to understand it easier
 

Attachments

  • IndexTest.w3x
    17.1 KB · Views: 75
  • Index Visualisation.w3x
    17.4 KB · Views: 92
Level 6
Joined
Oct 31, 2008
Messages
229
Storing the last variable in the array in a place where a variable was stored, might call malfunctions. in some cases you must first delete the value (like flush it). Now i have an idea which i am about to input in my map. You replace all variables with they're right previous and use the array more like a stack (you take an item and all above fall a place if you understand me). ill gladly help when i get a computer with wc3 and jngp

EDIT:In some cases you might need to store the place of a specific place in the array and thus by moving it you can have pesky malfunctions (another reason for remaking to a new system)
 
Storing the last variable in the array in a place where a variable was stored, might call malfunctions. in some cases you must first delete the value (like flush it). Now i have an idea which i am about to input in my map. You replace all variables with they're right previous and use the array more like a stack (you take an item and all above fall a place if you understand me). ill gladly help when i get a computer with wc3 and jngp

EDIT:In some cases you might need to store the place of a specific place in the array and thus by moving it you can have pesky malfunctions (another reason for remaking to a new system)

the only variable type this could happen to is the lightning type I think
how do I completely clear lightning type vars?
just by setting them = null?
edit: setting to null does not remove the bug

however your stack idea might sound funny but just moving the last value would be faster (imagine a stack of like a million of values (ok this won't happen in wc3....))

and I don't like the idea of moving the index of an index cause it is 1. weird and 2. takes a lot of time in gui for every action to click another time :/

and I won't code anything in JASS as long as I don't have to
I prefer slow code and slow coding instead of a billion of typos :grin:

edit2: the game crashes everytime a non existent lightning is MOVED and not when it's destroyed
might help understanding the problem

edit3: got the bug
wc3 does not use the gui values I said it should use in the loop and so it does not count correctly
to fix it:
  • Custom script: set bj_forLoopAIndexEnd = bj_forLoopAIndexEnd - 1
 
Last edited:
Status
Not open for further replies.
Top