I'm definitely no H.G. Wells, it goes to show.
Heres the issue. I've written a naive implementation of a 'Time Machine' sort of engine for my current project. It works sort of like the time reversal in Prince of Persia or Braid; by holding down a key, you can actually travel backwards in time for the previous X seconds.
Now this is a nifty thing, but I'm having trouble making it work with large numbers of objects. It works by running a loop every frame that writes to an array the properties of every single object within a qualifier group, which contains most every 'active object'. So once per frame it reads each object one at a time, and saves its X, Y, Angle, Animation, and Alterable Values to the array.
Then, when retrieving it, it simply reads backwards on the Z dimensions and sets each of the objects values accordingly. I have all sorts of other neat and complicated tricks, like saving a list of events that occured each frame which is run in reverse, etc. But that all works perfectly.
The part that DOESN'T work perfectly is the loop that SAVES the values of each object. It looks like this:
It might not be immediately obvious WHAT is causing the code to go so slowly. It is this:
Actually, its also the Flag Conditions.
Heres the problem. Each time the loop runs, it wants to pick a single specific object out of all the objects. The order it picks them in isn't important, just that it picks each object a single time. But the way it is set up right now, it must run that value comparison for N^2 times, meaning 10000 comparisons for 100 objects.
This is because when the game has the object selection list, it narrows it down by comparing the D Alterable Value of each single object against the variable. That means N comparisons. But it also runs the code N times, which means N^2. So even though it could theoretically be only "N" complexity, its N^2. All I want to do is pick a single object out of the scope, but I can't think of a way to do this without comparing to ALL objects. Even the Flag events compare at N^2.
I need some sort of way to pick an Nth object from the object selection list, which doesn't use up N comparisons. As we all know, Polynomial timecomplexity is the computer killing bane of mankind. So how can I go about doing this?
I tried the "Select Object" extension, but it simply didn't work at all. Maybe someone has an example of how to use it? I tried discarding the Selecting the first X and Discarding the first X-1 objects, but that didn't work. In fact, no matter what I tried with the extension the code would never actually run no matter what, no matter what code I was using. Is there a newer version, or is it simply completely incompatible with MMF2? I know it doesn't work with qualifiers, but I even tried it with normal objects and it didn't run. Is there any similar extension or any possible way to do the same thing...?
So thats just half the battle.
The other half is less complicated; writing that many values to an array at runtime causes slowdown on its own. Its only a teeny-tiny amount of slowdown though. I'm just curious if theres any 3d array style extension I could use in place of the built in MMF2 array? Its only an issue once theres about 400+ objects, and I doubt I'd ever be over 200. But even so, thats a teeny bit of lag added on top of other teeny bits of lag. I'd prefer something that runs without microscopic time.
So uh yeah, basically, is there any way I can select a single object at a time, from a list of objects (preferably qualifiers) and run an event referencing it, hitting each object once?