buzzsaw.qc 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. // buzzsaw.qc
  16. $skin buzzsaw
  17. $frame buzzsaw
  18. $frame bzzrot01 bzzrot02 bzzrot03 bzzrot04 bzzrot05 bzzrot06
  19. void() buzzsaw_stand1 = [ $buzzsaw, buzzsaw_stand1 ]
  20. {
  21. if ( self.pain_finished < time)
  22. {
  23. sound ( self, CHAN_VOICE, "buzz/buzz1.wav", 0.2, ATTN_NORM);
  24. self.pain_finished = time + 1;
  25. }
  26. self.angles_x = self.angles_x - 60;
  27. self.avelocity_x = 60;
  28. };
  29. void() buzzsaw_fly =
  30. {
  31. local vector dir;
  32. if ( self.pain_finished < time)
  33. {
  34. sound ( self, CHAN_VOICE, "buzz/buzz1.wav", 0.2, ATTN_NORM);
  35. self.pain_finished = time + 1;
  36. }
  37. dir = self.goalentity.origin - self.origin;
  38. dir = normalize (dir);
  39. dir = dir * self.speed;
  40. setorigin (self, self.origin + dir);
  41. self.angles_x = self.angles_x - 60;
  42. self.avelocity_x = 60;
  43. };
  44. /*
  45. void() buzzsaw_fly1 = [ $bzzrot01, buzzsaw_fly2 ] { buzzsaw_fly(); };
  46. void() buzzsaw_fly2 = [ $bzzrot02, buzzsaw_fly3 ] { buzzsaw_fly(); };
  47. void() buzzsaw_fly3 = [ $bzzrot03, buzzsaw_fly4 ] { buzzsaw_fly(); };
  48. void() buzzsaw_fly4 = [ $bzzrot04, buzzsaw_fly5 ] { buzzsaw_fly(); };
  49. void() buzzsaw_fly5 = [ $bzzrot05, buzzsaw_fly6 ] { buzzsaw_fly(); };
  50. void() buzzsaw_fly6 = [ $bzzrot06, buzzsaw_fly1 ] { buzzsaw_fly(); };
  51. */
  52. void() buzzsaw_fly1 = [ $bzzrot01, buzzsaw_fly1 ] { buzzsaw_fly(); };
  53. void() buzzsaw_touch =
  54. {
  55. local vector sprayDir;
  56. if ( other.classname == "player" || other.flags & FL_MONSTER)
  57. {
  58. if ( self.attack_finished < time )
  59. {
  60. sound (self, CHAN_WEAPON, "buzz/buzz.wav", 1, ATTN_NORM);
  61. self.attack_finished = time + 2;
  62. }
  63. T_Damage (other, self, self, self.currentammo);
  64. sprayDir = normalize(self.goalentity.origin - self.origin);
  65. sprayDir = sprayDir * 200;
  66. SpawnMeatSpray ( self.origin, sprayDir);
  67. other.velocity = sprayDir;
  68. other.velocity_z = 200;
  69. }
  70. };
  71. void() buzzsaw_use =
  72. {
  73. self.touch = buzzsaw_touch;
  74. if (self.target)
  75. {
  76. self.movetarget = find(world, targetname, self.target);
  77. self.goalentity = self.movetarget;
  78. self.th_stand = buzzsaw_fly1;
  79. self.th_walk = buzzsaw_fly1;
  80. self.th_run = buzzsaw_fly1;
  81. self.think = buzzsaw_fly1;
  82. self.nextthink = time + 0.1;
  83. }
  84. else
  85. {
  86. self.nextthink = time + 0.1;
  87. self.think = buzzsaw_stand1;
  88. }
  89. self.use = SUB_Null;
  90. };
  91. /*QUAKED buzzsaw (0 .5 .8) (-18 -18 -18) (18 18 18) Vertical
  92. The buzzsaw trap.
  93. currentammo: amount of damage for each contact. (default 10)
  94. speed: speed that it will follow it's path. (default 10)
  95. Use the angle buttons to point the buzzsaw in the direction it
  96. should face.
  97. Place on a monster path if you want it to move.
  98. If it is targeted, it will wait until triggered to activate.
  99. It will not damage players until activated.
  100. */
  101. void() buzzsaw =
  102. {
  103. precache_model ("progs/buzzsaw.mdl");
  104. precache_sound ("buzz/buzz.wav");
  105. precache_sound ("buzz/buzz1.wav");
  106. setmodel (self, "progs/buzzsaw.mdl");
  107. self.takedamage = DAMAGE_NO;
  108. self.solid = SOLID_TRIGGER;
  109. self.movetype = MOVETYPE_FLY;
  110. if(self.angles_y == 0 || self.angles_y == 180)
  111. setsize (self, '-18 0 -18', '18 0 18');
  112. else if(self.angles_y == 90 || self.angles_y == 270)
  113. setsize (self, '0 -18 -18', '0 18 18');
  114. else
  115. objerror ("Buzzsaw: Not at 90 degree angle!");
  116. setorigin (self, self.origin);
  117. if (!self.speed)
  118. self.speed = 10;
  119. if (!self.currentammo)
  120. self.currentammo = 10;
  121. self.pain_finished = time + random()*2;
  122. if (!self.targetname)
  123. {
  124. self.think = buzzsaw_use;
  125. self.nextthink = time + 0.2;
  126. }
  127. else
  128. {
  129. self.use = buzzsaw_use;
  130. }
  131. };