runes.qc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. // Rogue Runes
  16. // Jan'97 by ZOID <zoid@threewave.com>
  17. // Under contract to id software for Rogue Entertainment
  18. .float rune; // what rune does this guy have?
  19. .float runetime; // last time we told him he's already got a rune
  20. .float rune1_last_noise_time;
  21. .float rune2_last_noise_time;
  22. .float rune3_last_noise_time;
  23. .float rune4_last_regen_time;
  24. float runespawn; // have we spawned runes?
  25. entity rune_spawn_spot; // spawn spot for runes
  26. float ITEM_RUNE1 = 1; // Rune of Earth Magic: Resistance
  27. float ITEM_RUNE2 = 2; // Rune of Black Magic: Strength
  28. float ITEM_RUNE3 = 4; // Rune of Hell Magic: Haste
  29. float ITEM_RUNE4 = 8; // Rune of Edler Magic: Regeneration
  30. //prototypes
  31. void() RuneTouch =
  32. {
  33. if (other.classname != "player" || other.health <= 0)
  34. return;
  35. if (other.rune) {
  36. if (other.runetime < time)
  37. centerprint(other, "$qc_already_have_rune");
  38. other.runetime = time + 5;
  39. return;
  40. }
  41. other.rune = other.rune | self.rune;
  42. sound (other, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM);
  43. if (self.rune & ITEM_RUNE1)
  44. centerprint(other, "$qc_rune_resistance");
  45. else if (self.rune & ITEM_RUNE2)
  46. centerprint(other, "$qc_rune_strength");
  47. else if (self.rune & ITEM_RUNE3)
  48. centerprint(other, "$qc_rune_haste");
  49. else if (self.rune & ITEM_RUNE4)
  50. centerprint(other, "$qc_rune_regeneration");
  51. remove(self);
  52. };
  53. entity() RuneSpawnPoint =
  54. {
  55. while (1) {
  56. rune_spawn_spot = find(rune_spawn_spot, classname,
  57. "info_player_deathmatch");
  58. if (rune_spawn_spot != world)
  59. return rune_spawn_spot;
  60. }
  61. };
  62. void() RuneRespawn =
  63. {
  64. local entity spot;
  65. spot = RuneSpawnPoint();
  66. setorigin(self, spot.origin);
  67. self.velocity_z = 300;
  68. self.velocity_x = -300 + (random() * 600);
  69. self.velocity_y = -300 + (random() * 600);
  70. self.nextthink = time + 120;
  71. };
  72. void(float r, entity spot) SpawnRune =
  73. {
  74. local entity item;
  75. if (spot == world)
  76. spot = RuneSpawnPoint();
  77. item = spawn();
  78. setorigin(item, spot.origin);
  79. item.rune = r;
  80. item.velocity_z = 300;
  81. item.velocity_x = -300 + (random() * 600);
  82. item.velocity_y = -300 + (random() * 600);
  83. item.flags = FL_ITEM;
  84. item.solid = SOLID_TRIGGER;
  85. item.movetype = MOVETYPE_TOSS;
  86. if (r & ITEM_RUNE1)
  87. setmodel (item, "progs/end1.mdl");
  88. else if (r & ITEM_RUNE2)
  89. setmodel (item, "progs/end2.mdl");
  90. else if (r & ITEM_RUNE3)
  91. setmodel (item, "progs/end3.mdl");
  92. else if (r & ITEM_RUNE4)
  93. setmodel (item, "progs/end4.mdl");
  94. setsize (item, '-16 -16 0', '16 16 56');
  95. item.touch = RuneTouch;
  96. item.nextthink = time + 120; // remove after 2 minutes
  97. item.think = RuneRespawn;
  98. };
  99. // self is player
  100. void() DropRune =
  101. {
  102. if (self.rune & ITEM_RUNE1)
  103. SpawnRune(ITEM_RUNE1, self);
  104. if (self.rune & ITEM_RUNE2)
  105. SpawnRune(ITEM_RUNE2, self);
  106. if (self.rune & ITEM_RUNE3)
  107. SpawnRune(ITEM_RUNE3, self);
  108. if (self.rune & ITEM_RUNE4)
  109. SpawnRune(ITEM_RUNE4, self);
  110. self.rune = 0;
  111. };
  112. void() DoSpawnRunes =
  113. {
  114. remove(self);
  115. SpawnRune(ITEM_RUNE1, world);
  116. SpawnRune(ITEM_RUNE2, world);
  117. SpawnRune(ITEM_RUNE3, world);
  118. SpawnRune(ITEM_RUNE4, world);
  119. };
  120. void() SpawnRunes =
  121. {
  122. local entity spawner;
  123. if (!deathmatch || !(cvar("gamecfg") & GAMECFG_ENABLE_RUNES) || runespawn)
  124. return;
  125. runespawn = 1;
  126. spawner = spawn();
  127. spawner.think = DoSpawnRunes;
  128. spawner.nextthink = time + 0.1;
  129. };
  130. float(float damage, entity who) RuneApplyEarth =
  131. {
  132. if (who.rune & ITEM_RUNE1) {
  133. if (who.rune1_last_noise_time < time) {
  134. sound (who, CHAN_ITEM, "runes/end1.wav", 1, ATTN_NORM);
  135. // tune as needed
  136. who.rune1_last_noise_time = time + 1.0;
  137. }
  138. return damage/2;
  139. }
  140. return damage;
  141. };
  142. void(entity who) RuneApplyBlackNoise =
  143. {
  144. if (who.rune & ITEM_RUNE2)
  145. if (who.rune2_last_noise_time < time) {
  146. sound (who, CHAN_ITEM, "runes/end2.wav", 1, ATTN_NORM);
  147. // tune as needed
  148. who.rune2_last_noise_time = time + 1.0;
  149. }
  150. };
  151. float(float damage, entity who) RuneApplyBlack =
  152. {
  153. if (who.rune & ITEM_RUNE2)
  154. return damage*2;
  155. return damage;
  156. };
  157. float(float tvalue, entity who) RuneApplyHell =
  158. {
  159. if (who.rune & ITEM_RUNE3) {
  160. if (who.rune3_last_noise_time < time) {
  161. sound (who, CHAN_ITEM, "runes/end3.wav", 1, ATTN_NORM);
  162. // tune as needed
  163. who.rune3_last_noise_time = time + 1.0;
  164. }
  165. return (tvalue * 2) / 3;
  166. }
  167. return tvalue;
  168. };
  169. void(entity who) RuneApplyElder =
  170. {
  171. if (who.rune & ITEM_RUNE4) {
  172. if (who.rune4_last_regen_time < time && who.health < 100) {
  173. sound (who, CHAN_ITEM, "runes/end4.wav", 1, ATTN_NORM);
  174. who.health = who.health + 5;
  175. if (who.health > 100)
  176. who.health = 100;
  177. who.rune4_last_regen_time = time + 1.0;
  178. }
  179. }
  180. };
  181. float(entity who) RuneHasElder =
  182. {
  183. if (who.rune & ITEM_RUNE4)
  184. return TRUE;
  185. return FALSE;
  186. };
  187. void() RunePrecache =
  188. {
  189. if (cvar("deathmatch"))
  190. if (cvar("gamecfg") & GAMECFG_ENABLE_RUNES) {
  191. precache_model("progs/end1.mdl");
  192. precache_model("progs/end2.mdl");
  193. precache_model("progs/end3.mdl");
  194. precache_model("progs/end4.mdl");
  195. precache_sound("runes/end1.wav");
  196. precache_sound("runes/end2.wav");
  197. precache_sound("runes/end3.wav");
  198. precache_sound("runes/end4.wav");
  199. }
  200. };