enforcer.qc 11 KB

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