dog.qc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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. DOG
  18. ==============================================================================
  19. */
  20. $cd /raid/quake/id1/models/dog
  21. $origin 0 0 24
  22. $base base
  23. $skin skin
  24. $frame attack1 attack2 attack3 attack4 attack5 attack6 attack7 attack8
  25. $frame death1 death2 death3 death4 death5 death6 death7 death8 death9
  26. $frame deathb1 deathb2 deathb3 deathb4 deathb5 deathb6 deathb7 deathb8
  27. $frame deathb9
  28. $frame pain1 pain2 pain3 pain4 pain5 pain6
  29. $frame painb1 painb2 painb3 painb4 painb5 painb6 painb7 painb8 painb9 painb10
  30. $frame painb11 painb12 painb13 painb14 painb15 painb16
  31. $frame run1 run2 run3 run4 run5 run6 run7 run8 run9 run10 run11 run12
  32. $frame leap1 leap2 leap3 leap4 leap5 leap6 leap7 leap8 leap9
  33. $frame stand1 stand2 stand3 stand4 stand5 stand6 stand7 stand8 stand9
  34. $frame walk1 walk2 walk3 walk4 walk5 walk6 walk7 walk8
  35. void() dog_leap1;
  36. void() dog_run1;
  37. /*
  38. ================
  39. dog_bite
  40. ================
  41. */
  42. void() dog_bite =
  43. {
  44. local vector delta;
  45. local float ldmg;
  46. if (!self.enemy)
  47. return;
  48. ai_charge(10);
  49. if (!CanDamage (self.enemy, self))
  50. return;
  51. delta = self.enemy.origin - self.origin;
  52. if (vlen(delta) > 100)
  53. return;
  54. ldmg = (random() + random() + random()) * 8;
  55. T_Damage (self.enemy, self, self, ldmg);
  56. };
  57. void() Dog_JumpTouch =
  58. {
  59. local float ldmg;
  60. if (self.health <= 0)
  61. return;
  62. if (other.takedamage)
  63. {
  64. if ( vlen(self.velocity) > 300 )
  65. {
  66. ldmg = 10 + 10*random();
  67. T_Damage (other, self, self, ldmg);
  68. }
  69. }
  70. if (!checkbottom(self))
  71. {
  72. if (self.flags & FL_ONGROUND)
  73. { // jump randomly to not get hung up
  74. //dprint ("popjump\n");
  75. self.touch = SUB_Null;
  76. self.think = dog_leap1;
  77. self.nextthink = time + 0.1;
  78. // self.velocity_x = (random() - 0.5) * 600;
  79. // self.velocity_y = (random() - 0.5) * 600;
  80. // self.velocity_z = 200;
  81. // self.flags = self.flags - FL_ONGROUND;
  82. }
  83. return; // not on ground yet
  84. }
  85. self.touch = SUB_Null;
  86. self.think = dog_run1;
  87. self.nextthink = time + 0.1;
  88. };
  89. void() dog_stand1 =[ $stand1, dog_stand2 ] {ai_stand();};
  90. void() dog_stand2 =[ $stand2, dog_stand3 ] {ai_stand();};
  91. void() dog_stand3 =[ $stand3, dog_stand4 ] {ai_stand();};
  92. void() dog_stand4 =[ $stand4, dog_stand5 ] {ai_stand();};
  93. void() dog_stand5 =[ $stand5, dog_stand6 ] {ai_stand();};
  94. void() dog_stand6 =[ $stand6, dog_stand7 ] {ai_stand();};
  95. void() dog_stand7 =[ $stand7, dog_stand8 ] {ai_stand();};
  96. void() dog_stand8 =[ $stand8, dog_stand9 ] {ai_stand();};
  97. void() dog_stand9 =[ $stand9, dog_stand1 ] {ai_stand();};
  98. void() dog_walk1 =[ $walk1 , dog_walk2 ] {
  99. if (random() < 0.2)
  100. sound (self, CHAN_VOICE, "dog/idle.wav", 1, ATTN_IDLE);
  101. ai_walk(8);};
  102. void() dog_walk2 =[ $walk2 , dog_walk3 ] {ai_walk(8);};
  103. void() dog_walk3 =[ $walk3 , dog_walk4 ] {ai_walk(8);};
  104. void() dog_walk4 =[ $walk4 , dog_walk5 ] {ai_walk(8);};
  105. void() dog_walk5 =[ $walk5 , dog_walk6 ] {ai_walk(8);};
  106. void() dog_walk6 =[ $walk6 , dog_walk7 ] {ai_walk(8);};
  107. void() dog_walk7 =[ $walk7 , dog_walk8 ] {ai_walk(8);};
  108. void() dog_walk8 =[ $walk8 , dog_walk1 ] {ai_walk(8);};
  109. void() dog_run1 =[ $run1 , dog_run2 ] {
  110. if (random() < 0.2)
  111. sound (self, CHAN_VOICE, "dog/idle.wav", 1, ATTN_IDLE);
  112. ai_run(16);};
  113. void() dog_run2 =[ $run2 , dog_run3 ] {ai_run(32);};
  114. void() dog_run3 =[ $run3 , dog_run4 ] {ai_run(32);};
  115. void() dog_run4 =[ $run4 , dog_run5 ] {ai_run(20);};
  116. void() dog_run5 =[ $run5 , dog_run6 ] {ai_run(64);};
  117. void() dog_run6 =[ $run6 , dog_run7 ] {ai_run(32);};
  118. void() dog_run7 =[ $run7 , dog_run8 ] {ai_run(16);};
  119. void() dog_run8 =[ $run8 , dog_run9 ] {ai_run(32);};
  120. void() dog_run9 =[ $run9 , dog_run10 ] {ai_run(32);};
  121. void() dog_run10 =[ $run10 , dog_run11 ] {ai_run(20);};
  122. void() dog_run11 =[ $run11 , dog_run12 ] {ai_run(64);};
  123. void() dog_run12 =[ $run12 , dog_run1 ] {ai_run(32);};
  124. void() dog_atta1 =[ $attack1, dog_atta2 ] {ai_charge(10);};
  125. void() dog_atta2 =[ $attack2, dog_atta3 ] {ai_charge(10);};
  126. void() dog_atta3 =[ $attack3, dog_atta4 ] {ai_charge(10);};
  127. void() dog_atta4 =[ $attack4, dog_atta5 ] {
  128. sound (self, CHAN_VOICE, "dog/dattack1.wav", 1, ATTN_NORM);
  129. dog_bite();};
  130. void() dog_atta5 =[ $attack5, dog_atta6 ] {ai_charge(10);};
  131. void() dog_atta6 =[ $attack6, dog_atta7 ] {ai_charge(10);};
  132. void() dog_atta7 =[ $attack7, dog_atta8 ] {ai_charge(10);};
  133. void() dog_atta8 =[ $attack8, dog_run1 ] {ai_charge(10);};
  134. void() dog_leap1 =[ $leap1, dog_leap2 ] {ai_face();};
  135. void() dog_leap2 =[ $leap2, dog_leap3 ]
  136. {
  137. ai_face();
  138. self.touch = Dog_JumpTouch;
  139. makevectors (self.angles);
  140. self.origin_z = self.origin_z + 1;
  141. self.velocity = v_forward * 300 + '0 0 200';
  142. if (self.flags & FL_ONGROUND)
  143. self.flags = self.flags - FL_ONGROUND;
  144. };
  145. void() dog_leap3 =[ $leap3, dog_leap4 ] {};
  146. void() dog_leap4 =[ $leap4, dog_leap5 ] {};
  147. void() dog_leap5 =[ $leap5, dog_leap6 ] {};
  148. void() dog_leap6 =[ $leap6, dog_leap7 ] {};
  149. void() dog_leap7 =[ $leap7, dog_leap8 ] {};
  150. void() dog_leap8 =[ $leap8, dog_leap9 ] {};
  151. void() dog_leap9 =[ $leap9, dog_leap9 ] {};
  152. void() dog_pain1 =[ $pain1 , dog_pain2 ] {};
  153. void() dog_pain2 =[ $pain2 , dog_pain3 ] {};
  154. void() dog_pain3 =[ $pain3 , dog_pain4 ] {};
  155. void() dog_pain4 =[ $pain4 , dog_pain5 ] {};
  156. void() dog_pain5 =[ $pain5 , dog_pain6 ] {};
  157. void() dog_pain6 =[ $pain6 , dog_run1 ] {};
  158. void() dog_painb1 =[ $painb1 , dog_painb2 ] {};
  159. void() dog_painb2 =[ $painb2 , dog_painb3 ] {};
  160. void() dog_painb3 =[ $painb3 , dog_painb4 ] {ai_pain(4);};
  161. void() dog_painb4 =[ $painb4 , dog_painb5 ] {ai_pain(12);};
  162. void() dog_painb5 =[ $painb5 , dog_painb6 ] {ai_pain(12);};
  163. void() dog_painb6 =[ $painb6 , dog_painb7 ] {ai_pain(2);};
  164. void() dog_painb7 =[ $painb7 , dog_painb8 ] {};
  165. void() dog_painb8 =[ $painb8 , dog_painb9 ] {ai_pain(4);};
  166. void() dog_painb9 =[ $painb9 , dog_painb10 ] {};
  167. void() dog_painb10 =[ $painb10 , dog_painb11 ] {ai_pain(10);};
  168. void() dog_painb11 =[ $painb11 , dog_painb12 ] {};
  169. void() dog_painb12 =[ $painb12 , dog_painb13 ] {};
  170. void() dog_painb13 =[ $painb13 , dog_painb14 ] {};
  171. void() dog_painb14 =[ $painb14 , dog_painb15 ] {};
  172. void() dog_painb15 =[ $painb15 , dog_painb16 ] {};
  173. void() dog_painb16 =[ $painb16 , dog_run1 ] {};
  174. void() dog_pain =
  175. {
  176. sound (self, CHAN_VOICE, "dog/dpain1.wav", 1, ATTN_NORM);
  177. if (random() > 0.5)
  178. dog_pain1 ();
  179. else
  180. dog_painb1 ();
  181. };
  182. void() dog_die1 =[ $death1, dog_die2 ] {};
  183. void() dog_die2 =[ $death2, dog_die3 ] {};
  184. void() dog_die3 =[ $death3, dog_die4 ] {};
  185. void() dog_die4 =[ $death4, dog_die5 ] {};
  186. void() dog_die5 =[ $death5, dog_die6 ] {};
  187. void() dog_die6 =[ $death6, dog_die7 ] {};
  188. void() dog_die7 =[ $death7, dog_die8 ] {};
  189. void() dog_die8 =[ $death8, dog_die9 ] {};
  190. void() dog_die9 =[ $death9, dog_die9 ] {};
  191. void() dog_dieb1 =[ $deathb1, dog_dieb2 ] {};
  192. void() dog_dieb2 =[ $deathb2, dog_dieb3 ] {};
  193. void() dog_dieb3 =[ $deathb3, dog_dieb4 ] {};
  194. void() dog_dieb4 =[ $deathb4, dog_dieb5 ] {};
  195. void() dog_dieb5 =[ $deathb5, dog_dieb6 ] {};
  196. void() dog_dieb6 =[ $deathb6, dog_dieb7 ] {};
  197. void() dog_dieb7 =[ $deathb7, dog_dieb8 ] {};
  198. void() dog_dieb8 =[ $deathb8, dog_dieb9 ] {};
  199. void() dog_dieb9 =[ $deathb9, dog_dieb9 ] {};
  200. void() dog_die =
  201. {
  202. // check for gib
  203. if (self.health < -35)
  204. {
  205. sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM);
  206. ThrowGib ("progs/gib3.mdl", self.health);
  207. ThrowGib ("progs/gib3.mdl", self.health);
  208. ThrowGib ("progs/gib3.mdl", self.health);
  209. ThrowHead ("progs/h_dog.mdl", self.health);
  210. return;
  211. }
  212. // regular death
  213. sound (self, CHAN_VOICE, "dog/ddeath.wav", 1, ATTN_NORM);
  214. self.solid = SOLID_NOT;
  215. if (random() > 0.5)
  216. dog_die1 ();
  217. else
  218. dog_dieb1 ();
  219. };
  220. //============================================================================
  221. /*
  222. ==============
  223. CheckDogMelee
  224. Returns TRUE if a melee attack would hit right now
  225. ==============
  226. */
  227. float() CheckDogMelee =
  228. {
  229. if (enemy_range == RANGE_MELEE)
  230. { // FIXME: check canreach
  231. self.attack_state = AS_MELEE;
  232. return TRUE;
  233. }
  234. return FALSE;
  235. };
  236. /*
  237. ==============
  238. CheckDogJump
  239. ==============
  240. */
  241. float() CheckDogJump =
  242. {
  243. local vector dist;
  244. local float d;
  245. if (self.origin_z + self.mins_z > self.enemy.origin_z + self.enemy.mins_z
  246. + 0.75 * self.enemy.size_z)
  247. return FALSE;
  248. if (self.origin_z + self.maxs_z < self.enemy.origin_z + self.enemy.mins_z
  249. + 0.25 * self.enemy.size_z)
  250. return FALSE;
  251. dist = self.enemy.origin - self.origin;
  252. dist_z = 0;
  253. d = vlen(dist);
  254. if (d < 80)
  255. return FALSE;
  256. if (d > 150)
  257. return FALSE;
  258. return TRUE;
  259. };
  260. float() DogCheckAttack =
  261. {
  262. local vector vec;
  263. // if close enough for slashing, go for it
  264. if (CheckDogMelee ())
  265. {
  266. self.attack_state = AS_MELEE;
  267. return TRUE;
  268. }
  269. if (CheckDogJump ())
  270. {
  271. self.attack_state = AS_MISSILE;
  272. return TRUE;
  273. }
  274. return FALSE;
  275. };
  276. //===========================================================================
  277. /*QUAKED monster_dog (1 0 0) (-32 -32 -24) (32 32 40) Ambush
  278. */
  279. void() monster_dog =
  280. {
  281. if (deathmatch)
  282. {
  283. remove(self);
  284. return;
  285. }
  286. precache_model ("progs/h_dog.mdl");
  287. precache_model ("progs/dog.mdl");
  288. precache_sound ("dog/dattack1.wav");
  289. precache_sound ("dog/ddeath.wav");
  290. precache_sound ("dog/dpain1.wav");
  291. precache_sound ("dog/dsight.wav");
  292. precache_sound ("dog/idle.wav");
  293. self.solid = SOLID_SLIDEBOX;
  294. self.movetype = MOVETYPE_STEP;
  295. setmodel (self, "progs/dog.mdl");
  296. setsize (self, '-32 -32 -24', '32 32 40');
  297. self.health = 25;
  298. self.th_stand = dog_stand1;
  299. self.th_walk = dog_walk1;
  300. self.th_run = dog_run1;
  301. self.th_pain = dog_pain;
  302. self.th_die = dog_die;
  303. self.th_melee = dog_atta1;
  304. self.th_missile = dog_leap1;
  305. walkmonster_start();
  306. };