Hypergammaspaces' assorted ASM

FillAIDangerMap Efficiency Fix

When generating AI units’ movement, the game uses a nested for loop to iterate through each red unit, and then check the strength of every ally unit that could potentially reach it in the next turn. This causes a small amount of lag in the vanilla games, but for hacks using the Modular Stat Getters (especially with skill system), the strength getter increases in complexity from a single function call to dozens of nested function calls, ballooning the load on the CPU. With this function located inside this nested loop, it can potentially get called hundreds of times each time the AI moves a unit, including multiple calls for the same ally unit, causing noticeable loading times of several seconds.

This hack rewrites FillAIDangerMap to cache the result of GetUnitPower so that it only runs once per ally unit per calculation. This improves AI decision speed by 50% or more. It also fits in the same space of the vanilla function, so no repointing needed.

tl;dr If you have MSG and lots of deploy slots on your maps, install this

Before (thanks Pik for the gifs):

After:

36 Likes