Hmm, I wasn't aware of that Changelevel() command. I was trying with Teleport_NewMap(), which worked in the script I had created, but when using an UNLOADING script, it would process the random map selection and go to that map, then be immediately sent to the next map as if being executed by Exit_Normal().
It didn't work so I figured it couldn't be done. Isle's solution looks like it would work. Legend, I'd recommend you try that.
Randomly Selecting From a List
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Re: Randomly Selecting From a List
Not sure what you mean by that exactly.just a small problem of seeing the next map for a frame though.
By the looks of the code, it says changelevel_nointermission. Does that mean that the intermission screen will not be shown? Is there a way to keep it?
Re: Randomly Selecting From a List
So, would I put this in a library and use the load acs script? And put all the maps in an array?Isle wrote:if you want a random map you could change it when the next one loads. just use a global to make sure you don't keep changing levels. IE:just a small problem of seeing the next map for a frame though.Code: Select all
global int 1:loaded; int levels[5] = {"map01", "map02", "map03", "map04", "map05"}; script 1 OPEN { if(!loaded) { loaded = 1; changelevel(levels[random(0, 4)], 0, CHANGELEVEL_NOINTERMISSION); } else loaded = 0; }
I'm not sure how to combine the above with:
Which part would I replace?Code: Select all
Code: Select all • Expand view global int 0:list[20] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; #define last 19; // this will be used later on global int 1:max = 19; // (size of array - 1) Script 1 ENTER { int choice; int rand; rand = Random(0,max); // The array element chosen choice = list[rand]; // The value in that element int temp; temp = list[rand]; list[rand] = list[last]; // this is where we need the "last" variable. list[last] = temp; // it represents the last element of the full sized array max--; Teleport_NewMap (choice, 0, 0); // Sends the player to the chosen map. } Script 2 RETURN { TakeInventory(); GiveInventory("Pistol",1); GiveInventory("Clip",50); GiveInventory("Fist",1); int choice; int rand; rand = Random(0,max); // The array element chosen choice = list[rand]; // The value in that element int temp; temp = list[rand]; list[rand] = list[last]; // this is where we need the "last" variable. list[last] = temp; // it represents the last element of the full sized array max--; Teleport_NewMap (choice, 0, 0); // Sends the player to the chosen map. }
Re: Randomly Selecting From a List
The way Isle's method works is not changing the map right before you EXIT a level but changing the map just after you ENTER a new one. In other words, for a brief frame you'll see the first map load before it redirects and loads the actual map you want. That's why the no intermission. Otherwise the player would see the intermission of all 0%'s for the level they didn't play.Legend wrote:Not sure what you mean by that exactly.
Re: Randomly Selecting From a List
still not sure how to combine the code samples in my last post or where to put them. I've been looking in the wiki for help on how to implement it but still not sure how yet. If Slasher, or isle (or anyone else) could provide a few more pointers, I'd appreciate it. Thanks.