m_medic.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. // Copyright (c) ZeniMax Media Inc.
  2. // Licensed under the GNU General Public License 2.0.
  3. /*
  4. ==============================================================================
  5. MEDIC
  6. ==============================================================================
  7. */
  8. #include "g_local.h"
  9. #include "m_medic.h"
  10. qboolean visible (edict_t *self, edict_t *other);
  11. static int sound_idle1;
  12. static int sound_pain1;
  13. static int sound_pain2;
  14. static int sound_die;
  15. static int sound_sight;
  16. static int sound_search;
  17. static int sound_hook_launch;
  18. static int sound_hook_hit;
  19. static int sound_hook_heal;
  20. static int sound_hook_retract;
  21. edict_t *medic_FindDeadMonster (edict_t *self)
  22. {
  23. edict_t *ent = NULL;
  24. edict_t *best = NULL;
  25. while ((ent = findradius(ent, self->s.origin, 1024)) != NULL)
  26. {
  27. if (ent == self)
  28. continue;
  29. if (!(ent->svflags & SVF_MONSTER))
  30. continue;
  31. if (ent->monsterinfo.aiflags & AI_GOOD_GUY)
  32. continue;
  33. if (ent->owner)
  34. continue;
  35. if (ent->health > 0)
  36. continue;
  37. if (ent->nextthink)
  38. continue;
  39. if (!visible(self, ent))
  40. continue;
  41. if (!best)
  42. {
  43. best = ent;
  44. continue;
  45. }
  46. if (ent->max_health <= best->max_health)
  47. continue;
  48. best = ent;
  49. }
  50. return best;
  51. }
  52. void medic_idle (edict_t *self)
  53. {
  54. edict_t *ent;
  55. gi.sound (self, CHAN_VOICE, sound_idle1, 1, ATTN_IDLE, 0);
  56. ent = medic_FindDeadMonster(self);
  57. if (ent)
  58. {
  59. self->enemy = ent;
  60. self->enemy->owner = self;
  61. self->monsterinfo.aiflags |= AI_MEDIC;
  62. FoundTarget (self);
  63. }
  64. }
  65. void medic_search (edict_t *self)
  66. {
  67. edict_t *ent;
  68. gi.sound (self, CHAN_VOICE, sound_search, 1, ATTN_IDLE, 0);
  69. if (!self->oldenemy)
  70. {
  71. ent = medic_FindDeadMonster(self);
  72. if (ent)
  73. {
  74. self->oldenemy = self->enemy;
  75. self->enemy = ent;
  76. self->enemy->owner = self;
  77. self->monsterinfo.aiflags |= AI_MEDIC;
  78. FoundTarget (self);
  79. }
  80. }
  81. }
  82. void medic_sight (edict_t *self, edict_t *other)
  83. {
  84. gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
  85. }
  86. mframe_t medic_frames_stand [] =
  87. {
  88. ai_stand, 0, medic_idle,
  89. ai_stand, 0, NULL,
  90. ai_stand, 0, NULL,
  91. ai_stand, 0, NULL,
  92. ai_stand, 0, NULL,
  93. ai_stand, 0, NULL,
  94. ai_stand, 0, NULL,
  95. ai_stand, 0, NULL,
  96. ai_stand, 0, NULL,
  97. ai_stand, 0, NULL,
  98. ai_stand, 0, NULL,
  99. ai_stand, 0, NULL,
  100. ai_stand, 0, NULL,
  101. ai_stand, 0, NULL,
  102. ai_stand, 0, NULL,
  103. ai_stand, 0, NULL,
  104. ai_stand, 0, NULL,
  105. ai_stand, 0, NULL,
  106. ai_stand, 0, NULL,
  107. ai_stand, 0, NULL,
  108. ai_stand, 0, NULL,
  109. ai_stand, 0, NULL,
  110. ai_stand, 0, NULL,
  111. ai_stand, 0, NULL,
  112. ai_stand, 0, NULL,
  113. ai_stand, 0, NULL,
  114. ai_stand, 0, NULL,
  115. ai_stand, 0, NULL,
  116. ai_stand, 0, NULL,
  117. ai_stand, 0, NULL,
  118. ai_stand, 0, NULL,
  119. ai_stand, 0, NULL,
  120. ai_stand, 0, NULL,
  121. ai_stand, 0, NULL,
  122. ai_stand, 0, NULL,
  123. ai_stand, 0, NULL,
  124. ai_stand, 0, NULL,
  125. ai_stand, 0, NULL,
  126. ai_stand, 0, NULL,
  127. ai_stand, 0, NULL,
  128. ai_stand, 0, NULL,
  129. ai_stand, 0, NULL,
  130. ai_stand, 0, NULL,
  131. ai_stand, 0, NULL,
  132. ai_stand, 0, NULL,
  133. ai_stand, 0, NULL,
  134. ai_stand, 0, NULL,
  135. ai_stand, 0, NULL,
  136. ai_stand, 0, NULL,
  137. ai_stand, 0, NULL,
  138. ai_stand, 0, NULL,
  139. ai_stand, 0, NULL,
  140. ai_stand, 0, NULL,
  141. ai_stand, 0, NULL,
  142. ai_stand, 0, NULL,
  143. ai_stand, 0, NULL,
  144. ai_stand, 0, NULL,
  145. ai_stand, 0, NULL,
  146. ai_stand, 0, NULL,
  147. ai_stand, 0, NULL,
  148. ai_stand, 0, NULL,
  149. ai_stand, 0, NULL,
  150. ai_stand, 0, NULL,
  151. ai_stand, 0, NULL,
  152. ai_stand, 0, NULL,
  153. ai_stand, 0, NULL,
  154. ai_stand, 0, NULL,
  155. ai_stand, 0, NULL,
  156. ai_stand, 0, NULL,
  157. ai_stand, 0, NULL,
  158. ai_stand, 0, NULL,
  159. ai_stand, 0, NULL,
  160. ai_stand, 0, NULL,
  161. ai_stand, 0, NULL,
  162. ai_stand, 0, NULL,
  163. ai_stand, 0, NULL,
  164. ai_stand, 0, NULL,
  165. ai_stand, 0, NULL,
  166. ai_stand, 0, NULL,
  167. ai_stand, 0, NULL,
  168. ai_stand, 0, NULL,
  169. ai_stand, 0, NULL,
  170. ai_stand, 0, NULL,
  171. ai_stand, 0, NULL,
  172. ai_stand, 0, NULL,
  173. ai_stand, 0, NULL,
  174. ai_stand, 0, NULL,
  175. ai_stand, 0, NULL,
  176. ai_stand, 0, NULL,
  177. ai_stand, 0, NULL,
  178. };
  179. mmove_t medic_move_stand = {FRAME_wait1, FRAME_wait90, medic_frames_stand, NULL};
  180. void medic_stand (edict_t *self)
  181. {
  182. self->monsterinfo.currentmove = &medic_move_stand;
  183. }
  184. mframe_t medic_frames_walk [] =
  185. {
  186. ai_walk, 6.2, NULL,
  187. ai_walk, 18.1, NULL,
  188. ai_walk, 1, NULL,
  189. ai_walk, 9, NULL,
  190. ai_walk, 10, NULL,
  191. ai_walk, 9, NULL,
  192. ai_walk, 11, NULL,
  193. ai_walk, 11.6, NULL,
  194. ai_walk, 2, NULL,
  195. ai_walk, 9.9, NULL,
  196. ai_walk, 14, NULL,
  197. ai_walk, 9.3, NULL
  198. };
  199. mmove_t medic_move_walk = {FRAME_walk1, FRAME_walk12, medic_frames_walk, NULL};
  200. void medic_walk (edict_t *self)
  201. {
  202. self->monsterinfo.currentmove = &medic_move_walk;
  203. }
  204. mframe_t medic_frames_run [] =
  205. {
  206. ai_run, 18, NULL,
  207. ai_run, 22.5, NULL,
  208. ai_run, 25.4, NULL,
  209. ai_run, 23.4, NULL,
  210. ai_run, 24, NULL,
  211. ai_run, 35.6, NULL
  212. };
  213. mmove_t medic_move_run = {FRAME_run1, FRAME_run6, medic_frames_run, NULL};
  214. void medic_run (edict_t *self)
  215. {
  216. if (!(self->monsterinfo.aiflags & AI_MEDIC))
  217. {
  218. edict_t *ent;
  219. ent = medic_FindDeadMonster(self);
  220. if (ent)
  221. {
  222. self->oldenemy = self->enemy;
  223. self->enemy = ent;
  224. self->enemy->owner = self;
  225. self->monsterinfo.aiflags |= AI_MEDIC;
  226. FoundTarget (self);
  227. return;
  228. }
  229. }
  230. if (self->monsterinfo.aiflags & AI_STAND_GROUND)
  231. self->monsterinfo.currentmove = &medic_move_stand;
  232. else
  233. self->monsterinfo.currentmove = &medic_move_run;
  234. }
  235. mframe_t medic_frames_pain1 [] =
  236. {
  237. ai_move, 0, NULL,
  238. ai_move, 0, NULL,
  239. ai_move, 0, NULL,
  240. ai_move, 0, NULL,
  241. ai_move, 0, NULL,
  242. ai_move, 0, NULL,
  243. ai_move, 0, NULL,
  244. ai_move, 0, NULL
  245. };
  246. mmove_t medic_move_pain1 = {FRAME_paina1, FRAME_paina8, medic_frames_pain1, medic_run};
  247. mframe_t medic_frames_pain2 [] =
  248. {
  249. ai_move, 0, NULL,
  250. ai_move, 0, NULL,
  251. ai_move, 0, NULL,
  252. ai_move, 0, NULL,
  253. ai_move, 0, NULL,
  254. ai_move, 0, NULL,
  255. ai_move, 0, NULL,
  256. ai_move, 0, NULL,
  257. ai_move, 0, NULL,
  258. ai_move, 0, NULL,
  259. ai_move, 0, NULL,
  260. ai_move, 0, NULL,
  261. ai_move, 0, NULL,
  262. ai_move, 0, NULL,
  263. ai_move, 0, NULL
  264. };
  265. mmove_t medic_move_pain2 = {FRAME_painb1, FRAME_painb15, medic_frames_pain2, medic_run};
  266. void medic_pain (edict_t *self, edict_t *other, float kick, int damage)
  267. {
  268. if (self->health < (self->max_health / 2))
  269. self->s.skinnum = 1;
  270. if (level.time < self->pain_debounce_time)
  271. return;
  272. self->pain_debounce_time = level.time + 3;
  273. if (skill->value == 3)
  274. return; // no pain anims in nightmare
  275. if (random() < 0.5)
  276. {
  277. self->monsterinfo.currentmove = &medic_move_pain1;
  278. gi.sound (self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0);
  279. }
  280. else
  281. {
  282. self->monsterinfo.currentmove = &medic_move_pain2;
  283. gi.sound (self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0);
  284. }
  285. }
  286. void medic_fire_blaster (edict_t *self)
  287. {
  288. vec3_t start;
  289. vec3_t forward, right;
  290. vec3_t end;
  291. vec3_t dir;
  292. int effect;
  293. if ((self->s.frame == FRAME_attack9) || (self->s.frame == FRAME_attack12))
  294. effect = EF_BLASTER;
  295. else if ((self->s.frame == FRAME_attack19) || (self->s.frame == FRAME_attack22) || (self->s.frame == FRAME_attack25) || (self->s.frame == FRAME_attack28))
  296. effect = EF_HYPERBLASTER;
  297. else
  298. effect = 0;
  299. AngleVectors (self->s.angles, forward, right, NULL);
  300. G_ProjectSource (self->s.origin, monster_flash_offset[MZ2_MEDIC_BLASTER_1], forward, right, start);
  301. VectorCopy (self->enemy->s.origin, end);
  302. end[2] += self->enemy->viewheight;
  303. VectorSubtract (end, start, dir);
  304. monster_fire_blaster (self, start, dir, 2, 1000, MZ2_MEDIC_BLASTER_1, effect);
  305. }
  306. void medic_dead (edict_t *self)
  307. {
  308. VectorSet (self->mins, -16, -16, -24);
  309. VectorSet (self->maxs, 16, 16, -8);
  310. self->movetype = MOVETYPE_TOSS;
  311. self->svflags |= SVF_DEADMONSTER;
  312. self->nextthink = 0;
  313. gi.linkentity (self);
  314. }
  315. mframe_t medic_frames_death [] =
  316. {
  317. ai_move, 0, NULL,
  318. ai_move, 0, NULL,
  319. ai_move, 0, NULL,
  320. ai_move, 0, NULL,
  321. ai_move, 0, NULL,
  322. ai_move, 0, NULL,
  323. ai_move, 0, NULL,
  324. ai_move, 0, NULL,
  325. ai_move, 0, NULL,
  326. ai_move, 0, NULL,
  327. ai_move, 0, NULL,
  328. ai_move, 0, NULL,
  329. ai_move, 0, NULL,
  330. ai_move, 0, NULL,
  331. ai_move, 0, NULL,
  332. ai_move, 0, NULL,
  333. ai_move, 0, NULL,
  334. ai_move, 0, NULL,
  335. ai_move, 0, NULL,
  336. ai_move, 0, NULL,
  337. ai_move, 0, NULL,
  338. ai_move, 0, NULL,
  339. ai_move, 0, NULL,
  340. ai_move, 0, NULL,
  341. ai_move, 0, NULL,
  342. ai_move, 0, NULL,
  343. ai_move, 0, NULL,
  344. ai_move, 0, NULL,
  345. ai_move, 0, NULL,
  346. ai_move, 0, NULL
  347. };
  348. mmove_t medic_move_death = {FRAME_death1, FRAME_death30, medic_frames_death, medic_dead};
  349. void medic_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
  350. {
  351. int n;
  352. // if we had a pending patient, free him up for another medic
  353. if ((self->enemy) && (self->enemy->owner == self))
  354. self->enemy->owner = NULL;
  355. // check for gib
  356. if (self->health <= self->gib_health)
  357. {
  358. gi.sound (self, CHAN_VOICE, gi.soundindex ("misc/udeath.wav"), 1, ATTN_NORM, 0);
  359. for (n= 0; n < 2; n++)
  360. ThrowGib (self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC);
  361. for (n= 0; n < 4; n++)
  362. ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
  363. ThrowHead (self, "models/objects/gibs/head2/tris.md2", damage, GIB_ORGANIC);
  364. self->deadflag = DEAD_DEAD;
  365. return;
  366. }
  367. if (self->deadflag == DEAD_DEAD)
  368. return;
  369. // regular death
  370. gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
  371. self->deadflag = DEAD_DEAD;
  372. self->takedamage = DAMAGE_YES;
  373. self->monsterinfo.currentmove = &medic_move_death;
  374. }
  375. void medic_duck_down (edict_t *self)
  376. {
  377. if (self->monsterinfo.aiflags & AI_DUCKED)
  378. return;
  379. self->monsterinfo.aiflags |= AI_DUCKED;
  380. self->maxs[2] -= 32;
  381. self->takedamage = DAMAGE_YES;
  382. self->monsterinfo.pausetime = level.time + 1;
  383. gi.linkentity (self);
  384. }
  385. void medic_duck_hold (edict_t *self)
  386. {
  387. if (level.time >= self->monsterinfo.pausetime)
  388. self->monsterinfo.aiflags &= ~AI_HOLD_FRAME;
  389. else
  390. self->monsterinfo.aiflags |= AI_HOLD_FRAME;
  391. }
  392. void medic_duck_up (edict_t *self)
  393. {
  394. self->monsterinfo.aiflags &= ~AI_DUCKED;
  395. self->maxs[2] += 32;
  396. self->takedamage = DAMAGE_AIM;
  397. gi.linkentity (self);
  398. }
  399. mframe_t medic_frames_duck [] =
  400. {
  401. ai_move, -1, NULL,
  402. ai_move, -1, NULL,
  403. ai_move, -1, medic_duck_down,
  404. ai_move, -1, medic_duck_hold,
  405. ai_move, -1, NULL,
  406. ai_move, -1, NULL,
  407. ai_move, -1, medic_duck_up,
  408. ai_move, -1, NULL,
  409. ai_move, -1, NULL,
  410. ai_move, -1, NULL,
  411. ai_move, -1, NULL,
  412. ai_move, -1, NULL,
  413. ai_move, -1, NULL,
  414. ai_move, -1, NULL,
  415. ai_move, -1, NULL,
  416. ai_move, -1, NULL
  417. };
  418. mmove_t medic_move_duck = {FRAME_duck1, FRAME_duck16, medic_frames_duck, medic_run};
  419. void medic_dodge (edict_t *self, edict_t *attacker, float eta)
  420. {
  421. if (random() > 0.25)
  422. return;
  423. if (!self->enemy)
  424. self->enemy = attacker;
  425. self->monsterinfo.currentmove = &medic_move_duck;
  426. }
  427. mframe_t medic_frames_attackHyperBlaster [] =
  428. {
  429. ai_charge, 0, NULL,
  430. ai_charge, 0, NULL,
  431. ai_charge, 0, NULL,
  432. ai_charge, 0, NULL,
  433. ai_charge, 0, medic_fire_blaster,
  434. ai_charge, 0, medic_fire_blaster,
  435. ai_charge, 0, medic_fire_blaster,
  436. ai_charge, 0, medic_fire_blaster,
  437. ai_charge, 0, medic_fire_blaster,
  438. ai_charge, 0, medic_fire_blaster,
  439. ai_charge, 0, medic_fire_blaster,
  440. ai_charge, 0, medic_fire_blaster,
  441. ai_charge, 0, medic_fire_blaster,
  442. ai_charge, 0, medic_fire_blaster,
  443. ai_charge, 0, medic_fire_blaster,
  444. ai_charge, 0, medic_fire_blaster
  445. };
  446. mmove_t medic_move_attackHyperBlaster = {FRAME_attack15, FRAME_attack30, medic_frames_attackHyperBlaster, medic_run};
  447. void medic_continue (edict_t *self)
  448. {
  449. if (visible (self, self->enemy) )
  450. if (random() <= 0.95)
  451. self->monsterinfo.currentmove = &medic_move_attackHyperBlaster;
  452. }
  453. mframe_t medic_frames_attackBlaster [] =
  454. {
  455. ai_charge, 0, NULL,
  456. ai_charge, 5, NULL,
  457. ai_charge, 5, NULL,
  458. ai_charge, 3, NULL,
  459. ai_charge, 2, NULL,
  460. ai_charge, 0, NULL,
  461. ai_charge, 0, NULL,
  462. ai_charge, 0, NULL,
  463. ai_charge, 0, medic_fire_blaster,
  464. ai_charge, 0, NULL,
  465. ai_charge, 0, NULL,
  466. ai_charge, 0, medic_fire_blaster,
  467. ai_charge, 0, NULL,
  468. ai_charge, 0, medic_continue // Change to medic_continue... Else, go to frame 32
  469. };
  470. mmove_t medic_move_attackBlaster = {FRAME_attack1, FRAME_attack14, medic_frames_attackBlaster, medic_run};
  471. void medic_hook_launch (edict_t *self)
  472. {
  473. gi.sound (self, CHAN_WEAPON, sound_hook_launch, 1, ATTN_NORM, 0);
  474. }
  475. void ED_CallSpawn (edict_t *ent);
  476. static vec3_t medic_cable_offsets[] =
  477. {
  478. 45.0, -9.2, 15.5,
  479. 48.4, -9.7, 15.2,
  480. 47.8, -9.8, 15.8,
  481. 47.3, -9.3, 14.3,
  482. 45.4, -10.1, 13.1,
  483. 41.9, -12.7, 12.0,
  484. 37.8, -15.8, 11.2,
  485. 34.3, -18.4, 10.7,
  486. 32.7, -19.7, 10.4,
  487. 32.7, -19.7, 10.4
  488. };
  489. void medic_cable_attack (edict_t *self)
  490. {
  491. vec3_t offset, start, end, f, r;
  492. trace_t tr;
  493. vec3_t dir, angles;
  494. float distance;
  495. if (!self->enemy->inuse)
  496. return;
  497. AngleVectors (self->s.angles, f, r, NULL);
  498. VectorCopy (medic_cable_offsets[self->s.frame - FRAME_attack42], offset);
  499. G_ProjectSource (self->s.origin, offset, f, r, start);
  500. // check for max distance
  501. VectorSubtract (start, self->enemy->s.origin, dir);
  502. distance = VectorLength(dir);
  503. if (distance > 256)
  504. return;
  505. // check for min/max pitch
  506. vectoangles (dir, angles);
  507. if (angles[0] < -180)
  508. angles[0] += 360;
  509. if (fabs(angles[0]) > 45)
  510. return;
  511. tr = gi.trace (start, NULL, NULL, self->enemy->s.origin, self, MASK_SHOT);
  512. if (tr.fraction != 1.0 && tr.ent != self->enemy)
  513. return;
  514. if (self->s.frame == FRAME_attack43)
  515. {
  516. gi.sound (self->enemy, CHAN_AUTO, sound_hook_hit, 1, ATTN_NORM, 0);
  517. self->enemy->monsterinfo.aiflags |= AI_RESURRECTING;
  518. }
  519. else if (self->s.frame == FRAME_attack50)
  520. {
  521. self->enemy->spawnflags = 0;
  522. self->enemy->monsterinfo.aiflags = 0;
  523. self->enemy->target = NULL;
  524. self->enemy->targetname = NULL;
  525. self->enemy->combattarget = NULL;
  526. self->enemy->deathtarget = NULL;
  527. self->enemy->owner = self;
  528. ED_CallSpawn (self->enemy);
  529. self->enemy->owner = NULL;
  530. if (self->enemy->think)
  531. {
  532. self->enemy->nextthink = level.time;
  533. self->enemy->think (self->enemy);
  534. }
  535. self->enemy->monsterinfo.aiflags |= AI_RESURRECTING;
  536. if (self->oldenemy && self->oldenemy->client)
  537. {
  538. self->enemy->enemy = self->oldenemy;
  539. FoundTarget (self->enemy);
  540. }
  541. }
  542. else
  543. {
  544. if (self->s.frame == FRAME_attack44)
  545. gi.sound (self, CHAN_WEAPON, sound_hook_heal, 1, ATTN_NORM, 0);
  546. }
  547. // adjust start for beam origin being in middle of a segment
  548. VectorMA (start, 8, f, start);
  549. // adjust end z for end spot since the monster is currently dead
  550. VectorCopy (self->enemy->s.origin, end);
  551. end[2] = self->enemy->absmin[2] + self->enemy->size[2] / 2;
  552. gi.WriteByte (svc_temp_entity);
  553. gi.WriteByte (TE_MEDIC_CABLE_ATTACK);
  554. gi.WriteShort (self - g_edicts);
  555. gi.WritePosition (start);
  556. gi.WritePosition (end);
  557. gi.multicast (self->s.origin, MULTICAST_PVS);
  558. }
  559. void medic_hook_retract (edict_t *self)
  560. {
  561. gi.sound (self, CHAN_WEAPON, sound_hook_retract, 1, ATTN_NORM, 0);
  562. self->enemy->monsterinfo.aiflags &= ~AI_RESURRECTING;
  563. }
  564. mframe_t medic_frames_attackCable [] =
  565. {
  566. ai_move, 2, NULL,
  567. ai_move, 3, NULL,
  568. ai_move, 5, NULL,
  569. ai_move, 4.4, NULL,
  570. ai_charge, 4.7, NULL,
  571. ai_charge, 5, NULL,
  572. ai_charge, 6, NULL,
  573. ai_charge, 4, NULL,
  574. ai_charge, 0, NULL,
  575. ai_move, 0, medic_hook_launch,
  576. ai_move, 0, medic_cable_attack,
  577. ai_move, 0, medic_cable_attack,
  578. ai_move, 0, medic_cable_attack,
  579. ai_move, 0, medic_cable_attack,
  580. ai_move, 0, medic_cable_attack,
  581. ai_move, 0, medic_cable_attack,
  582. ai_move, 0, medic_cable_attack,
  583. ai_move, 0, medic_cable_attack,
  584. ai_move, 0, medic_cable_attack,
  585. ai_move, -15, medic_hook_retract,
  586. ai_move, -1.5, NULL,
  587. ai_move, -1.2, NULL,
  588. ai_move, -3, NULL,
  589. ai_move, -2, NULL,
  590. ai_move, 0.3, NULL,
  591. ai_move, 0.7, NULL,
  592. ai_move, 1.2, NULL,
  593. ai_move, 1.3, NULL
  594. };
  595. mmove_t medic_move_attackCable = {FRAME_attack33, FRAME_attack60, medic_frames_attackCable, medic_run};
  596. void medic_attack(edict_t *self)
  597. {
  598. if (self->monsterinfo.aiflags & AI_MEDIC)
  599. self->monsterinfo.currentmove = &medic_move_attackCable;
  600. else
  601. self->monsterinfo.currentmove = &medic_move_attackBlaster;
  602. }
  603. qboolean medic_checkattack (edict_t *self)
  604. {
  605. if (self->monsterinfo.aiflags & AI_MEDIC)
  606. {
  607. medic_attack(self);
  608. return true;
  609. }
  610. return M_CheckAttack (self);
  611. }
  612. /*QUAKED monster_medic (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
  613. */
  614. void SP_monster_medic (edict_t *self)
  615. {
  616. if (deathmatch->value)
  617. {
  618. G_FreeEdict (self);
  619. return;
  620. }
  621. sound_idle1 = gi.soundindex ("medic/idle.wav");
  622. sound_pain1 = gi.soundindex ("medic/medpain1.wav");
  623. sound_pain2 = gi.soundindex ("medic/medpain2.wav");
  624. sound_die = gi.soundindex ("medic/meddeth1.wav");
  625. sound_sight = gi.soundindex ("medic/medsght1.wav");
  626. sound_search = gi.soundindex ("medic/medsrch1.wav");
  627. sound_hook_launch = gi.soundindex ("medic/medatck2.wav");
  628. sound_hook_hit = gi.soundindex ("medic/medatck3.wav");
  629. sound_hook_heal = gi.soundindex ("medic/medatck4.wav");
  630. sound_hook_retract = gi.soundindex ("medic/medatck5.wav");
  631. gi.soundindex ("medic/medatck1.wav");
  632. self->movetype = MOVETYPE_STEP;
  633. self->solid = SOLID_BBOX;
  634. self->s.modelindex = gi.modelindex ("models/monsters/medic/tris.md2");
  635. VectorSet (self->mins, -24, -24, -24);
  636. VectorSet (self->maxs, 24, 24, 32);
  637. self->health = 300;
  638. self->gib_health = -130;
  639. self->mass = 400;
  640. self->pain = medic_pain;
  641. self->die = medic_die;
  642. self->monsterinfo.stand = medic_stand;
  643. self->monsterinfo.walk = medic_walk;
  644. self->monsterinfo.run = medic_run;
  645. self->monsterinfo.dodge = medic_dodge;
  646. self->monsterinfo.attack = medic_attack;
  647. self->monsterinfo.melee = NULL;
  648. self->monsterinfo.sight = medic_sight;
  649. self->monsterinfo.idle = medic_idle;
  650. self->monsterinfo.search = medic_search;
  651. self->monsterinfo.checkattack = medic_checkattack;
  652. gi.linkentity (self);
  653. self->monsterinfo.currentmove = &medic_move_stand;
  654. self->monsterinfo.scale = MODEL_SCALE;
  655. walkmonster_start (self);
  656. }