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

  1. /*
  2. ==============================================================================
  3.  
  4. FLIPPER
  5.  
  6. ==============================================================================
  7. */
  8.  
  9. #include "g_local.h"
  10. #include "m_flipper.h"
  11.  
  12.  
  13. static int    sound_chomp;
  14. static int    sound_attack;
  15. static int    sound_pain1;
  16. static int    sound_pain2;
  17. static int    sound_death;
  18. static int    sound_idle;
  19. static int    sound_search;
  20. static int    sound_sight;
  21.  
  22.  
  23. void flipper_stand (edict_t *self);
  24.  
  25. mframe_t flipper_frames_stand [] =
  26. {
  27.     ai_stand, 0, NULL
  28. };
  29.     
  30. mmove_t    flipper_move_stand = {FRAME_flphor01, FRAME_flphor01, flipper_frames_stand, NULL};
  31.  
  32. void flipper_stand (edict_t *self)
  33. {
  34.         self->monsterinfo.currentmove = &flipper_move_stand;
  35. }
  36.  
  37. #define FLIPPER_RUN_SPEED    24
  38.  
  39. mframe_t flipper_frames_run [] =
  40. {
  41.     ai_run, FLIPPER_RUN_SPEED, NULL,    // 6
  42.     ai_run, FLIPPER_RUN_SPEED, NULL,
  43.     ai_run, FLIPPER_RUN_SPEED, NULL,
  44.     ai_run, FLIPPER_RUN_SPEED, NULL,
  45.     ai_run, FLIPPER_RUN_SPEED, NULL,    // 10
  46.  
  47.     ai_run, FLIPPER_RUN_SPEED, NULL,
  48.     ai_run, FLIPPER_RUN_SPEED, NULL,
  49.     ai_run, FLIPPER_RUN_SPEED, NULL,
  50.     ai_run, FLIPPER_RUN_SPEED, NULL,
  51.     ai_run, FLIPPER_RUN_SPEED, NULL,
  52.     ai_run, FLIPPER_RUN_SPEED, NULL,
  53.     ai_run, FLIPPER_RUN_SPEED, NULL,
  54.     ai_run, FLIPPER_RUN_SPEED, NULL,
  55.     ai_run, FLIPPER_RUN_SPEED, NULL,
  56.     ai_run, FLIPPER_RUN_SPEED, NULL,    // 20
  57.  
  58.     ai_run, FLIPPER_RUN_SPEED, NULL,
  59.     ai_run, FLIPPER_RUN_SPEED, NULL,
  60.     ai_run, FLIPPER_RUN_SPEED, NULL,
  61.     ai_run, FLIPPER_RUN_SPEED, NULL,
  62.     ai_run, FLIPPER_RUN_SPEED, NULL,
  63.     ai_run, FLIPPER_RUN_SPEED, NULL,
  64.     ai_run, FLIPPER_RUN_SPEED, NULL,
  65.     ai_run, FLIPPER_RUN_SPEED, NULL,
  66.     ai_run, FLIPPER_RUN_SPEED, NULL        // 29
  67. };
  68. mmove_t flipper_move_run_loop = {FRAME_flpver06, FRAME_flpver29, flipper_frames_run, NULL};
  69.  
  70. void flipper_run_loop (edict_t *self)
  71. {
  72.     self->monsterinfo.currentmove = &flipper_move_run_loop;
  73. }
  74.  
  75. mframe_t flipper_frames_run_start [] =
  76. {
  77.     ai_run, 8, NULL,
  78.     ai_run, 8, NULL,
  79.     ai_run, 8, NULL,
  80.     ai_run, 8, NULL,
  81.     ai_run, 8, NULL,
  82.     ai_run, 8, NULL
  83. };
  84. mmove_t flipper_move_run_start = {FRAME_flpver01, FRAME_flpver06, flipper_frames_run_start, flipper_run_loop};
  85.  
  86. void flipper_run (edict_t *self)
  87. {
  88.     self->monsterinfo.currentmove = &flipper_move_run_start;
  89. }
  90.  
  91. /* Standard Swimming */ 
  92. mframe_t flipper_frames_walk [] =
  93. {
  94.     ai_walk, 4, NULL,
  95.     ai_walk, 4, NULL,
  96.     ai_walk, 4, NULL,
  97.     ai_walk, 4, NULL,
  98.     ai_walk, 4, NULL,
  99.     ai_walk, 4, NULL,
  100.     ai_walk, 4, NULL,
  101.     ai_walk, 4, NULL,
  102.     ai_walk, 4, NULL,
  103.     ai_walk, 4, NULL,
  104.     ai_walk, 4, NULL,
  105.     ai_walk, 4, NULL,
  106.     ai_walk, 4, NULL,
  107.     ai_walk, 4, NULL,
  108.     ai_walk, 4, NULL,
  109.     ai_walk, 4, NULL,
  110.     ai_walk, 4, NULL,
  111.     ai_walk, 4, NULL,
  112.     ai_walk, 4, NULL,
  113.     ai_walk, 4, NULL,
  114.     ai_walk, 4, NULL,
  115.     ai_walk, 4, NULL,
  116.     ai_walk, 4, NULL,
  117.     ai_walk, 4, NULL
  118. };
  119. mmove_t flipper_move_walk = {FRAME_flphor01, FRAME_flphor24, flipper_frames_walk, NULL};
  120.  
  121. void flipper_walk (edict_t *self)
  122. {
  123.     self->monsterinfo.currentmove = &flipper_move_walk;
  124. }
  125.  
  126. mframe_t flipper_frames_start_run [] =
  127. {
  128.     ai_run, 8, NULL,
  129.     ai_run, 8, NULL,
  130.     ai_run, 8, NULL,
  131.     ai_run, 8, NULL,
  132.     ai_run, 8, flipper_run
  133. };
  134. mmove_t flipper_move_start_run = {FRAME_flphor01, FRAME_flphor05, flipper_frames_start_run, NULL};
  135.  
  136. void flipper_start_run (edict_t *self)
  137. {
  138.     self->monsterinfo.currentmove = &flipper_move_start_run;
  139. }
  140.  
  141. mframe_t flipper_frames_pain2 [] =
  142. {
  143.     ai_move, 0, NULL,
  144.     ai_move, 0, NULL,
  145.     ai_move, 0,    NULL,
  146.     ai_move, 0,    NULL,
  147.     ai_move, 0, NULL
  148. };
  149. mmove_t flipper_move_pain2 = {FRAME_flppn101, FRAME_flppn105, flipper_frames_pain2, flipper_run};
  150.  
  151. mframe_t flipper_frames_pain1 [] =
  152. {
  153.     ai_move, 0, NULL,
  154.     ai_move, 0, NULL,
  155.     ai_move, 0,    NULL,
  156.     ai_move, 0,    NULL,
  157.     ai_move, 0, NULL
  158. };
  159. mmove_t flipper_move_pain1 = {FRAME_flppn201, FRAME_flppn205, flipper_frames_pain1, flipper_run};
  160.  
  161. void flipper_bite (edict_t *self)
  162. {
  163.     vec3_t    aim;
  164.  
  165.     VectorSet (aim, MELEE_DISTANCE, 0, 0);
  166.     fire_hit (self, aim, 5, 0);
  167. }
  168.  
  169. void flipper_preattack (edict_t *self)
  170. {
  171.     gi.sound (self, CHAN_WEAPON, sound_chomp, 1, ATTN_NORM, 0);
  172. }
  173.  
  174. mframe_t flipper_frames_attack [] =
  175. {
  176.     ai_charge, 0,    flipper_preattack,
  177.     ai_charge, 0,    NULL,
  178.     ai_charge, 0,    NULL,
  179.     ai_charge, 0,    NULL,
  180.     ai_charge, 0,    NULL,
  181.     ai_charge, 0,    NULL,
  182.     ai_charge, 0,    NULL,
  183.     ai_charge, 0,    NULL,
  184.     ai_charge, 0,    NULL,
  185.     ai_charge, 0,    NULL,
  186.     ai_charge, 0,    NULL,
  187.     ai_charge, 0,    NULL,
  188.     ai_charge, 0,    NULL,
  189.     ai_charge, 0,    flipper_bite,
  190.     ai_charge, 0,    NULL,
  191.     ai_charge, 0,    NULL,
  192.     ai_charge, 0,    NULL,
  193.     ai_charge, 0,    NULL,
  194.     ai_charge, 0,    flipper_bite,
  195.     ai_charge, 0,    NULL
  196. };
  197. mmove_t flipper_move_attack = {FRAME_flpbit01, FRAME_flpbit20, flipper_frames_attack, flipper_run};
  198.  
  199. void flipper_melee(edict_t *self)
  200. {
  201.     self->monsterinfo.currentmove = &flipper_move_attack;
  202. }
  203.  
  204. void flipper_pain (edict_t *self, edict_t *other, float kick, int damage)
  205. {
  206.     int        n;
  207.  
  208.     if (self->health < (self->max_health / 2))
  209.         self->s.skinnum = 1;
  210.  
  211.     if (level.time < self->pain_debounce_time)
  212.         return;
  213.  
  214.     self->pain_debounce_time = level.time + 3;
  215.     
  216.  
  217.     n = (rand() + 1) % 2;
  218.     if (n == 0)
  219.     {
  220.         gi.sound (self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0);
  221.         self->monsterinfo.currentmove = &flipper_move_pain1;
  222.     }
  223.     else
  224.     {
  225.         gi.sound (self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0);
  226.         self->monsterinfo.currentmove = &flipper_move_pain2;
  227.     }
  228. }
  229.  
  230. void flipper_dead (edict_t *self)
  231. {
  232.     VectorSet (self->mins, -16, -16, -24);
  233.     VectorSet (self->maxs, 16, 16, -8);
  234.     self->movetype = MOVETYPE_TOSS;
  235.     self->nextthink = 0;
  236.     gi.linkentity (self);
  237. }
  238.  
  239. mframe_t flipper_frames_death [] =
  240. {
  241.     ai_move, 0,     NULL,
  242.     ai_move, 0,     NULL,
  243.     ai_move, 0,     NULL,
  244.     ai_move, 0,     NULL,
  245.     ai_move, 0,     NULL,
  246.     ai_move, 0,     NULL,
  247.     ai_move, 0,     NULL,
  248.     ai_move, 0,     NULL,
  249.     ai_move, 0,     NULL,
  250.     ai_move, 0,     NULL,
  251.  
  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.  
  263.     ai_move, 0,     NULL,
  264.     ai_move, 0,     NULL,
  265.     ai_move, 0,     NULL,
  266.     ai_move, 0,     NULL,
  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.  
  274.     ai_move, 0,     NULL,
  275.     ai_move, 0,     NULL,
  276.     ai_move, 0,     NULL,
  277.     ai_move, 0,     NULL,
  278.     ai_move, 0,     NULL,
  279.     ai_move, 0,     NULL,
  280.     ai_move, 0,     NULL,
  281.     ai_move, 0,     NULL,
  282.     ai_move, 0,     NULL,
  283.     ai_move, 0,     NULL,
  284.  
  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.     ai_move, 0,     NULL,
  297.     ai_move, 0,     NULL,
  298.     ai_move, 0,     NULL,
  299.     ai_move, 0,     NULL,
  300.     ai_move, 0,     NULL,
  301.     ai_move, 0,     NULL
  302. };
  303. mmove_t flipper_move_death = {FRAME_flpdth01, FRAME_flpdth56, flipper_frames_death, flipper_dead};
  304.  
  305. void flipper_sight (edict_t *self, edict_t *other)
  306. {
  307.     gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
  308. }
  309.  
  310. void flipper_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
  311. {
  312.     int        n;
  313.  
  314. // check for gib
  315.     if (self->health <= self->gib_health)
  316.     {
  317.         gi.sound (self, CHAN_VOICE, gi.soundindex ("misc/udeath.wav"), 1, ATTN_NORM, 0);
  318.         for (n= 0; n < 2; n++)
  319.             ThrowGib (self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC);
  320.         for (n= 0; n < 2; n++)
  321.             ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
  322.         ThrowHead (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
  323.         self->deadflag = DEAD_DEAD;
  324.         return;
  325.     }
  326.  
  327.     if (self->deadflag == DEAD_DEAD)
  328.         return;
  329.  
  330. // regular death
  331.     gi.sound (self, CHAN_VOICE, sound_death, 1, ATTN_NORM, 0);
  332.     self->deadflag = DEAD_DEAD;
  333.     self->takedamage = DAMAGE_YES;
  334.     self->monsterinfo.currentmove = &flipper_move_death;
  335. }
  336.  
  337. /*QUAKED monster_flipper (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
  338. */
  339. void SP_monster_flipper (edict_t *self)
  340. {
  341.     if (deathmatch->value)
  342.     {
  343.         G_FreeEdict (self);
  344.         return;
  345.     }
  346.  
  347.     sound_pain1        = gi.soundindex ("flipper/flppain1.wav");    
  348.     sound_pain2        = gi.soundindex ("flipper/flppain2.wav");    
  349.     sound_death        = gi.soundindex ("flipper/flpdeth1.wav");    
  350.     sound_chomp        = gi.soundindex ("flipper/flpatck1.wav");
  351.     sound_attack    = gi.soundindex ("flipper/flpatck2.wav");
  352.     sound_idle        = gi.soundindex ("flipper/flpidle1.wav");
  353.     sound_search    = gi.soundindex ("flipper/flpsrch1.wav");
  354.     sound_sight        = gi.soundindex ("flipper/flpsght1.wav");
  355.  
  356.     self->movetype = MOVETYPE_STEP;
  357.     self->solid = SOLID_BBOX;
  358.     self->s.modelindex = gi.modelindex ("models/monsters/flipper/tris.md2");
  359.     VectorSet (self->mins, -16, -16, 0);
  360.     VectorSet (self->maxs, 16, 16, 32);
  361.  
  362.     self->health = 50;
  363.     self->gib_health = -30;
  364.     self->mass = 100;
  365.  
  366.     self->pain = flipper_pain;
  367.     self->die = flipper_die;
  368.  
  369.     self->monsterinfo.stand = flipper_stand;
  370.     self->monsterinfo.walk = flipper_walk;
  371.     self->monsterinfo.run = flipper_start_run;
  372.     self->monsterinfo.melee = flipper_melee;
  373.     self->monsterinfo.sight = flipper_sight;
  374.  
  375.     gi.linkentity (self);
  376.  
  377.     self->monsterinfo.currentmove = &flipper_move_stand;    
  378.     self->monsterinfo.scale = MODEL_SCALE;
  379.  
  380.     swimmonster_start (self);
  381. }
  382.