daily pastebin goal
39%
SHARE
TWEET

Untitled

a guest Feb 7th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ------------------------------------------------------------------------------------------------
  2. //
  3. //   A version of PowerTimeFreezer which does not mute sound while in effect.
  4. //
  5. // ------------------------------------------------------------------------------------------------
  6. // Credits: Blue Shadow & Kinsie, thank you!
  7. // Credit: https://forum.zdoom.org/viewtopic.php?f=43&t=57013
  8.  
  9. class SMPowerTimeFreezerSound : PowerTimeFreezer
  10. {
  11.     override void InitEffect()
  12.     {
  13.         int freezemask;
  14.  
  15.         Powerup.InitEffect();
  16.  
  17.         if (Owner == null || Owner.player == null)
  18.             return;
  19.  
  20.         CVar doomSMPauseMusicCvar = CVar.FindCVar("sm_pausemusic");
  21.         CVar doomSMPauseSoundsCvar = CVar.FindCVar("sm_pausesounds");
  22.  
  23.         // When this powerup is in effect, pause the music.
  24.         S_PauseSound(doomSMPauseMusicCvar, doomSMPauseSoundsCvar);
  25.  
  26.         // When this powerup is in effect, pause the music.
  27.         //S_PauseSound(false, true);
  28.  
  29.         // Give the player and his teammates the power to move when time is frozen.
  30.         freezemask = 1 << Owner.PlayerNumber();
  31.         Owner.player.timefreezer |= freezemask;
  32.         for (int i = 0; i < MAXPLAYERS; i++)
  33.         {
  34.             if (playeringame[i] &&
  35.                 players[i].mo != null &&
  36.                 players[i].mo.IsTeammate(Owner)
  37.                )
  38.             {
  39.                 players[i].timefreezer |= freezemask;
  40.             }
  41.         }
  42.  
  43.         // [RH] The effect ends one tic after the counter hits zero, so make
  44.         // sure we start at an odd count.
  45.         EffectTics += !(EffectTics & 1);
  46.         if ((EffectTics & 1) == 0)
  47.         {
  48.             EffectTics++;
  49.         }
  50.         // Make sure the effect starts and ends on an even tic.
  51.         if ((level.time & 1) == 0)
  52.         {
  53.             level.frozen = true;;
  54.         }
  55.         else
  56.         {
  57.             // Compensate for skipped tic, but beware of overflow.
  58.             if(EffectTics < 0x7fffffff)
  59.                 EffectTics++;
  60.         }
  61.     }
  62.  
  63.     override void EndEffect()
  64.     {
  65.         Powerup.EndEffect();
  66.  
  67.         // If there is an owner, remove the timefreeze flag corresponding to
  68.         // her from all players.
  69.         if (Owner != null && Owner.player != null)
  70.         {
  71.             int freezemask = ~(1 << Owner.PlayerNumber());
  72.             for (int i = 0; i < MAXPLAYERS; ++i)
  73.             {
  74.                 players[i].timefreezer &= freezemask;
  75.             }
  76.         }
  77.  
  78.         // Are there any players who still have timefreezer bits set?
  79.         for (int i = 0; i < MAXPLAYERS; ++i)
  80.         {
  81.             if (playeringame[i] && players[i].timefreezer != 0)
  82.             {
  83.                 return;
  84.             }
  85.         }
  86.  
  87.         // No, so allow other actors to move about freely once again.
  88.         level.frozen = false;
  89.  
  90.         // Also, turn the music back on.
  91.         S_ResumeSound(true);
  92.     }
  93. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top