home *** CD-ROM | disk | FTP | other *** search
/ Gambler 19 / GAMBLERCD19.BIN / UTILS / 3D / BRONIE / DUAL_LAU.ZIP / src / m_medic.c < prev    next >
C/C++ Source or Header  |  1997-11-26  |  17KB  |  747 lines

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