Custom Map #2147: Disco Time!. By: TrickyCorp

Started by AutoPost, August 09, 2021, 09:00:33 AM

Previous topic - Next topic

AutoPost

This topic is for discussion of map #2147: Disco Time!


Author: TrickyCorp
Size: 192x120

CS Z

The lag was pretty bad towards the end (about 12 to 15 UPS in the lower left and never got over 30 UPS at 4x).  I've got a powerful desktop computer too so I'm sure some people will have worse lag.

I've noticed that on most maps with this particular unit, it has the habit of causing lag.  Without looking at the 4RPL, I'm going to hazard a guess that each unit constantly calls a bunch of expensive GetCreeper() + GetDistance() calls to find a nearby creeper-filled space.  The more range it has, the more calls it makes.  If there is no creeper in range (GetCreeperInRange()), the unit should go to sleep for 5 to 15 frames or something along those lines.  That way, only the units that are actually able to attack creeper are actually executing expensive functions and the rest of the units remain relatively dormant.

Also, you could further optimize the creeper detection and removal by randomly spacing out GetCreeper() calls to skip cell checks in the scan region.  It's a trick I used for the MOAB unit where I randomly skipped X number of spaces on the grid for its special effects explosion sequence.  Creeper travels everywhere, so if there is creeper in one cell, it's likely in a nearby cell too, so the player won't really notice if you skip cells to attack as long as you eventually get all of them.  However, the overall game performance boost will be noticeable.

TrickyPlayer

Quote from: CS Z on August 09, 2021, 04:15:10 PM
I've noticed that on most maps with this particular unit, it has the habit of causing lag.  Without looking at the 4RPL, I'm going to hazard a guess that each unit constantly calls a bunch of expensive GetCreeper() + GetDistance() calls to find a nearby creeper-filled space.  The more range it has, the more calls it makes.  If there is no creeper in range (GetCreeperInRange()), the unit should go to sleep for 5 to 15 frames or something along those lines.  That way, only the units that are actually able to attack creeper are actually executing expensive functions and the rest of the units remain relatively dormant.

Nah, the script uses GetEnemy, but I suppose giving the unit a break if it finds no creeper could be good. However, I'm already planning quite some time on limiting this structure's build limit instead, so I might not actually do this. If anyone ever plans on using this rainbow blaster themselves though and don't want to limit them to around 20 max, they might have to make this change themselves.

What I will do though, is slightly optimize the script so that it only calls for range when it could shoot (And if it can't find creeper, it delays the next shot for 10 frames), and make the unit self destruct if it existed for too long without shooting (Am thinking of making this self destruct times 5 minutes so there's plenty of time for it to be reset)
When you want an explanation for something I use in my levels, or if you want to suggest something, feel free to tell me. Just don't ask/suggest things every other day please :P