Advertisement
Guest User

random spawner for zandronum multiplayer

a guest
Aug 19th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.26 KB | None | 0 0
  1. str weapons[3] = { "weapon0", "weapon1", "weapon2", "weapon3" }; /* array to store all your weapon names in, remeber array start at 0 */
  2.  
  3. Script 1 (void)
  4. {
  5.     int x, y, z, ang, tid, rand;
  6.  
  7.     /* get the spawner actor's position */
  8.     x = GetActorX(0);
  9.     y = GetActorY(0);
  10.     z = GetActorZ(0);
  11.    
  12.     /* and angle */
  13.     ang = GetActorAngle (0);
  14.        
  15.     while(TRUE){  /* this is just the main loop that will be forever looped forever */
  16.         rand = Random(0, 3); /* choose random weapon, min should be 0, max should be same as array to get all things in array, in this case 0 to 3 */
  17.         /* you can actually do without the rand variable, feel free to replace rand with the Random function in the array below, kept it in for ease of explanation */
  18.         tid = UniqueTID(); /* grab a new unique tid for the weapon we're about to spawn */
  19.         SpawnForced (weapons[rand], x, y, z , tid, ang); /* spawn the random weapon at the position of the spawning actor with the uniquetid */
  20.        
  21.         while(ThingCount(T_NONE, tid)) { /* loop until the item you just spawned is picked up */
  22.              Delay(1); }
  23.              
  24.         if(!GetCVar("SV_WeaponStay") /* if sv_weaponstay is not on */
  25.           && GetCVar("SV_ItemRespawn")){ /* and items are set to respawn */
  26.          
  27.           /* then we recreate the awful respawn timer for items found here : https://doomwiki.org/wiki/Spawning
  28.              because there is no such thing as sv_itemrespawn for zandronum apparently and I can't find a concrete respawn time */
  29.             Delay(428); /* wait 12 seconds */
  30.             /* we approximate this */
  31.             /* "Is the current tic value a multiple of 32? If not, do not respawn." */
  32.             /* by random initial delay, and then a check every 32, instead of having to have a tic counter running somewhere */
  33.             Delay(Random(0, 31));
  34.             /* now we recreate "Choose a random number from 0 to 255. Is it less than or equal to 4? If so, respawn." */
  35.             while(Random(0,255)<5){
  36.                 Delay(32);}  }
  37.         while(!GetCVar("SV_ItemRespawn")){ /* In case items aren't set to respawn */
  38.           Delay(5); } /* wait around and see if they are so that maps aren't broken if people accidentally set flags the wrong way or change their mind */
  39.        
  40.         }  
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement