From 41e0b6dfdd94941c2fa45b4bd33c4169aac3002e Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Sun, 9 Oct 2011 15:47:30 +0000 Subject: [PATCH] cleanup flyer/ and add sanity checks --- src/game/baseq2/monster/flyer/flyer.c | 845 +++++++++++++++++--------- src/game/baseq2/monster/flyer/flyer.h | 359 +++++------ 2 files changed, 732 insertions(+), 472 deletions(-) diff --git a/src/game/baseq2/monster/flyer/flyer.c b/src/game/baseq2/monster/flyer/flyer.c index 82466a04..28e99e9e 100644 --- a/src/game/baseq2/monster/flyer/flyer.c +++ b/src/game/baseq2/monster/flyer/flyer.c @@ -1,72 +1,85 @@ /* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ -/* -============================================================================== - -flyer - -============================================================================== -*/ + * Copyright (C) 1997-2001 Id Software, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * ======================================================================= + * + * Flyer. + * + * ======================================================================= + */ #include "../../header/local.h" #include "flyer.h" -qboolean visible (edict_t *self, edict_t *other); +qboolean visible(edict_t *self, edict_t *other); -static int nextmove; // Used for start/stop frames - -static int sound_sight; -static int sound_idle; -static int sound_pain1; -static int sound_pain2; -static int sound_slash; -static int sound_sproing; -static int sound_die; +static int nextmove; /* Used for start/stop frames */ +static int sound_sight; +static int sound_idle; +static int sound_pain1; +static int sound_pain2; +static int sound_slash; +static int sound_sproing; +static int sound_die; void flyer_check_melee(edict_t *self); -void flyer_loop_melee (edict_t *self); -void flyer_melee (edict_t *self); -void flyer_setstart (edict_t *self); -void flyer_stand (edict_t *self); -void flyer_nextmove (edict_t *self); +void flyer_loop_melee(edict_t *self); +void flyer_melee(edict_t *self); +void flyer_setstart(edict_t *self); +void flyer_stand(edict_t *self); +void flyer_nextmove(edict_t *self); - -void flyer_sight (edict_t *self, edict_t *other) -{ - gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0); +void +flyer_sight(edict_t *self, edict_t *other /* other */) +{ + if (!self) + { + return; + } + + gi.sound(self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0); } -void flyer_idle (edict_t *self) -{ - gi.sound (self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0); +void +flyer_idle(edict_t *self) +{ + if (!self) + { + return; + } + + gi.sound(self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0); } -void flyer_pop_blades (edict_t *self) -{ - gi.sound (self, CHAN_VOICE, sound_sproing, 1, ATTN_NORM, 0); +void +flyer_pop_blades(edict_t *self) +{ + if (!self) + { + return; + } + + gi.sound(self, CHAN_VOICE, sound_sproing, 1, ATTN_NORM, 0); } - -mframe_t flyer_frames_stand [] = -{ +mframe_t flyer_frames_stand[] = { {ai_stand, 0, NULL}, {ai_stand, 0, NULL}, {ai_stand, 0, NULL}, @@ -113,11 +126,16 @@ mframe_t flyer_frames_stand [] = {ai_stand, 0, NULL}, {ai_stand, 0, NULL} }; -mmove_t flyer_move_stand = {FRAME_stand01, FRAME_stand45, flyer_frames_stand, NULL}; - -mframe_t flyer_frames_walk [] = +mmove_t flyer_move_stand = { + FRAME_stand01, + FRAME_stand45, + flyer_frames_stand, + NULL +}; + +mframe_t flyer_frames_walk[] = { {ai_walk, 5, NULL}, {ai_walk, 5, NULL}, {ai_walk, 5, NULL}, @@ -164,10 +182,16 @@ mframe_t flyer_frames_walk [] = {ai_walk, 5, NULL}, {ai_walk, 5, NULL} }; -mmove_t flyer_move_walk = {FRAME_stand01, FRAME_stand45, flyer_frames_walk, NULL}; -mframe_t flyer_frames_run [] = +mmove_t flyer_move_walk = { + FRAME_stand01, + FRAME_stand45, + flyer_frames_walk, + NULL +}; + +mframe_t flyer_frames_run[] = { {ai_run, 10, NULL}, {ai_run, 10, NULL}, {ai_run, 10, NULL}, @@ -214,386 +238,619 @@ mframe_t flyer_frames_run [] = {ai_run, 10, NULL}, {ai_run, 10, NULL} }; -mmove_t flyer_move_run = {FRAME_stand01, FRAME_stand45, flyer_frames_run, NULL}; -void flyer_run (edict_t *self) +mmove_t flyer_move_run = { + FRAME_stand01, + FRAME_stand45, + flyer_frames_run, + NULL +}; + +void +flyer_run(edict_t *self) +{ + if (!self) + { + return; + } + if (self->monsterinfo.aiflags & AI_STAND_GROUND) + { self->monsterinfo.currentmove = &flyer_move_stand; + } else + { self->monsterinfo.currentmove = &flyer_move_run; + } } -void flyer_walk (edict_t *self) -{ +void +flyer_walk(edict_t *self) +{ + if (!self) + { + return; + } + self->monsterinfo.currentmove = &flyer_move_walk; } -void flyer_stand (edict_t *self) -{ - self->monsterinfo.currentmove = &flyer_move_stand; +void +flyer_stand(edict_t *self) +{ + if (!self) + { + return; + } + + self->monsterinfo.currentmove = &flyer_move_stand; } -mframe_t flyer_frames_start [] = -{ - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, flyer_nextmove} +mframe_t flyer_frames_start[] = { + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, flyer_nextmove} }; -mmove_t flyer_move_start = {FRAME_start01, FRAME_start06, flyer_frames_start, NULL}; -mframe_t flyer_frames_stop [] = +mmove_t flyer_move_start = { - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, flyer_nextmove} + FRAME_start01, + FRAME_start06, + flyer_frames_start, + NULL }; -mmove_t flyer_move_stop = {FRAME_stop01, FRAME_stop07, flyer_frames_stop, NULL}; -void flyer_stop (edict_t *self) +mframe_t flyer_frames_stop[] = { + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, flyer_nextmove} +}; + +mmove_t flyer_move_stop = { - self->monsterinfo.currentmove = &flyer_move_stop; + FRAME_stop01, + FRAME_stop07, + flyer_frames_stop, + NULL +}; + +void +flyer_stop(edict_t *self) +{ + if (!self) + { + return; + } + + self->monsterinfo.currentmove = &flyer_move_stop; } -void flyer_start (edict_t *self) -{ - self->monsterinfo.currentmove = &flyer_move_start; +void +flyer_start(edict_t *self) +{ + if (!self) + { + return; + } + + self->monsterinfo.currentmove = &flyer_move_start; } - -mframe_t flyer_frames_rollright [] = -{ - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL} +mframe_t flyer_frames_rollright[] = { + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL} }; -mmove_t flyer_move_rollright = {FRAME_rollr01, FRAME_rollr09, flyer_frames_rollright, NULL}; -mframe_t flyer_frames_rollleft [] = +mmove_t flyer_move_rollright = { - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL} + FRAME_rollr01, + FRAME_rollr09, + flyer_frames_rollright, + NULL }; -mmove_t flyer_move_rollleft = {FRAME_rollf01, FRAME_rollf09, flyer_frames_rollleft, NULL}; -mframe_t flyer_frames_pain3 [] = -{ - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL} +mframe_t flyer_frames_rollleft[] = { + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL} }; -mmove_t flyer_move_pain3 = {FRAME_pain301, FRAME_pain304, flyer_frames_pain3, flyer_run}; -mframe_t flyer_frames_pain2 [] = +mmove_t flyer_move_rollleft = { - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL} + FRAME_rollf01, + FRAME_rollf09, + flyer_frames_rollleft, + NULL }; -mmove_t flyer_move_pain2 = {FRAME_pain201, FRAME_pain204, flyer_frames_pain2, flyer_run}; -mframe_t flyer_frames_pain1 [] = -{ - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL} +mframe_t flyer_frames_pain3[] = { + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL} }; -mmove_t flyer_move_pain1 = {FRAME_pain101, FRAME_pain109, flyer_frames_pain1, flyer_run}; -mframe_t flyer_frames_defense [] = +mmove_t flyer_move_pain3 = { - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, // Hold this frame - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL} + FRAME_pain301, + FRAME_pain304, + flyer_frames_pain3, + flyer_run }; -mmove_t flyer_move_defense = {FRAME_defens01, FRAME_defens06, flyer_frames_defense, NULL}; -mframe_t flyer_frames_bankright [] = -{ - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL} +mframe_t flyer_frames_pain2[] = { + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL} }; -mmove_t flyer_move_bankright = {FRAME_bankr01, FRAME_bankr07, flyer_frames_bankright, NULL}; -mframe_t flyer_frames_bankleft [] = +mmove_t flyer_move_pain2 = { - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL} + FRAME_pain201, + FRAME_pain204, + flyer_frames_pain2, + flyer_run }; -mmove_t flyer_move_bankleft = {FRAME_bankl01, FRAME_bankl07, flyer_frames_bankleft, NULL}; +mframe_t flyer_frames_pain1[] = { + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL} +}; -void flyer_fire (edict_t *self, int flash_number) +mmove_t flyer_move_pain1 = { - vec3_t start; - vec3_t forward, right; - vec3_t end; - vec3_t dir; - int effect; + FRAME_pain101, + FRAME_pain109, + flyer_frames_pain1, + flyer_run +}; - if ((self->s.frame == FRAME_attak204) || (self->s.frame == FRAME_attak207) || (self->s.frame == FRAME_attak210)) +mframe_t flyer_frames_defense[] = { + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, /* Hold this frame */ + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL} +}; + +mmove_t flyer_move_defense = +{ + FRAME_defens01, + FRAME_defens06, + flyer_frames_defense, + NULL +}; + +mframe_t flyer_frames_bankright[] = { + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL} +}; + +mmove_t flyer_move_bankright = +{ + FRAME_bankr01, + FRAME_bankr07, + flyer_frames_bankright, + NULL +}; + +mframe_t flyer_frames_bankleft[] = { + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL} +}; + +mmove_t flyer_move_bankleft = +{ + FRAME_bankl01, + FRAME_bankl07, + flyer_frames_bankleft, + NULL +}; + +void +flyer_fire(edict_t *self, int flash_number) +{ + vec3_t start; + vec3_t forward, right; + vec3_t end; + vec3_t dir; + int effect; + + if (!self) + { + return; + } + + if ((self->s.frame == FRAME_attak204) || + (self->s.frame == FRAME_attak207) || + (self->s.frame == FRAME_attak210)) + { effect = EF_HYPERBLASTER; + } else + { effect = 0; - AngleVectors (self->s.angles, forward, right, NULL); - G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start); - - VectorCopy (self->enemy->s.origin, end); + } + + AngleVectors(self->s.angles, forward, right, NULL); + G_ProjectSource(self->s.origin, monster_flash_offset[flash_number], + forward, right, start); + + VectorCopy(self->enemy->s.origin, end); end[2] += self->enemy->viewheight; - VectorSubtract (end, start, dir); + VectorSubtract(end, start, dir); - monster_fire_blaster (self, start, dir, 1, 1000, flash_number, effect); + monster_fire_blaster(self, start, dir, 1, 1000, flash_number, effect); } -void flyer_fireleft (edict_t *self) -{ - flyer_fire (self, MZ2_FLYER_BLASTER_1); +void +flyer_fireleft(edict_t *self) +{ + if (!self) + { + return; + } + + flyer_fire(self, MZ2_FLYER_BLASTER_1); } -void flyer_fireright (edict_t *self) -{ - flyer_fire (self, MZ2_FLYER_BLASTER_2); +void +flyer_fireright(edict_t *self) +{ + if (!self) + { + return; + } + + flyer_fire(self, MZ2_FLYER_BLASTER_2); } - -mframe_t flyer_frames_attack2 [] = -{ - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL}, - {ai_charge, -10, flyer_fireleft}, // left gun - {ai_charge, -10, flyer_fireright}, // right gun - {ai_charge, -10, flyer_fireleft}, // left gun - {ai_charge, -10, flyer_fireright}, // right gun - {ai_charge, -10, flyer_fireleft}, // left gun - {ai_charge, -10, flyer_fireright}, // right gun - {ai_charge, -10, flyer_fireleft}, // left gun - {ai_charge, -10, flyer_fireright}, // right gun - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL} +mframe_t flyer_frames_attack2[] = { + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL}, + {ai_charge, -10, flyer_fireleft}, /* left gun */ + {ai_charge, -10, flyer_fireright}, /* right gun */ + {ai_charge, -10, flyer_fireleft}, /* left gun */ + {ai_charge, -10, flyer_fireright}, /* right gun */ + {ai_charge, -10, flyer_fireleft}, /* left gun */ + {ai_charge, -10, flyer_fireright}, /* right gun */ + {ai_charge, -10, flyer_fireleft}, /* left gun */ + {ai_charge, -10, flyer_fireright}, /* right gun */ + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL} }; -mmove_t flyer_move_attack2 = {FRAME_attak201, FRAME_attak217, flyer_frames_attack2, flyer_run}; - -void flyer_slash_left (edict_t *self) +mmove_t flyer_move_attack2 = { - vec3_t aim; + FRAME_attak201, + FRAME_attak217, + flyer_frames_attack2, + flyer_run +}; - VectorSet (aim, MELEE_DISTANCE, self->mins[0], 0); - fire_hit (self, aim, 5, 0); - gi.sound (self, CHAN_WEAPON, sound_slash, 1, ATTN_NORM, 0); +void +flyer_slash_left(edict_t *self) +{ + vec3_t aim; + + if (!self) + { + return; + } + + VectorSet(aim, MELEE_DISTANCE, self->mins[0], 0); + fire_hit(self, aim, 5, 0); + gi.sound(self, CHAN_WEAPON, sound_slash, 1, ATTN_NORM, 0); } -void flyer_slash_right (edict_t *self) +void +flyer_slash_right(edict_t *self) { - vec3_t aim; - - VectorSet (aim, MELEE_DISTANCE, self->maxs[0], 0); - fire_hit (self, aim, 5, 0); - gi.sound (self, CHAN_WEAPON, sound_slash, 1, ATTN_NORM, 0); + vec3_t aim; + + if (!self) + { + return; + } + + VectorSet(aim, MELEE_DISTANCE, self->maxs[0], 0); + fire_hit(self, aim, 5, 0); + gi.sound(self, CHAN_WEAPON, sound_slash, 1, ATTN_NORM, 0); } -mframe_t flyer_frames_start_melee [] = -{ - {ai_charge, 0, flyer_pop_blades}, - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL} +mframe_t flyer_frames_start_melee[] = { + {ai_charge, 0, flyer_pop_blades}, + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL} }; -mmove_t flyer_move_start_melee = {FRAME_attak101, FRAME_attak106, flyer_frames_start_melee, flyer_loop_melee}; -mframe_t flyer_frames_end_melee [] = +mmove_t flyer_move_start_melee = { - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL} + FRAME_attak101, + FRAME_attak106, + flyer_frames_start_melee, + flyer_loop_melee }; -mmove_t flyer_move_end_melee = {FRAME_attak119, FRAME_attak121, flyer_frames_end_melee, flyer_run}; - -mframe_t flyer_frames_loop_melee [] = -{ - {ai_charge, 0, NULL}, // Loop Start - {ai_charge, 0, NULL}, - {ai_charge, 0, flyer_slash_left}, // Left Wing Strike - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL}, - {ai_charge, 0, flyer_slash_right}, // Right Wing Strike - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL}, - {ai_charge, 0, NULL} // Loop Ends - +mframe_t flyer_frames_end_melee[] = { + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL} }; -mmove_t flyer_move_loop_melee = {FRAME_attak107, FRAME_attak118, flyer_frames_loop_melee, flyer_check_melee}; -void flyer_loop_melee (edict_t *self) +mmove_t flyer_move_end_melee = { + FRAME_attak119, + FRAME_attak121, + flyer_frames_end_melee, + flyer_run +}; + +mframe_t flyer_frames_loop_melee[] = { + {ai_charge, 0, NULL}, /* Loop Start */ + {ai_charge, 0, NULL}, + {ai_charge, 0, flyer_slash_left}, /* Left Wing Strike */ + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL}, + {ai_charge, 0, flyer_slash_right}, /* Right Wing Strike */ + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL}, + {ai_charge, 0, NULL} /* Loop Ends */ +}; + +mmove_t flyer_move_loop_melee = +{ + FRAME_attak107, + FRAME_attak118, + flyer_frames_loop_melee, + flyer_check_melee +}; + +void +flyer_loop_melee(edict_t *self) +{ + if (!self) + { + return; + } + self->monsterinfo.currentmove = &flyer_move_loop_melee; } - - -void flyer_attack (edict_t *self) -{ +void +flyer_attack(edict_t *self) +{ + if (!self) + { + return; + } + self->monsterinfo.currentmove = &flyer_move_attack2; } -void flyer_setstart (edict_t *self) -{ +void +flyer_setstart(edict_t *self) +{ + if (!self) + { + return; + } + nextmove = ACTION_run; self->monsterinfo.currentmove = &flyer_move_start; } -void flyer_nextmove (edict_t *self) -{ +void +flyer_nextmove(edict_t *self) +{ + if (!self) + { + return; + } + if (nextmove == ACTION_attack1) + { self->monsterinfo.currentmove = &flyer_move_start_melee; + } else if (nextmove == ACTION_attack2) + { self->monsterinfo.currentmove = &flyer_move_attack2; + } else if (nextmove == ACTION_run) + { self->monsterinfo.currentmove = &flyer_move_run; + } } -void flyer_melee (edict_t *self) -{ +void +flyer_melee(edict_t *self) +{ + if (!self) + { + return; + } + self->monsterinfo.currentmove = &flyer_move_start_melee; } -void flyer_check_melee(edict_t *self) -{ - if (range (self, self->enemy) == RANGE_MELEE) +void +flyer_check_melee(edict_t *self) +{ + if (!self) + { + return; + } + + if (range(self, self->enemy) == RANGE_MELEE) + { if (random() <= 0.8) + { self->monsterinfo.currentmove = &flyer_move_loop_melee; + } else + { self->monsterinfo.currentmove = &flyer_move_end_melee; + } + } else + { self->monsterinfo.currentmove = &flyer_move_end_melee; + } } -void flyer_pain (edict_t *self, edict_t *other, float kick, int damage) +void +flyer_pain(edict_t *self, edict_t *other /* unused */, + float kick /* unused */, int damage) { - int n; - + int n; + + if (!self) + { + return; + } + if (self->health < (self->max_health / 2)) + { self->s.skinnum = 1; + } if (level.time < self->pain_debounce_time) + { return; + } self->pain_debounce_time = level.time + 3; + if (skill->value == 3) - return; // no pain anims in nightmare + { + return; /* no pain anims in nightmare */ + } n = rand() % 3; + if (n == 0) { - gi.sound (self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0); + gi.sound(self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0); self->monsterinfo.currentmove = &flyer_move_pain1; } else if (n == 1) { - gi.sound (self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0); + gi.sound(self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0); self->monsterinfo.currentmove = &flyer_move_pain2; } else { - gi.sound (self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0); + gi.sound(self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0); self->monsterinfo.currentmove = &flyer_move_pain3; } } - -void flyer_die(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point) -{ - gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0); +void +flyer_die(edict_t *self, edict_t *inflictor /* unused */, + edict_t *attacker /* unused */, int damage /* unused */, + vec3_t point /* unused */) +{ + if (!self) + { + return; + } + + gi.sound(self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0); BecomeExplosion1(self); } - -/*QUAKED monster_flyer (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight -*/ -void SP_monster_flyer (edict_t *self) -{ +/* + * QUAKED monster_flyer (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight + */ +void +SP_monster_flyer(edict_t *self) +{ + if (!self) + { + return; + } + if (deathmatch->value) { - G_FreeEdict (self); + G_FreeEdict(self); return; } - // fix a map bug in jail5.bsp + /* fix a map bug in jail5.bsp */ if (!Q_stricmp(level.mapname, "jail5") && (self->s.origin[2] == -104)) { self->targetname = self->target; self->target = NULL; } - sound_sight = gi.soundindex ("flyer/flysght1.wav"); - sound_idle = gi.soundindex ("flyer/flysrch1.wav"); - sound_pain1 = gi.soundindex ("flyer/flypain1.wav"); - sound_pain2 = gi.soundindex ("flyer/flypain2.wav"); - sound_slash = gi.soundindex ("flyer/flyatck2.wav"); - sound_sproing = gi.soundindex ("flyer/flyatck1.wav"); - sound_die = gi.soundindex ("flyer/flydeth1.wav"); + sound_sight = gi.soundindex("flyer/flysght1.wav"); + sound_idle = gi.soundindex("flyer/flysrch1.wav"); + sound_pain1 = gi.soundindex("flyer/flypain1.wav"); + sound_pain2 = gi.soundindex("flyer/flypain2.wav"); + sound_slash = gi.soundindex("flyer/flyatck2.wav"); + sound_sproing = gi.soundindex("flyer/flyatck1.wav"); + sound_die = gi.soundindex("flyer/flydeth1.wav"); - gi.soundindex ("flyer/flyatck3.wav"); + gi.soundindex("flyer/flyatck3.wav"); - self->s.modelindex = gi.modelindex ("models/monsters/flyer/tris.md2"); - VectorSet (self->mins, -16, -16, -24); - VectorSet (self->maxs, 16, 16, 32); + self->s.modelindex = gi.modelindex("models/monsters/flyer/tris.md2"); + VectorSet(self->mins, -16, -16, -24); + VectorSet(self->maxs, 16, 16, 32); self->movetype = MOVETYPE_STEP; self->solid = SOLID_BBOX; - self->s.sound = gi.soundindex ("flyer/flyidle1.wav"); + self->s.sound = gi.soundindex("flyer/flyidle1.wav"); self->health = 50; self->mass = 50; @@ -609,11 +866,11 @@ void SP_monster_flyer (edict_t *self) self->monsterinfo.sight = flyer_sight; self->monsterinfo.idle = flyer_idle; - gi.linkentity (self); + gi.linkentity(self); - self->monsterinfo.currentmove = &flyer_move_stand; + self->monsterinfo.currentmove = &flyer_move_stand; self->monsterinfo.scale = MODEL_SCALE; - flymonster_start (self); + flymonster_start(self); } diff --git a/src/game/baseq2/monster/flyer/flyer.h b/src/game/baseq2/monster/flyer/flyer.h index ebe08064..50c4f156 100644 --- a/src/game/baseq2/monster/flyer/flyer.h +++ b/src/game/baseq2/monster/flyer/flyer.h @@ -1,182 +1,185 @@ /* -Copyright (C) 1997-2001 Id Software, Inc. + * Copyright (C) 1997-2001 Id Software, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * ======================================================================= + * + * Flyer animations. + * + * ======================================================================= + */ -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. +#define ACTION_nothing 0 +#define ACTION_attack1 1 +#define ACTION_attack2 2 +#define ACTION_run 3 +#define ACTION_walk 4 -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +#define FRAME_start01 0 +#define FRAME_start02 1 +#define FRAME_start03 2 +#define FRAME_start04 3 +#define FRAME_start05 4 +#define FRAME_start06 5 +#define FRAME_stop01 6 +#define FRAME_stop02 7 +#define FRAME_stop03 8 +#define FRAME_stop04 9 +#define FRAME_stop05 10 +#define FRAME_stop06 11 +#define FRAME_stop07 12 +#define FRAME_stand01 13 +#define FRAME_stand02 14 +#define FRAME_stand03 15 +#define FRAME_stand04 16 +#define FRAME_stand05 17 +#define FRAME_stand06 18 +#define FRAME_stand07 19 +#define FRAME_stand08 20 +#define FRAME_stand09 21 +#define FRAME_stand10 22 +#define FRAME_stand11 23 +#define FRAME_stand12 24 +#define FRAME_stand13 25 +#define FRAME_stand14 26 +#define FRAME_stand15 27 +#define FRAME_stand16 28 +#define FRAME_stand17 29 +#define FRAME_stand18 30 +#define FRAME_stand19 31 +#define FRAME_stand20 32 +#define FRAME_stand21 33 +#define FRAME_stand22 34 +#define FRAME_stand23 35 +#define FRAME_stand24 36 +#define FRAME_stand25 37 +#define FRAME_stand26 38 +#define FRAME_stand27 39 +#define FRAME_stand28 40 +#define FRAME_stand29 41 +#define FRAME_stand30 42 +#define FRAME_stand31 43 +#define FRAME_stand32 44 +#define FRAME_stand33 45 +#define FRAME_stand34 46 +#define FRAME_stand35 47 +#define FRAME_stand36 48 +#define FRAME_stand37 49 +#define FRAME_stand38 50 +#define FRAME_stand39 51 +#define FRAME_stand40 52 +#define FRAME_stand41 53 +#define FRAME_stand42 54 +#define FRAME_stand43 55 +#define FRAME_stand44 56 +#define FRAME_stand45 57 +#define FRAME_attak101 58 +#define FRAME_attak102 59 +#define FRAME_attak103 60 +#define FRAME_attak104 61 +#define FRAME_attak105 62 +#define FRAME_attak106 63 +#define FRAME_attak107 64 +#define FRAME_attak108 65 +#define FRAME_attak109 66 +#define FRAME_attak110 67 +#define FRAME_attak111 68 +#define FRAME_attak112 69 +#define FRAME_attak113 70 +#define FRAME_attak114 71 +#define FRAME_attak115 72 +#define FRAME_attak116 73 +#define FRAME_attak117 74 +#define FRAME_attak118 75 +#define FRAME_attak119 76 +#define FRAME_attak120 77 +#define FRAME_attak121 78 +#define FRAME_attak201 79 +#define FRAME_attak202 80 +#define FRAME_attak203 81 +#define FRAME_attak204 82 +#define FRAME_attak205 83 +#define FRAME_attak206 84 +#define FRAME_attak207 85 +#define FRAME_attak208 86 +#define FRAME_attak209 87 +#define FRAME_attak210 88 +#define FRAME_attak211 89 +#define FRAME_attak212 90 +#define FRAME_attak213 91 +#define FRAME_attak214 92 +#define FRAME_attak215 93 +#define FRAME_attak216 94 +#define FRAME_attak217 95 +#define FRAME_bankl01 96 +#define FRAME_bankl02 97 +#define FRAME_bankl03 98 +#define FRAME_bankl04 99 +#define FRAME_bankl05 100 +#define FRAME_bankl06 101 +#define FRAME_bankl07 102 +#define FRAME_bankr01 103 +#define FRAME_bankr02 104 +#define FRAME_bankr03 105 +#define FRAME_bankr04 106 +#define FRAME_bankr05 107 +#define FRAME_bankr06 108 +#define FRAME_bankr07 109 +#define FRAME_rollf01 110 +#define FRAME_rollf02 111 +#define FRAME_rollf03 112 +#define FRAME_rollf04 113 +#define FRAME_rollf05 114 +#define FRAME_rollf06 115 +#define FRAME_rollf07 116 +#define FRAME_rollf08 117 +#define FRAME_rollf09 118 +#define FRAME_rollr01 119 +#define FRAME_rollr02 120 +#define FRAME_rollr03 121 +#define FRAME_rollr04 122 +#define FRAME_rollr05 123 +#define FRAME_rollr06 124 +#define FRAME_rollr07 125 +#define FRAME_rollr08 126 +#define FRAME_rollr09 127 +#define FRAME_defens01 128 +#define FRAME_defens02 129 +#define FRAME_defens03 130 +#define FRAME_defens04 131 +#define FRAME_defens05 132 +#define FRAME_defens06 133 +#define FRAME_pain101 134 +#define FRAME_pain102 135 +#define FRAME_pain103 136 +#define FRAME_pain104 137 +#define FRAME_pain105 138 +#define FRAME_pain106 139 +#define FRAME_pain107 140 +#define FRAME_pain108 141 +#define FRAME_pain109 142 +#define FRAME_pain201 143 +#define FRAME_pain202 144 +#define FRAME_pain203 145 +#define FRAME_pain204 146 +#define FRAME_pain301 147 +#define FRAME_pain302 148 +#define FRAME_pain303 149 +#define FRAME_pain304 150 -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ -// G:\quake2\baseq2\models/monsters/flyer - -// This file generated by ModelGen - Do NOT Modify - -#define ACTION_nothing 0 -#define ACTION_attack1 1 -#define ACTION_attack2 2 -#define ACTION_run 3 -#define ACTION_walk 4 - -#define FRAME_start01 0 -#define FRAME_start02 1 -#define FRAME_start03 2 -#define FRAME_start04 3 -#define FRAME_start05 4 -#define FRAME_start06 5 -#define FRAME_stop01 6 -#define FRAME_stop02 7 -#define FRAME_stop03 8 -#define FRAME_stop04 9 -#define FRAME_stop05 10 -#define FRAME_stop06 11 -#define FRAME_stop07 12 -#define FRAME_stand01 13 -#define FRAME_stand02 14 -#define FRAME_stand03 15 -#define FRAME_stand04 16 -#define FRAME_stand05 17 -#define FRAME_stand06 18 -#define FRAME_stand07 19 -#define FRAME_stand08 20 -#define FRAME_stand09 21 -#define FRAME_stand10 22 -#define FRAME_stand11 23 -#define FRAME_stand12 24 -#define FRAME_stand13 25 -#define FRAME_stand14 26 -#define FRAME_stand15 27 -#define FRAME_stand16 28 -#define FRAME_stand17 29 -#define FRAME_stand18 30 -#define FRAME_stand19 31 -#define FRAME_stand20 32 -#define FRAME_stand21 33 -#define FRAME_stand22 34 -#define FRAME_stand23 35 -#define FRAME_stand24 36 -#define FRAME_stand25 37 -#define FRAME_stand26 38 -#define FRAME_stand27 39 -#define FRAME_stand28 40 -#define FRAME_stand29 41 -#define FRAME_stand30 42 -#define FRAME_stand31 43 -#define FRAME_stand32 44 -#define FRAME_stand33 45 -#define FRAME_stand34 46 -#define FRAME_stand35 47 -#define FRAME_stand36 48 -#define FRAME_stand37 49 -#define FRAME_stand38 50 -#define FRAME_stand39 51 -#define FRAME_stand40 52 -#define FRAME_stand41 53 -#define FRAME_stand42 54 -#define FRAME_stand43 55 -#define FRAME_stand44 56 -#define FRAME_stand45 57 -#define FRAME_attak101 58 -#define FRAME_attak102 59 -#define FRAME_attak103 60 -#define FRAME_attak104 61 -#define FRAME_attak105 62 -#define FRAME_attak106 63 -#define FRAME_attak107 64 -#define FRAME_attak108 65 -#define FRAME_attak109 66 -#define FRAME_attak110 67 -#define FRAME_attak111 68 -#define FRAME_attak112 69 -#define FRAME_attak113 70 -#define FRAME_attak114 71 -#define FRAME_attak115 72 -#define FRAME_attak116 73 -#define FRAME_attak117 74 -#define FRAME_attak118 75 -#define FRAME_attak119 76 -#define FRAME_attak120 77 -#define FRAME_attak121 78 -#define FRAME_attak201 79 -#define FRAME_attak202 80 -#define FRAME_attak203 81 -#define FRAME_attak204 82 -#define FRAME_attak205 83 -#define FRAME_attak206 84 -#define FRAME_attak207 85 -#define FRAME_attak208 86 -#define FRAME_attak209 87 -#define FRAME_attak210 88 -#define FRAME_attak211 89 -#define FRAME_attak212 90 -#define FRAME_attak213 91 -#define FRAME_attak214 92 -#define FRAME_attak215 93 -#define FRAME_attak216 94 -#define FRAME_attak217 95 -#define FRAME_bankl01 96 -#define FRAME_bankl02 97 -#define FRAME_bankl03 98 -#define FRAME_bankl04 99 -#define FRAME_bankl05 100 -#define FRAME_bankl06 101 -#define FRAME_bankl07 102 -#define FRAME_bankr01 103 -#define FRAME_bankr02 104 -#define FRAME_bankr03 105 -#define FRAME_bankr04 106 -#define FRAME_bankr05 107 -#define FRAME_bankr06 108 -#define FRAME_bankr07 109 -#define FRAME_rollf01 110 -#define FRAME_rollf02 111 -#define FRAME_rollf03 112 -#define FRAME_rollf04 113 -#define FRAME_rollf05 114 -#define FRAME_rollf06 115 -#define FRAME_rollf07 116 -#define FRAME_rollf08 117 -#define FRAME_rollf09 118 -#define FRAME_rollr01 119 -#define FRAME_rollr02 120 -#define FRAME_rollr03 121 -#define FRAME_rollr04 122 -#define FRAME_rollr05 123 -#define FRAME_rollr06 124 -#define FRAME_rollr07 125 -#define FRAME_rollr08 126 -#define FRAME_rollr09 127 -#define FRAME_defens01 128 -#define FRAME_defens02 129 -#define FRAME_defens03 130 -#define FRAME_defens04 131 -#define FRAME_defens05 132 -#define FRAME_defens06 133 -#define FRAME_pain101 134 -#define FRAME_pain102 135 -#define FRAME_pain103 136 -#define FRAME_pain104 137 -#define FRAME_pain105 138 -#define FRAME_pain106 139 -#define FRAME_pain107 140 -#define FRAME_pain108 141 -#define FRAME_pain109 142 -#define FRAME_pain201 143 -#define FRAME_pain202 144 -#define FRAME_pain203 145 -#define FRAME_pain204 146 -#define FRAME_pain301 147 -#define FRAME_pain302 148 -#define FRAME_pain303 149 -#define FRAME_pain304 150 - -#define MODEL_SCALE 1.000000 +#define MODEL_SCALE 1.000000