dmatch.qc 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. // dmatch - general deathmatch additions
  16. // =======================================
  17. // =======================================
  18. void() tag_token_respawn =
  19. {
  20. local entity spawnPoint;
  21. local entity tagToken;
  22. tagToken = find (world, classname, "dmatch_tag_token");
  23. if(tagToken == world)
  24. return;
  25. spawnPoint = SelectSpawnPoint();
  26. setorigin(tagToken, spawnPoint.origin);
  27. tag_token_owner = world;
  28. tagToken.solid = SOLID_TRIGGER;
  29. tagToken.touch = tag_token_touch;
  30. tagToken.think = SUB_Null;
  31. tagToken.owner = world;
  32. tagToken.tag_frags = 0;
  33. droptofloor();
  34. };
  35. // =======================================
  36. // =======================================
  37. void() tag_token_fall =
  38. {
  39. self.tag_frags = 0;
  40. self.think = tag_token_respawn;
  41. self.nextthink = time + 30;
  42. droptofloor();
  43. };
  44. // =======================================
  45. // =======================================
  46. void() tag_token_drop =
  47. {
  48. local entity tagToken;
  49. tagToken = find (world, classname, "dmatch_tag_token");
  50. if(tagToken == world)
  51. return;
  52. bprint("$qc_lost_token", tagToken.owner.netname);
  53. tagToken.tag_frags = 0;
  54. tagToken.solid = SOLID_TRIGGER;
  55. tagToken.owner = world;
  56. tagToken.touch = tag_token_touch;
  57. tagToken.think = tag_token_fall;
  58. tagToken.nextthink = time + 0.1;
  59. };
  60. // =======================================
  61. // =======================================
  62. void() tag_token_think =
  63. {
  64. if ( self.owner.health > 0)
  65. {
  66. if ( self.tag_message_time < time )
  67. {
  68. bprint("$qc_has_token", self.owner.netname);
  69. self.tag_message_time = time + 30;
  70. }
  71. setorigin ( self, self.owner.origin + '0 0 48');
  72. self.think = tag_token_think;
  73. self.nextthink = time + 0.1;
  74. }
  75. else
  76. {
  77. tag_token_drop();
  78. }
  79. };
  80. // =======================================
  81. // =======================================
  82. void() tag_token_touch =
  83. {
  84. if (other.classname != "player")
  85. return;
  86. tag_token_owner = other;
  87. self.tag_frags = 0;
  88. sound ( self, CHAN_AUTO, "runes/end1.wav", 1, ATTN_NORM);
  89. bprint("$qc_got_token", other.netname);
  90. self.tag_message_time = time + 30;
  91. self.owner = other;
  92. self.solid = SOLID_NOT;
  93. self.touch = SUB_Null;
  94. self.think = tag_token_think;
  95. self.nextthink = time + 0.1;
  96. };
  97. /*QUAKED dmatch_tag_token (1 1 0) (-16 -16 -16) (16 16 16)
  98. The deathmatch tag token.
  99. */
  100. void() dmatch_tag_token =
  101. {
  102. if ( cvar("teamplay") != TEAM_DMATCH_TAG )
  103. {
  104. remove (self);
  105. return;
  106. }
  107. precache_model ("progs/sphere.mdl");
  108. precache_sound ("runes/end1.wav");
  109. setmodel(self, "progs/sphere.mdl");
  110. self.skin = 1;
  111. setsize (self, '-16 -16 -16', '16 16 16');
  112. self.touch = tag_token_touch;
  113. self.effects = self.effects | EF_DIMLIGHT;
  114. StartItem();
  115. };
  116. // =======================================
  117. // =======================================
  118. void(entity targ, entity attacker) dmatch_score =
  119. {
  120. local entity tagToken;
  121. if ( teamplay == TEAM_DMATCH_TAG )
  122. {
  123. tagToken = find (world, classname, "dmatch_tag_token");
  124. if(tagToken == world)
  125. {
  126. attacker.frags = attacker.frags + 1;
  127. return;
  128. }
  129. if ( attacker == tag_token_owner)
  130. {
  131. tagToken.tag_frags = tagToken.tag_frags + 1;
  132. attacker.frags = attacker.frags + 3;
  133. if ( tagToken.tag_frags == 5 )
  134. {
  135. sprint (attacker, "$qc_got_quad");
  136. attacker.items = attacker.items | IT_QUAD;
  137. stuffcmd (attacker, "bf\n");
  138. sound (attacker,CHAN_VOICE,"items/damage.wav", 1, ATTN_NORM);
  139. attacker.super_time = 1;
  140. attacker.super_damage_finished = time + 30;
  141. }
  142. else if (tagToken.tag_frags == 10)
  143. {
  144. bprint("$qc_lost_token", attacker.netname);
  145. tagToken.solid = SOLID_TRIGGER;
  146. tagToken.tag_frags = 0;
  147. tagToken.touch = tag_token_touch;
  148. tag_token_respawn();
  149. }
  150. }
  151. else
  152. {
  153. if (targ == tag_token_owner)
  154. {
  155. attacker.frags = attacker.frags + 5;
  156. sound ( self, CHAN_AUTO, "runes/end1.wav", 1, ATTN_NORM);
  157. if (attacker.classname == "player")
  158. {
  159. tag_token_owner = attacker;
  160. tagToken.tag_frags = 0;
  161. tagToken.tag_message_time = time + 0.5;
  162. tagToken.owner = attacker;
  163. tagToken.solid = SOLID_NOT;
  164. tagToken.touch = SUB_Null;
  165. tagToken.think = tag_token_think;
  166. tagToken.nextthink = time + 0.1;
  167. }
  168. }
  169. else
  170. attacker.frags = attacker.frags + 1;
  171. }
  172. }
  173. };