Okay, big update here guys:
I think that the “new” memory leak / crashing is related to the damage-queue bug. So, the whole thing about delayed hits was originally implemented to solve a visual / performance issue - ten bajillion hits all being resolved on the same frame. As it turns out, this isn’t a big performance deal, and keeping a super long damage queue just makes it worse. Furthermore, it was leading to really weird issues with speed-independent damage resolution, which even led to porcupine damage resolving ultra-fast, and sometimes several seconds (or even minutes!) after the damage was originally done, resulting in super-dead berserkers.
So, here’s the new solution. If too much damage happens at once, it still delays the hits, but only for one update cycle. Then, it takes all those delayed hits and unleashes them in the next update cycle, but it “congeals” their numbers together, so 10 simultaneous hits will just create one bouncing number with the sum of the damage. Congealed hits segregate by visual text type - so red will group with red, white with white, blue with blue, gold with gold, etc. Visually I’m not sure how much of a difference this will make since there’s still 60 update cycles per second, but it should theoretically help performance. Another thing I can do is increase the “visual damage congeal” time (which is completely separate from hit resolution, it’s just a display issue) so that all damage numbers over a second are “congealed” rather than all damage over one frame, or something in between. This way there might be some point in turning on damage numbers late game - right now it’s just a sea of numbers that obscures everything you’re doing so I always personally turn it off.
Anyway, the visual stuff is semi irrelevant. The most important thing is this solves several problems with the damage queue.
First, damage resolves in game time now, I plugged the glitch that made it resolve in real-time while doing the above fix. This should keep battles mostly deterministic on different speeds.
Second, it should give you credit for hits faster, so if you’ve put enough damage into the super-duper sheep to kill it, you don’t have to wait 5 minutes or pause the game to run the ‘damage clock’ forward.
Third, berserkers seem to not get ultra-murdered by porcupine like they used to. This is because their damage now resolves in proportion to their animations and cooldowns, not via the damage queue. Although the damage queue would delay hits, sometimes even up to a minute, they would resolve one right after another, at a rate of one per update cycle, so when the berserkers hits finally landed, they’d all land way faster than the berserker could normally attack, so four or five full cooldown cycles of attacks would be dealt out over a single second, and he’d get hit by all the porcupine damage at once, and his regen and nearby healers would have no chance to save him.
I found some other bugs while I was at it, too. For one, porcupine damage was sometimes hitting the wrong target, because the enemy wasn’t always keeping perfect track of who had hit them with the melee attack. (Ie, a berserker hits a thorned enemy, but before the porcupine resolves a ranger’s arrow hits them, so the porcupine attacks the ranger!) This is now fixed.
Next, I found some “invisible poison” being applied randomly when testing the super sheep level. Turned out that Ketta had 0 points in “poison shot” which was not being ignored - instead it was just giving her a poison damage flavor with 0 amount of poison. This would resolve so that it would show the poison effect on the enemy sprite, but not in the preview panel, and would do 0 damage every second. Now I just make it explicitly ignore passive skills with 0 points in them.
So, the thing to look out for with fixing the damage queue is that I’ve changed the way damage resolves. If I made a mistake, this means that hits could be getting dropped, ignored, or otherwise folded, spindled, or mutilated. I don’t think I did any of that, but if you guys could keep a close eye on things for me, that’d be much appreciated.
To aid in debugging stuff like this in the future, in the next few patches I will try to eventually create a “battle log” that you can have the game write out to, so we can examine it to make sure nothing bad is happening. If anyone has any suggestions for how to format that or what data it should capture, I’m all ears.
Finally, the next test version will be 1.0.21. If I had been smart, the first patch would have been 1.0.01 so I could have counted up from there, but I forgot the leading zero. I also forgot to correct my mistake with the second test version and just do 1.0.11. At any rate, I’m fixing this now to give myself more room. I’m not entirely sure how the internal Adobe AIR version checker works, but I know that 1.0.21 is unambiguously “bigger” than 1.0.2, regardless of how it’s reckoning things, so that’s where we’re going from here.
I’ll let you know when the new version is up.