sphere.qc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. // vengeance sphere
  16. // ==============================
  17. // sphere_impact
  18. // ==============================
  19. void() sphere_impact =
  20. {
  21. if (other.health)
  22. {
  23. T_Damage (other, self, self, 1000 );
  24. }
  25. // don't do radius damage to the other, because all the damage
  26. // was done in the impact
  27. T_RadiusDamage (self, self, 300, other);
  28. // sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
  29. self.origin = self.origin - 8*normalize(self.velocity);
  30. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  31. WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  32. WriteCoord (MSG_BROADCAST, self.origin_x);
  33. WriteCoord (MSG_BROADCAST, self.origin_y);
  34. WriteCoord (MSG_BROADCAST, self.origin_z);
  35. BecomeExplosion ();
  36. };
  37. void(entity ownerEntity) sphere_remove =
  38. {
  39. local entity theSphere;
  40. theSphere = find(world, classname, "Vengeance");
  41. while(theSphere != world)
  42. {
  43. if(theSphere.owner == self)
  44. {
  45. bprint("$qc_death_denied_vengance", theSphere.owner.netname);
  46. remove(theSphere);
  47. theSphere = find(world, classname, "Vengeance");
  48. }
  49. else
  50. theSphere = find(theSphere, classname, "Vengeance");
  51. }
  52. };
  53. // ==============================
  54. // sphere_attack
  55. // ==============================
  56. void() sphere_attack =
  57. {
  58. self.solid = SOLID_TRIGGER;
  59. self.touch = sphere_impact;
  60. if (self.enemy.health < 1)
  61. {
  62. sprint ( self.owner, "$qc_you_are_denied_vengeance");
  63. remove(self);
  64. return;
  65. }
  66. ai_track(self.enemy, 650);
  67. self.nextthink = time + 0.1;
  68. self.think = sphere_attack;
  69. };
  70. // ==============================
  71. // sphere_think
  72. // ==============================
  73. void() sphere_think =
  74. {
  75. if (self.shieldSoundTime < time)
  76. {
  77. sound ( self, CHAN_VOICE, "sphere/sphere.wav", 1, ATTN_NORM);
  78. self.shieldSoundTime = time + 4;
  79. }
  80. if (time > self.delay)
  81. {
  82. if (self.owner.items2 & IT2_V_SPHERE)
  83. self.owner.items2 = self.owner.items2 - IT2_V_SPHERE;
  84. sprint ( self.owner, "$qc_vengeance_lost");
  85. remove (self);
  86. return;
  87. }
  88. if (self.owner.health < 1)
  89. {
  90. if (self.owner.items2 & IT2_V_SPHERE)
  91. self.owner.items2 = self.owner.items2 - IT2_V_SPHERE;
  92. if ( self.owner.enemy.classname == "player" )
  93. {
  94. self.enemy = self.owner.enemy;
  95. sphere_attack();
  96. return;
  97. }
  98. if ( self.owner.enemy.owner.classname == "player")
  99. {
  100. self.enemy = self.owner.enemy.owner;
  101. sphere_attack();
  102. return;
  103. }
  104. remove (self);
  105. return;
  106. }
  107. ai_orbit(self.owner, 16, '0 0 48');
  108. self.think = sphere_think;
  109. self.nextthink = time + 0.1;
  110. };
  111. // ==============================
  112. // sphere_spawn
  113. // ==============================
  114. void() sphere_spawn =
  115. {
  116. local entity missile;
  117. missile = spawn();
  118. missile.movetype = MOVETYPE_FLYMISSILE;
  119. // missile.solid = SOLID_BBOX;
  120. missile.solid = SOLID_NOT;
  121. missile.classname = "Vengeance";
  122. missile.owner = other;
  123. missile.weapon = 0;
  124. missile.delay = time + 30;
  125. setmodel (missile, "progs/sphere.mdl");
  126. setsize (missile, '0 0 0', '0 0 0');
  127. setorigin (missile, self.origin );
  128. missile.avelocity = '40 40 40';
  129. missile.think = sphere_think;
  130. missile.nextthink = time + 0.1;
  131. };
  132. /*QUAKED item_sphere (0 0 1) (-8 -8 -8) (8 8 8) ?
  133. The $qc_vengeance_sphere. DEATHMATCH ONLY.
  134. */
  135. void() item_sphere =
  136. {
  137. if (!deathmatch)
  138. {
  139. remove(self);
  140. return;
  141. }
  142. precache_model ("progs/sphere.mdl");
  143. precache_sound ("sphere/sphere.wav");
  144. self.noise = "sphere/sphere.wav";
  145. self.netname = "$qc_vengeance_sphere";
  146. self.touch = newitems_touch;
  147. setmodel (self, "progs/sphere.mdl");
  148. setsize (self, '-8 -8 -8', '8 8 8');
  149. self.avelocity = '40 40 40';
  150. StartItem ();
  151. };