Advertisement
techforce

Hitsound

Oct 1st, 2014
3,218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Attempts to dampen the DB (decible) factor depending on pointcontents of ent emitting sound
  2. float() SUB_Db =
  3. {
  4. //float ATTN_NONE    = 0;
  5. //loat ATTN_NORM    = 1;
  6. //float ATTN_IDLE    = 2;
  7. //float ATTN_STATIC    = 3;
  8.  
  9. //float CONTENT_EMPTY    = -1;
  10. //float CONTENT_SOLID    = -2;
  11. //float CONTENT_WATER    = -3;
  12. //float CONTENT_SLIME    = -4;
  13. //float CONTENT_LAVA    = -5;
  14. //float CONTENT_SKY    = -6;
  15.  
  16.  
  17. local float pc;
  18. pc = pointcontents(self.origin);
  19. if (pc == -3 || pc == -4)
  20. return (3);
  21.  
  22.  
  23.  
  24. if (pc == -2)
  25. {
  26. if (self.classname == "debug_marker")
  27. if (Volume (self.enemy) >= 300)
  28. return (0);
  29. else
  30. return (1);
  31. }
  32.  
  33. if (random () < 0.5)
  34. return (2);
  35. else
  36. return (1);
  37.  
  38. };
  39.  
  40. // Pick a random sound channel
  41. float () RND_CHAN =
  42. {
  43. local float j;
  44. j = (rint(random () * 6)) + 1;
  45. if (j == 1)
  46. return (RN_CH1);
  47. if (j == 2)
  48. return (RN_CH2);
  49. if (j == 3)
  50. return (RN_CH3);
  51. if (j == 4)
  52. return (RN_CH4);
  53. if (j == 5)
  54. return (RN_CH5);
  55. if (j == 6)
  56. return (RN_CH6);
  57. if (j == 7)
  58. return (RN_CH7);
  59.  
  60. };
  61.  
  62. void (entity obj) Hitsound =
  63. {
  64. local float s,k;
  65.  
  66. s = (rint(random () * 149) + 1);
  67. if (random () < 0.5)
  68. k = s;
  69. else
  70. k = s /15;
  71. if ((s < 0.25))
  72. {
  73. if (random () < 0.5)
  74. sound (obj, RND_CHAN (), "weapons/tink1.wav", 1, ATTN_IDLE);
  75. else
  76. soundpitch (obj, RND_CHAN (), "weapons/tink1.wav", 1, SUB_Db(), k);
  77. }
  78. if ((s > 0.75))
  79. {
  80. if (random () < 0.5)
  81. sound (obj, RND_CHAN (), "weapons/ric1.wav", 1, ATTN_IDLE);
  82. else
  83. soundpitch (obj, RND_CHAN (), "weapons/ric1.wav", 1, SUB_Db(), k);
  84. }
  85. else
  86. {
  87. if (((s > 0.25) && (s < 0.5)))
  88. {
  89. if (random () < 0.5)
  90. sound (obj, RND_CHAN (), "weapons/ric2.wav", 1, ATTN_IDLE);
  91. else
  92. soundpitch (obj, RND_CHAN (), "weapons/ric2.wav", 1, SUB_Db(), k);
  93. }
  94. else
  95. {
  96. if (((s > 0.5) && (s < 0.75)))
  97. {
  98. if (random () < 0.5)
  99. sound (obj, RND_CHAN (), "weapons/ric3.wav", 1, ATTN_IDLE);
  100. else
  101. soundpitch (obj, RND_CHAN (), "weapons/ric3.wav", 1, SUB_Db(), s);
  102. }
  103. }
  104. }
  105. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement