September 19th, 2017, 18:13
Posts: 10,492
Threads: 395
Joined: Aug 2015
Because calling the "unitValue" procedure from there crashes the game for no reason - (probably out of memory or stack or something like that).
That's the only problem - all the targets are already marked on the map so it has them precalculated, the only thing missing is the value of its own stack. Which means I had to make my own way to find targets instead of using what's available.
...I wonder, if I could make it reserve double the amount of memory for that structure with targets, and use the second half to store own stack strength...as other stacks are being calculated there anyway it should work...
ehhh...not easy at all and we'd need to test the whole thing all over agai...wait, it's not that simple.
Intercontinental attacks don't just look at total stack power. They also look at which of the units are seaworthy - attacking a ship full of hammerhands using 2 water elementals is a perfectly good move even though the defender is like 10x more powerful - the units can't participate in the battle. So the precalculated targets can't be used unless it's on land, and there is no way I'll conveniently find so much free space in the original target seeking mapping procedure to squeeze all of those movement type checks in.
Also if the targets need to be calculated, then even successfully calling "unit value" would not work - it would iincrease the time consumed by possible as much as a factor of 100 - and this is what takes the most time from AI turns already - about 30-50 seconds in worst case.
(not to mention randomly allocating a ton of extra memory is anything but safe - game might thrown an out-of-memory error at unexpected times. Although this one is in EMS I believe so it should be safe...)