random.qc 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /* Copyright (C) 1996-2022 id Software LLC
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; either version 2 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  13. See file, 'COPYING', for details.
  14. */
  15. // Random.qc
  16. // =======================================================
  17. // Random Items!
  18. // =======================================================
  19. // equal divisions of 1:
  20. // 5: 0.2, 0.4, 0.6, 0.8, 1
  21. // 6: 0.16, 0.33, 0.48, 0.66, 0.83, 1
  22. // 7: 0.14, 0.28, 0.43, 0.56, 0.71, 0.86, 1
  23. // 8: 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1
  24. void() random_pick_type =
  25. {
  26. local float randItem;
  27. randItem = random();
  28. self.touch = powerup_touch;
  29. setsize (self, '-16 -16 -24', '16 16 32');
  30. if(randItem < 0.2)
  31. {
  32. self.touch = newitems_touch;
  33. self.noise = "shield/pickup.wav";
  34. setmodel (self, "progs/shield.mdl");
  35. self.netname = "$qc_power_shield";
  36. self.items = 0;
  37. self.items2 = IT2_SHIELD;
  38. // if(norandom == 1)
  39. // self.classname = "item_powerup_shield";
  40. }
  41. else if (randItem < 0.4)
  42. {
  43. self.touch = newitems_touch;
  44. self.noise = "belt/pickup.wav";
  45. setmodel (self, "progs/beltup.mdl");
  46. self.netname = "$qc_anti_grav_belt";
  47. self.items = 0;
  48. self.items2 = IT2_ANTIGRAV;
  49. // if(norandom == 1)
  50. // self.classname = "item_powerup_belt";
  51. }
  52. else if (randItem < 0.6)
  53. {
  54. self.noise = "items/protect.wav";
  55. setmodel (self, "progs/invulner.mdl");
  56. self.netname = "$qc_pentagram_of_protection";
  57. self.items = IT_INVULNERABILITY;
  58. self.items2 = 0;
  59. // if(norandom == 1)
  60. // self.classname = "item_artifact_invulnerability";
  61. }
  62. else if (randItem < 0.8)
  63. {
  64. self.noise = "items/inv1.wav";
  65. setmodel (self, "progs/invisibl.mdl");
  66. self.netname = "$qc_ring_of_shadows";
  67. self.items = IT_INVISIBILITY;
  68. self.items2 = 0;
  69. // if(norandom == 1)
  70. // self.classname = "item_artifact_invisibility";
  71. }
  72. else
  73. {
  74. self.noise = "items/damage.wav";
  75. setmodel (self, "progs/quaddama.mdl");
  76. self.netname = "$qc_quad_damage";
  77. self.items = IT_QUAD;
  78. self.items2 = 0;
  79. // if(norandom == 1)
  80. // self.classname = "item_artifact_super_damage";
  81. }
  82. };
  83. /*QUAKED item_random_powerup (0 .5 .8) (-16 -16 -24) (16 16 32)
  84. The Random Box!
  85. Contains a random powerup.
  86. */
  87. void() item_random_powerup =
  88. {
  89. if (!deathmatch)
  90. {
  91. remove(self);
  92. return;
  93. }
  94. // Precache the lot of it....
  95. precache_model ("progs/shield.mdl");
  96. precache_model ("progs/p_shield.mdl");
  97. precache_model ("progs/beltup.mdl");
  98. precache_model ("progs/invulner.mdl");
  99. precache_model ("progs/invisibl.mdl");
  100. precache_model ("progs/quaddama.mdl");
  101. precache_sound ("items/inv1.wav");
  102. precache_sound ("items/inv2.wav");
  103. precache_sound ("items/inv3.wav");
  104. precache_sound ("items/protect.wav");
  105. precache_sound ("items/protect2.wav");
  106. precache_sound ("items/protect3.wav");
  107. precache_sound ("items/damage.wav");
  108. precache_sound ("items/damage2.wav");
  109. precache_sound ("items/damage3.wav");
  110. precache_sound ("belt/pickup.wav");
  111. precache_sound ("belt/use.wav");
  112. precache_sound ("belt/fadeout.wav");
  113. precache_sound ("shield/pickup.wav");
  114. precache_sound ("shield/hit.wav");
  115. precache_sound ("shield/fadeout.wav");
  116. random_pick_type();
  117. StartItem ();
  118. };
  119. void() random_regen =
  120. {
  121. random_pick_type();
  122. SUB_regen();
  123. };