Page 1 of 1

Avoid a bug

PostPosted: 18 Jan 2010, 12:26
by Andronikos
Sometimes the AI players troops running around the map and they ignore their AI positions. How can I avoid this bug, when I creating a mission? :?

PostPosted: 18 Jan 2010, 15:32
by Thunderwolf
By having less that 256 units (including animals, serfs etc.) in total, something like that at least.

PostPosted: 19 Jan 2010, 09:08
by Andronikos
By having less that 256 units (including animals, serfs etc.) in total, something like that at least.
"By having less that 256 units" - including soldiers too? And what about AI defendig positions - are there any limits? In the first minutes I haven`t any problems, but later, after about 20 minutes, one of my enemy`s soldiers get crazy. I changed the AI def. positions, the map etc., but it don`t works - so the only think I should do is to put less units in the map?

PostPosted: 19 Jan 2010, 12:47
by Lewin
Yes, this bug is unofficially known as "Drunk Soldiers", because the units run around like they are intoxicated. :D We don't actually know if the unit count is per team or over the whole game. We also don't know if 256 is the number, but it seems likely. AI defence positions are different, but THEY TOO HAVE A LIMIT. (keep reading) Soldiers going crazy basically has to be drunk soldiers, going over the AI defence limit just means excess ones are ignored.

Are you using my mission editor? (latest version 0.9 required for these instructions to work properly) If so then I suggest you click Help -> Help on the menu, then go to Appendix -> Game Bugs and also Command Limits. Game bugs explains some of the errors that are relevant to mission making, and the Command Limits page shows the the limits available for some commands (I think AI Defence Positions is 20 per team) You really should read these two pages as I think they will give you a better understand of the bugs and limits you need to know about for scripting.

Hope this helps, let me know if you want more information or have more questions.
Lewin.

PostPosted: 20 Jan 2010, 09:51
by Xmasjos
I think it is 255, because that's the maximum for an int in assembly. If you go to 256, you'll get -1 (or -255, I'm not sure of that). That's the problem at the maximum producing with the weapons.

PostPosted: 20 Jan 2010, 14:10
by harold
256 overflows to 0
255 = -1 (no overflow, it's just equal)
254 = -2 (proof, see blow)
(etc, up until 128 = -128, which means that 128 has the odd property of being nonzero but being its own negative anyway)
The last two depend on whether you treat the numbers as signed or not

254 = 11111110 (binary)
Lets take an arbitrary x, say 23 aka 00010111
00010111
11111110
----------- + (8bit binary addition)
00010101 (with overflow, but let's ignore that)
which is 1 + 4 + 16 = 21
Solve: 23 + y = 21 for y -> y = -2
Therefore, 254 equals -2, in 8bit arithmetic.
QED