demon.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. DEMON
  18. ==============================================================================
  19. */
  20. $cd /raid/quake/id1/models/demon3
  21. $scale 0.8
  22. $origin 0 0 24
  23. $base base
  24. $skin base
  25. $frame stand1 stand2 stand3 stand4 stand5 stand6 stand7 stand8 stand9
  26. $frame stand10 stand11 stand12 stand13
  27. $frame walk1 walk2 walk3 walk4 walk5 walk6 walk7 walk8
  28. $frame run1 run2 run3 run4 run5 run6
  29. $frame leap1 leap2 leap3 leap4 leap5 leap6 leap7 leap8 leap9 leap10
  30. $frame leap11 leap12
  31. $frame pain1 pain2 pain3 pain4 pain5 pain6
  32. $frame death1 death2 death3 death4 death5 death6 death7 death8 death9
  33. $frame attacka1 attacka2 attacka3 attacka4 attacka5 attacka6 attacka7 attacka8
  34. $frame attacka9 attacka10 attacka11 attacka12 attacka13 attacka14 attacka15
  35. //============================================================================
  36. void() Demon_JumpTouch;
  37. void() demon1_stand1 =[ $stand1, demon1_stand2 ] {ai_stand();};
  38. void() demon1_stand2 =[ $stand2, demon1_stand3 ] {ai_stand();};
  39. void() demon1_stand3 =[ $stand3, demon1_stand4 ] {ai_stand();};
  40. void() demon1_stand4 =[ $stand4, demon1_stand5 ] {ai_stand();};
  41. void() demon1_stand5 =[ $stand5, demon1_stand6 ] {ai_stand();};
  42. void() demon1_stand6 =[ $stand6, demon1_stand7 ] {ai_stand();};
  43. void() demon1_stand7 =[ $stand7, demon1_stand8 ] {ai_stand();};
  44. void() demon1_stand8 =[ $stand8, demon1_stand9 ] {ai_stand();};
  45. void() demon1_stand9 =[ $stand9, demon1_stand10 ] {ai_stand();};
  46. void() demon1_stand10 =[ $stand10, demon1_stand11 ] {ai_stand();};
  47. void() demon1_stand11 =[ $stand11, demon1_stand12 ] {ai_stand();};
  48. void() demon1_stand12 =[ $stand12, demon1_stand13 ] {ai_stand();};
  49. void() demon1_stand13 =[ $stand13, demon1_stand1 ] {ai_stand();};
  50. void() demon1_walk1 =[ $walk1, demon1_walk2 ] {
  51. if (random() < 0.2)
  52. sound (self, CHAN_VOICE, "demon/idle1.wav", 1, ATTN_IDLE);
  53. ai_walk(8);
  54. };
  55. void() demon1_walk2 =[ $walk2, demon1_walk3 ] {ai_walk(6);};
  56. void() demon1_walk3 =[ $walk3, demon1_walk4 ] {ai_walk(6);};
  57. void() demon1_walk4 =[ $walk4, demon1_walk5 ] {ai_walk(7);};
  58. void() demon1_walk5 =[ $walk5, demon1_walk6 ] {ai_walk(4);};
  59. void() demon1_walk6 =[ $walk6, demon1_walk7 ] {ai_walk(6);};
  60. void() demon1_walk7 =[ $walk7, demon1_walk8 ] {ai_walk(10);};
  61. void() demon1_walk8 =[ $walk8, demon1_walk1 ] {ai_walk(10);};
  62. void() demon1_run1 =[ $run1, demon1_run2 ] {
  63. if (random() < 0.2)
  64. sound (self, CHAN_VOICE, "demon/idle1.wav", 1, ATTN_IDLE);
  65. ai_run(20);};
  66. void() demon1_run2 =[ $run2, demon1_run3 ] {ai_run(15);};
  67. void() demon1_run3 =[ $run3, demon1_run4 ] {ai_run(36);};
  68. void() demon1_run4 =[ $run4, demon1_run5 ] {ai_run(20);};
  69. void() demon1_run5 =[ $run5, demon1_run6 ] {ai_run(15);};
  70. void() demon1_run6 =[ $run6, demon1_run1 ] {ai_run(36);};
  71. void() demon1_jump1 =[ $leap1, demon1_jump2 ] {ai_face();};
  72. void() demon1_jump2 =[ $leap2, demon1_jump3 ] {ai_face();};
  73. void() demon1_jump3 =[ $leap3, demon1_jump4 ] {ai_face();};
  74. void() demon1_jump4 =[ $leap4, demon1_jump5 ]
  75. {
  76. ai_face();
  77. self.touch = Demon_JumpTouch;
  78. makevectors (self.angles);
  79. self.origin_z = self.origin_z + 1;
  80. self.velocity = v_forward * 600 + '0 0 250';
  81. if (self.flags & FL_ONGROUND)
  82. self.flags = self.flags - FL_ONGROUND;
  83. };
  84. void() demon1_jump5 =[ $leap5, demon1_jump6 ] {};
  85. void() demon1_jump6 =[ $leap6, demon1_jump7 ] {};
  86. void() demon1_jump7 =[ $leap7, demon1_jump8 ] {};
  87. void() demon1_jump8 =[ $leap8, demon1_jump9 ] {};
  88. void() demon1_jump9 =[ $leap9, demon1_jump10 ] {};
  89. void() demon1_jump10 =[ $leap10, demon1_jump1 ] {
  90. self.nextthink = time + 3;
  91. // if three seconds pass, assume demon is stuck and jump again
  92. };
  93. void() demon1_jump11 =[ $leap11, demon1_jump12 ] {};
  94. void() demon1_jump12 =[ $leap12, demon1_run1 ] {};
  95. void() demon1_atta1 =[ $attacka1, demon1_atta2 ] {ai_charge(4);};
  96. void() demon1_atta2 =[ $attacka2, demon1_atta3 ] {ai_charge(0);};
  97. void() demon1_atta3 =[ $attacka3, demon1_atta4 ] {ai_charge(0);};
  98. void() demon1_atta4 =[ $attacka4, demon1_atta5 ] {ai_charge(1);};
  99. void() demon1_atta5 =[ $attacka5, demon1_atta6 ] {ai_charge(2); Demon_Melee(200);};
  100. void() demon1_atta6 =[ $attacka6, demon1_atta7 ] {ai_charge(1);};
  101. void() demon1_atta7 =[ $attacka7, demon1_atta8 ] {ai_charge(6);};
  102. void() demon1_atta8 =[ $attacka8, demon1_atta9 ] {ai_charge(8);};
  103. void() demon1_atta9 =[ $attacka9, demon1_atta10] {ai_charge(4);};
  104. void() demon1_atta10 =[ $attacka10, demon1_atta11] {ai_charge(2);};
  105. void() demon1_atta11 =[ $attacka11, demon1_atta12] {Demon_Melee(-200);};
  106. void() demon1_atta12 =[ $attacka12, demon1_atta13] {ai_charge(5);};
  107. void() demon1_atta13 =[ $attacka13, demon1_atta14] {ai_charge(8);};
  108. void() demon1_atta14 =[ $attacka14, demon1_atta15] {ai_charge(4);};
  109. void() demon1_atta15 =[ $attacka15, demon1_run1] {ai_charge(4);};
  110. void() demon1_pain1 =[ $pain1, demon1_pain2 ] {};
  111. void() demon1_pain2 =[ $pain2, demon1_pain3 ] {};
  112. void() demon1_pain3 =[ $pain3, demon1_pain4 ] {};
  113. void() demon1_pain4 =[ $pain4, demon1_pain5 ] {};
  114. void() demon1_pain5 =[ $pain5, demon1_pain6 ] {};
  115. void() demon1_pain6 =[ $pain6, demon1_run1 ] {};
  116. void(entity attacker, float damage) demon1_pain =
  117. {
  118. if (self.touch == Demon_JumpTouch)
  119. return;
  120. if (self.pain_finished > time)
  121. return;
  122. self.pain_finished = time + 1;
  123. sound (self, CHAN_VOICE, "demon/dpain1.wav", 1, ATTN_NORM);
  124. if (random()*200 > damage)
  125. return; // didn't flinch
  126. demon1_pain1 ();
  127. };
  128. void() demon1_die1 =[ $death1, demon1_die2 ] {
  129. sound (self, CHAN_VOICE, "demon/ddeath.wav", 1, ATTN_NORM);};
  130. void() demon1_die2 =[ $death2, demon1_die3 ] {};
  131. void() demon1_die3 =[ $death3, demon1_die4 ] {};
  132. void() demon1_die4 =[ $death4, demon1_die5 ] {};
  133. void() demon1_die5 =[ $death5, demon1_die6 ] {};
  134. void() demon1_die6 =[ $death6, demon1_die7 ]
  135. {self.solid = SOLID_NOT;};
  136. void() demon1_die7 =[ $death7, demon1_die8 ] {};
  137. void() demon1_die8 =[ $death8, demon1_die9 ] {};
  138. void() demon1_die9 =[ $death9, demon1_die9 ] {};
  139. void() demon_die =
  140. {
  141. // check for gib
  142. if (self.health < -80)
  143. {
  144. sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM);
  145. ThrowHead ("progs/h_demon.mdl", self.health);
  146. ThrowGib ("progs/gib1.mdl", self.health);
  147. ThrowGib ("progs/gib1.mdl", self.health);
  148. ThrowGib ("progs/gib1.mdl", self.health);
  149. return;
  150. }
  151. // regular death
  152. demon1_die1 ();
  153. };
  154. void() Demon_MeleeAttack =
  155. {
  156. demon1_atta1 ();
  157. };
  158. /*QUAKED monster_demon1 (1 0 0) (-32 -32 -24) (32 32 64) Ambush
  159. */
  160. void() monster_demon1 =
  161. {
  162. if (deathmatch)
  163. {
  164. remove(self);
  165. return;
  166. }
  167. precache_model ("progs/demon.mdl");
  168. precache_model ("progs/h_demon.mdl");
  169. precache_sound ("demon/ddeath.wav");
  170. precache_sound ("demon/dhit2.wav");
  171. precache_sound ("demon/djump.wav");
  172. precache_sound ("demon/dpain1.wav");
  173. precache_sound ("demon/idle1.wav");
  174. precache_sound ("demon/sight2.wav");
  175. self.solid = SOLID_SLIDEBOX;
  176. self.movetype = MOVETYPE_STEP;
  177. setmodel (self, "progs/demon.mdl");
  178. setsize (self, VEC_HULL2_MIN, VEC_HULL2_MAX);
  179. self.health = 300;
  180. self.th_stand = demon1_stand1;
  181. self.th_walk = demon1_walk1;
  182. self.th_run = demon1_run1;
  183. self.th_die = demon_die;
  184. self.th_melee = Demon_MeleeAttack; // one of two attacks
  185. self.th_missile = demon1_jump1; // jump attack
  186. self.th_pain = demon1_pain;
  187. walkmonster_start();
  188. };
  189. /*
  190. ==============================================================================
  191. DEMON
  192. ==============================================================================
  193. */
  194. /*
  195. ==============
  196. CheckDemonMelee
  197. Returns TRUE if a melee attack would hit right now
  198. ==============
  199. */
  200. float() CheckDemonMelee =
  201. {
  202. if (enemy_range == RANGE_MELEE)
  203. { // FIXME: check canreach
  204. self.attack_state = AS_MELEE;
  205. return TRUE;
  206. }
  207. return FALSE;
  208. };
  209. /*
  210. ==============
  211. CheckDemonJump
  212. ==============
  213. */
  214. float() CheckDemonJump =
  215. {
  216. local vector dist;
  217. local float d;
  218. if (self.origin_z + self.mins_z > self.enemy.origin_z + self.enemy.mins_z
  219. + 0.75 * self.enemy.size_z)
  220. return FALSE;
  221. if (self.origin_z + self.maxs_z < self.enemy.origin_z + self.enemy.mins_z
  222. + 0.25 * self.enemy.size_z)
  223. return FALSE;
  224. dist = self.enemy.origin - self.origin;
  225. dist_z = 0;
  226. d = vlen(dist);
  227. if (d < 100)
  228. return FALSE;
  229. if (d > 200)
  230. {
  231. if (random() < 0.9)
  232. return FALSE;
  233. }
  234. return TRUE;
  235. };
  236. float() DemonCheckAttack =
  237. {
  238. local vector vec;
  239. // if close enough for slashing, go for it
  240. if (CheckDemonMelee ())
  241. {
  242. self.attack_state = AS_MELEE;
  243. return TRUE;
  244. }
  245. if (CheckDemonJump ())
  246. {
  247. self.attack_state = AS_MISSILE;
  248. sound (self, CHAN_VOICE, "demon/djump.wav", 1, ATTN_NORM);
  249. return TRUE;
  250. }
  251. return FALSE;
  252. };
  253. //===========================================================================
  254. void(float side) Demon_Melee =
  255. {
  256. local float ldmg;
  257. local vector delta;
  258. ai_face ();
  259. walkmove (self.ideal_yaw, 12); // allow a little closing
  260. delta = self.enemy.origin - self.origin;
  261. if (vlen(delta) > 100)
  262. return;
  263. if (!CanDamage (self.enemy, self))
  264. return;
  265. sound (self, CHAN_WEAPON, "demon/dhit2.wav", 1, ATTN_NORM);
  266. ldmg = 10 + 5*random();
  267. T_Damage (self.enemy, self, self, ldmg);
  268. makevectors (self.angles);
  269. SpawnMeatSpray (self.origin + v_forward*16, side * v_right);
  270. };
  271. void() Demon_JumpTouch =
  272. {
  273. local float ldmg;
  274. if (self.health <= 0)
  275. return;
  276. if (other.takedamage)
  277. {
  278. if ( vlen(self.velocity) > 400 )
  279. {
  280. ldmg = 40 + 10*random();
  281. T_Damage (other, self, self, ldmg);
  282. }
  283. }
  284. if (!checkbottom(self))
  285. {
  286. if (self.flags & FL_ONGROUND)
  287. { // jump randomly to not get hung up
  288. //dprint ("popjump\n");
  289. self.touch = SUB_Null;
  290. self.think = demon1_jump1;
  291. self.nextthink = time + 0.1;
  292. // self.velocity_x = (random() - 0.5) * 600;
  293. // self.velocity_y = (random() - 0.5) * 600;
  294. // self.velocity_z = 200;
  295. // self.flags = self.flags - FL_ONGROUND;
  296. }
  297. return; // not on ground yet
  298. }
  299. self.touch = SUB_Null;
  300. self.think = demon1_jump11;
  301. self.nextthink = time + 0.1;
  302. };