items_runes.qc 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. /*
  16. ===============================================================================
  17. END OF LEVEL RUNES
  18. ===============================================================================
  19. */
  20. float SIGIL_E1 = 1;
  21. float SIGIL_E2 = 2;
  22. float SIGIL_E3 = 4;
  23. float SIGIL_E4 = 8;
  24. float SIGIL_E5 = 16;
  25. float SIGIL_E6 = 32;
  26. float SIGIL_NUMBITS = 6;
  27. float SIGIL_ALL = SIGIL_E1 | SIGIL_E2 | SIGIL_E3 | SIGIL_E4 | SIGIL_E5;
  28. float SIGIL_ALL_ALL_ALLLL = SIGIL_E1 | SIGIL_E2 | SIGIL_E3 | SIGIL_E4 | SIGIL_E5 | SIGIL_E6;
  29. void() sigil_touch =
  30. {
  31. if (other.classname != "player")
  32. return;
  33. if (other.health <= 0)
  34. return;
  35. centerprint_all (self.netname); // Netname is localized
  36. sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  37. stuffcmd (other, "bf\n");
  38. self.solid = SOLID_NOT;
  39. self.model = string_null;
  40. float lastPickup = SUB_LeftShift(self.spawnflags & SIGIL_ALL, SIGIL_NUMBITS);
  41. serverflags = serverflags | (self.spawnflags & SIGIL_ALL) | lastPickup;
  42. if (cvar("horde") && (self.spawnflags & SIGIL_E2)) // Hunger
  43. {
  44. local entity e;
  45. e = find(world, classname, "player");
  46. while (e)
  47. {
  48. e.hunger_time = time + HUNGER_MAX;
  49. dprint("hunger time is: ");
  50. dprint(ftos(e.hunger_time));
  51. dprint("\n");
  52. e = find(e, classname, "player");
  53. }
  54. }
  55. activator = other;
  56. SUB_UseTargets(); // fire all targets / killtargets
  57. };
  58. float sigil_getLastPickup()
  59. {
  60. float lastPickup = SUB_RightShift(serverflags, SIGIL_NUMBITS) & SIGIL_ALL;
  61. return lastPickup;
  62. }
  63. void sigil_clearLastPickup()
  64. {
  65. serverflags = serverflags & ~SUB_LeftShift(SIGIL_ALL, SIGIL_NUMBITS);
  66. }
  67. /*QUAKED item_sigil (0 .5 .8) (-16 -16 -24) (16 16 32) E1 E2 E3 E4 E5 E6
  68. End of level sigil, pick up to end episode and return to jrstart.
  69. */
  70. void() item_sigil =
  71. {
  72. dprint("SPAWNING SIGIL: ");
  73. dprint(ftos(self.spawnflags));
  74. dprint("\n");
  75. if (!self.spawnflags)
  76. self.spawnflags|= SIGIL_E1;
  77. precache_sound ("misc/runekey.wav");
  78. self.noise = "misc/runekey.wav";
  79. string tempmdl = string_null;
  80. if (self.spawnflags & SIGIL_E1)
  81. {
  82. self.spawnflags = SIGIL_E1;
  83. tempmdl = "progs/mg1_rune1.mdl";
  84. self.netname = "$qc_mg1_pickup_rune1";
  85. }
  86. else if (self.spawnflags & SIGIL_E2)
  87. {
  88. self.spawnflags = SIGIL_E2;
  89. tempmdl = "progs/mg1_rune2.mdl";
  90. self.netname = "$qc_mg1_pickup_rune2";
  91. }
  92. else if (self.spawnflags & SIGIL_E3)
  93. {
  94. self.spawnflags = SIGIL_E3;
  95. tempmdl = "progs/mg1_rune3.mdl";
  96. self.netname = "$qc_mg1_pickup_rune3";
  97. }
  98. else if (self.spawnflags & SIGIL_E4)
  99. {
  100. self.spawnflags = SIGIL_E4;
  101. tempmdl = "progs/mg1_rune4.mdl";
  102. self.netname = "$qc_mg1_pickup_rune4";
  103. }
  104. else if (self.spawnflags & SIGIL_E5)
  105. {
  106. self.spawnflags = SIGIL_E5;
  107. tempmdl = "progs/mg1_rune5.mdl";
  108. self.netname = "$qc_mg1_pickup_rune5";
  109. }
  110. else if (self.spawnflags & SIGIL_E6)
  111. {
  112. self.spawnflags = SIGIL_E6;
  113. tempmdl = "progs/mg1_rune6.mdl";
  114. self.netname = "$qc_mg1_pickup_rune6";
  115. }
  116. dprint("PREP SIGIL\n");
  117. precache_model (tempmdl);
  118. setmodel (self, tempmdl);
  119. self.touch = sigil_touch;
  120. setsize (self, '-16 -16 -24', '16 16 32');
  121. StartItem ();
  122. };
  123. // ===============================================================================
  124. const float RUNE_INDICATOR_ACTIVE = 64;
  125. void misc_rune_indicator_use()
  126. {
  127. self.alpha = 1.0;
  128. SUB_UseTargets();
  129. }
  130. void misc_rune_indicator()
  131. {
  132. float active = self.spawnflags & RUNE_INDICATOR_ACTIVE ? TRUE : FALSE;
  133. self.spawnflags (-) RUNE_INDICATOR_ACTIVE;
  134. if (!self.spawnflags)
  135. {
  136. self.spawnflags|= SIGIL_E1;
  137. }
  138. self.spawnflags &= SIGIL_ALL_ALL_ALLLL;
  139. string mdl = string_null;
  140. if (self.spawnflags & SIGIL_E1)
  141. {
  142. self.spawnflags = SIGIL_E1;
  143. mdl = "progs/mg1_rune1.mdl";
  144. }
  145. else if (self.spawnflags & SIGIL_E2)
  146. {
  147. self.spawnflags = SIGIL_E2;
  148. mdl = "progs/mg1_rune2.mdl";
  149. }
  150. else if (self.spawnflags & SIGIL_E3)
  151. {
  152. self.spawnflags = SIGIL_E3;
  153. mdl = "progs/mg1_rune3.mdl";
  154. }
  155. else if (self.spawnflags & SIGIL_E4)
  156. {
  157. self.spawnflags = SIGIL_E4;
  158. mdl = "progs/mg1_rune4.mdl";
  159. }
  160. else if (self.spawnflags & SIGIL_E5)
  161. {
  162. self.spawnflags = SIGIL_E5;
  163. mdl = "progs/mg1_rune5.mdl";
  164. }
  165. else if (self.spawnflags & SIGIL_E6)
  166. {
  167. self.spawnflags = SIGIL_E6;
  168. mdl = "progs/mg1_rune6.mdl";
  169. }
  170. precache_model (mdl);
  171. setmodel (self, mdl);
  172. self.use = misc_rune_indicator_use;
  173. if(((self.spawnflags & serverflags) == self.spawnflags) || active )
  174. {
  175. self.think = SUB_UseTargets;
  176. self.nextthink = time + 0.2;
  177. }
  178. else
  179. {
  180. //Show a ghost of the rune before you collect it.
  181. self.alpha = 0.2;
  182. }
  183. }