diff --git a/src/game/baseq2/monster/gunner/gunner.c b/src/game/baseq2/monster/gunner/gunner.c index 5fc244af..8f42f717 100644 --- a/src/game/baseq2/monster/gunner/gunner.c +++ b/src/game/baseq2/monster/gunner/gunner.c @@ -1,70 +1,82 @@ /* -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. - -*/ -/* -============================================================================== - -GUNNER - -============================================================================== -*/ + * 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. + * + * ======================================================================= + * + * Gunner. + * + * ======================================================================= + */ #include "../../header/local.h" #include "gunner.h" +static int sound_pain; +static int sound_pain2; +static int sound_death; +static int sound_idle; +static int sound_open; +static int sound_search; +static int sound_sight; -static int sound_pain; -static int sound_pain2; -static int sound_death; -static int sound_idle; -static int sound_open; -static int sound_search; -static int sound_sight; - - -void gunner_idlesound (edict_t *self) -{ - gi.sound (self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0); +void +gunner_idlesound(edict_t *self) +{ + if (!self) + { + return; + } + + gi.sound(self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0); } -void gunner_sight (edict_t *self, edict_t *other) -{ - gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0); +void +gunner_sight(edict_t *self, edict_t *other /* unused */) +{ + if (!self) + { + return; + } + + gi.sound(self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0); } -void gunner_search (edict_t *self) -{ - gi.sound (self, CHAN_VOICE, sound_search, 1, ATTN_NORM, 0); +void +gunner_search(edict_t *self) +{ + if (!self) + { + return; + } + + gi.sound(self, CHAN_VOICE, sound_search, 1, ATTN_NORM, 0); } - -qboolean visible (edict_t *self, edict_t *other); -void GunnerGrenade (edict_t *self); -void GunnerFire (edict_t *self); +qboolean visible(edict_t *self, edict_t *other); +void GunnerGrenade(edict_t *self); +void GunnerFire(edict_t *self); void gunner_fire_chain(edict_t *self); void gunner_refire_chain(edict_t *self); +void gunner_stand(edict_t *self); -void gunner_stand (edict_t *self); - -mframe_t gunner_frames_fidget [] = -{ +mframe_t gunner_frames_fidget[] = { {ai_stand, 0, NULL}, {ai_stand, 0, NULL}, {ai_stand, 0, NULL}, @@ -119,18 +131,35 @@ mframe_t gunner_frames_fidget [] = {ai_stand, 0, NULL}, {ai_stand, 0, NULL} }; -mmove_t gunner_move_fidget = {FRAME_stand31, FRAME_stand70, gunner_frames_fidget, gunner_stand}; -void gunner_fidget (edict_t *self) +mmove_t gunner_move_fidget = { - if (self->monsterinfo.aiflags & AI_STAND_GROUND) + FRAME_stand31, + FRAME_stand70, + gunner_frames_fidget, + gunner_stand +}; + +void +gunner_fidget(edict_t *self) +{ + if (!self) + { return; + } + + if (self->monsterinfo.aiflags & AI_STAND_GROUND) + { + return; + } + if (random() <= 0.05) + { self->monsterinfo.currentmove = &gunner_move_fidget; + } } -mframe_t gunner_frames_stand [] = -{ +mframe_t gunner_frames_stand[] = { {ai_stand, 0, NULL}, {ai_stand, 0, NULL}, {ai_stand, 0, NULL}, @@ -164,16 +193,27 @@ mframe_t gunner_frames_stand [] = {ai_stand, 0, NULL}, {ai_stand, 0, gunner_fidget} }; -mmove_t gunner_move_stand = {FRAME_stand01, FRAME_stand30, gunner_frames_stand, NULL}; -void gunner_stand (edict_t *self) +mmove_t gunner_move_stand = { - self->monsterinfo.currentmove = &gunner_move_stand; + FRAME_stand01, + FRAME_stand30, + gunner_frames_stand, + NULL +}; + +void +gunner_stand(edict_t *self) +{ + if (!self) + { + return; + } + + self->monsterinfo.currentmove = &gunner_move_stand; } - -mframe_t gunner_frames_walk [] = -{ +mframe_t gunner_frames_walk[] = { {ai_walk, 0, NULL}, {ai_walk, 3, NULL}, {ai_walk, 4, NULL}, @@ -188,294 +228,476 @@ mframe_t gunner_frames_walk [] = {ai_walk, 7, NULL}, {ai_walk, 4, NULL} }; -mmove_t gunner_move_walk = {FRAME_walk07, FRAME_walk19, gunner_frames_walk, NULL}; -void gunner_walk (edict_t *self) +mmove_t gunner_move_walk = { + FRAME_walk07, + FRAME_walk19, + gunner_frames_walk, + NULL +}; + +void +gunner_walk(edict_t *self) +{ + if (!self) + { + return; + } + self->monsterinfo.currentmove = &gunner_move_walk; } -mframe_t gunner_frames_run [] = -{ +mframe_t gunner_frames_run[] = { {ai_run, 26, NULL}, - {ai_run, 9, NULL}, - {ai_run, 9, NULL}, - {ai_run, 9, NULL}, + {ai_run, 9, NULL}, + {ai_run, 9, NULL}, + {ai_run, 9, NULL}, {ai_run, 15, NULL}, {ai_run, 10, NULL}, {ai_run, 13, NULL}, - {ai_run, 6, NULL} + {ai_run, 6, NULL} }; -mmove_t gunner_move_run = {FRAME_run01, FRAME_run08, gunner_frames_run, NULL}; - -void gunner_run (edict_t *self) +mmove_t gunner_move_run = { + FRAME_run01, + FRAME_run08, + gunner_frames_run, + NULL +}; + +void +gunner_run(edict_t *self) +{ + if (!self) + { + return; + } + if (self->monsterinfo.aiflags & AI_STAND_GROUND) + { self->monsterinfo.currentmove = &gunner_move_stand; + } else + { self->monsterinfo.currentmove = &gunner_move_run; + } } -mframe_t gunner_frames_runandshoot [] = -{ +mframe_t gunner_frames_runandshoot[] = { {ai_run, 32, NULL}, {ai_run, 15, NULL}, {ai_run, 10, NULL}, {ai_run, 18, NULL}, - {ai_run, 8, NULL}, + {ai_run, 8, NULL}, {ai_run, 20, NULL} }; -mmove_t gunner_move_runandshoot = {FRAME_runs01, FRAME_runs06, gunner_frames_runandshoot, NULL}; - -void gunner_runandshoot (edict_t *self) +mmove_t gunner_move_runandshoot = { + FRAME_runs01, + FRAME_runs06, + gunner_frames_runandshoot, + NULL +}; + +void +gunner_runandshoot(edict_t *self) +{ + if (!self) + { + return; + } + self->monsterinfo.currentmove = &gunner_move_runandshoot; } -mframe_t gunner_frames_pain3 [] = -{ +mframe_t gunner_frames_pain3[] = { {ai_move, -3, NULL}, - {ai_move, 1, NULL}, - {ai_move, 1, NULL}, - {ai_move, 0, NULL}, - {ai_move, 1, NULL} + {ai_move, 1, NULL}, + {ai_move, 1, NULL}, + {ai_move, 0, NULL}, + {ai_move, 1, NULL} }; -mmove_t gunner_move_pain3 = {FRAME_pain301, FRAME_pain305, gunner_frames_pain3, gunner_run}; -mframe_t gunner_frames_pain2 [] = +mmove_t gunner_move_pain3 = { + FRAME_pain301, + FRAME_pain305, + gunner_frames_pain3, + gunner_run +}; + +mframe_t gunner_frames_pain2[] = { {ai_move, -2, NULL}, {ai_move, 11, NULL}, - {ai_move, 6, NULL}, - {ai_move, 2, NULL}, + {ai_move, 6, NULL}, + {ai_move, 2, NULL}, {ai_move, -1, NULL}, {ai_move, -7, NULL}, {ai_move, -2, NULL}, {ai_move, -7, NULL} }; -mmove_t gunner_move_pain2 = {FRAME_pain201, FRAME_pain208, gunner_frames_pain2, gunner_run}; -mframe_t gunner_frames_pain1 [] = +mmove_t gunner_move_pain2 = { - {ai_move, 2, NULL}, - {ai_move, 0, NULL}, - {ai_move, -5, NULL}, - {ai_move, 3, NULL}, - {ai_move, -1, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 1, NULL}, - {ai_move, 1, NULL}, - {ai_move, 2, NULL}, - {ai_move, 1, NULL}, - {ai_move, 0, NULL}, - {ai_move, -2, NULL}, - {ai_move, -2, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL} + FRAME_pain201, + FRAME_pain208, + gunner_frames_pain2, + gunner_run }; -mmove_t gunner_move_pain1 = {FRAME_pain101, FRAME_pain118, gunner_frames_pain1, gunner_run}; -void gunner_pain (edict_t *self, edict_t *other, float kick, int damage) +mframe_t gunner_frames_pain1[] = { + {ai_move, 2, NULL}, + {ai_move, 0, NULL}, + {ai_move, -5, NULL}, + {ai_move, 3, NULL}, + {ai_move, -1, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 1, NULL}, + {ai_move, 1, NULL}, + {ai_move, 2, NULL}, + {ai_move, 1, NULL}, + {ai_move, 0, NULL}, + {ai_move, -2, NULL}, + {ai_move, -2, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL} +}; + +mmove_t gunner_move_pain1 = { + FRAME_pain101, + FRAME_pain118, + gunner_frames_pain1, + gunner_run +}; + +void +gunner_pain(edict_t *self, edict_t *other /* unused */, + float kick /* unused */, int damage) +{ + 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 (rand()&1) - gi.sound (self, CHAN_VOICE, sound_pain, 1, ATTN_NORM, 0); + if (rand() & 1) + { + gi.sound(self, CHAN_VOICE, sound_pain, 1, ATTN_NORM, 0); + } else - gi.sound (self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0); + { + gi.sound(self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0); + } if (skill->value == 3) - return; // no pain anims in nightmare + { + return; /* no pain anims in nightmare */ + } if (damage <= 10) + { self->monsterinfo.currentmove = &gunner_move_pain3; + } else if (damage <= 25) + { self->monsterinfo.currentmove = &gunner_move_pain2; + } else + { self->monsterinfo.currentmove = &gunner_move_pain1; + } } -void gunner_dead (edict_t *self) -{ - VectorSet (self->mins, -16, -16, -24); - VectorSet (self->maxs, 16, 16, -8); +void +gunner_dead(edict_t *self) +{ + if (!self) + { + return; + } + + VectorSet(self->mins, -16, -16, -24); + VectorSet(self->maxs, 16, 16, -8); self->movetype = MOVETYPE_TOSS; self->svflags |= SVF_DEADMONSTER; self->nextthink = 0; - gi.linkentity (self); + gi.linkentity(self); } -mframe_t gunner_frames_death [] = -{ - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, -7, NULL}, - {ai_move, -3, NULL}, - {ai_move, -5, NULL}, - {ai_move, 8, NULL}, - {ai_move, 6, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL}, - {ai_move, 0, NULL} +mframe_t gunner_frames_death[] = { + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, -7, NULL}, + {ai_move, -3, NULL}, + {ai_move, -5, NULL}, + {ai_move, 8, NULL}, + {ai_move, 6, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL}, + {ai_move, 0, NULL} }; -mmove_t gunner_move_death = {FRAME_death01, FRAME_death11, gunner_frames_death, gunner_dead}; -void gunner_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point) +mmove_t gunner_move_death = { - int n; + FRAME_death01, + FRAME_death11, + gunner_frames_death, + gunner_dead +}; +void +gunner_die(edict_t *self, edict_t *inflictor /* unused */, + edict_t *attacker /* unused */, int damage /* unused */, + vec3_t point) +{ + int n; + + if (!self) + { + return; + } + self->s.skinnum |= 1; self->monsterinfo.power_armor_type = POWER_ARMOR_NONE; - // check for gib + /* check for gib */ if (self->health <= self->gib_health) { - gi.sound (self, CHAN_VOICE, gi.soundindex ("misc/udeath.wav"), 1, ATTN_NORM, 0); - for (n= 0; n < 2; n++) - ThrowGib (self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC); - for (n= 0; n < 4; n++) - ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC); - ThrowHead (self, "models/objects/gibs/head2/tris.md2", damage, GIB_ORGANIC); + gi.sound(self, CHAN_VOICE, gi.soundindex( "misc/udeath.wav"), 1, ATTN_NORM, 0); + + for (n = 0; n < 2; n++) + { + ThrowGib(self, "models/objects/gibs/bone/tris.md2", + damage, GIB_ORGANIC); + } + + for (n = 0; n < 4; n++) + { + ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", + damage, GIB_ORGANIC); + } + + ThrowHead(self, "models/objects/gibs/head2/tris.md2", + damage, GIB_ORGANIC); self->deadflag = DEAD_DEAD; return; } if (self->deadflag == DEAD_DEAD) + { return; + } - // regular death - gi.sound (self, CHAN_VOICE, sound_death, 1, ATTN_NORM, 0); + /* regular death */ + gi.sound(self, CHAN_VOICE, sound_death, 1, ATTN_NORM, 0); self->deadflag = DEAD_DEAD; self->takedamage = DAMAGE_YES; self->monsterinfo.currentmove = &gunner_move_death; } - -void gunner_duck_down (edict_t *self) -{ - if (self->monsterinfo.aiflags & AI_DUCKED) +void +gunner_duck_down(edict_t *self) +{ + if (!self) + { return; + } + + if (self->monsterinfo.aiflags & AI_DUCKED) + { + return; + } + self->monsterinfo.aiflags |= AI_DUCKED; + if (skill->value >= 2) { if (random() > 0.5) - GunnerGrenade (self); + { + GunnerGrenade(self); + } } self->maxs[2] -= 32; self->takedamage = DAMAGE_YES; self->monsterinfo.pausetime = level.time + 1; - gi.linkentity (self); + gi.linkentity(self); } -void gunner_duck_hold (edict_t *self) -{ +void +gunner_duck_hold(edict_t *self) +{ + if (!self) + { + return; + } + if (level.time >= self->monsterinfo.pausetime) + { self->monsterinfo.aiflags &= ~AI_HOLD_FRAME; + } else + { self->monsterinfo.aiflags |= AI_HOLD_FRAME; + } } -void gunner_duck_up (edict_t *self) -{ +void +gunner_duck_up(edict_t *self) +{ + if (!self) + { + return; + } + self->monsterinfo.aiflags &= ~AI_DUCKED; self->maxs[2] += 32; self->takedamage = DAMAGE_AIM; - gi.linkentity (self); + gi.linkentity(self); } -mframe_t gunner_frames_duck [] = -{ - {ai_move, 1, gunner_duck_down}, - {ai_move, 1, NULL}, - {ai_move, 1, gunner_duck_hold}, - {ai_move, 0, NULL}, +mframe_t gunner_frames_duck[] = { + {ai_move, 1, gunner_duck_down}, + {ai_move, 1, NULL}, + {ai_move, 1, gunner_duck_hold}, + {ai_move, 0, NULL}, {ai_move, -1, NULL}, {ai_move, -1, NULL}, - {ai_move, 0, gunner_duck_up}, + {ai_move, 0, gunner_duck_up}, {ai_move, -1, NULL} }; -mmove_t gunner_move_duck = {FRAME_duck01, FRAME_duck08, gunner_frames_duck, gunner_run}; -void gunner_dodge (edict_t *self, edict_t *attacker, float eta) +mmove_t gunner_move_duck = { - if (random() > 0.25) + FRAME_duck01, + FRAME_duck08, + gunner_frames_duck, + gunner_run +}; + +void +gunner_dodge(edict_t *self, edict_t *attacker, float eta /* unused */) +{ + if (!self || !attacker) + { return; + } + + if (random() > 0.25) + { + return; + } if (!self->enemy) + { self->enemy = attacker; + } self->monsterinfo.currentmove = &gunner_move_duck; } - -void gunner_opengun (edict_t *self) -{ - gi.sound (self, CHAN_VOICE, sound_open, 1, ATTN_IDLE, 0); +void +gunner_opengun(edict_t *self) +{ + if (!self) + { + return; + } + + gi.sound(self, CHAN_VOICE, sound_open, 1, ATTN_IDLE, 0); } -void GunnerFire (edict_t *self) +void +GunnerFire(edict_t *self) { - vec3_t start; - vec3_t forward, right; - vec3_t target; - vec3_t aim; - int flash_number; - + vec3_t start; + vec3_t forward, right; + vec3_t target; + vec3_t aim; + int flash_number; + + if (!self) + { + return; + } + flash_number = MZ2_GUNNER_MACHINEGUN_1 + (self->s.frame - FRAME_attak216); - AngleVectors (self->s.angles, forward, right, NULL); - G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start); + AngleVectors(self->s.angles, forward, right, NULL); + G_ProjectSource(self->s.origin, monster_flash_offset[flash_number], + forward, right, start); - // project enemy back a bit and target there - VectorCopy (self->enemy->s.origin, target); - VectorMA (target, -0.2, self->enemy->velocity, target); + /* project enemy back a bit and target there */ + VectorCopy(self->enemy->s.origin, target); + VectorMA(target, -0.2, self->enemy->velocity, target); target[2] += self->enemy->viewheight; - VectorSubtract (target, start, aim); - VectorNormalize (aim); - monster_fire_bullet (self, start, aim, 3, 4, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, flash_number); + VectorSubtract(target, start, aim); + VectorNormalize(aim); + monster_fire_bullet(self, start, aim, 3, 4, + DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, + flash_number); } -void GunnerGrenade (edict_t *self) +void +GunnerGrenade(edict_t *self) { - vec3_t start; - vec3_t forward, right; - vec3_t aim; - int flash_number; - + vec3_t start; + vec3_t forward, right; + vec3_t aim; + int flash_number; + + if (!self) + { + return; + } + if (self->s.frame == FRAME_attak105) + { flash_number = MZ2_GUNNER_GRENADE_1; + } else if (self->s.frame == FRAME_attak108) + { flash_number = MZ2_GUNNER_GRENADE_2; + } else if (self->s.frame == FRAME_attak111) + { flash_number = MZ2_GUNNER_GRENADE_3; - else + } + else + { flash_number = MZ2_GUNNER_GRENADE_4; + } - AngleVectors (self->s.angles, forward, right, NULL); - G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start); + AngleVectors(self->s.angles, forward, right, NULL); + G_ProjectSource(self->s.origin, monster_flash_offset[flash_number], + forward, right, start); - //FIXME : do a spread -225 -75 75 225 degrees around forward - VectorCopy (forward, aim); + VectorCopy(forward, aim); - monster_fire_grenade (self, start, aim, 50, 600, flash_number); + monster_fire_grenade(self, start, aim, 50, 600, flash_number); } -mframe_t gunner_frames_attack_chain [] = -{ +mframe_t gunner_frames_attack_chain[] = { {ai_charge, 0, gunner_opengun}, {ai_charge, 0, NULL}, {ai_charge, 0, NULL}, @@ -484,23 +706,35 @@ mframe_t gunner_frames_attack_chain [] = {ai_charge, 0, NULL}, {ai_charge, 0, NULL} }; -mmove_t gunner_move_attack_chain = {FRAME_attak209, FRAME_attak215, gunner_frames_attack_chain, gunner_fire_chain}; -mframe_t gunner_frames_fire_chain [] = +mmove_t gunner_move_attack_chain = { - {ai_charge, 0, GunnerFire}, - {ai_charge, 0, GunnerFire}, - {ai_charge, 0, GunnerFire}, - {ai_charge, 0, GunnerFire}, - {ai_charge, 0, GunnerFire}, - {ai_charge, 0, GunnerFire}, - {ai_charge, 0, GunnerFire}, - {ai_charge, 0, GunnerFire} + FRAME_attak209, + FRAME_attak215, + gunner_frames_attack_chain, + gunner_fire_chain }; -mmove_t gunner_move_fire_chain = {FRAME_attak216, FRAME_attak223, gunner_frames_fire_chain, gunner_refire_chain}; -mframe_t gunner_frames_endfire_chain [] = +mframe_t gunner_frames_fire_chain[] = { + {ai_charge, 0, GunnerFire}, + {ai_charge, 0, GunnerFire}, + {ai_charge, 0, GunnerFire}, + {ai_charge, 0, GunnerFire}, + {ai_charge, 0, GunnerFire}, + {ai_charge, 0, GunnerFire}, + {ai_charge, 0, GunnerFire}, + {ai_charge, 0, GunnerFire} +}; + +mmove_t gunner_move_fire_chain = { + FRAME_attak216, + FRAME_attak223, + gunner_frames_fire_chain, + gunner_refire_chain +}; + +mframe_t gunner_frames_endfire_chain[] = { {ai_charge, 0, NULL}, {ai_charge, 0, NULL}, {ai_charge, 0, NULL}, @@ -509,10 +743,16 @@ mframe_t gunner_frames_endfire_chain [] = {ai_charge, 0, NULL}, {ai_charge, 0, NULL} }; -mmove_t gunner_move_endfire_chain = {FRAME_attak224, FRAME_attak230, gunner_frames_endfire_chain, gunner_run}; -mframe_t gunner_frames_attack_grenade [] = +mmove_t gunner_move_endfire_chain = { + FRAME_attak224, + FRAME_attak230, + gunner_frames_endfire_chain, + gunner_run +}; + +mframe_t gunner_frames_attack_grenade[] = { {ai_charge, 0, NULL}, {ai_charge, 0, NULL}, {ai_charge, 0, NULL}, @@ -535,66 +775,107 @@ mframe_t gunner_frames_attack_grenade [] = {ai_charge, 0, NULL}, {ai_charge, 0, NULL} }; -mmove_t gunner_move_attack_grenade = {FRAME_attak101, FRAME_attak121, gunner_frames_attack_grenade, gunner_run}; -void gunner_attack(edict_t *self) +mmove_t gunner_move_attack_grenade = { - if (range (self, self->enemy) == RANGE_MELEE) + FRAME_attak101, + FRAME_attak121, + gunner_frames_attack_grenade, + gunner_run +}; + +void +gunner_attack(edict_t *self) +{ + if (!self) + { + return; + } + + if (range(self, self->enemy) == RANGE_MELEE) { self->monsterinfo.currentmove = &gunner_move_attack_chain; } else { if (random() <= 0.5) + { self->monsterinfo.currentmove = &gunner_move_attack_grenade; + } else + { self->monsterinfo.currentmove = &gunner_move_attack_chain; + } } } -void gunner_fire_chain(edict_t *self) -{ +void +gunner_fire_chain(edict_t *self) +{ + if (!self) + { + return; + } + self->monsterinfo.currentmove = &gunner_move_fire_chain; } -void gunner_refire_chain(edict_t *self) -{ +void +gunner_refire_chain(edict_t *self) +{ + if (!self) + { + return; + } + if (self->enemy->health > 0) - if ( visible (self, self->enemy) ) + { + if (visible(self, self->enemy)) + { if (random() <= 0.5) { self->monsterinfo.currentmove = &gunner_move_fire_chain; return; } + } + } + self->monsterinfo.currentmove = &gunner_move_endfire_chain; } -/*QUAKED monster_gunner (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight -*/ -void SP_monster_gunner (edict_t *self) -{ +/* + * QUAKED monster_gunner (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight + */ +void +SP_monster_gunner(edict_t *self) +{ + if (!self) + { + return; + } + if (deathmatch->value) { - G_FreeEdict (self); + G_FreeEdict(self); return; } - sound_death = gi.soundindex ("gunner/death1.wav"); - sound_pain = gi.soundindex ("gunner/gunpain2.wav"); - sound_pain2 = gi.soundindex ("gunner/gunpain1.wav"); - sound_idle = gi.soundindex ("gunner/gunidle1.wav"); - sound_open = gi.soundindex ("gunner/gunatck1.wav"); - sound_search = gi.soundindex ("gunner/gunsrch1.wav"); - sound_sight = gi.soundindex ("gunner/sight1.wav"); + sound_death = gi.soundindex("gunner/death1.wav"); + sound_pain = gi.soundindex("gunner/gunpain2.wav"); + sound_pain2 = gi.soundindex("gunner/gunpain1.wav"); + sound_idle = gi.soundindex("gunner/gunidle1.wav"); + sound_open = gi.soundindex("gunner/gunatck1.wav"); + sound_search = gi.soundindex("gunner/gunsrch1.wav"); + sound_sight = gi.soundindex("gunner/sight1.wav"); - gi.soundindex ("gunner/gunatck2.wav"); - gi.soundindex ("gunner/gunatck3.wav"); + gi.soundindex("gunner/gunatck2.wav"); + gi.soundindex("gunner/gunatck3.wav"); self->movetype = MOVETYPE_STEP; self->solid = SOLID_BBOX; - self->s.modelindex = gi.modelindex ("models/monsters/gunner/tris.md2"); - VectorSet (self->mins, -16, -16, -24); - VectorSet (self->maxs, 16, 16, 32); + self->s.modelindex = gi.modelindex("models/monsters/gunner/tris.md2"); + VectorSet(self->mins, -16, -16, -24); + VectorSet(self->maxs, 16, 16, 32); self->health = 175; self->gib_health = -70; @@ -612,11 +893,11 @@ void SP_monster_gunner (edict_t *self) self->monsterinfo.sight = gunner_sight; self->monsterinfo.search = gunner_search; - gi.linkentity (self); + gi.linkentity(self); - self->monsterinfo.currentmove = &gunner_move_stand; + self->monsterinfo.currentmove = &gunner_move_stand; self->monsterinfo.scale = MODEL_SCALE; - walkmonster_start (self); + walkmonster_start(self); } diff --git a/src/game/baseq2/monster/gunner/gunner.h b/src/game/baseq2/monster/gunner/gunner.h index 718832c1..a8b7556a 100644 --- a/src/game/baseq2/monster/gunner/gunner.h +++ b/src/game/baseq2/monster/gunner/gunner.h @@ -1,234 +1,237 @@ /* -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. + * + * ======================================================================= + * + * Gunner 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 FRAME_stand01 0 +#define FRAME_stand02 1 +#define FRAME_stand03 2 +#define FRAME_stand04 3 +#define FRAME_stand05 4 +#define FRAME_stand06 5 +#define FRAME_stand07 6 +#define FRAME_stand08 7 +#define FRAME_stand09 8 +#define FRAME_stand10 9 +#define FRAME_stand11 10 +#define FRAME_stand12 11 +#define FRAME_stand13 12 +#define FRAME_stand14 13 +#define FRAME_stand15 14 +#define FRAME_stand16 15 +#define FRAME_stand17 16 +#define FRAME_stand18 17 +#define FRAME_stand19 18 +#define FRAME_stand20 19 +#define FRAME_stand21 20 +#define FRAME_stand22 21 +#define FRAME_stand23 22 +#define FRAME_stand24 23 +#define FRAME_stand25 24 +#define FRAME_stand26 25 +#define FRAME_stand27 26 +#define FRAME_stand28 27 +#define FRAME_stand29 28 +#define FRAME_stand30 29 +#define FRAME_stand31 30 +#define FRAME_stand32 31 +#define FRAME_stand33 32 +#define FRAME_stand34 33 +#define FRAME_stand35 34 +#define FRAME_stand36 35 +#define FRAME_stand37 36 +#define FRAME_stand38 37 +#define FRAME_stand39 38 +#define FRAME_stand40 39 +#define FRAME_stand41 40 +#define FRAME_stand42 41 +#define FRAME_stand43 42 +#define FRAME_stand44 43 +#define FRAME_stand45 44 +#define FRAME_stand46 45 +#define FRAME_stand47 46 +#define FRAME_stand48 47 +#define FRAME_stand49 48 +#define FRAME_stand50 49 +#define FRAME_stand51 50 +#define FRAME_stand52 51 +#define FRAME_stand53 52 +#define FRAME_stand54 53 +#define FRAME_stand55 54 +#define FRAME_stand56 55 +#define FRAME_stand57 56 +#define FRAME_stand58 57 +#define FRAME_stand59 58 +#define FRAME_stand60 59 +#define FRAME_stand61 60 +#define FRAME_stand62 61 +#define FRAME_stand63 62 +#define FRAME_stand64 63 +#define FRAME_stand65 64 +#define FRAME_stand66 65 +#define FRAME_stand67 66 +#define FRAME_stand68 67 +#define FRAME_stand69 68 +#define FRAME_stand70 69 +#define FRAME_walk01 70 +#define FRAME_walk02 71 +#define FRAME_walk03 72 +#define FRAME_walk04 73 +#define FRAME_walk05 74 +#define FRAME_walk06 75 +#define FRAME_walk07 76 +#define FRAME_walk08 77 +#define FRAME_walk09 78 +#define FRAME_walk10 79 +#define FRAME_walk11 80 +#define FRAME_walk12 81 +#define FRAME_walk13 82 +#define FRAME_walk14 83 +#define FRAME_walk15 84 +#define FRAME_walk16 85 +#define FRAME_walk17 86 +#define FRAME_walk18 87 +#define FRAME_walk19 88 +#define FRAME_walk20 89 +#define FRAME_walk21 90 +#define FRAME_walk22 91 +#define FRAME_walk23 92 +#define FRAME_walk24 93 +#define FRAME_run01 94 +#define FRAME_run02 95 +#define FRAME_run03 96 +#define FRAME_run04 97 +#define FRAME_run05 98 +#define FRAME_run06 99 +#define FRAME_run07 100 +#define FRAME_run08 101 +#define FRAME_runs01 102 +#define FRAME_runs02 103 +#define FRAME_runs03 104 +#define FRAME_runs04 105 +#define FRAME_runs05 106 +#define FRAME_runs06 107 +#define FRAME_attak101 108 +#define FRAME_attak102 109 +#define FRAME_attak103 110 +#define FRAME_attak104 111 +#define FRAME_attak105 112 +#define FRAME_attak106 113 +#define FRAME_attak107 114 +#define FRAME_attak108 115 +#define FRAME_attak109 116 +#define FRAME_attak110 117 +#define FRAME_attak111 118 +#define FRAME_attak112 119 +#define FRAME_attak113 120 +#define FRAME_attak114 121 +#define FRAME_attak115 122 +#define FRAME_attak116 123 +#define FRAME_attak117 124 +#define FRAME_attak118 125 +#define FRAME_attak119 126 +#define FRAME_attak120 127 +#define FRAME_attak121 128 +#define FRAME_attak201 129 +#define FRAME_attak202 130 +#define FRAME_attak203 131 +#define FRAME_attak204 132 +#define FRAME_attak205 133 +#define FRAME_attak206 134 +#define FRAME_attak207 135 +#define FRAME_attak208 136 +#define FRAME_attak209 137 +#define FRAME_attak210 138 +#define FRAME_attak211 139 +#define FRAME_attak212 140 +#define FRAME_attak213 141 +#define FRAME_attak214 142 +#define FRAME_attak215 143 +#define FRAME_attak216 144 +#define FRAME_attak217 145 +#define FRAME_attak218 146 +#define FRAME_attak219 147 +#define FRAME_attak220 148 +#define FRAME_attak221 149 +#define FRAME_attak222 150 +#define FRAME_attak223 151 +#define FRAME_attak224 152 +#define FRAME_attak225 153 +#define FRAME_attak226 154 +#define FRAME_attak227 155 +#define FRAME_attak228 156 +#define FRAME_attak229 157 +#define FRAME_attak230 158 +#define FRAME_pain101 159 +#define FRAME_pain102 160 +#define FRAME_pain103 161 +#define FRAME_pain104 162 +#define FRAME_pain105 163 +#define FRAME_pain106 164 +#define FRAME_pain107 165 +#define FRAME_pain108 166 +#define FRAME_pain109 167 +#define FRAME_pain110 168 +#define FRAME_pain111 169 +#define FRAME_pain112 170 +#define FRAME_pain113 171 +#define FRAME_pain114 172 +#define FRAME_pain115 173 +#define FRAME_pain116 174 +#define FRAME_pain117 175 +#define FRAME_pain118 176 +#define FRAME_pain201 177 +#define FRAME_pain202 178 +#define FRAME_pain203 179 +#define FRAME_pain204 180 +#define FRAME_pain205 181 +#define FRAME_pain206 182 +#define FRAME_pain207 183 +#define FRAME_pain208 184 +#define FRAME_pain301 185 +#define FRAME_pain302 186 +#define FRAME_pain303 187 +#define FRAME_pain304 188 +#define FRAME_pain305 189 +#define FRAME_death01 190 +#define FRAME_death02 191 +#define FRAME_death03 192 +#define FRAME_death04 193 +#define FRAME_death05 194 +#define FRAME_death06 195 +#define FRAME_death07 196 +#define FRAME_death08 197 +#define FRAME_death09 198 +#define FRAME_death10 199 +#define FRAME_death11 200 +#define FRAME_duck01 201 +#define FRAME_duck02 202 +#define FRAME_duck03 203 +#define FRAME_duck04 204 +#define FRAME_duck05 205 +#define FRAME_duck06 206 +#define FRAME_duck07 207 +#define FRAME_duck08 208 -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. - -*/ -// G:\quake2\baseq2\models/gunner - -// This file generated by ModelGen - Do NOT Modify - -#define FRAME_stand01 0 -#define FRAME_stand02 1 -#define FRAME_stand03 2 -#define FRAME_stand04 3 -#define FRAME_stand05 4 -#define FRAME_stand06 5 -#define FRAME_stand07 6 -#define FRAME_stand08 7 -#define FRAME_stand09 8 -#define FRAME_stand10 9 -#define FRAME_stand11 10 -#define FRAME_stand12 11 -#define FRAME_stand13 12 -#define FRAME_stand14 13 -#define FRAME_stand15 14 -#define FRAME_stand16 15 -#define FRAME_stand17 16 -#define FRAME_stand18 17 -#define FRAME_stand19 18 -#define FRAME_stand20 19 -#define FRAME_stand21 20 -#define FRAME_stand22 21 -#define FRAME_stand23 22 -#define FRAME_stand24 23 -#define FRAME_stand25 24 -#define FRAME_stand26 25 -#define FRAME_stand27 26 -#define FRAME_stand28 27 -#define FRAME_stand29 28 -#define FRAME_stand30 29 -#define FRAME_stand31 30 -#define FRAME_stand32 31 -#define FRAME_stand33 32 -#define FRAME_stand34 33 -#define FRAME_stand35 34 -#define FRAME_stand36 35 -#define FRAME_stand37 36 -#define FRAME_stand38 37 -#define FRAME_stand39 38 -#define FRAME_stand40 39 -#define FRAME_stand41 40 -#define FRAME_stand42 41 -#define FRAME_stand43 42 -#define FRAME_stand44 43 -#define FRAME_stand45 44 -#define FRAME_stand46 45 -#define FRAME_stand47 46 -#define FRAME_stand48 47 -#define FRAME_stand49 48 -#define FRAME_stand50 49 -#define FRAME_stand51 50 -#define FRAME_stand52 51 -#define FRAME_stand53 52 -#define FRAME_stand54 53 -#define FRAME_stand55 54 -#define FRAME_stand56 55 -#define FRAME_stand57 56 -#define FRAME_stand58 57 -#define FRAME_stand59 58 -#define FRAME_stand60 59 -#define FRAME_stand61 60 -#define FRAME_stand62 61 -#define FRAME_stand63 62 -#define FRAME_stand64 63 -#define FRAME_stand65 64 -#define FRAME_stand66 65 -#define FRAME_stand67 66 -#define FRAME_stand68 67 -#define FRAME_stand69 68 -#define FRAME_stand70 69 -#define FRAME_walk01 70 -#define FRAME_walk02 71 -#define FRAME_walk03 72 -#define FRAME_walk04 73 -#define FRAME_walk05 74 -#define FRAME_walk06 75 -#define FRAME_walk07 76 -#define FRAME_walk08 77 -#define FRAME_walk09 78 -#define FRAME_walk10 79 -#define FRAME_walk11 80 -#define FRAME_walk12 81 -#define FRAME_walk13 82 -#define FRAME_walk14 83 -#define FRAME_walk15 84 -#define FRAME_walk16 85 -#define FRAME_walk17 86 -#define FRAME_walk18 87 -#define FRAME_walk19 88 -#define FRAME_walk20 89 -#define FRAME_walk21 90 -#define FRAME_walk22 91 -#define FRAME_walk23 92 -#define FRAME_walk24 93 -#define FRAME_run01 94 -#define FRAME_run02 95 -#define FRAME_run03 96 -#define FRAME_run04 97 -#define FRAME_run05 98 -#define FRAME_run06 99 -#define FRAME_run07 100 -#define FRAME_run08 101 -#define FRAME_runs01 102 -#define FRAME_runs02 103 -#define FRAME_runs03 104 -#define FRAME_runs04 105 -#define FRAME_runs05 106 -#define FRAME_runs06 107 -#define FRAME_attak101 108 -#define FRAME_attak102 109 -#define FRAME_attak103 110 -#define FRAME_attak104 111 -#define FRAME_attak105 112 -#define FRAME_attak106 113 -#define FRAME_attak107 114 -#define FRAME_attak108 115 -#define FRAME_attak109 116 -#define FRAME_attak110 117 -#define FRAME_attak111 118 -#define FRAME_attak112 119 -#define FRAME_attak113 120 -#define FRAME_attak114 121 -#define FRAME_attak115 122 -#define FRAME_attak116 123 -#define FRAME_attak117 124 -#define FRAME_attak118 125 -#define FRAME_attak119 126 -#define FRAME_attak120 127 -#define FRAME_attak121 128 -#define FRAME_attak201 129 -#define FRAME_attak202 130 -#define FRAME_attak203 131 -#define FRAME_attak204 132 -#define FRAME_attak205 133 -#define FRAME_attak206 134 -#define FRAME_attak207 135 -#define FRAME_attak208 136 -#define FRAME_attak209 137 -#define FRAME_attak210 138 -#define FRAME_attak211 139 -#define FRAME_attak212 140 -#define FRAME_attak213 141 -#define FRAME_attak214 142 -#define FRAME_attak215 143 -#define FRAME_attak216 144 -#define FRAME_attak217 145 -#define FRAME_attak218 146 -#define FRAME_attak219 147 -#define FRAME_attak220 148 -#define FRAME_attak221 149 -#define FRAME_attak222 150 -#define FRAME_attak223 151 -#define FRAME_attak224 152 -#define FRAME_attak225 153 -#define FRAME_attak226 154 -#define FRAME_attak227 155 -#define FRAME_attak228 156 -#define FRAME_attak229 157 -#define FRAME_attak230 158 -#define FRAME_pain101 159 -#define FRAME_pain102 160 -#define FRAME_pain103 161 -#define FRAME_pain104 162 -#define FRAME_pain105 163 -#define FRAME_pain106 164 -#define FRAME_pain107 165 -#define FRAME_pain108 166 -#define FRAME_pain109 167 -#define FRAME_pain110 168 -#define FRAME_pain111 169 -#define FRAME_pain112 170 -#define FRAME_pain113 171 -#define FRAME_pain114 172 -#define FRAME_pain115 173 -#define FRAME_pain116 174 -#define FRAME_pain117 175 -#define FRAME_pain118 176 -#define FRAME_pain201 177 -#define FRAME_pain202 178 -#define FRAME_pain203 179 -#define FRAME_pain204 180 -#define FRAME_pain205 181 -#define FRAME_pain206 182 -#define FRAME_pain207 183 -#define FRAME_pain208 184 -#define FRAME_pain301 185 -#define FRAME_pain302 186 -#define FRAME_pain303 187 -#define FRAME_pain304 188 -#define FRAME_pain305 189 -#define FRAME_death01 190 -#define FRAME_death02 191 -#define FRAME_death03 192 -#define FRAME_death04 193 -#define FRAME_death05 194 -#define FRAME_death06 195 -#define FRAME_death07 196 -#define FRAME_death08 197 -#define FRAME_death09 198 -#define FRAME_death10 199 -#define FRAME_death11 200 -#define FRAME_duck01 201 -#define FRAME_duck02 202 -#define FRAME_duck03 203 -#define FRAME_duck04 204 -#define FRAME_duck05 205 -#define FRAME_duck06 206 -#define FRAME_duck07 207 -#define FRAME_duck08 208 - -#define MODEL_SCALE 1.150000 +#define MODEL_SCALE 1.150000