enforcer.qc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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. SOLDIER / PLAYER
  18. ==============================================================================
  19. */
  20. $cd /raid/quake/id1/models/enforcer
  21. $origin 0 -6 24
  22. $base base
  23. $skin skin
  24. $frame stand1 stand2 stand3 stand4 stand5 stand6 stand7
  25. $frame walk1 walk2 walk3 walk4 walk5 walk6 walk7 walk8 walk9 walk10
  26. $frame walk11 walk12 walk13 walk14 walk15 walk16
  27. $frame run1 run2 run3 run4 run5 run6 run7 run8
  28. $frame attack1 attack2 attack3 attack4 attack5 attack6
  29. $frame attack7 attack8 attack9 attack10
  30. $frame death1 death2 death3 death4 death5 death6 death7 death8
  31. $frame death9 death10 death11 death12 death13 death14
  32. $frame fdeath1 fdeath2 fdeath3 fdeath4 fdeath5 fdeath6 fdeath7 fdeath8
  33. $frame fdeath9 fdeath10 fdeath11
  34. $frame paina1 paina2 paina3 paina4
  35. $frame painb1 painb2 painb3 painb4 painb5
  36. $frame painc1 painc2 painc3 painc4 painc5 painc6 painc7 painc8
  37. $frame paind1 paind2 paind3 paind4 paind5 paind6 paind7 paind8
  38. $frame paind9 paind10 paind11 paind12 paind13 paind14 paind15 paind16
  39. $frame paind17 paind18 paind19
  40. void() Laser_Touch =
  41. {
  42. local vector org;
  43. if (other == self.owner)
  44. return; // don't explode on owner
  45. if (pointcontents(self.origin) == CONTENT_SKY)
  46. {
  47. remove(self);
  48. return;
  49. }
  50. sound (self, CHAN_WEAPON, "enforcer/enfstop.wav", 1, ATTN_STATIC);
  51. org = self.origin - 8*normalize(self.velocity);
  52. if (other.health)
  53. {
  54. SpawnBlood (org, self.velocity*0.2, 15);
  55. T_Damage (other, self, self.owner, 15);
  56. }
  57. else
  58. {
  59. WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  60. WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  61. WriteCoord (MSG_BROADCAST, org_x);
  62. WriteCoord (MSG_BROADCAST, org_y);
  63. WriteCoord (MSG_BROADCAST, org_z);
  64. }
  65. remove(self);
  66. };
  67. void(vector org, vector vec) LaunchLaser =
  68. {
  69. local vector vec;
  70. if (self.classname == "monster_enforcer")
  71. sound (self, CHAN_WEAPON, "enforcer/enfire.wav", 1, ATTN_NORM);
  72. vec = normalize(vec);
  73. newmis = spawn();
  74. newmis.owner = self;
  75. newmis.movetype = MOVETYPE_FLY;
  76. newmis.solid = SOLID_BBOX;
  77. newmis.effects = EF_DIMLIGHT;
  78. newmis.classname = "enforcer_laser";
  79. setmodel (newmis, "progs/laser.mdl");
  80. setsize (newmis, '0 0 0', '0 0 0');
  81. if (self.classname == "monster_morph")
  82. {
  83. if (!self.owner)
  84. newmis.skin = 1;
  85. }
  86. setorigin (newmis, org);
  87. newmis.velocity = vec * 600;
  88. newmis.angles = vectoangles(newmis.velocity);
  89. newmis.nextthink = time + 5;
  90. newmis.think = SUB_Remove;
  91. newmis.touch = Laser_Touch;
  92. };
  93. void() enforcer_fire =
  94. {
  95. local vector org;
  96. self.effects = self.effects | EF_MUZZLEFLASH;
  97. makevectors (self.angles);
  98. org = self.origin + v_forward * 30 + v_right * 8.5 + '0 0 16';
  99. LaunchLaser(org, self.enemy.origin - self.origin);
  100. };
  101. //============================================================================
  102. void() enf_stand1 =[ $stand1, enf_stand2 ] {ai_stand();};
  103. void() enf_stand2 =[ $stand2, enf_stand3 ] {ai_stand();};
  104. void() enf_stand3 =[ $stand3, enf_stand4 ] {ai_stand();};
  105. void() enf_stand4 =[ $stand4, enf_stand5 ] {ai_stand();};
  106. void() enf_stand5 =[ $stand5, enf_stand6 ] {ai_stand();};
  107. void() enf_stand6 =[ $stand6, enf_stand7 ] {ai_stand();};
  108. void() enf_stand7 =[ $stand7, enf_stand1 ] {ai_stand();};
  109. void() enf_walk1 =[ $walk1 , enf_walk2 ] {
  110. if (random() < 0.2)
  111. sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE);
  112. ai_walk(2);};
  113. void() enf_walk2 =[ $walk2 , enf_walk3 ] {ai_walk(4);};
  114. void() enf_walk3 =[ $walk3 , enf_walk4 ] {ai_walk(4);};
  115. void() enf_walk4 =[ $walk4 , enf_walk5 ] {ai_walk(3);};
  116. void() enf_walk5 =[ $walk5 , enf_walk6 ] {ai_walk(1);};
  117. void() enf_walk6 =[ $walk6 , enf_walk7 ] {ai_walk(2);};
  118. void() enf_walk7 =[ $walk7 , enf_walk8 ] {ai_walk(2);};
  119. void() enf_walk8 =[ $walk8 , enf_walk9 ] {ai_walk(1);};
  120. void() enf_walk9 =[ $walk9 , enf_walk10 ] {ai_walk(2);};
  121. void() enf_walk10 =[ $walk10, enf_walk11 ] {ai_walk(4);};
  122. void() enf_walk11 =[ $walk11, enf_walk12 ] {ai_walk(4);};
  123. void() enf_walk12 =[ $walk12, enf_walk13 ] {ai_walk(1);};
  124. void() enf_walk13 =[ $walk13, enf_walk14 ] {ai_walk(2);};
  125. void() enf_walk14 =[ $walk14, enf_walk15 ] {ai_walk(3);};
  126. void() enf_walk15 =[ $walk15, enf_walk16 ] {ai_walk(4);};
  127. void() enf_walk16 =[ $walk16, enf_walk1 ] {ai_walk(2);};
  128. void() enf_run1 =[ $run1 , enf_run2 ] {
  129. if (random() < 0.2)
  130. sound (self, CHAN_VOICE, "enforcer/idle1.wav", 1, ATTN_IDLE);
  131. ai_run(18);};
  132. void() enf_run2 =[ $run2 , enf_run3 ] {ai_run(14);};
  133. void() enf_run3 =[ $run3 , enf_run4 ] {ai_run(7);};
  134. void() enf_run4 =[ $run4 , enf_run5 ] {ai_run(12);};
  135. void() enf_run5 =[ $run5 , enf_run6 ] {ai_run(14);};
  136. void() enf_run6 =[ $run6 , enf_run7 ] {ai_run(14);};
  137. void() enf_run7 =[ $run7 , enf_run8 ] {ai_run(7);};
  138. void() enf_run8 =[ $run8 , enf_run1 ] {ai_run(11);};
  139. void() enf_atk1 =[ $attack1, enf_atk2 ] {ai_face();};
  140. void() enf_atk2 =[ $attack2, enf_atk3 ] {ai_face();};
  141. void() enf_atk3 =[ $attack3, enf_atk4 ] {ai_face();};
  142. void() enf_atk4 =[ $attack4, enf_atk5 ] {ai_face();};
  143. void() enf_atk5 =[ $attack5, enf_atk6 ] {ai_face();};
  144. void() enf_atk6 =[ $attack6, enf_atk7 ] {enforcer_fire();};
  145. void() enf_atk7 =[ $attack7, enf_atk8 ] {ai_face();};
  146. void() enf_atk8 =[ $attack8, enf_atk9 ] {ai_face();};
  147. void() enf_atk9 =[ $attack5, enf_atk10 ] {ai_face();};
  148. void() enf_atk10 =[ $attack6, enf_atk11 ] {enforcer_fire();};
  149. void() enf_atk11 =[ $attack7, enf_atk12 ] {ai_face();};
  150. void() enf_atk12 =[ $attack8, enf_atk13 ] {ai_face();};
  151. void() enf_atk13 =[ $attack9, enf_atk14 ] {ai_face();};
  152. void() enf_atk14 =[ $attack10, enf_run1 ] {ai_face();
  153. SUB_CheckRefire (enf_atk1);
  154. };
  155. void() enf_paina1 =[ $paina1, enf_paina2 ] {};
  156. void() enf_paina2 =[ $paina2, enf_paina3 ] {};
  157. void() enf_paina3 =[ $paina3, enf_paina4 ] {};
  158. void() enf_paina4 =[ $paina4, enf_run1 ] {};
  159. void() enf_painb1 =[ $painb1, enf_painb2 ] {};
  160. void() enf_painb2 =[ $painb2, enf_painb3 ] {};
  161. void() enf_painb3 =[ $painb3, enf_painb4 ] {};
  162. void() enf_painb4 =[ $painb4, enf_painb5 ] {};
  163. void() enf_painb5 =[ $painb5, enf_run1 ] {};
  164. void() enf_painc1 =[ $painc1, enf_painc2 ] {};
  165. void() enf_painc2 =[ $painc2, enf_painc3 ] {};
  166. void() enf_painc3 =[ $painc3, enf_painc4 ] {};
  167. void() enf_painc4 =[ $painc4, enf_painc5 ] {};
  168. void() enf_painc5 =[ $painc5, enf_painc6 ] {};
  169. void() enf_painc6 =[ $painc6, enf_painc7 ] {};
  170. void() enf_painc7 =[ $painc7, enf_painc8 ] {};
  171. void() enf_painc8 =[ $painc8, enf_run1 ] {};
  172. void() enf_paind1 =[ $paind1, enf_paind2 ] {};
  173. void() enf_paind2 =[ $paind2, enf_paind3 ] {};
  174. void() enf_paind3 =[ $paind3, enf_paind4 ] {};
  175. void() enf_paind4 =[ $paind4, enf_paind5 ] {ai_painforward(2);};
  176. void() enf_paind5 =[ $paind5, enf_paind6 ] {ai_painforward(1);};
  177. void() enf_paind6 =[ $paind6, enf_paind7 ] {};
  178. void() enf_paind7 =[ $paind7, enf_paind8 ] {};
  179. void() enf_paind8 =[ $paind8, enf_paind9 ] {};
  180. void() enf_paind9 =[ $paind9, enf_paind10 ] {};
  181. void() enf_paind10 =[ $paind10, enf_paind11 ] {};
  182. void() enf_paind11 =[ $paind11, enf_paind12 ] {ai_painforward(1);};
  183. void() enf_paind12 =[ $paind12, enf_paind13 ] {ai_painforward(1);};
  184. void() enf_paind13 =[ $paind13, enf_paind14 ] {ai_painforward(1);};
  185. void() enf_paind14 =[ $paind14, enf_paind15 ] {};
  186. void() enf_paind15 =[ $paind15, enf_paind16 ] {};
  187. void() enf_paind16 =[ $paind16, enf_paind17 ] {ai_pain(1);};
  188. void() enf_paind17 =[ $paind17, enf_paind18 ] {ai_pain(1);};
  189. void() enf_paind18 =[ $paind18, enf_paind19 ] {};
  190. void() enf_paind19 =[ $paind19, enf_run1 ] {};
  191. void(entity attacker, float damage) enf_pain =
  192. {
  193. local float r;
  194. r = random ();
  195. if (self.pain_finished > time)
  196. return;
  197. if (r < 0.5)
  198. sound (self, CHAN_VOICE, "enforcer/pain1.wav", 1, ATTN_NORM);
  199. else
  200. sound (self, CHAN_VOICE, "enforcer/pain2.wav", 1, ATTN_NORM);
  201. if (r < 0.2)
  202. {
  203. self.pain_finished = time + 1;
  204. enf_paina1 ();
  205. }
  206. else if (r < 0.4)
  207. {
  208. self.pain_finished = time + 1;
  209. enf_painb1 ();
  210. }
  211. else if (r < 0.7)
  212. {
  213. self.pain_finished = time + 1;
  214. enf_painc1 ();
  215. }
  216. else
  217. {
  218. self.pain_finished = time + 2;
  219. enf_paind1 ();
  220. }
  221. };
  222. //============================================================================
  223. void() enf_die1 =[ $death1, enf_die2 ] {};
  224. void() enf_die2 =[ $death2, enf_die3 ] {};
  225. void() enf_die3 =[ $death3, enf_die4 ]
  226. {self.solid = SOLID_NOT;self.ammo_cells = 5;DropBackpack();};
  227. void() enf_die4 =[ $death4, enf_die5 ] {ai_forward(14);};
  228. void() enf_die5 =[ $death5, enf_die6 ] {ai_forward(2);};
  229. void() enf_die6 =[ $death6, enf_die7 ] {};
  230. void() enf_die7 =[ $death7, enf_die8 ] {};
  231. void() enf_die8 =[ $death8, enf_die9 ] {};
  232. void() enf_die9 =[ $death9, enf_die10 ] {ai_forward(3);};
  233. void() enf_die10 =[ $death10, enf_die11 ] {ai_forward(5);};
  234. void() enf_die11 =[ $death11, enf_die12 ] {ai_forward(5);};
  235. void() enf_die12 =[ $death12, enf_die13 ] {ai_forward(5);};
  236. void() enf_die13 =[ $death13, enf_die14 ] {};
  237. void() enf_die14 =[ $death14, enf_die14 ] {};
  238. void() enf_fdie1 =[ $fdeath1, enf_fdie2 ] {
  239. };
  240. void() enf_fdie2 =[ $fdeath2, enf_fdie3 ] {};
  241. void() enf_fdie3 =[ $fdeath3, enf_fdie4 ]
  242. {self.solid = SOLID_NOT;self.ammo_cells = 5;DropBackpack();};
  243. void() enf_fdie4 =[ $fdeath4, enf_fdie5 ] {};
  244. void() enf_fdie5 =[ $fdeath5, enf_fdie6 ] {};
  245. void() enf_fdie6 =[ $fdeath6, enf_fdie7 ] {};
  246. void() enf_fdie7 =[ $fdeath7, enf_fdie8 ] {};
  247. void() enf_fdie8 =[ $fdeath8, enf_fdie9 ] {};
  248. void() enf_fdie9 =[ $fdeath9, enf_fdie10 ] {};
  249. void() enf_fdie10 =[ $fdeath10, enf_fdie11 ] {};
  250. void() enf_fdie11 =[ $fdeath11, enf_fdie11 ] {};
  251. void() enf_die =
  252. {
  253. // check for gib
  254. if (self.health < -35)
  255. {
  256. sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM);
  257. ThrowHead ("progs/h_mega.mdl", self.health);
  258. ThrowGib ("progs/gib1.mdl", self.health);
  259. ThrowGib ("progs/gib2.mdl", self.health);
  260. ThrowGib ("progs/gib3.mdl", self.health);
  261. return;
  262. }
  263. // regular death
  264. sound (self, CHAN_VOICE, "enforcer/death1.wav", 1, ATTN_NORM);
  265. if (random() > 0.5)
  266. enf_die1 ();
  267. else
  268. enf_fdie1 ();
  269. };
  270. /*QUAKED monster_enforcer (1 0 0) (-16 -16 -24) (16 16 40) Ambush
  271. */
  272. void() monster_enforcer =
  273. {
  274. if (deathmatch)
  275. {
  276. remove(self);
  277. return;
  278. }
  279. precache_model2 ("progs/enforcer.mdl");
  280. precache_model2 ("progs/h_mega.mdl");
  281. precache_model2 ("progs/laser.mdl");
  282. precache_sound2 ("enforcer/death1.wav");
  283. precache_sound2 ("enforcer/enfire.wav");
  284. precache_sound2 ("enforcer/enfstop.wav");
  285. precache_sound2 ("enforcer/idle1.wav");
  286. precache_sound2 ("enforcer/pain1.wav");
  287. precache_sound2 ("enforcer/pain2.wav");
  288. precache_sound2 ("enforcer/sight1.wav");
  289. precache_sound2 ("enforcer/sight2.wav");
  290. precache_sound2 ("enforcer/sight3.wav");
  291. precache_sound2 ("enforcer/sight4.wav");
  292. self.solid = SOLID_SLIDEBOX;
  293. self.movetype = MOVETYPE_STEP;
  294. setmodel (self, "progs/enforcer.mdl");
  295. setsize (self, '-16 -16 -24', '16 16 40');
  296. self.health = 80;
  297. self.th_stand = enf_stand1;
  298. self.th_walk = enf_walk1;
  299. self.th_run = enf_run1;
  300. self.th_pain = enf_pain;
  301. self.th_die = enf_die;
  302. self.th_missile = enf_atk1;
  303. walkmonster_start();
  304. };