Randomize player starting everything

This tut will help you make your players randomize in solo and coop, and give you options for different starting weapons, viewarms, and laststand pistols.

NOTE

This tut assumes you already know how to get weapons or viewarms into your map, via raw folders or csvs.

1. Copy _loadout.gsc from your root/raw/maps folder to your root/mods/mapname/maps folder, if you haven't already

2. Open _loadout.gsc in your mods folder in a text editor, i.e. Sublime Text 2, Notepad, and Notepad++

3. Under players = get_players(); in the init_loadout() function put this:

 level.bodys = [];  level.bodys[level.bodys.size] = 0;  level.bodys[level.bodys.size] = 1;  level.bodys[level.bodys.size] = 2;  level.bodys[level.bodys.size] = 3;  level.startguns = [];  //The following sets up 4 possible guns, be sure to add_weapon below, where appropriate  level.startguns[level.startguns.size] = "zombie_colt";//change weapon, not needed for player randomizing  level.startguns[level.startguns.size] = "zombie_colt";//change weapon, not needed for player randomizing  level.startguns[level.startguns.size] = "zombie_colt";//change weapon, not needed for player randomizing  level.startguns[level.startguns.size] = "zombie_colt";//change weapon, not needed for player randomizing  //The following will randomize the each players weapons at start. Comment out to not do that  level.startguns = array_randomize(level.startguns);//randomizes starting gun each game per player, not needed for player randomizing  level.bodys = array_randomize(level.bodys); 

4. Search for "zombiemode" and find add_weapon("zombie_colt");

5. Add the four weapons you would like to start with, if you want multiple weapons otherwise skip this step, i.e.:

  add_weapon( "change weapon");   add_weapon( "change weapon");   add_weapon( "change weapon");   add_weapon( "zombie_colt"); 

6. Add PrecacheModel("vewarms") for each viewarms you will be using under the add_weapon lines, if you want to use multiple viewarms, otherwise skip this step, i.e.:

  PrecacheModel( "change arms" );   PrecacheModel( "change arms" );   PrecacheModel( "change arms" );   PrecacheModel( "change arms" ); 

6. Scroll down to give_model( class) function.

7. Find the following:

  else if( isDefined( level.use_zombie_heroes ) && level.use_zombie_heroes )    { 

8. Paste this under it: (replacing the switch that is there)

   self.body_select = randomint(4);    if(isdefined(self.entity_num)){     self.body_select = level.bodys[self.entity_num];    }    if(!IsDefined( self.mybod )) self.mybod = self.body_select;    else self.body_select = self.mybod;    self.entity_num = self.mybod;      switch( self.body_select)    {    case 0:     character\char_zomb_player_0::main();     // self SetUp_Weapons(level.startguns[0]);     // self SetViewModel("change arms");     break;    case 1:     character\char_zomb_player_1::main();     // self SetUp_Weapons(level.startguns[1]);     // self SetViewModel("change arms");     break;    case 2:     character\char_zomb_player_2::main();     // self SetUp_Weapons(level.startguns[2]);     // self SetViewModel("change arms");     break;    case 3:     character\char_zomb_player_3::main();     // self SetUp_Weapons(level.startguns[3]);     // self SetViewModel("change arms");     break;    } 

8.1 Copy dlc3_code.gsc to your mods/mapnme/maps folder and open it, then modify the level_start_vox() function like this to fix the first time playing demsy quote

level_start_vox() {  wait( 6 );//moved here  index = maps\_zombiemode_weapons::get_player_index( self );  plr = "plr_" + index + "_";  // wait( 6 );//commented out  self thread create_and_play_dialog( plr, "vox_level_start", 0.25 ); } 

8.2 In dlc3_code.gsc, find player_zombie_awareness function and add a wait(6); before the index line:

player_zombie_awareness() {  self endon("disconnect");  self endon("death");  players = getplayers();  wait(6);//add this line so it doesn't get the index before the players are established (or move index line to before its needed lower in the function)  index = maps\_zombiemode_weapons::get_player_index(self); 

NOTE

Random players are done. For any of the following you do not want, simply skip the step.

9. If you want different starting weapons or viewarms, uncomment the appropriate lines above and modify the string (the text between the quotes) and add this function above give_model( class):

SetUp_Weapons(weapon){  self GiveWeapon(weapon);  self.player_switchweapon = weapon;  self.last_stand_weapon = weapon; } 

10. For different starting weapons change:

if( IsDefined( level.player_switchweapon ) )     {         // the wait was added to fix a revive issue with the host         // for some reson the SwitchToWeapon message gets lost         // this can be removed if that is ever resolved         if ( isdefined(wait_for_switch_weapon) && wait_for_switch_weapon == true )         {             wait(0.5);         }         self SwitchToWeapon( level.player_switchweapon );     }

to (level changes to self):

if( IsDefined( self.player_switchweapon ) )  {   // the wait was added to fix a revive issue with the host   // for some reson the SwitchToWeapon message gets lost   // this can be removed if that is ever resolved   if ( isdefined(wait_for_switch_weapon) && wait_for_switch_weapon == true )   {    wait(0.5);   }   self SwitchToWeapon( self.player_switchweapon );  } 

11. If using different viewarms for each, find and comment out this:

 if( IsDefined( level.player_viewmodel ) )  {   self SetViewModel( level.player_viewmodel );  } 

12. To update laststand pisols open your _laststand.gsc in raw/maps folder and find laststand_take_player_weapons() function and add this under self.laststandpistol = undefined;:

 if(isDefined(self.last_stand_weapon)){   self.laststandpistol = self.last_stand_weapon;  } 

13. Don't forget to update pistol for single player solo revive if you have it, however you added it.

TROUBLESHOOTING:

If you are given all the weapons you add, find and comment out the following in your give_loadout function:

 for( i = 0; i < level.player_loadout.size; i++ )  {   self GiveWeapon( level.player_loadout[i] );  } 

And if you have a switch after that you can comment out the entire switch too, up to:

level.gaveweapons[level.gaveweapons.size] = "gave"; 

Leave this^ if you have it