knight.qc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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. KNIGHT
  18. ==============================================================================
  19. */
  20. $cd /raid/quake/id1/models/knight
  21. $origin 0 0 24
  22. $base base
  23. $skin badass3
  24. $skin statue
  25. $frame stand1 stand2 stand3 stand4 stand5 stand6 stand7 stand8 stand9
  26. $frame runb1 runb2 runb3 runb4 runb5 runb6 runb7 runb8
  27. //frame runc1 runc2 runc3 runc4 runc5 runc6
  28. $frame runattack1 runattack2 runattack3 runattack4 runattack5
  29. $frame runattack6 runattack7 runattack8 runattack9 runattack10
  30. $frame runattack11
  31. $frame pain1 pain2 pain3
  32. $frame painb1 painb2 painb3 painb4 painb5 painb6 painb7 painb8 painb9
  33. $frame painb10 painb11
  34. //frame attack1 attack2 attack3 attack4 attack5 attack6 attack7
  35. //frame attack8 attack9 attack10 attack11
  36. $frame attackb1 attackb1 attackb2 attackb3 attackb4 attackb5
  37. $frame attackb6 attackb7 attackb8 attackb9 attackb10
  38. $frame walk1 walk2 walk3 walk4 walk5 walk6 walk7 walk8 walk9
  39. $frame walk10 walk11 walk12 walk13 walk14
  40. $frame kneel1 kneel2 kneel3 kneel4 kneel5
  41. $frame standing2 standing3 standing4 standing5
  42. $frame death1 death2 death3 death4 death5 death6 death7 death8
  43. $frame death9 death10
  44. $frame deathb1 deathb2 deathb3 deathb4 deathb5 deathb6 deathb7 deathb8
  45. $frame deathb9 deathb10 deathb11
  46. void() knight_stand1 =[ $stand1, knight_stand2 ] {ai_stand();};
  47. void() knight_stand2 =[ $stand2, knight_stand3 ] {ai_stand();};
  48. void() knight_stand3 =[ $stand3, knight_stand4 ] {ai_stand();};
  49. void() knight_stand4 =[ $stand4, knight_stand5 ] {ai_stand();};
  50. void() knight_stand5 =[ $stand5, knight_stand6 ] {ai_stand();};
  51. void() knight_stand6 =[ $stand6, knight_stand7 ] {ai_stand();};
  52. void() knight_stand7 =[ $stand7, knight_stand8 ] {ai_stand();};
  53. void() knight_stand8 =[ $stand8, knight_stand9 ] {ai_stand();};
  54. void() knight_stand9 =[ $stand9, knight_stand1 ] {ai_stand();};
  55. void() kn_idle_sound =
  56. {
  57. if (random() < 0.2)
  58. {
  59. if (self.spawnflags & 2) // statue
  60. sound (self, CHAN_VOICE, "statue/idle.wav", 1, ATTN_IDLE);
  61. else
  62. sound (self, CHAN_VOICE, "knight/idle.wav", 1, ATTN_IDLE);
  63. }
  64. };
  65. void() knight_walk1 =[ $walk1, knight_walk2 ]
  66. { kn_idle_sound(); ai_walk(3);};
  67. void() knight_walk2 =[ $walk2, knight_walk3 ] {ai_walk(2);};
  68. void() knight_walk3 =[ $walk3, knight_walk4 ] {ai_walk(3);};
  69. void() knight_walk4 =[ $walk4, knight_walk5 ] {ai_walk(4);};
  70. void() knight_walk5 =[ $walk5, knight_walk6 ] {ai_walk(3);};
  71. void() knight_walk6 =[ $walk6, knight_walk7 ] {ai_walk(3);};
  72. void() knight_walk7 =[ $walk7, knight_walk8 ] {ai_walk(3);};
  73. void() knight_walk8 =[ $walk8, knight_walk9 ] {ai_walk(4);};
  74. void() knight_walk9 =[ $walk9, knight_walk10 ] {ai_walk(3);};
  75. void() knight_walk10 =[ $walk10, knight_walk11 ] {ai_walk(3);};
  76. void() knight_walk11 =[ $walk11, knight_walk12 ] {ai_walk(2);};
  77. void() knight_walk12 =[ $walk12, knight_walk13 ] {ai_walk(3);};
  78. void() knight_walk13 =[ $walk13, knight_walk14 ] {ai_walk(4);};
  79. void() knight_walk14 =[ $walk14, knight_walk1 ] {ai_walk(3);};
  80. void() knight_run1 =[ $runb1, knight_run2 ]
  81. { kn_idle_sound(); ai_run(16); };
  82. void() knight_run2 =[ $runb2, knight_run3 ] {ai_run(20);};
  83. void() knight_run3 =[ $runb3, knight_run4 ] {ai_run(13);};
  84. void() knight_run4 =[ $runb4, knight_run5 ] {ai_run(7);};
  85. void() knight_run5 =[ $runb5, knight_run6 ] {ai_run(16);};
  86. void() knight_run6 =[ $runb6, knight_run7 ] {ai_run(20);};
  87. void() knight_run7 =[ $runb7, knight_run8 ] {ai_run(14);};
  88. void() knight_run8 =[ $runb8, knight_run1 ] {ai_run(6);};
  89. void() knight_runatk1 =[ $runattack1, knight_runatk2 ]
  90. {
  91. if (random() > 0.5)
  92. sound (self, CHAN_WEAPON, "knight/sword2.wav", 1, ATTN_NORM);
  93. else
  94. sound (self, CHAN_WEAPON, "knight/sword1.wav", 1, ATTN_NORM);
  95. ai_charge(20);
  96. };
  97. void() knight_runatk2 =[ $runattack2, knight_runatk3 ] {ai_charge_side();};
  98. void() knight_runatk3 =[ $runattack3, knight_runatk4 ] {ai_charge_side();};
  99. void() knight_runatk4 =[ $runattack4, knight_runatk5 ] {ai_charge_side();};
  100. void() knight_runatk5 =[ $runattack5, knight_runatk6 ] {ai_melee_side();};
  101. void() knight_runatk6 =[ $runattack6, knight_runatk7 ] {ai_melee_side();};
  102. void() knight_runatk7 =[ $runattack7, knight_runatk8 ] {ai_melee_side();};
  103. void() knight_runatk8 =[ $runattack8, knight_runatk9 ] {ai_melee_side();};
  104. void() knight_runatk9 =[ $runattack9, knight_runatk10 ] {ai_melee_side();};
  105. void() knight_runatk10 =[ $runattack10, knight_runatk11 ] {ai_charge_side();};
  106. void() knight_runatk11 =[ $runattack11, knight_run1 ] {ai_charge(10);};
  107. void() knight_atk1 =[ $attackb1, knight_atk2 ]
  108. {
  109. sound (self, CHAN_WEAPON, "knight/sword1.wav", 1, ATTN_NORM);
  110. ai_charge(0);};
  111. void() knight_atk2 =[ $attackb2, knight_atk3 ] {ai_charge(7);};
  112. void() knight_atk3 =[ $attackb3, knight_atk4 ] {ai_charge(4);};
  113. void() knight_atk4 =[ $attackb4, knight_atk5 ] {ai_charge(0);};
  114. void() knight_atk5 =[ $attackb5, knight_atk6 ] {ai_charge(3);};
  115. void() knight_atk6 =[ $attackb6, knight_atk7 ] {ai_charge(4); ai_melee();};
  116. void() knight_atk7 =[ $attackb7, knight_atk8 ] {ai_charge(1); ai_melee();};
  117. void() knight_atk8 =[ $attackb8, knight_atk9 ] {ai_charge(3);
  118. ai_melee();};
  119. void() knight_atk9 =[ $attackb9, knight_atk10] {ai_charge(1);};
  120. void() knight_atk10=[ $attackb10, knight_run1 ] {ai_charge(5);};
  121. //void() knight_atk9 =[ $attack9, knight_atk10 ] {};
  122. //void() knight_atk10 =[ $attack10, knight_atk11 ] {};
  123. //void() knight_atk11 =[ $attack11, knight_run1 ] {};
  124. //===========================================================================
  125. void() knight_pain1 =[ $pain1, knight_pain2 ] {};
  126. void() knight_pain2 =[ $pain2, knight_pain3 ] {};
  127. void() knight_pain3 =[ $pain3, knight_run1 ] {};
  128. void() knight_painb1 =[ $painb1, knight_painb2 ] {ai_painforward(0);};
  129. void() knight_painb2 =[ $painb2, knight_painb3 ] {ai_painforward(3);};
  130. void() knight_painb3 =[ $painb3, knight_painb4 ] {};
  131. void() knight_painb4 =[ $painb4, knight_painb5 ] {};
  132. void() knight_painb5 =[ $painb5, knight_painb6 ] {ai_painforward(2);};
  133. void() knight_painb6 =[ $painb6, knight_painb7 ] {ai_painforward(4);};
  134. void() knight_painb7 =[ $painb7, knight_painb8 ] {ai_painforward(2);};
  135. void() knight_painb8 =[ $painb8, knight_painb9 ] {ai_painforward(5);};
  136. void() knight_painb9 =[ $painb9, knight_painb10 ] {ai_painforward(5);};
  137. void() knight_painb10 =[ $painb10, knight_painb11 ] {ai_painforward(0);};
  138. void() knight_painb11 =[ $painb11, knight_run1 ] {};
  139. void(entity attacker, float damage) knight_pain =
  140. {
  141. local float r;
  142. if (self.pain_finished > time)
  143. return;
  144. r = random();
  145. if (self.spawnflags & 2) // statue
  146. sound (self, CHAN_VOICE, "statue/pain.wav", 1, ATTN_NORM);
  147. else
  148. sound (self, CHAN_VOICE, "knight/khurt.wav", 1, ATTN_NORM);
  149. if (r < 0.85)
  150. {
  151. knight_pain1 ();
  152. self.pain_finished = time + 1;
  153. }
  154. else
  155. {
  156. knight_painb1 ();
  157. self.pain_finished = time + 1;
  158. }
  159. };
  160. //===========================================================================
  161. void() knight_bow1 =[ $kneel1, knight_bow2 ] {ai_turn();};
  162. void() knight_bow2 =[ $kneel2, knight_bow3 ] {ai_turn();};
  163. void() knight_bow3 =[ $kneel3, knight_bow4 ] {ai_turn();};
  164. void() knight_bow4 =[ $kneel4, knight_bow5 ] {ai_turn();};
  165. void() knight_bow5 =[ $kneel5, knight_bow5 ] {ai_turn();};
  166. void() knight_bow6 =[ $kneel4, knight_bow7 ] {ai_turn();};
  167. void() knight_bow7 =[ $kneel3, knight_bow8 ] {ai_turn();};
  168. void() knight_bow8 =[ $kneel2, knight_bow9 ] {ai_turn();};
  169. void() knight_bow9 =[ $kneel1, knight_bow10 ] {ai_turn();};
  170. void() knight_bow10 =[ $walk1, knight_walk1 ] {ai_turn();};
  171. void() knight_die1 =[ $death1, knight_die2 ] {};
  172. void() knight_die2 =[ $death2, knight_die3 ] {};
  173. void() knight_die3 =[ $death3, knight_die4 ]
  174. {self.solid = SOLID_NOT;};
  175. void() knight_die4 =[ $death4, knight_die5 ] {};
  176. void() knight_die5 =[ $death5, knight_die6 ] {};
  177. void() knight_die6 =[ $death6, knight_die7 ] {};
  178. void() knight_die7 =[ $death7, knight_die8 ] {};
  179. void() knight_die8 =[ $death8, knight_die9 ] {};
  180. void() knight_die9 =[ $death9, knight_die10] {};
  181. void() knight_die10=[ $death10, knight_die10] {};
  182. void() knight_dieb1 =[ $deathb1, knight_dieb2 ] {};
  183. void() knight_dieb2 =[ $deathb2, knight_dieb3 ] {};
  184. void() knight_dieb3 =[ $deathb3, knight_dieb4 ]
  185. {self.solid = SOLID_NOT;};
  186. void() knight_dieb4 =[ $deathb4, knight_dieb5 ] {};
  187. void() knight_dieb5 =[ $deathb5, knight_dieb6 ] {};
  188. void() knight_dieb6 =[ $deathb6, knight_dieb7 ] {};
  189. void() knight_dieb7 =[ $deathb7, knight_dieb8 ] {};
  190. void() knight_dieb8 =[ $deathb8, knight_dieb9 ] {};
  191. void() knight_dieb9 =[ $deathb9, knight_dieb10] {};
  192. void() knight_dieb10 = [ $deathb10, knight_dieb11] {};
  193. void() knight_dieb11 = [ $deathb11, knight_dieb11] {};
  194. void() knight_die =
  195. {
  196. // check for gib
  197. if (self.health < -40)
  198. {
  199. sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM);
  200. ThrowHead ("progs/h_knight.mdl", self.health);
  201. if (self.spawnflags & 2) // statue
  202. {
  203. ThrowGib ( "progs/statgib1.mdl", self.health);
  204. ThrowGib ( "progs/statgib2.mdl", self.health);
  205. ThrowGib ( "progs/statgib3.mdl", self.health);
  206. }
  207. else
  208. {
  209. ThrowGib ("progs/gib1.mdl", self.health);
  210. ThrowGib ("progs/gib2.mdl", self.health);
  211. ThrowGib ("progs/gib3.mdl", self.health);
  212. }
  213. return;
  214. }
  215. // regular death
  216. if (self.spawnflags & 2) // statue
  217. sound (self, CHAN_VOICE, "statue/death.wav", 1, ATTN_NORM);
  218. else
  219. sound (self, CHAN_VOICE, "knight/kdeath.wav", 1, ATTN_NORM);
  220. if (random() < 0.5)
  221. knight_die1 ();
  222. else
  223. knight_dieb1 ();
  224. };
  225. void() knight_pause =
  226. {
  227. sound ( self, CHAN_VOICE, "statue/see.wav", 1, ATTN_NORM);
  228. self.takedamage = DAMAGE_AIM;
  229. self.th_stand = knight_stand1;
  230. self.th_walk = knight_walk1;
  231. self.th_run = knight_run1;
  232. self.th_melee = knight_atk1;
  233. self.th_pain = knight_pain;
  234. self.th_die = knight_die;
  235. self.use = SUB_Null;
  236. self.think = knight_run1;
  237. self.enemy = activator;
  238. self.nextthink = time + 0.1;
  239. self.think = FoundTarget;
  240. self.delay = 0;
  241. };
  242. void() knight_pause1 =
  243. {
  244. self.takedamage = DAMAGE_NO;
  245. self.use = knight_pause;
  246. self.think = knight_pause1;
  247. self.nextthink = time + 0.1;
  248. };
  249. /*QUAKED monster_knight (1 0 0) (-16 -16 -24) (16 16 40) Ambush Statue
  250. Statue - select this to use the stone skin and have him frozen in place.
  251. delay: time from sight to attack (default 5)
  252. frame: frame to be frozen in. (default 44)
  253. */
  254. void() monster_knight =
  255. {
  256. if (deathmatch)
  257. {
  258. remove(self);
  259. return;
  260. }
  261. precache_model ("progs/knight.mdl");
  262. precache_model ("progs/h_knight.mdl");
  263. if (self.spawnflags & 2) // statue
  264. {
  265. precache_model ( "progs/statgib1.mdl");
  266. precache_model ( "progs/statgib2.mdl");
  267. precache_model ( "progs/statgib3.mdl");
  268. precache_sound ( "statue/see.wav");
  269. precache_sound ( "statue/idle.wav");
  270. precache_sound ( "statue/pain.wav");
  271. precache_sound ( "statue/death.wav");
  272. }
  273. else
  274. {
  275. precache_sound ("knight/kdeath.wav");
  276. precache_sound ("knight/khurt.wav");
  277. precache_sound ("knight/ksight.wav");
  278. precache_sound ("knight/idle.wav");
  279. }
  280. precache_sound ("knight/sword1.wav");
  281. precache_sound ("knight/sword2.wav");
  282. self.solid = SOLID_SLIDEBOX;
  283. self.movetype = MOVETYPE_STEP;
  284. setmodel (self, "progs/knight.mdl");
  285. setsize (self, '-16 -16 -24', '16 16 40');
  286. self.health = 75;
  287. if (self.spawnflags & 2) // statue
  288. {
  289. if (self.frame == 0)
  290. self.frame = 44;
  291. self.skin = 1;
  292. if (!self.targetname)
  293. {
  294. dprint ("statue not targeted\n");
  295. dprint (self.classname);
  296. dprint (" at ");
  297. dprint (vtos(self.origin));
  298. dprint ("\n");
  299. return;
  300. }
  301. self.use = knight_pause;
  302. self.th_stand = knight_pause1;
  303. self.th_walk = knight_pause1;
  304. self.th_run = knight_pause1;
  305. /*
  306. self.th_stand = knight_pause1;
  307. self.th_walk = knight_pause;
  308. self.th_run = knight_pause;
  309. self.th_melee = knight_atk1;
  310. self.th_pain = knight_pause;
  311. self.th_die = knight_die;
  312. */
  313. walkmonster_start ();
  314. }
  315. else
  316. {
  317. self.th_stand = knight_stand1;
  318. self.th_walk = knight_walk1;
  319. self.th_run = knight_run1;
  320. self.th_melee = knight_atk1;
  321. self.th_pain = knight_pain;
  322. self.th_die = knight_die;
  323. walkmonster_start ();
  324. }
  325. };