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

  1. /*
  2. ==============================================================================
  3.  
  4. insane
  5.  
  6. ==============================================================================
  7. */
  8.  
  9. #include "g_local.h"
  10. #include "m_insane.h"
  11.  
  12.  
  13. static int    sound_fist;
  14. static int    sound_shake;
  15. static int    sound_moan;
  16. static int    sound_scream[8];
  17.  
  18. void insane_fist (edict_t *self)
  19. {
  20.     gi.sound (self, CHAN_VOICE, sound_fist, 1, ATTN_IDLE, 0);
  21. }
  22.  
  23. void insane_shake (edict_t *self)
  24. {
  25.     gi.sound (self, CHAN_VOICE, sound_shake, 1, ATTN_IDLE, 0);
  26. }
  27.  
  28. void insane_moan (edict_t *self)
  29. {
  30.     gi.sound (self, CHAN_VOICE, sound_moan, 1, ATTN_IDLE, 0);
  31. }
  32.  
  33. void insane_scream (edict_t *self)
  34. {
  35.     gi.sound (self, CHAN_VOICE, sound_scream[rand()%8], 1, ATTN_IDLE, 0);
  36. }
  37.  
  38.  
  39. void insane_stand (edict_t *self);
  40. void insane_dead (edict_t *self);
  41. void insane_cross (edict_t *self);
  42. void insane_walk (edict_t *self);
  43. void insane_run (edict_t *self);
  44. void insane_checkdown (edict_t *self);
  45. void insane_checkup (edict_t *self);
  46. void insane_onground (edict_t *self);
  47.  
  48.  
  49. mframe_t insane_frames_stand_normal [] =
  50. {
  51.     ai_stand, 0, NULL,
  52.     ai_stand, 0, NULL,
  53.     ai_stand, 0, NULL,
  54.     ai_stand, 0, NULL,
  55.     ai_stand, 0, NULL,
  56.     ai_stand, 0, insane_checkdown
  57. };
  58. mmove_t insane_move_stand_normal = {FRAME_stand60, FRAME_stand65, insane_frames_stand_normal, insane_stand};
  59.  
  60. mframe_t insane_frames_stand_insane [] =
  61. {
  62.     ai_stand,    0,    insane_shake,
  63.     ai_stand,    0,    NULL,
  64.     ai_stand,    0,    NULL,
  65.     ai_stand,    0,    NULL,
  66.     ai_stand,    0,    NULL,
  67.     ai_stand,    0,    NULL,
  68.     ai_stand,    0,    NULL,
  69.     ai_stand,    0,    NULL,
  70.     ai_stand,    0,    NULL,
  71.     ai_stand,    0,    NULL,
  72.     ai_stand,    0,    NULL,
  73.     ai_stand,    0,    NULL,
  74.     ai_stand,    0,    NULL,
  75.     ai_stand,    0,    NULL,
  76.     ai_stand,    0,    NULL,
  77.     ai_stand,    0,    NULL,
  78.     ai_stand,    0,    NULL,
  79.     ai_stand,    0,    NULL,
  80.     ai_stand,    0,    NULL,
  81.     ai_stand,    0,    NULL,
  82.     ai_stand,    0,    NULL,
  83.     ai_stand,    0,    NULL,
  84.     ai_stand,    0,    NULL,
  85.     ai_stand,    0,    NULL,
  86.     ai_stand,    0,    NULL,
  87.     ai_stand,    0,    NULL,
  88.     ai_stand,    0,    NULL,
  89.     ai_stand,    0,    NULL,
  90.     ai_stand,    0,    NULL,
  91.     ai_stand,    0,    insane_checkdown
  92. };
  93. mmove_t insane_move_stand_insane = {FRAME_stand65, FRAME_stand94, insane_frames_stand_insane, insane_stand};
  94.  
  95. mframe_t insane_frames_uptodown [] =
  96. {
  97.     ai_move,    0,    NULL,
  98.     ai_move,    0,    NULL,
  99.     ai_move,    0,    NULL,
  100.     ai_move,    0,    NULL,
  101.     ai_move,    0,    NULL,
  102.     ai_move,    0,    NULL,
  103.     ai_move,    0,    NULL,
  104.     ai_move,    0,    insane_moan,
  105.     ai_move,    0,    NULL,
  106.     ai_move,    0,    NULL,
  107.  
  108.     ai_move,    0,    NULL,
  109.     ai_move,    0,    NULL,
  110.     ai_move,    0,    NULL,
  111.     ai_move,    0,    NULL,
  112.     ai_move,    0,    NULL,
  113.     ai_move,    0,    NULL,
  114.     ai_move,    0,    NULL,
  115.     ai_move,    0,    NULL,
  116.     ai_move,    0,    NULL,
  117.     ai_move,    0,    NULL,
  118.  
  119.     ai_move,    2.7,    NULL,
  120.     ai_move,    4.1,    NULL,
  121.     ai_move,    6,        NULL,
  122.     ai_move,    7.6,    NULL,
  123.     ai_move,    3.6,    NULL,
  124.     ai_move,    0,    NULL,
  125.     ai_move,    0,    NULL,
  126.     ai_move,    0,    insane_fist,
  127.     ai_move,    0,    NULL,
  128.     ai_move,    0,    NULL,
  129.  
  130.     ai_move,    0,    NULL,
  131.     ai_move,    0,    NULL,
  132.     ai_move,    0,    NULL,
  133.     ai_move,    0,    insane_fist,
  134.     ai_move,    0,    NULL,
  135.     ai_move,    0,    NULL,
  136.     ai_move,    0,    NULL,
  137.     ai_move,    0,    NULL,
  138.     ai_move,    0,    NULL,
  139.     ai_move,    0,    NULL
  140. };
  141. mmove_t insane_move_uptodown = {FRAME_stand1, FRAME_stand40, insane_frames_uptodown, insane_onground};
  142.  
  143.  
  144. mframe_t insane_frames_downtoup [] =
  145. {
  146.     ai_move,    -0.7,    NULL,            // 41
  147.     ai_move,    -1.2,    NULL,            // 42
  148.     ai_move,    -1.5,        NULL,        // 43
  149.     ai_move,    -4.5,        NULL,        // 44
  150.     ai_move,    -3.5,    NULL,            // 45
  151.     ai_move,    -0.2,    NULL,            // 46
  152.     ai_move,    0,    NULL,            // 47
  153.     ai_move,    -1.3,    NULL,            // 48
  154.     ai_move,    -3,    NULL,                // 49
  155.     ai_move,    -2,    NULL,            // 50
  156.     ai_move,    0,    NULL,                // 51
  157.     ai_move,    0,    NULL,                // 52
  158.     ai_move,    0,    NULL,                // 53
  159.     ai_move,    -3.3,    NULL,            // 54
  160.     ai_move,    -1.6,    NULL,            // 55
  161.     ai_move,    -0.3,    NULL,            // 56
  162.     ai_move,    0,    NULL,                // 57
  163.     ai_move,    0,    NULL,                // 58
  164.     ai_move,    0,    NULL                // 59
  165. };
  166. mmove_t insane_move_downtoup = {FRAME_stand41, FRAME_stand59, insane_frames_downtoup, insane_stand};
  167.  
  168. mframe_t insane_frames_jumpdown [] =
  169. {
  170.     ai_move,    0.2,    NULL,
  171.     ai_move,    11.5,    NULL,
  172.     ai_move,    5.1,    NULL,
  173.     ai_move,    7.1,    NULL,
  174.     ai_move,    0,    NULL
  175. };
  176. mmove_t insane_move_jumpdown = {FRAME_stand96, FRAME_stand100, insane_frames_jumpdown, insane_onground};
  177.  
  178.  
  179. mframe_t insane_frames_down [] =
  180. {
  181.     ai_move,    0,        NULL,        // 100
  182.     ai_move,    0,        NULL,
  183.     ai_move,    0,        NULL,
  184.     ai_move,    0,        NULL,
  185.     ai_move,    0,        NULL,
  186.     ai_move,    0,        NULL,
  187.     ai_move,    0,        NULL,
  188.     ai_move,    0,        NULL,
  189.     ai_move,    0,        NULL,
  190.     ai_move,    0,        NULL,
  191.     ai_move,    0,        NULL,        // 110
  192.     ai_move,    -1.7,        NULL,
  193.     ai_move,    -1.6,        NULL,
  194.     ai_move,    0,        NULL,
  195.     ai_move,    0,        NULL,
  196.     ai_move,    0,        NULL,
  197.     ai_move,    0,        insane_fist,
  198.     ai_move,    0,        NULL,
  199.     ai_move,    0,        NULL,
  200.     ai_move,    0,        NULL,
  201.     ai_move,    0,        NULL,        // 120
  202.     ai_move,    0,        NULL,
  203.     ai_move,    0,        NULL,
  204.     ai_move,    0,        NULL,
  205.     ai_move,    0,        NULL,
  206.     ai_move,    0,        NULL,
  207.     ai_move,    0,        NULL,
  208.     ai_move,    0,        NULL,
  209.     ai_move,    0,        NULL,
  210.     ai_move,    0,        NULL,
  211.     ai_move,    0,        NULL,        // 130
  212.     ai_move,    0,        NULL,
  213.     ai_move,    0,        NULL,
  214.     ai_move,    0,        insane_moan,
  215.     ai_move,    0,        NULL,
  216.     ai_move,    0,        NULL,
  217.     ai_move,    0,        NULL,
  218.     ai_move,    0,        NULL,
  219.     ai_move,    0,        NULL,
  220.     ai_move,    0,        NULL,
  221.     ai_move,    0,        NULL,        // 140
  222.     ai_move,    0,        NULL,
  223.     ai_move,    0,        NULL,
  224.     ai_move,    0,        NULL,
  225.     ai_move,    0,        NULL,
  226.     ai_move,    0,        NULL,
  227.     ai_move,    0,        NULL,
  228.     ai_move,    0,        NULL,
  229.     ai_move,    0,        NULL,
  230.     ai_move,    0,        NULL,
  231.     ai_move,    0,        NULL,        // 150
  232.     ai_move,    0.5,        NULL,
  233.     ai_move,    0,        NULL,
  234.     ai_move,    -0.2,        insane_scream,
  235.     ai_move,    0,        NULL,
  236.     ai_move,    0.2,        NULL,
  237.     ai_move,    0.4,        NULL,
  238.     ai_move,    0.6,        NULL,
  239.     ai_move,    0.8,        NULL,
  240.     ai_move,    0.7,        NULL,
  241.     ai_move,    0,        insane_checkup        // 160
  242. };
  243. mmove_t insane_move_down = {FRAME_stand100, FRAME_stand160, insane_frames_down, insane_onground};
  244.  
  245. mframe_t insane_frames_walk_normal [] =
  246. {
  247.     ai_walk,    0,        insane_scream,
  248.     ai_walk,    2.5,    NULL,
  249.     ai_walk,    3.5,    NULL,
  250.     ai_walk,    1.7,    NULL,
  251.     ai_walk,    2.3,    NULL,
  252.     ai_walk,    2.4,    NULL,
  253.     ai_walk,    2.2,    NULL,
  254.     ai_walk,    4.2,    NULL,
  255.     ai_walk,    5.6,    NULL,
  256.     ai_walk,    3.3,    NULL,
  257.     ai_walk,    2.4,    NULL,
  258.     ai_walk,    0.9,    NULL,
  259.     ai_walk,    0,        NULL
  260. };
  261. mmove_t insane_move_walk_normal = {FRAME_walk27, FRAME_walk39, insane_frames_walk_normal, insane_walk};
  262. mmove_t insane_move_run_normal = {FRAME_walk27, FRAME_walk39, insane_frames_walk_normal, insane_run};
  263.  
  264. mframe_t insane_frames_walk_insane [] =
  265. {
  266.     ai_walk,    0,        insane_scream,        // walk 1
  267.     ai_walk,    3.4,    NULL,        // walk 2
  268.     ai_walk,    3.6,    NULL,        // 3
  269.     ai_walk,    2.9,    NULL,        // 4
  270.     ai_walk,    2.2,    NULL,        // 5
  271.     ai_walk,    2.6,    NULL,        // 6
  272.     ai_walk,    0,        NULL,        // 7
  273.     ai_walk,    0.7,    NULL,        // 8
  274.     ai_walk,    4.8,    NULL,        // 9
  275.     ai_walk,    5.3,    NULL,        // 10
  276.     ai_walk,    1.1,    NULL,        // 11
  277.     ai_walk,    2,        NULL,        // 12
  278.     ai_walk,    0.5,    NULL,        // 13
  279.     ai_walk,    0,        NULL,        // 14
  280.     ai_walk,    0,        NULL,        // 15
  281.     ai_walk,    4.9,    NULL,        // 16
  282.     ai_walk,    6.7,    NULL,        // 17
  283.     ai_walk,    3.8,    NULL,        // 18
  284.     ai_walk,    2,        NULL,        // 19
  285.     ai_walk,    0.2,    NULL,        // 20
  286.     ai_walk,    0,        NULL,        // 21
  287.     ai_walk,    3.4,    NULL,        // 22
  288.     ai_walk,    6.4,    NULL,        // 23
  289.     ai_walk,    5,        NULL,        // 24
  290.     ai_walk,    1.8,    NULL,        // 25
  291.     ai_walk,    0,        NULL        // 26
  292. };
  293. mmove_t insane_move_walk_insane = {FRAME_walk1, FRAME_walk26, insane_frames_walk_insane, insane_walk};
  294. mmove_t insane_move_run_insane = {FRAME_walk1, FRAME_walk26, insane_frames_walk_insane, insane_run};
  295.  
  296. mframe_t insane_frames_stand_pain [] =
  297. {
  298.     ai_move,    0,        NULL,
  299.     ai_move,    0,        NULL,
  300.     ai_move,    0,        NULL,
  301.     ai_move,    0,        NULL,
  302.     ai_move,    0,        NULL,
  303.     ai_move,    0,        NULL,
  304.     ai_move,    0,        NULL,
  305.     ai_move,    0,        NULL,
  306.     ai_move,    0,        NULL,
  307.     ai_move,    0,        NULL,
  308.     ai_move,    0,        NULL
  309. };
  310. mmove_t insane_move_stand_pain = {FRAME_st_pain2, FRAME_st_pain12, insane_frames_stand_pain, insane_run};
  311.  
  312. mframe_t insane_frames_stand_death [] =
  313. {
  314.     ai_move,    0,        NULL,
  315.     ai_move,    0,        NULL,
  316.     ai_move,    0,        NULL,
  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. };
  332. mmove_t insane_move_stand_death = {FRAME_st_death2, FRAME_st_death18, insane_frames_stand_death, insane_dead};
  333.  
  334. mframe_t insane_frames_crawl [] =
  335. {
  336.     ai_walk,    0,        insane_scream,
  337.     ai_walk,    1.5,    NULL,
  338.     ai_walk,    2.1,    NULL,
  339.     ai_walk,    3.6,    NULL,
  340.     ai_walk,    2,        NULL,
  341.     ai_walk,    0.9,    NULL,
  342.     ai_walk,    3,        NULL,
  343.     ai_walk,    3.4,    NULL,
  344.     ai_walk,    2.4,    NULL
  345. };
  346. mmove_t insane_move_crawl = {FRAME_crawl1, FRAME_crawl9, insane_frames_crawl, NULL};
  347. mmove_t insane_move_runcrawl = {FRAME_crawl1, FRAME_crawl9, insane_frames_crawl, NULL};
  348.  
  349. mframe_t insane_frames_crawl_pain [] =
  350. {
  351.     ai_move,    0,        NULL,
  352.     ai_move,    0,        NULL,
  353.     ai_move,    0,        NULL,
  354.     ai_move,    0,        NULL,
  355.     ai_move,    0,        NULL,
  356.     ai_move,    0,        NULL,
  357.     ai_move,    0,        NULL,
  358.     ai_move,    0,        NULL,
  359.     ai_move,    0,        NULL
  360. };
  361. mmove_t insane_move_crawl_pain = {FRAME_cr_pain2, FRAME_cr_pain10, insane_frames_crawl_pain, insane_run};
  362.  
  363. mframe_t insane_frames_crawl_death [] =
  364. {
  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. };
  373. mmove_t insane_move_crawl_death = {FRAME_cr_death10, FRAME_cr_death16, insane_frames_crawl_death, insane_dead};
  374.  
  375. mframe_t insane_frames_cross [] =
  376. {
  377.     ai_move,    0,        insane_moan,
  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.     ai_move,    0,        NULL,
  388.     ai_move,    0,        NULL,
  389.     ai_move,    0,        NULL,
  390.     ai_move,    0,        NULL,
  391.     ai_move,    0,        NULL
  392. };
  393. mmove_t insane_move_cross = {FRAME_cross1, FRAME_cross15, insane_frames_cross, insane_cross};
  394.  
  395. mframe_t insane_frames_struggle_cross [] =
  396. {
  397.     ai_move,    0,        insane_scream,
  398.     ai_move,    0,        NULL,
  399.     ai_move,    0,        NULL,
  400.     ai_move,    0,        NULL,
  401.     ai_move,    0,        NULL,
  402.     ai_move,    0,        NULL,
  403.     ai_move,    0,        NULL,
  404.     ai_move,    0,        NULL,
  405.     ai_move,    0,        NULL,
  406.     ai_move,    0,        NULL,
  407.     ai_move,    0,        NULL,
  408.     ai_move,    0,        NULL,
  409.     ai_move,    0,        NULL,
  410.     ai_move,    0,        NULL,
  411.     ai_move,    0,        NULL
  412. };
  413. mmove_t insane_move_struggle_cross = {FRAME_cross16, FRAME_cross30, insane_frames_struggle_cross, insane_cross};
  414.  
  415. void insane_cross (edict_t *self)
  416. {
  417.     if (random() < 0.8)        
  418.         self->monsterinfo.currentmove = &insane_move_cross;
  419.     else
  420.         self->monsterinfo.currentmove = &insane_move_struggle_cross;
  421. }
  422.  
  423. void insane_walk (edict_t *self)
  424. {
  425.     if ( self->spawnflags & 16 )            // Hold Ground?
  426.         if (self->s.frame == FRAME_cr_pain10)
  427.         {
  428.             self->monsterinfo.currentmove = &insane_move_down;
  429.             return;
  430.         }
  431.     if (self->spawnflags & 4)
  432.         self->monsterinfo.currentmove = &insane_move_crawl;
  433.     else
  434.         if (random() <= 0.5)
  435.             self->monsterinfo.currentmove = &insane_move_walk_normal;
  436.         else
  437.             self->monsterinfo.currentmove = &insane_move_walk_insane;
  438. }
  439.  
  440. void insane_run (edict_t *self)
  441. {
  442.     if ( self->spawnflags & 16 )            // Hold Ground?
  443.         if (self->s.frame == FRAME_cr_pain10)
  444.         {
  445.             self->monsterinfo.currentmove = &insane_move_down;
  446.             return;
  447.         }
  448.     if (self->spawnflags & 4)                // Crawling?
  449.         self->monsterinfo.currentmove = &insane_move_runcrawl;
  450.     else
  451.         if (random() <= 0.5)                // Else, mix it up
  452.             self->monsterinfo.currentmove = &insane_move_run_normal;
  453.         else
  454.             self->monsterinfo.currentmove = &insane_move_run_insane;
  455. }
  456.  
  457.  
  458. void insane_pain (edict_t *self, edict_t *other, float kick, int damage)
  459. {
  460.     int    l,r;
  461.  
  462. //    if (self->health < (self->max_health / 2))
  463. //        self->s.skinnum = 1;
  464.  
  465.     if (level.time < self->pain_debounce_time)
  466.         return;
  467.  
  468.     self->pain_debounce_time = level.time + 3;
  469.  
  470.     r = 1 + (rand()&1);
  471.     if (self->health < 25)
  472.         l = 25;
  473.     else if (self->health < 50)
  474.         l = 50;
  475.     else if (self->health < 75)
  476.         l = 75;
  477.     else
  478.         l = 100;
  479.     gi.sound (self, CHAN_VOICE, gi.soundindex (va("player/male/pain%i_%i.wav", l, r)), 1, ATTN_IDLE, 0);
  480.  
  481.     // Don't go into pain frames if crucified.
  482.     if (self->spawnflags & 8)
  483.     {
  484.         self->monsterinfo.currentmove = &insane_move_struggle_cross;            
  485.         return;
  486.     }
  487.     
  488.     if  ( ((self->s.frame >= FRAME_crawl1) && (self->s.frame <= FRAME_crawl9)) || ((self->s.frame >= FRAME_stand99) && (self->s.frame <= FRAME_stand160)) )
  489.     {
  490.         self->monsterinfo.currentmove = &insane_move_crawl_pain;
  491.     }
  492.     else
  493.         self->monsterinfo.currentmove = &insane_move_stand_pain;
  494.  
  495. }
  496.  
  497. void insane_onground (edict_t *self)
  498. {
  499.     self->monsterinfo.currentmove = &insane_move_down;
  500. }
  501.  
  502. void insane_checkdown (edict_t *self)
  503. {
  504. //    if ( (self->s.frame == FRAME_stand94) || (self->s.frame == FRAME_stand65) )
  505.     if (self->spawnflags & 32)                // Always stand
  506.         return;
  507.     if (random() < 0.3)
  508.         if (random() < 0.5)
  509.             self->monsterinfo.currentmove = &insane_move_uptodown;
  510.         else
  511.             self->monsterinfo.currentmove = &insane_move_jumpdown; 
  512. }
  513.  
  514. void insane_checkup (edict_t *self)
  515. {
  516.     // If Hold_Ground and Crawl are set
  517.     if ( (self->spawnflags & 4) && (self->spawnflags & 16) )
  518.         return;
  519.     if (random() < 0.5)
  520.         self->monsterinfo.currentmove = &insane_move_downtoup;                
  521.  
  522. }
  523.  
  524. void insane_stand (edict_t *self)
  525. {
  526.     if (self->spawnflags & 8)            // If crucified
  527.     {
  528.         self->monsterinfo.currentmove = &insane_move_cross;
  529.         self->monsterinfo.aiflags |= AI_STAND_GROUND;
  530.     }
  531.     // If Hold_Ground and Crawl are set
  532.     else if ( (self->spawnflags & 4) && (self->spawnflags & 16) )
  533.         self->monsterinfo.currentmove = &insane_move_down;
  534.     else
  535.         if (random() < 0.5)
  536.             self->monsterinfo.currentmove = &insane_move_stand_normal;
  537.         else
  538.             self->monsterinfo.currentmove = &insane_move_stand_insane;
  539. }
  540.  
  541. void insane_dead (edict_t *self)
  542. {
  543.     if (self->spawnflags & 8)
  544.     {
  545.         self->flags |= FL_FLY;
  546.     }
  547.     else
  548.     {
  549.         VectorSet (self->mins, -16, -16, -24);
  550.         VectorSet (self->maxs, 16, 16, -8);
  551.         self->movetype = MOVETYPE_TOSS;
  552.     }
  553.     self->nextthink = 0;
  554.     gi.linkentity (self);
  555. }
  556.  
  557.  
  558. void insane_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
  559. {
  560.     int        n;
  561.  
  562.     if (self->health <= self->gib_health)
  563.     {
  564.         gi.sound (self, CHAN_VOICE, gi.soundindex ("misc/udeath.wav"), 1, ATTN_IDLE, 0);
  565.         for (n= 0; n < 2; n++)
  566.             ThrowGib (self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC);
  567.         for (n= 0; n < 4; n++)
  568.             ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
  569.         ThrowHead (self, "models/objects/gibs/head2/tris.md2", damage, GIB_ORGANIC);
  570.         self->deadflag = DEAD_DEAD;
  571.         return;
  572.     }
  573.  
  574.     if (self->deadflag == DEAD_DEAD)
  575.         return;
  576.  
  577.     gi.sound (self, CHAN_VOICE, gi.soundindex(va("player/male/death%i.wav", (rand()%4)+1)), 1, ATTN_IDLE, 0);
  578.  
  579.     self->deadflag = DEAD_DEAD;
  580.     self->takedamage = DAMAGE_YES;
  581.  
  582.     if (self->spawnflags & 8)
  583.     {
  584.         insane_dead (self);
  585.     }
  586.     else
  587.     {
  588.         if ( ((self->s.frame >= FRAME_crawl1) && (self->s.frame <= FRAME_crawl9)) || ((self->s.frame >= FRAME_stand99) && (self->s.frame <= FRAME_stand160)) )        
  589.             self->monsterinfo.currentmove = &insane_move_crawl_death;
  590.         else
  591.             self->monsterinfo.currentmove = &insane_move_stand_death;
  592.     }
  593. }
  594.  
  595.  
  596. /*QUAKED misc_insane (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn CRAWL CRUCIFIED STAND_GROUND ALWAYS_STAND
  597. */
  598. void SP_misc_insane (edict_t *self)
  599. {
  600. //    static int skin = 0;    //@@
  601.  
  602.     if (deathmatch->value)
  603.     {
  604.         G_FreeEdict (self);
  605.         return;
  606.     }
  607.  
  608.     sound_fist = gi.soundindex ("insane/insane11.wav");
  609.     sound_shake = gi.soundindex ("insane/insane5.wav");
  610.     sound_moan = gi.soundindex ("insane/insane7.wav");
  611.     sound_scream[0] = gi.soundindex ("insane/insane1.wav");
  612.     sound_scream[1] = gi.soundindex ("insane/insane2.wav");
  613.     sound_scream[2] = gi.soundindex ("insane/insane3.wav");
  614.     sound_scream[3] = gi.soundindex ("insane/insane4.wav");
  615.     sound_scream[4] = gi.soundindex ("insane/insane6.wav");
  616.     sound_scream[5] = gi.soundindex ("insane/insane8.wav");
  617.     sound_scream[6] = gi.soundindex ("insane/insane9.wav");
  618.     sound_scream[7] = gi.soundindex ("insane/insane10.wav");
  619.  
  620.     self->movetype = MOVETYPE_STEP;
  621.     self->solid = SOLID_BBOX;
  622.     self->s.modelindex = gi.modelindex("models/monsters/insane/tris.md2");
  623.  
  624.     VectorSet (self->mins, -16, -16, -24);
  625.     VectorSet (self->maxs, 16, 16, 32);
  626.  
  627.     self->health = 100;
  628.     self->gib_health = -50;
  629.     self->mass = 300;
  630.  
  631.     self->pain = insane_pain;
  632.     self->die = insane_die;
  633.  
  634.     self->monsterinfo.stand = insane_stand;
  635.     self->monsterinfo.walk = insane_walk;
  636.     self->monsterinfo.run = insane_run;
  637.     self->monsterinfo.dodge = NULL;
  638.     self->monsterinfo.attack = NULL;
  639.     self->monsterinfo.melee = NULL;
  640.     self->monsterinfo.sight = NULL;
  641.     self->monsterinfo.aiflags |= AI_GOOD_GUY;
  642.  
  643. //@@
  644. //    self->s.skinnum = skin;
  645. //    skin++;
  646. //    if (skin > 12)
  647. //        skin = 0;
  648.  
  649.     gi.linkentity (self);
  650.  
  651.     if (self->spawnflags & 16)                // Stand Ground
  652.         self->monsterinfo.aiflags |= AI_STAND_GROUND;
  653.  
  654.     self->monsterinfo.currentmove = &insane_move_stand_normal;
  655.     
  656.     self->monsterinfo.scale = MODEL_SCALE;
  657.  
  658.     if (self->spawnflags & 8)                    // Crucified ?
  659.     {
  660.         VectorSet (self->mins, -16, 0, 0);
  661.         VectorSet (self->maxs, 16, 8, 32);
  662.         self->flags |= FL_NO_KNOCKBACK;
  663.         flymonster_start (self);
  664.     }
  665.     else
  666.     {
  667.         walkmonster_start (self);
  668.         self->s.skinnum = rand()%3;
  669.     }
  670. }
  671.