Cleanup infantry and add sanity checks

This commit is contained in:
Yamagi Burmeister 2014-02-05 19:43:26 +01:00
parent cc4c996cd5
commit b123f6870d
2 changed files with 600 additions and 437 deletions

View file

@ -1,9 +1,8 @@
/* /* =======================================================================
============================================================================== *
* Infantry.
INFANTRY *
* =======================================================================
==============================================================================
*/ */
#include "../../header/local.h" #include "../../header/local.h"
@ -11,7 +10,6 @@ INFANTRY
void InfantryMachineGun(edict_t *self); void InfantryMachineGun(edict_t *self);
static int sound_pain1; static int sound_pain1;
static int sound_pain2; static int sound_pain2;
static int sound_die1; static int sound_die1;
@ -25,8 +23,7 @@ static int sound_sight;
static int sound_search; static int sound_search;
static int sound_idle; static int sound_idle;
mframe_t infantry_frames_stand [] = mframe_t infantry_frames_stand[] = {
{
{ai_stand, 0, NULL}, {ai_stand, 0, NULL},
{ai_stand, 0, NULL}, {ai_stand, 0, NULL},
{ai_stand, 0, NULL}, {ai_stand, 0, NULL},
@ -50,16 +47,26 @@ mframe_t infantry_frames_stand [] =
{ai_stand, 0, NULL}, {ai_stand, 0, NULL},
{ai_stand, 0, NULL} {ai_stand, 0, NULL}
}; };
mmove_t infantry_move_stand = {FRAME_stand50, FRAME_stand71, infantry_frames_stand, NULL};
void infantry_stand (edict_t *self) mmove_t infantry_move_stand = {
FRAME_stand50,
FRAME_stand71,
infantry_frames_stand,
NULL
};
void
infantry_stand(edict_t *self)
{ {
if (!self)
{
return;
}
self->monsterinfo.currentmove = &infantry_move_stand; self->monsterinfo.currentmove = &infantry_move_stand;
} }
mframe_t infantry_frames_fidget[] = {
mframe_t infantry_frames_fidget [] =
{
{ai_stand, 1, NULL}, {ai_stand, 1, NULL},
{ai_stand, 0, NULL}, {ai_stand, 0, NULL},
{ai_stand, 1, NULL}, {ai_stand, 1, NULL},
@ -110,16 +117,27 @@ mframe_t infantry_frames_fidget [] =
{ai_stand, -3, NULL}, {ai_stand, -3, NULL},
{ai_stand, -2, NULL} {ai_stand, -2, NULL}
}; };
mmove_t infantry_move_fidget = {FRAME_stand01, FRAME_stand49, infantry_frames_fidget, infantry_stand};
void infantry_fidget (edict_t *self) mmove_t infantry_move_fidget = {
FRAME_stand01,
FRAME_stand49,
infantry_frames_fidget,
infantry_stand
};
void
infantry_fidget(edict_t *self)
{ {
if (!self)
{
return;
}
self->monsterinfo.currentmove = &infantry_move_fidget; self->monsterinfo.currentmove = &infantry_move_fidget;
gi.sound(self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0); gi.sound(self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0);
} }
mframe_t infantry_frames_walk [] = mframe_t infantry_frames_walk[] = {
{
{ai_walk, 5, NULL}, {ai_walk, 5, NULL},
{ai_walk, 4, NULL}, {ai_walk, 4, NULL},
{ai_walk, 4, NULL}, {ai_walk, 4, NULL},
@ -133,15 +151,26 @@ mframe_t infantry_frames_walk [] =
{ai_walk, 4, NULL}, {ai_walk, 4, NULL},
{ai_walk, 5, NULL} {ai_walk, 5, NULL}
}; };
mmove_t infantry_move_walk = {FRAME_walk03, FRAME_walk14, infantry_frames_walk, NULL};
void infantry_walk (edict_t *self) mmove_t infantry_move_walk = {
FRAME_walk03,
FRAME_walk14,
infantry_frames_walk,
NULL
};
void
infantry_walk(edict_t *self)
{ {
if (!self)
{
return;
}
self->monsterinfo.currentmove = &infantry_move_walk; self->monsterinfo.currentmove = &infantry_move_walk;
} }
mframe_t infantry_frames_run [] = mframe_t infantry_frames_run[] = {
{
{ai_run, 10, NULL}, {ai_run, 10, NULL},
{ai_run, 20, NULL}, {ai_run, 20, NULL},
{ai_run, 5, NULL}, {ai_run, 5, NULL},
@ -151,21 +180,35 @@ mframe_t infantry_frames_run [] =
{ai_run, 2, NULL}, {ai_run, 2, NULL},
{ai_run, 6, NULL} {ai_run, 6, NULL}
}; };
mmove_t infantry_move_run = {FRAME_run01, FRAME_run08, infantry_frames_run, NULL};
void infantry_run (edict_t *self) mmove_t infantry_move_run = {
FRAME_run01,
FRAME_run08,
infantry_frames_run,
NULL
};
void
infantry_run(edict_t *self)
{ {
if (!self)
{
return;
}
monster_done_dodge(self); monster_done_dodge(self);
if (self->monsterinfo.aiflags & AI_STAND_GROUND) if (self->monsterinfo.aiflags & AI_STAND_GROUND)
{
self->monsterinfo.currentmove = &infantry_move_stand; self->monsterinfo.currentmove = &infantry_move_stand;
}
else else
{
self->monsterinfo.currentmove = &infantry_move_run; self->monsterinfo.currentmove = &infantry_move_run;
} }
}
mframe_t infantry_frames_pain1[] = {
mframe_t infantry_frames_pain1 [] =
{
{ai_move, -3, NULL}, {ai_move, -3, NULL},
{ai_move, -2, NULL}, {ai_move, -2, NULL},
{ai_move, -1, NULL}, {ai_move, -1, NULL},
@ -177,10 +220,15 @@ mframe_t infantry_frames_pain1 [] =
{ai_move, 6, NULL}, {ai_move, 6, NULL},
{ai_move, 2, NULL} {ai_move, 2, NULL}
}; };
mmove_t infantry_move_pain1 = {FRAME_pain101, FRAME_pain110, infantry_frames_pain1, infantry_run};
mframe_t infantry_frames_pain2 [] = mmove_t infantry_move_pain1 = {
{ FRAME_pain101,
FRAME_pain110,
infantry_frames_pain1,
infantry_run
};
mframe_t infantry_frames_pain2[] = {
{ai_move, -3, NULL}, {ai_move, -3, NULL},
{ai_move, -3, NULL}, {ai_move, -3, NULL},
{ai_move, 0, NULL}, {ai_move, 0, NULL},
@ -192,33 +240,50 @@ mframe_t infantry_frames_pain2 [] =
{ai_move, 5, NULL}, {ai_move, 5, NULL},
{ai_move, 2, NULL} {ai_move, 2, NULL}
}; };
mmove_t infantry_move_pain2 = {FRAME_pain201, FRAME_pain210, infantry_frames_pain2, infantry_run};
void infantry_pain (edict_t *self, edict_t *other, float kick, int damage) mmove_t infantry_move_pain2 = {
FRAME_pain201,
FRAME_pain210,
infantry_frames_pain2,
infantry_run
};
void
infantry_pain(edict_t *self, edict_t *other /* unused */, float kick, int damage)
{ {
int n; int n;
if (!self)
{
return;
}
if (self->health < (self->max_health / 2)) if (self->health < (self->max_health / 2))
{
self->s.skinnum = 1; self->s.skinnum = 1;
}
if (!self->groundentity) if (!self->groundentity)
{ {
// if ((g_showlogic) && (g_showlogic->value))
// gi.dprintf ("infantry: pain avoided due to no ground\n");
return; return;
} }
monster_done_dodge(self); monster_done_dodge(self);
if (level.time < self->pain_debounce_time) if (level.time < self->pain_debounce_time)
{
return; return;
}
self->pain_debounce_time = level.time + 3; self->pain_debounce_time = level.time + 3;
if (skill->value == 3) if (skill->value == 3)
return; // no pain anims in nightmare {
return; /* no pain anims in nightmare */
}
n = rand() % 2; n = rand() % 2;
if (n == 0) if (n == 0)
{ {
self->monsterinfo.currentmove = &infantry_move_pain1; self->monsterinfo.currentmove = &infantry_move_pain1;
@ -230,14 +295,14 @@ void infantry_pain (edict_t *self, edict_t *other, float kick, int damage)
gi.sound(self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0); gi.sound(self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0);
} }
// PMM - clear duck flag /* clear duck flag */
if (self->monsterinfo.aiflags & AI_DUCKED) if (self->monsterinfo.aiflags & AI_DUCKED)
{
monster_duck_up(self); monster_duck_up(self);
} }
}
vec3_t aimangles[] = {
vec3_t aimangles[] =
{
{0.0, 5.0, 0.0}, {0.0, 5.0, 0.0},
{10.0, 15.0, 0.0}, {10.0, 15.0, 0.0},
{20.0, 25.0, 0.0}, {20.0, 25.0, 0.0},
@ -252,22 +317,31 @@ vec3_t aimangles[] =
{90.0, 35.0, 0.0} {90.0, 35.0, 0.0}
}; };
void InfantryMachineGun (edict_t *self) void
InfantryMachineGun(edict_t *self)
{ {
vec3_t start, target; vec3_t start, target;
vec3_t forward, right; vec3_t forward, right;
vec3_t vec; vec3_t vec;
int flash_number; int flash_number;
if(!self->enemy || !self->enemy->inuse) //PGM if (!self)
return; //PGM {
return;
}
// pmm - new attack start frame if (!self->enemy || !self->enemy->inuse)
{
return;
}
/* new attack start frame */
if (self->s.frame == FRAME_attak104) if (self->s.frame == FRAME_attak104)
{ {
flash_number = MZ2_INFANTRY_MACHINEGUN_1; flash_number = MZ2_INFANTRY_MACHINEGUN_1;
AngleVectors(self->s.angles, forward, right, NULL); AngleVectors(self->s.angles, forward, right, NULL);
G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start); G_ProjectSource(self->s.origin, monster_flash_offset[flash_number],
forward, right, start);
if (self->enemy) if (self->enemy)
{ {
@ -286,22 +360,36 @@ void InfantryMachineGun (edict_t *self)
flash_number = MZ2_INFANTRY_MACHINEGUN_2 + (self->s.frame - FRAME_death211); flash_number = MZ2_INFANTRY_MACHINEGUN_2 + (self->s.frame - FRAME_death211);
AngleVectors(self->s.angles, forward, right, NULL); AngleVectors(self->s.angles, forward, right, NULL);
G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start); G_ProjectSource(self->s.origin, monster_flash_offset[flash_number],
forward, right, start);
VectorSubtract(self->s.angles, aimangles[flash_number - MZ2_INFANTRY_MACHINEGUN_2], vec); VectorSubtract(self->s.angles, aimangles[flash_number - MZ2_INFANTRY_MACHINEGUN_2], vec);
AngleVectors(vec, forward, NULL, NULL); AngleVectors(vec, forward, NULL, NULL);
} }
monster_fire_bullet (self, start, forward, 3, 4, DEFAULT_BULLET_HSPREAD, DEFAULT_BULLET_VSPREAD, flash_number); monster_fire_bullet(self, start, forward, 3, 4, DEFAULT_BULLET_HSPREAD,
DEFAULT_BULLET_VSPREAD, flash_number);
} }
void infantry_sight (edict_t *self, edict_t *other) void
infantry_sight(edict_t *self, edict_t *other /* unused */)
{ {
if (!self)
{
return;
}
gi.sound(self, CHAN_BODY, sound_sight, 1, ATTN_NORM, 0); gi.sound(self, CHAN_BODY, sound_sight, 1, ATTN_NORM, 0);
} }
void infantry_dead (edict_t *self) void
infantry_dead(edict_t *self)
{ {
if (!self)
{
return;
}
VectorSet(self->mins, -16, -16, -24); VectorSet(self->mins, -16, -16, -24);
VectorSet(self->maxs, 16, 16, -8); VectorSet(self->maxs, 16, 16, -8);
self->movetype = MOVETYPE_TOSS; self->movetype = MOVETYPE_TOSS;
@ -311,8 +399,7 @@ void infantry_dead (edict_t *self)
M_FlyCheck(self); M_FlyCheck(self);
} }
mframe_t infantry_frames_death1 [] = mframe_t infantry_frames_death1[] = {
{
{ai_move, -4, NULL}, {ai_move, -4, NULL},
{ai_move, 0, NULL}, {ai_move, 0, NULL},
{ai_move, 0, NULL}, {ai_move, 0, NULL},
@ -334,11 +421,16 @@ mframe_t infantry_frames_death1 [] =
{ai_move, -3, NULL}, {ai_move, -3, NULL},
{ai_move, -3, NULL} {ai_move, -3, NULL}
}; };
mmove_t infantry_move_death1 = {FRAME_death101, FRAME_death120, infantry_frames_death1, infantry_dead};
// Off with his head mmove_t infantry_move_death1 = {
mframe_t infantry_frames_death2 [] = FRAME_death101,
{ FRAME_death120,
infantry_frames_death1,
infantry_dead
};
/* Off with his head */
mframe_t infantry_frames_death2[] = {
{ai_move, 0, NULL}, {ai_move, 0, NULL},
{ai_move, 1, NULL}, {ai_move, 1, NULL},
{ai_move, 5, NULL}, {ai_move, 5, NULL},
@ -365,10 +457,15 @@ mframe_t infantry_frames_death2 [] =
{ai_move, 4, NULL}, {ai_move, 4, NULL},
{ai_move, 0, NULL} {ai_move, 0, NULL}
}; };
mmove_t infantry_move_death2 = {FRAME_death201, FRAME_death225, infantry_frames_death2, infantry_dead};
mframe_t infantry_frames_death3 [] = mmove_t infantry_move_death2 = {
{ FRAME_death201,
FRAME_death225,
infantry_frames_death2,
infantry_dead
};
mframe_t infantry_frames_death3[] = {
{ai_move, 0, NULL}, {ai_move, 0, NULL},
{ai_move, 0, NULL}, {ai_move, 0, NULL},
{ai_move, 0, NULL}, {ai_move, 0, NULL},
@ -379,34 +476,56 @@ mframe_t infantry_frames_death3 [] =
{ai_move, 0, NULL}, {ai_move, 0, NULL},
{ai_move, 0, NULL} {ai_move, 0, NULL}
}; };
mmove_t infantry_move_death3 = {FRAME_death301, FRAME_death309, infantry_frames_death3, infantry_dead};
mmove_t infantry_move_death3 = {
FRAME_death301,
FRAME_death309,
infantry_frames_death3,
infantry_dead
};
void infantry_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point) void
infantry_die(edict_t *self, edict_t *inflictor /* unused */, edict_t *attacker /* unused */,
int damage, vec3_t point /* unused */)
{ {
int n; int n;
// check for gib if (!self)
{
return;
}
/* check for gib */
if (self->health <= self->gib_health) if (self->health <= self->gib_health)
{ {
gi.sound(self, CHAN_VOICE, gi.soundindex("misc/udeath.wav"), 1, ATTN_NORM, 0); gi.sound(self, CHAN_VOICE, gi.soundindex("misc/udeath.wav"), 1, ATTN_NORM, 0);
for (n = 0; n < 2; n++) for (n = 0; n < 2; n++)
{
ThrowGib(self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC); ThrowGib(self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC);
}
for (n = 0; n < 4; n++) for (n = 0; n < 4; n++)
{
ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC); ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
}
ThrowHead(self, "models/objects/gibs/head2/tris.md2", damage, GIB_ORGANIC); ThrowHead(self, "models/objects/gibs/head2/tris.md2", damage, GIB_ORGANIC);
self->deadflag = DEAD_DEAD; self->deadflag = DEAD_DEAD;
return; return;
} }
if (self->deadflag == DEAD_DEAD) if (self->deadflag == DEAD_DEAD)
{
return; return;
}
// regular death /* regular death */
self->deadflag = DEAD_DEAD; self->deadflag = DEAD_DEAD;
self->takedamage = DAMAGE_YES; self->takedamage = DAMAGE_YES;
n = rand() % 3; n = rand() % 3;
if (n == 0) if (n == 0)
{ {
self->monsterinfo.currentmove = &infantry_move_death1; self->monsterinfo.currentmove = &infantry_move_death1;
@ -424,83 +543,121 @@ void infantry_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int dam
} }
} }
mframe_t infantry_frames_duck [] = mframe_t infantry_frames_duck[] = {
{
{ai_move, -2, monster_duck_down}, {ai_move, -2, monster_duck_down},
{ai_move, -5, monster_duck_hold}, {ai_move, -5, monster_duck_hold},
{ai_move, 3, NULL}, {ai_move, 3, NULL},
{ai_move, 4, monster_duck_up}, {ai_move, 4, monster_duck_up},
{ai_move, 0, NULL} {ai_move, 0, NULL}
}; };
mmove_t infantry_move_duck = {FRAME_duck01, FRAME_duck05, infantry_frames_duck, infantry_run};
// PMM - dodge code moved below so I can see the attack frames mmove_t infantry_move_duck = {
FRAME_duck01,
FRAME_duck05,
infantry_frames_duck,
infantry_run
};
void
void infantry_cock_gun (edict_t *self) infantry_cock_gun(edict_t *self)
{ {
// pmm .. code that was here no longer needed if (!self)
{
return;
}
gi.sound(self, CHAN_WEAPON, sound_weapon_cock, 1, ATTN_NORM, 0); gi.sound(self, CHAN_WEAPON, sound_weapon_cock, 1, ATTN_NORM, 0);
} }
void infantry_fire (edict_t *self) void
infantry_fire(edict_t *self)
{ {
InfantryMachineGun (self); if (!self)
if (level.time >= self->monsterinfo.pausetime) {
self->monsterinfo.aiflags &= ~AI_HOLD_FRAME; return;
else
self->monsterinfo.aiflags |= AI_HOLD_FRAME;
} }
// this is here instead of cock_gun InfantryMachineGun(self);
void infantry_fire_prep (edict_t *self) if (level.time >= self->monsterinfo.pausetime)
{
self->monsterinfo.aiflags &= ~AI_HOLD_FRAME;
}
else
{
self->monsterinfo.aiflags |= AI_HOLD_FRAME;
}
}
void
infantry_fire_prep(edict_t *self)
{ {
int n; int n;
if (!self)
{
return;
}
n = (rand() & 15) + 3 + 1; n = (rand() & 15) + 3 + 1;
self->monsterinfo.pausetime = level.time + n * FRAMETIME; self->monsterinfo.pausetime = level.time + n * FRAMETIME;
} }
// pmm mframe_t infantry_frames_attack1[] = {
// frames reordered, tweaked for new frames {ai_charge, -3, NULL}, /* 101 */
{ai_charge, -2, NULL}, /* 102 */
mframe_t infantry_frames_attack1 [] = {ai_charge, -1, infantry_fire_prep}, /* 103 */
{ {ai_charge, 5, infantry_fire}, /* 104 */
{ai_charge, -3, NULL}, //101 {ai_charge, 1, NULL}, /* 105 */
{ai_charge, -2, NULL}, //102 {ai_charge, -3, NULL}, /* 106 */
{ai_charge, -1, infantry_fire_prep}, //103 {ai_charge, -2, NULL}, /* 107 */
{ai_charge, 5, infantry_fire}, //104 {ai_charge, 2, infantry_cock_gun}, /* 108 */
{ai_charge, 1, NULL}, //105 {ai_charge, 1, NULL}, /* 109 */
{ai_charge, -3, NULL}, //106 {ai_charge, 1, NULL}, /* 110 */
{ai_charge, -2, NULL}, //107 {ai_charge, -1, NULL}, /* 111 */
{ai_charge, 2, infantry_cock_gun}, //108 {ai_charge, 0, NULL}, /* 112 */
{ai_charge, 1, NULL}, //109 {ai_charge, -1, NULL}, /* 113 */
{ai_charge, 1, NULL}, //110 {ai_charge, -1, NULL}, /* 114 */
{ai_charge, -1, NULL}, //111 {ai_charge, 4, NULL} /* 115 */
{ai_charge, 0, NULL}, //112
{ai_charge, -1, NULL}, //113
{ai_charge, -1, NULL}, //114
{ai_charge, 4, NULL} //115
}; };
mmove_t infantry_move_attack1 = {FRAME_attak101, FRAME_attak115, infantry_frames_attack1, infantry_run};
mmove_t infantry_move_attack1 = {
FRAME_attak101,
FRAME_attak115,
infantry_frames_attack1,
infantry_run
};
void infantry_swing (edict_t *self) void
infantry_swing(edict_t *self)
{ {
if (!self)
{
return;
}
gi.sound(self, CHAN_WEAPON, sound_punch_swing, 1, ATTN_NORM, 0); gi.sound(self, CHAN_WEAPON, sound_punch_swing, 1, ATTN_NORM, 0);
} }
void infantry_smack (edict_t *self) void
infantry_smack(edict_t *self)
{ {
vec3_t aim; vec3_t aim;
VectorSet (aim, MELEE_DISTANCE, 0, 0); if (!self)
if (fire_hit (self, aim, (5 + (rand() % 5)), 50)) {
gi.sound (self, CHAN_WEAPON, sound_punch_hit, 1, ATTN_NORM, 0); return;
} }
mframe_t infantry_frames_attack2 [] = VectorSet(aim, MELEE_DISTANCE, 0, 0);
if (fire_hit(self, aim, (5 + (rand() % 5)), 50))
{ {
gi.sound(self, CHAN_WEAPON, sound_punch_hit, 1, ATTN_NORM, 0);
}
}
mframe_t infantry_frames_attack2[] = {
{ai_charge, 3, NULL}, {ai_charge, 3, NULL},
{ai_charge, 6, NULL}, {ai_charge, 6, NULL},
{ai_charge, 0, infantry_swing}, {ai_charge, 0, infantry_swing},
@ -510,24 +667,44 @@ mframe_t infantry_frames_attack2 [] =
{ai_charge, 6, NULL}, {ai_charge, 6, NULL},
{ai_charge, 3, NULL}, {ai_charge, 3, NULL},
}; };
mmove_t infantry_move_attack2 = {FRAME_attak201, FRAME_attak208, infantry_frames_attack2, infantry_run};
void infantry_attack(edict_t *self) mmove_t infantry_move_attack2 = {
FRAME_attak201,
FRAME_attak208,
infantry_frames_attack2,
infantry_run
};
void
infantry_attack(edict_t *self)
{ {
if (!self)
{
return;
}
monster_done_dodge(self); monster_done_dodge(self);
if (range(self, self->enemy) == RANGE_MELEE) if (range(self, self->enemy) == RANGE_MELEE)
{
self->monsterinfo.currentmove = &infantry_move_attack2; self->monsterinfo.currentmove = &infantry_move_attack2;
}
else else
{
self->monsterinfo.currentmove = &infantry_move_attack1; self->monsterinfo.currentmove = &infantry_move_attack1;
} }
}
//=========== void
//PGM infantry_jump_now(edict_t *self)
void infantry_jump_now (edict_t *self)
{ {
vec3_t forward, up; vec3_t forward, up;
if (!self)
{
return;
}
monster_jump_start(self); monster_jump_start(self);
AngleVectors(self->s.angles, forward, NULL, up); AngleVectors(self->s.angles, forward, NULL, up);
@ -535,10 +712,16 @@ void infantry_jump_now (edict_t *self)
VectorMA(self->velocity, 300, up, self->velocity); VectorMA(self->velocity, 300, up, self->velocity);
} }
void infantry_jump2_now (edict_t *self) void
infantry_jump2_now(edict_t *self)
{ {
vec3_t forward, up; vec3_t forward, up;
if (!self)
{
return;
}
monster_jump_start(self); monster_jump_start(self);
AngleVectors(self->s.angles, forward, NULL, up); AngleVectors(self->s.angles, forward, NULL, up);
@ -546,21 +729,30 @@ void infantry_jump2_now (edict_t *self)
VectorMA(self->velocity, 400, up, self->velocity); VectorMA(self->velocity, 400, up, self->velocity);
} }
void infantry_jump_wait_land (edict_t *self) void
infantry_jump_wait_land(edict_t *self)
{ {
if (!self)
{
return;
}
if (self->groundentity == NULL) if (self->groundentity == NULL)
{ {
self->monsterinfo.nextframe = self->s.frame; self->monsterinfo.nextframe = self->s.frame;
if (monster_jump_finished(self)) if (monster_jump_finished(self))
{
self->monsterinfo.nextframe = self->s.frame + 1; self->monsterinfo.nextframe = self->s.frame + 1;
} }
}
else else
{
self->monsterinfo.nextframe = self->s.frame + 1; self->monsterinfo.nextframe = self->s.frame + 1;
} }
}
mframe_t infantry_frames_jump [] = mframe_t infantry_frames_jump[] = {
{
{ai_move, 0, NULL}, {ai_move, 0, NULL},
{ai_move, 0, NULL}, {ai_move, 0, NULL},
{ai_move, 0, NULL}, {ai_move, 0, NULL},
@ -572,10 +764,15 @@ mframe_t infantry_frames_jump [] =
{ai_move, 0, NULL}, {ai_move, 0, NULL},
{ai_move, 0, NULL} {ai_move, 0, NULL}
}; };
mmove_t infantry_move_jump = { FRAME_jump01, FRAME_jump10, infantry_frames_jump, infantry_run };
mframe_t infantry_frames_jump2 [] = mmove_t infantry_move_jump = {
{ FRAME_jump01,
FRAME_jump10,
infantry_frames_jump,
infantry_run
};
mframe_t infantry_frames_jump2[] = {
{ai_move, -8, NULL}, {ai_move, -8, NULL},
{ai_move, -4, NULL}, {ai_move, -4, NULL},
{ai_move, -4, NULL}, {ai_move, -4, NULL},
@ -587,25 +784,51 @@ mframe_t infantry_frames_jump2 [] =
{ai_move, 0, NULL}, {ai_move, 0, NULL},
{ai_move, 0, NULL} {ai_move, 0, NULL}
}; };
mmove_t infantry_move_jump2 = { FRAME_jump01, FRAME_jump10, infantry_frames_jump2, infantry_run };
void infantry_jump (edict_t *self) mmove_t infantry_move_jump2 = {
FRAME_jump01,
FRAME_jump10,
infantry_frames_jump2,
infantry_run
};
void
infantry_jump(edict_t *self)
{
if (!self)
{ {
if(!self->enemy)
return; return;
}
if (!self->enemy)
{
return;
}
monster_done_dodge(self); monster_done_dodge(self);
if (self->enemy->s.origin[2] > self->s.origin[2]) if (self->enemy->s.origin[2] > self->s.origin[2])
{
self->monsterinfo.currentmove = &infantry_move_jump2; self->monsterinfo.currentmove = &infantry_move_jump2;
}
else else
{
self->monsterinfo.currentmove = &infantry_move_jump; self->monsterinfo.currentmove = &infantry_move_jump;
} }
}
qboolean infantry_blocked (edict_t *self, float dist) qboolean
infantry_blocked(edict_t *self, float dist)
{ {
if (!self)
{
return false;
}
if (blocked_checkshot(self, 0.25 + (0.05 * skill->value))) if (blocked_checkshot(self, 0.25 + (0.05 * skill->value)))
{
return true; return true;
}
if (blocked_checkjump(self, dist, 192, 40)) if (blocked_checkjump(self, dist, 192, 40))
{ {
@ -614,96 +837,22 @@ qboolean infantry_blocked (edict_t *self, float dist)
} }
if (blocked_checkplat(self, dist)) if (blocked_checkplat(self, dist))
{
return true; return true;
}
return false; return false;
} }
//PGM
//===========
/*
void infantry_dodge (edict_t *self, edict_t *attacker, float eta, trace_t *tr)
{
//===========
//PMM - rogue rewrite of gunner dodge code.
float r;
float height;
int shooting = 0;
if (!self->enemy) void
infantry_duck(edict_t *self, float eta)
{ {
self->enemy = attacker; if (!self)
FoundTarget (self);
}
// PMM - don't bother if it's going to hit anyway; fix for weird in-your-face etas (I was
// seeing numbers like 13 and 14)
if ((eta < 0.1) || (eta > 5))
return;
r = random();
if (r > (0.25*((skill->value)+1)))
return;
if ((self->monsterinfo.currentmove == &infantry_move_attack1) ||
(self->monsterinfo.currentmove == &infantry_move_attack2))
{ {
shooting = 1;
}
if (self->monsterinfo.aiflags & AI_DODGING)
{
height = self->absmax[2];
}
else
{
height = self->absmax[2]-32-1; // the -1 is because the absmax is s.origin + maxs + 1
}
// check to see if it makes sense to duck
if (tr->endpos[2] <= height)
{
vec3_t right,diff;
if (shooting)
{
self->monsterinfo.attack_state = AS_SLIDING;
return;
}
AngleVectors (self->s.angles, NULL, right, NULL);
VectorSubtract (tr->endpos, self->s.origin, diff);
if (DotProduct (right, diff) < 0)
{
self->monsterinfo.lefty = 1;
}
// if it doesn't sense to duck, try to strafe away
monster_done_dodge (self);
self->monsterinfo.currentmove = &infantry_move_run;
self->monsterinfo.attack_state = AS_SLIDING;
return; return;
} }
if (skill->value == 0) /* if we're jumping, don't dodge */
{
self->monsterinfo.currentmove = &infantry_move_duck;
// PMM - stupid dodge
self->monsterinfo.duck_wait_time = level.time + eta + 1;
self->monsterinfo.aiflags |= AI_DODGING;
return;
}
if (!shooting)
{
self->monsterinfo.currentmove = &infantry_move_duck;
self->monsterinfo.duck_wait_time = level.time + eta + (0.1 * (3 - skill->value));
self->monsterinfo.aiflags |= AI_DODGING;
}
return;
//PMM
//===========
*/
void infantry_duck (edict_t *self, float eta)
{
// if we're jumping, don't dodge
if ((self->monsterinfo.currentmove == &infantry_move_jump) || if ((self->monsterinfo.currentmove == &infantry_move_jump) ||
(self->monsterinfo.currentmove == &infantry_move_jump2)) (self->monsterinfo.currentmove == &infantry_move_jump2))
{ {
@ -713,7 +862,7 @@ void infantry_duck (edict_t *self, float eta)
if ((self->monsterinfo.currentmove == &infantry_move_attack1) || if ((self->monsterinfo.currentmove == &infantry_move_attack1) ||
(self->monsterinfo.currentmove == &infantry_move_attack2)) (self->monsterinfo.currentmove == &infantry_move_attack2))
{ {
// if we're shooting, and not on easy, don't dodge /* if we're shooting, and not on easy, don't dodge */
if (skill->value) if (skill->value)
{ {
self->monsterinfo.aiflags &= ~AI_DUCKED; self->monsterinfo.aiflags &= ~AI_DUCKED;
@ -722,12 +871,16 @@ void infantry_duck (edict_t *self, float eta)
} }
if (skill->value == 0) if (skill->value == 0)
// PMM - stupid dodge {
/* stupid dodge */
self->monsterinfo.duck_wait_time = level.time + eta + 1; self->monsterinfo.duck_wait_time = level.time + eta + 1;
}
else else
{
self->monsterinfo.duck_wait_time = level.time + eta + (0.1 * (3 - skill->value)); self->monsterinfo.duck_wait_time = level.time + eta + (0.1 * (3 - skill->value));
}
// has to be done immediately otherwise he can get stuck /* has to be done immediately otherwise he can get stuck */
monster_duck_down(self); monster_duck_down(self);
self->monsterinfo.nextframe = FRAME_duck01; self->monsterinfo.nextframe = FRAME_duck01;
@ -735,9 +888,15 @@ void infantry_duck (edict_t *self, float eta)
return; return;
} }
void infantry_sidestep (edict_t *self) void
infantry_sidestep(edict_t *self)
{ {
// if we're jumping, don't dodge if (!self)
{
return;
}
/* if we're jumping, don't dodge */
if ((self->monsterinfo.currentmove == &infantry_move_jump) || if ((self->monsterinfo.currentmove == &infantry_move_jump) ||
(self->monsterinfo.currentmove == &infantry_move_jump2)) (self->monsterinfo.currentmove == &infantry_move_jump2))
{ {
@ -747,7 +906,7 @@ void infantry_sidestep (edict_t *self)
if ((self->monsterinfo.currentmove == &infantry_move_attack1) || if ((self->monsterinfo.currentmove == &infantry_move_attack1) ||
(self->monsterinfo.currentmove == &infantry_move_attack2)) (self->monsterinfo.currentmove == &infantry_move_attack2))
{ {
// if we're shooting, and not on easy, don't dodge /* if we're shooting, and not on easy, don't dodge */
if (skill->value) if (skill->value)
{ {
self->monsterinfo.aiflags &= ~AI_DODGING; self->monsterinfo.aiflags &= ~AI_DODGING;
@ -756,13 +915,22 @@ void infantry_sidestep (edict_t *self)
} }
if (self->monsterinfo.currentmove != &infantry_move_run) if (self->monsterinfo.currentmove != &infantry_move_run)
{
self->monsterinfo.currentmove = &infantry_move_run; self->monsterinfo.currentmove = &infantry_move_run;
} }
}
/*QUAKED monster_infantry (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight /*
* QUAKED monster_infantry (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
*/ */
void SP_monster_infantry (edict_t *self) void
SP_monster_infantry(edict_t *self)
{ {
if (!self)
{
return;
}
if (deathmatch->value) if (deathmatch->value)
{ {
G_FreeEdict(self); G_FreeEdict(self);
@ -783,7 +951,6 @@ void SP_monster_infantry (edict_t *self)
sound_search = gi.soundindex("infantry/infsrch1.wav"); sound_search = gi.soundindex("infantry/infsrch1.wav");
sound_idle = gi.soundindex("infantry/infidle1.wav"); sound_idle = gi.soundindex("infantry/infidle1.wav");
self->movetype = MOVETYPE_STEP; self->movetype = MOVETYPE_STEP;
self->solid = SOLID_BBOX; self->solid = SOLID_BBOX;
self->s.modelindex = gi.modelindex("models/monsters/infantry/tris.md2"); self->s.modelindex = gi.modelindex("models/monsters/infantry/tris.md2");
@ -800,13 +967,10 @@ void SP_monster_infantry (edict_t *self)
self->monsterinfo.stand = infantry_stand; self->monsterinfo.stand = infantry_stand;
self->monsterinfo.walk = infantry_walk; self->monsterinfo.walk = infantry_walk;
self->monsterinfo.run = infantry_run; self->monsterinfo.run = infantry_run;
// pmm
self->monsterinfo.dodge = M_MonsterDodge; self->monsterinfo.dodge = M_MonsterDodge;
self->monsterinfo.duck = infantry_duck; self->monsterinfo.duck = infantry_duck;
self->monsterinfo.unduck = monster_duck_up; self->monsterinfo.unduck = monster_duck_up;
self->monsterinfo.sidestep = infantry_sidestep; self->monsterinfo.sidestep = infantry_sidestep;
// self->monsterinfo.dodge = infantry_dodge;
// pmm
self->monsterinfo.attack = infantry_attack; self->monsterinfo.attack = infantry_attack;
self->monsterinfo.melee = NULL; self->monsterinfo.melee = NULL;
self->monsterinfo.sight = infantry_sight; self->monsterinfo.sight = infantry_sight;

View file

@ -1,6 +1,9 @@
// G:\quake2\baseq2\models/monsters/infantry /* =======================================================================
*
// This file generated by ModelGen - Do NOT Modify * Infantry animations.
*
* =======================================================================
*/
#define FRAME_gun02 0 #define FRAME_gun02 0
#define FRAME_stand01 1 #define FRAME_stand01 1
@ -209,8 +212,6 @@
#define FRAME_attak206 204 #define FRAME_attak206 204
#define FRAME_attak207 205 #define FRAME_attak207 205
#define FRAME_attak208 206 #define FRAME_attak208 206
//PGM
#define FRAME_jump01 207 #define FRAME_jump01 207
#define FRAME_jump02 208 #define FRAME_jump02 208
#define FRAME_jump03 209 #define FRAME_jump03 209
@ -221,6 +222,4 @@
#define FRAME_jump08 214 #define FRAME_jump08 214
#define FRAME_jump09 215 #define FRAME_jump09 215
#define FRAME_jump10 216 #define FRAME_jump10 216
//PGM
#define MODEL_SCALE 1.000000 #define MODEL_SCALE 1.000000