Randomize Starting Spawn Areas

RANDOMIZED STARTING SPAWN AREAS

This tutorial will show you an easy way to make multiple possible randomized starting spawn areas for all players to spawn in together. There will be an option to set it truly random, or not to repeat the same spawn area twice. Truly random could repeat the same area many many times.

RADIANT

1. Open Radiant

2. Find your initial_spawn_points structs.

https://i.gyazo.com/3039647f033756bcddfe6e72c14d11e4.png

3. Select one of the structs and press the space bar4. Place the new struct in the center of the other 45. Change the new struct kvp targetname to randomize_start6. Select all 5 structs and press the space bar

7. Move the new set to another zone you would like to spawn in (write down this zone's targetname value)

8. Repeat steps 4 and 5 for each zone you would like to possibly start in.

9. Save and compile map

SCRIPT

10. Open your nazi_zombie_mapname

11. Find the following:

 zones = [];  zones[ zones.size ] = "start_zone"; 

12. Add the zones that you added spawns to in radiant like this:

 zones = [];  zones[ zones.size ] = "start_zone";  zones[ zones.size ] = "another_zone";//another_zone will be replaced by the name of the zone you put other structs in  //zones[ zones.size ] = "yes_another_zone";//yes_another_zone will be replaced by the name of the zone you put other structs in 

13. Save and close nazi_zombie_mapname.gsc

14. If you don't have a copy of zombiemode.gsc in your mods/mapname/maps folder, copy one from raw/maps now

15. Open the _zombiemode.gsc from mods/mapname/maps folder

16. Find and replace this:

coop_player_spawn_placement() {  structs = getstructarray( "initial_spawn_points", "targetname" );  

With this:

coop_player_spawn_placement() {  never_same_area = 1;//make undefined or 0 if you don't mind the same area in a row possibility  randomstarts = GetStructArray( "randomize_start","targetname" );  randnum = randomInt(randomstarts.size);  if(IsDefined( never_same_area ) && never_same_area && randomstarts.size>1){   if(randnum==getdvarint("laststart")){    if(randnum==(randomstarts.size-1)) randnum = 0;    else randnum++;   }  }  setdvar("laststart",randnum);  randomstart = randomstarts[randnum];  structs = [];  allstructs = GetStructArray( "initial_spawn_points", "targetname" );   for( i=0;i<allstructs.size;i++ ){   //distance of 150 may need adjusted depending on how you space your structs   if(Distance( allstructs[i].origin,randomstart.origin )<150) structs[structs.size] = allstructs[i];  } 

17. Review never_same_area comment to see if this is how you want it:

- never_same_area = 1 will spawn a different area every time

- never_same_area = undefined or never_same_area = 0 will be truly random

18. Save and close _zombiemode.gsc

19. When map is done compiling, select _zombiemode.gsc in the Mod Builder tab, if necessary, and build mod.

20. Start map and test.