So in my custom story i want to change to different maps with one script, posted in the end of all the maps.
It will work like this:
You start in the default map (Which is NOT random).
You get to a point where the script calls and you change map:
There are 3 different maps to change to, and the first change should be completely random.
After getting to the "end-point" in map 1, the script calls again, but now it can only choose between the 2 maps which haven't been played yet.
At last when finishing that map, you will change to the last map, not played.
I cannot figure out how to script this.
Yes it's something with SetGlobalVarInt("Map_1", 1) and GetGlobalVarInt and that... but when it also has to choose randomly between them. It cannot seem to form correctly in my head.
Could anybody help me?
Lets just call the maps:
Path_1
Path_2
Path_3
Trying is the first step to success.
(This post was last modified: 11-19-2012, 05:02 PM by FlawlessHappiness.)
And you should do something like this for the other maps. Sorry for not putting all the script, but I'm in a friend's house (Gooby) and I don't have time.
You'll want to use the RandInt(int, int) function, there you can set the range to pick from (say, RandInt(1, 3), then you can append that to the name of the map you want to change to.
For example (this will need to be inside a function)
int MapNum = RandInt(1, 3);
ChangeMap("Path_" + MapNum, .... etc);
That is, very basically, a way to get a random map to jump to - you'll need to be careful with the names of maps (so that they are all Path_1, Path_2 etc) and also the names of the start positions will have to be the same since you need to provide the ChangeMap function with the name of the start pos.
You'll probably run into problems in keeping a record of which maps you have already been to, you should be able to do this with global variables but it would be best to use an array, but I'm not sure how arrays behave in the global script yet so I won't give you advice on that
EDIT: Ninja'd, but the problem with only using a variable for which map you've been to is as you say, if 2 gets picked then you are buggered. Also, global variables as far as I understand get wiped if the player saves/exits/restarts, so its kinda dangerous
(This post was last modified: 11-19-2012, 05:55 PM by Adrianis.)
(11-19-2012, 05:53 PM)Adrianis Wrote: Also, global variables as far as I understand get wiped if the player saves/exits/restarts, so its kinda dangerous
They don't get wiped if the player saves, only if the player exits without saving, which isn't an issue.
if(GetGlobalVarInt("PlayedFirstPath_2") == 1)
{
AddTimer("ChangeMap_Second_"+RandInt(1, 2), 0, "ChangeMap_Second_1_3");
//IF THE PLAYER PLAYED 1 AND 3, CALL SEPARATE TIMER THAT CHOOSES BETWEEN 1 AND 3//
return;
}
2(a). If you get something besides a 2, everything keeps going normally.
or
2(b). If you get a 2 you will enter the "while" script, because "maper" being equal to 2 fulfills the conditions under which the while will run.
3. The script inside the while will pick a new number for maper at random, also from 1 to 3. It will keep repeating this process until "maper" is no longer 2, because as long as it is, the while script will never end, and keep repeating itself.
2(a). If you get something besides a 2, everything keeps going normally.
or
2(b). If you get a 2 you will enter the "while" script, because "maper" being equal to 2 fulfills the conditions under which the while will run.
3. The script inside the while will pick a new number for maper at random, also from 1 to 3. It will keep repeating this process until "maper" is no longer 2, because as long as it is, the while script will never end, and keep repeating itself.