I have written the following code to create random ennemy attack on a town.
This code is launched 5 times when a civil is walken (with waypoints) on 5 different triggers (which launch the following code).
Each execution of the code change one of the 5 variable to 1. In the game this change free an enemy group on its waypoint.
?!local server:x=floor(random 5)
publicvariable "x"
?(x) == 0: goto "val_0"
?(x) == 1: goto "val_1"
?(x) == 2: goto "val_2"
?(x) == 3: goto "val_3"
?(x) == 4: goto "val_4"
#val_0
? (zero_x) == 1 : goto "val_1"
zero_x=1
publicvariable "zero_x"
goto "fin"
#val_1
? (un_x) == 1 : goto "val_2"
un_x=1
publicvariable "un_x"
goto "fin"
#val_2
? (deux_x) == 1 : goto "val_3"
deux_x=1
publicvariable "deux_x"
goto "fin"
#val_3
? (trois_x) == 1 : goto "val_4"
trois_x=1
publicvariable "trois_x"
goto "fin"
#val_4
? (quatre_x) == 1 : goto "val_0"
quatre_x=1
publicvariable "quatre_x"
#fin
This code must be launch only 5 time. If it is launch more there is no exit !
initialization of variables are in the init file :
PublicVariable "_x";
PublicVariable "_zero_x";
PublicVariable "_un_x";
PublicVariable "_deux_x";
PublicVariable "_trois_x";
PublicVariable "_quatre_x";
_x = 0;
_zero_x = 0;
_un_x = 0;
_deux_x = 0;
_trois_x = 0;
_quatre_x = 0;
The problem i find is that variable : _zero_x, _un_x, ..., _quatre_x, never keep there state o or 1 for each launch of the code.
How can i do this ?