soldier.qc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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/soldier3
  21. $origin 0 -6 24
  22. $base base
  23. $skin skin
  24. $frame stand1 stand2 stand3 stand4 stand5 stand6 stand7 stand8
  25. $frame death1 death2 death3 death4 death5 death6 death7 death8
  26. $frame death9 death10
  27. $frame deathc1 deathc2 deathc3 deathc4 deathc5 deathc6 deathc7 deathc8
  28. $frame deathc9 deathc10 deathc11
  29. $frame load1 load2 load3 load4 load5 load6 load7 load8 load9 load10 load11
  30. $frame pain1 pain2 pain3 pain4 pain5 pain6
  31. $frame painb1 painb2 painb3 painb4 painb5 painb6 painb7 painb8 painb9 painb10
  32. $frame painb11 painb12 painb13 painb14
  33. $frame painc1 painc2 painc3 painc4 painc5 painc6 painc7 painc8 painc9 painc10
  34. $frame painc11 painc12 painc13
  35. $frame run1 run2 run3 run4 run5 run6 run7 run8
  36. $frame shoot1 shoot2 shoot3 shoot4 shoot5 shoot6 shoot7 shoot8 shoot9
  37. $frame prowl_1 prowl_2 prowl_3 prowl_4 prowl_5 prowl_6 prowl_7 prowl_8
  38. $frame prowl_9 prowl_10 prowl_11 prowl_12 prowl_13 prowl_14 prowl_15 prowl_16
  39. $frame prowl_17 prowl_18 prowl_19 prowl_20 prowl_21 prowl_22 prowl_23 prowl_24
  40. /*
  41. ==============================================================================
  42. SOLDIER CODE
  43. ==============================================================================
  44. */
  45. void() army_fire;
  46. void() army_stand1 =[ $stand1, army_stand2 ] {ai_stand();};
  47. void() army_stand2 =[ $stand2, army_stand3 ] {ai_stand();};
  48. void() army_stand3 =[ $stand3, army_stand4 ] {ai_stand();};
  49. void() army_stand4 =[ $stand4, army_stand5 ] {ai_stand();};
  50. void() army_stand5 =[ $stand5, army_stand6 ] {ai_stand();};
  51. void() army_stand6 =[ $stand6, army_stand7 ] {ai_stand();};
  52. void() army_stand7 =[ $stand7, army_stand8 ] {ai_stand();};
  53. void() army_stand8 =[ $stand8, army_stand1 ] {ai_stand();};
  54. void() army_walk1 =[ $prowl_1, army_walk2 ] {
  55. if (random() < 0.2)
  56. sound (self, CHAN_VOICE, "soldier/idle.wav", 1, ATTN_IDLE);
  57. ai_walk(1);};
  58. void() army_walk2 =[ $prowl_2, army_walk3 ] {ai_walk(1);};
  59. void() army_walk3 =[ $prowl_3, army_walk4 ] {ai_walk(1);};
  60. void() army_walk4 =[ $prowl_4, army_walk5 ] {ai_walk(1);};
  61. void() army_walk5 =[ $prowl_5, army_walk6 ] {ai_walk(2);};
  62. void() army_walk6 =[ $prowl_6, army_walk7 ] {ai_walk(3);};
  63. void() army_walk7 =[ $prowl_7, army_walk8 ] {ai_walk(4);};
  64. void() army_walk8 =[ $prowl_8, army_walk9 ] {ai_walk(4);};
  65. void() army_walk9 =[ $prowl_9, army_walk10 ] {ai_walk(2);};
  66. void() army_walk10 =[ $prowl_10, army_walk11 ] {ai_walk(2);};
  67. void() army_walk11 =[ $prowl_11, army_walk12 ] {ai_walk(2);};
  68. void() army_walk12 =[ $prowl_12, army_walk13 ] {ai_walk(1);};
  69. void() army_walk13 =[ $prowl_13, army_walk14 ] {ai_walk(0);};
  70. void() army_walk14 =[ $prowl_14, army_walk15 ] {ai_walk(1);};
  71. void() army_walk15 =[ $prowl_15, army_walk16 ] {ai_walk(1);};
  72. void() army_walk16 =[ $prowl_16, army_walk17 ] {ai_walk(1);};
  73. void() army_walk17 =[ $prowl_17, army_walk18 ] {ai_walk(3);};
  74. void() army_walk18 =[ $prowl_18, army_walk19 ] {ai_walk(3);};
  75. void() army_walk19 =[ $prowl_19, army_walk20 ] {ai_walk(3);};
  76. void() army_walk20 =[ $prowl_20, army_walk21 ] {ai_walk(3);};
  77. void() army_walk21 =[ $prowl_21, army_walk22 ] {ai_walk(2);};
  78. void() army_walk22 =[ $prowl_22, army_walk23 ] {ai_walk(1);};
  79. void() army_walk23 =[ $prowl_23, army_walk24 ] {ai_walk(1);};
  80. void() army_walk24 =[ $prowl_24, army_walk1 ] {ai_walk(1);};
  81. void() army_run1 =[ $run1, army_run2 ] {
  82. if (random() < 0.2)
  83. sound (self, CHAN_VOICE, "soldier/idle.wav", 1, ATTN_IDLE);
  84. ai_run(11);};
  85. void() army_run2 =[ $run2, army_run3 ] {ai_run(15);};
  86. void() army_run3 =[ $run3, army_run4 ] {ai_run(10);};
  87. void() army_run4 =[ $run4, army_run5 ] {ai_run(10);};
  88. void() army_run5 =[ $run5, army_run6 ] {ai_run(8);};
  89. void() army_run6 =[ $run6, army_run7 ] {ai_run(15);};
  90. void() army_run7 =[ $run7, army_run8 ] {ai_run(10);};
  91. void() army_run8 =[ $run8, army_run1 ] {ai_run(8);};
  92. void() army_atk1 =[ $shoot1, army_atk2 ] {ai_face();};
  93. void() army_atk2 =[ $shoot2, army_atk3 ] {ai_face();};
  94. void() army_atk3 =[ $shoot3, army_atk4 ] {ai_face();};
  95. void() army_atk4 =[ $shoot4, army_atk5 ] {ai_face();};
  96. void() army_atk5 =[ $shoot5, army_atk6 ] {ai_face();army_fire();
  97. self.effects = self.effects | EF_MUZZLEFLASH;};
  98. void() army_atk6 =[ $shoot6, army_atk7 ] {ai_face();};
  99. void() army_atk7 =[ $shoot7, army_atk8 ] {ai_face();SUB_CheckRefire (army_atk1);};
  100. void() army_atk8 =[ $shoot8, army_atk9 ] {ai_face();};
  101. void() army_atk9 =[ $shoot9, army_run1 ] {ai_face();};
  102. void() army_pain1 =[ $pain1, army_pain2 ] {};
  103. void() army_pain2 =[ $pain2, army_pain3 ] {};
  104. void() army_pain3 =[ $pain3, army_pain4 ] {};
  105. void() army_pain4 =[ $pain4, army_pain5 ] {};
  106. void() army_pain5 =[ $pain5, army_pain6 ] {};
  107. void() army_pain6 =[ $pain6, army_run1 ] {ai_pain(1);};
  108. void() army_painb1 =[ $painb1, army_painb2 ] {};
  109. void() army_painb2 =[ $painb2, army_painb3 ] {ai_painforward(13);};
  110. void() army_painb3 =[ $painb3, army_painb4 ] {ai_painforward(9);};
  111. void() army_painb4 =[ $painb4, army_painb5 ] {};
  112. void() army_painb5 =[ $painb5, army_painb6 ] {};
  113. void() army_painb6 =[ $painb6, army_painb7 ] {};
  114. void() army_painb7 =[ $painb7, army_painb8 ] {};
  115. void() army_painb8 =[ $painb8, army_painb9 ] {};
  116. void() army_painb9 =[ $painb9, army_painb10] {};
  117. void() army_painb10=[ $painb10, army_painb11] {};
  118. void() army_painb11=[ $painb11, army_painb12] {};
  119. void() army_painb12=[ $painb12, army_painb13] {ai_pain(2);};
  120. void() army_painb13=[ $painb13, army_painb14] {};
  121. void() army_painb14=[ $painb14, army_run1 ] {};
  122. void() army_painc1 =[ $painc1, army_painc2 ] {};
  123. void() army_painc2 =[ $painc2, army_painc3 ] {ai_pain(1);};
  124. void() army_painc3 =[ $painc3, army_painc4 ] {};
  125. void() army_painc4 =[ $painc4, army_painc5 ] {};
  126. void() army_painc5 =[ $painc5, army_painc6 ] {ai_painforward(1);};
  127. void() army_painc6 =[ $painc6, army_painc7 ] {ai_painforward(1);};
  128. void() army_painc7 =[ $painc7, army_painc8 ] {};
  129. void() army_painc8 =[ $painc8, army_painc9 ] {ai_pain(1);};
  130. void() army_painc9 =[ $painc9, army_painc10] {ai_painforward(4);};
  131. void() army_painc10=[ $painc10, army_painc11] {ai_painforward(3);};
  132. void() army_painc11=[ $painc11, army_painc12] {ai_painforward(6);};
  133. void() army_painc12=[ $painc12, army_painc13] {ai_painforward(8);};
  134. void() army_painc13=[ $painc13, army_run1] {};
  135. void(entity attacker, float damage) army_pain =
  136. {
  137. local float r;
  138. if (self.pain_finished > time)
  139. return;
  140. r = random();
  141. if (r < 0.2)
  142. {
  143. self.pain_finished = time + 0.6;
  144. army_pain1 ();
  145. sound (self, CHAN_VOICE, "soldier/pain1.wav", 1, ATTN_NORM);
  146. }
  147. else if (r < 0.6)
  148. {
  149. self.pain_finished = time + 1.1;
  150. army_painb1 ();
  151. sound (self, CHAN_VOICE, "soldier/pain2.wav", 1, ATTN_NORM);
  152. }
  153. else
  154. {
  155. self.pain_finished = time + 1.1;
  156. army_painc1 ();
  157. sound (self, CHAN_VOICE, "soldier/pain2.wav", 1, ATTN_NORM);
  158. }
  159. };
  160. void() army_fire =
  161. {
  162. local vector dir;
  163. local entity en;
  164. ai_face();
  165. sound (self, CHAN_WEAPON, "soldier/sattck1.wav", 1, ATTN_NORM);
  166. // fire somewhat behind the player, so a dodging player is harder to hit
  167. en = self.enemy;
  168. dir = en.origin - en.velocity*0.2;
  169. dir = normalize (dir - self.origin);
  170. FireBullets (4, dir, '0.1 0.1 0');
  171. };
  172. void() army_die1 =[ $death1, army_die2 ] {};
  173. void() army_die2 =[ $death2, army_die3 ] {};
  174. void() army_die3 =[ $death3, army_die4 ]
  175. {self.solid = SOLID_NOT;self.ammo_shells = 5;DropBackpack();};
  176. void() army_die4 =[ $death4, army_die5 ] {};
  177. void() army_die5 =[ $death5, army_die6 ] {};
  178. void() army_die6 =[ $death6, army_die7 ] {};
  179. void() army_die7 =[ $death7, army_die8 ] {};
  180. void() army_die8 =[ $death8, army_die9 ] {};
  181. void() army_die9 =[ $death9, army_die10 ] {};
  182. void() army_die10 =[ $death10, army_die10 ] {};
  183. void() army_cdie1 =[ $deathc1, army_cdie2 ] {};
  184. void() army_cdie2 =[ $deathc2, army_cdie3 ] {ai_back(5);};
  185. void() army_cdie3 =[ $deathc3, army_cdie4 ]
  186. {self.solid = SOLID_NOT;self.ammo_shells = 5;DropBackpack();ai_back(4);};
  187. void() army_cdie4 =[ $deathc4, army_cdie5 ] {ai_back(13);};
  188. void() army_cdie5 =[ $deathc5, army_cdie6 ] {ai_back(3);};
  189. void() army_cdie6 =[ $deathc6, army_cdie7 ] {ai_back(4);};
  190. void() army_cdie7 =[ $deathc7, army_cdie8 ] {};
  191. void() army_cdie8 =[ $deathc8, army_cdie9 ] {};
  192. void() army_cdie9 =[ $deathc9, army_cdie10 ] {};
  193. void() army_cdie10 =[ $deathc10, army_cdie11 ] {};
  194. void() army_cdie11 =[ $deathc11, army_cdie11 ] {};
  195. void() army_die =
  196. {
  197. // check for gib
  198. if (self.health < -35)
  199. {
  200. sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM);
  201. ThrowHead ("progs/h_guard.mdl", self.health);
  202. ThrowGib ("progs/gib1.mdl", self.health);
  203. ThrowGib ("progs/gib2.mdl", self.health);
  204. ThrowGib ("progs/gib3.mdl", self.health);
  205. return;
  206. }
  207. // regular death
  208. sound (self, CHAN_VOICE, "soldier/death1.wav", 1, ATTN_NORM);
  209. if (random() < 0.5)
  210. army_die1 ();
  211. else
  212. army_cdie1 ();
  213. };
  214. /*QUAKED monster_army (1 0 0) (-16 -16 -24) (16 16 40) Ambush
  215. */
  216. void() monster_army =
  217. {
  218. if (deathmatch)
  219. {
  220. remove(self);
  221. return;
  222. }
  223. precache_model ("progs/soldier.mdl");
  224. precache_model ("progs/h_guard.mdl");
  225. precache_model ("progs/gib1.mdl");
  226. precache_model ("progs/gib2.mdl");
  227. precache_model ("progs/gib3.mdl");
  228. precache_sound ("soldier/death1.wav");
  229. precache_sound ("soldier/idle.wav");
  230. precache_sound ("soldier/pain1.wav");
  231. precache_sound ("soldier/pain2.wav");
  232. precache_sound ("soldier/sattck1.wav");
  233. precache_sound ("soldier/sight1.wav");
  234. precache_sound ("player/udeath.wav"); // gib death
  235. self.solid = SOLID_SLIDEBOX;
  236. self.movetype = MOVETYPE_STEP;
  237. setmodel (self, "progs/soldier.mdl");
  238. setsize (self, '-16 -16 -24', '16 16 40');
  239. self.health = 30;
  240. self.th_stand = army_stand1;
  241. self.th_walk = army_walk1;
  242. self.th_run = army_run1;
  243. self.th_missile = army_atk1;
  244. self.th_pain = army_pain;
  245. self.th_die = army_die;
  246. walkmonster_start ();
  247. };