Advertisement
Guest User

Perfect respawn timer version

a guest
Aug 19th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.43 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. int tics; /* variable for tic counter */
  4.  
  5. script 1 OPEN /* script to keep track of tics */
  6. {
  7.     while(TRUE){
  8.     Delay(1);
  9.     ++tics; }
  10. }
  11.  
  12. Script 1 (void)
  13. {
  14.     int x, y, z, ang, tid;
  15.  
  16.     /* get the spawner actor's position */
  17.     x = GetActorX(0);
  18.     y = GetActorY(0);
  19.     z = GetActorZ(0);
  20.    
  21.     /* and angle */
  22.     ang = GetActorAngle (0);
  23.        
  24.     while(TRUE){  /* this is just the main loop that will be forever looped forever */
  25.         /* 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 */
  26.         tid = UniqueTID(); /* grab a new unique tid for the weapon we're about to spawn */
  27.         /* for Random() function to 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 */
  28.         SpawnForced (weapons[Random(0, 3);], x, y, z , tid, ang); /* spawn the random weapon at the position of the spawning actor with the uniquetid */
  29.        
  30.         while(ThingCount(T_NONE, tid)) { /* loop until the item you just spawned is picked up */
  31.              Delay(1); }
  32.              
  33.         if(!GetCVar("SV_WeaponStay") /* if sv_weaponstay is not on */
  34.           && GetCVar("SV_ItemRespawn")){ /* and items are set to respawn */
  35.          
  36.           /* then we recreate the awful respawn timer for items found here : https://doomwiki.org/wiki/Spawning
  37.              because there is no such thing as sv_itemrespawn for zandronum apparently and I can't find a concrete respawn time */
  38.             Delay(428); /* wait 12 seconds */
  39.             /* we recreate this */
  40.             /* "Is the current tic value a multiple of 32? If not, do not respawn." */
  41.             /* and "Choose a random number from 0 to 255. Is it less than or equal to 4? If so, respawn." */
  42.             While(()tics % 32) != 0){
  43.                 Delay(1); }
  44.             /* now we recreate "Choose a random number from 0 to 255. Is it less than or equal to 4? If so, respawn." */
  45.             while(Random(0,255)<5){
  46.                 Delay(32);}  }
  47.         while(!GetCVar("SV_ItemRespawn")){ /* In case items aren't set to respawn */
  48.           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 */
  49.        
  50.         }  
  51.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement