Firstly, nice work on the script
Weird, removing the check States.PlayerEnabled from OnTick fixed location 5.
I'm pretty sure I was enabled, though.
That was a typo. You used "P" instead of "I":
if States.PlayerEnabled(P) = TRUE then
In a more powerful compiler it would have given you a warning about P being uninitialized.
*sigh* if only "var aaaAllies: array[0..99] of Boolean;" worked...
It works for me... The only limitation is that you can't set it with:
- Code:
aaaAllies := [FALSE, FALSE, FALSE, ...]
However, global variables are initialised to 0 or FALSE by default anyway, so this is not necessary
Even if it was necessary, using a for-loop to set every element to FALSE is very simple.
Also, why not use a 2D array? It will make your code neater since you wouldn't have to use that 10*P+U complication.
- Code:
var aaaAllies: array[0..7] of array[0..7] of Boolean;
//And your main loop becomes:
for P1 := 0 to 7 do
for P2 := 0 to 7 do
if aaaAllies[P1][P2] = TRUE then begin
You might find that performance struggles when players have large villages with 100s of units. You could improve performance by processing each player on a different tick (spreading out the load). Replace the outer loop from above (for P1 := 0 to 7 do) with:
P1 := States.GameTime mod 8; //P1 will cycle from 0..7 every 8 ticks
After seeing your script I added a command States.LocationCount which returns the number of locations on the map (even if no player is using them). This should help you because instead of writing:
for P1 := 0 to 7 do
you can write:
for P1 := 0 to States.LocationCount-1 do