Parasite blocked attack bugfix and dead code elimination

This commit is contained in:
BjossiAlfreds 2020-01-01 21:50:07 +00:00
parent ccd16599ef
commit e04bd67aa3
18 changed files with 37 additions and 179 deletions

View file

@ -24,104 +24,8 @@ int num_hint_paths;
qboolean face_wall(edict_t *self);
qboolean monsterlost_checkhint2(edict_t *self);
qboolean parasite_drain_attack_ok(vec3_t start, vec3_t end);
void HuntTarget(edict_t *self);
qboolean
blocked_checkshot(edict_t *self, float shotChance)
{
qboolean playerVisible;
if (!self)
{
return false;
}
if (!self->enemy)
{
return false;
}
/* blocked checkshot is only against players. this will
filter out player sounds and other shit they should
not be firing at. */
if (!(self->enemy->client))
{
return false;
}
if (random() < shotChance)
{
return false;
}
if (!strcmp(self->classname, "monster_parasite"))
{
vec3_t f, r, offset, start, end;
trace_t tr;
AngleVectors(self->s.angles, f, r, NULL);
VectorSet(offset, 24, 0, 6);
G_ProjectSource(self->s.origin, offset, f, r, start);
VectorCopy(self->enemy->s.origin, end);
if (!parasite_drain_attack_ok(start, end))
{
end[2] = self->enemy->s.origin[2] + self->enemy->maxs[2] - 8;
if (!parasite_drain_attack_ok(start, end))
{
end[2] = self->enemy->s.origin[2] + self->enemy->mins[2] + 8;
if (!parasite_drain_attack_ok(start, end))
{
return false;
}
}
}
VectorCopy(self->enemy->s.origin, end);
tr = gi.trace(start, NULL, NULL, end, self, MASK_SHOT);
if (tr.ent != self->enemy)
{
self->monsterinfo.aiflags |= AI_BLOCKED;
if (self->monsterinfo.attack)
{
self->monsterinfo.attack(self);
}
self->monsterinfo.aiflags &= ~AI_BLOCKED;
return true;
}
}
playerVisible = visible(self, self->enemy);
/* always shoot at teslas */
if (playerVisible)
{
if (!strcmp(self->enemy->classname, "tesla"))
{
/* turn on AI_BLOCKED to let the monster know the attack
is being called by the blocked functions... */
self->monsterinfo.aiflags |= AI_BLOCKED;
if (self->monsterinfo.attack)
{
self->monsterinfo.attack(self);
}
self->monsterinfo.aiflags &= ~AI_BLOCKED;
return true;
}
}
return false;
}
qboolean
blocked_checkplat(edict_t *self, float dist)
{

View file

@ -924,7 +924,6 @@ void fire_tracker(edict_t *self, vec3_t start, vec3_t dir, int damage,
int speed, edict_t *enemy);
/* g_newai.c */
qboolean blocked_checkshot(edict_t *self, float shotChance);
qboolean blocked_checkplat(edict_t *self, float dist);
qboolean blocked_checkjump(edict_t *self, float dist, float maxDown, float maxUp);
qboolean blocked_checknewenemy(edict_t *self);

View file

@ -977,11 +977,6 @@ chick_blocked(edict_t *self, float dist)
return false;
}
if (blocked_checkshot(self, 0.25 + (0.05 * skill->value)))
{
return true;
}
if (blocked_checkplat(self, dist))
{
return true;

View file

@ -804,16 +804,6 @@ floater_die(edict_t *self, edict_t *inflictor /* unused */, edict_t *attacker /*
qboolean
floater_blocked(edict_t *self, float dist)
{
if (!self)
{
return false;
}
if (blocked_checkshot(self, 0.25 + (0.05 * skill->value)))
{
return true;
}
return false;
}

View file

@ -991,10 +991,6 @@ flyer_blocked(edict_t *self, float dist)
}
/* we're a normal flyer */
if (blocked_checkshot(self, 0.25 + (0.05 * skill->value)))
{
return true;
}
return false;
}

View file

@ -474,11 +474,6 @@ gladiator_blocked(edict_t *self, float dist)
return false;
}
if (blocked_checkshot(self, 0.25 + (0.05 * skill->value) ))
{
return true;
}
if (blocked_checkplat(self, dist))
{
return true;

View file

@ -1101,11 +1101,6 @@ gunner_blocked(edict_t *self, float dist)
return false;
}
if (blocked_checkshot(self, 0.25 + (0.05 * skill->value)))
{
return true;
}
if (blocked_checkplat(self, dist))
{
return true;

View file

@ -760,16 +760,6 @@ hover_die(edict_t *self, edict_t *inflictor /* unused */, edict_t *attacker /* u
qboolean
hover_blocked(edict_t *self, float dist)
{
if (!self)
{
return false;
}
if (blocked_checkshot(self, 0.25 + (0.05 * skill->value)))
{
return true;
}
return false;
}

View file

@ -821,11 +821,6 @@ infantry_blocked(edict_t *self, float dist)
return false;
}
if (blocked_checkshot(self, 0.25 + (0.05 * skill->value)))
{
return true;
}
if (blocked_checkjump(self, dist, 192, 40))
{
infantry_jump(self);

View file

@ -1866,11 +1866,6 @@ medic_blocked(edict_t *self, float dist)
return false;
}
if (blocked_checkshot(self, 0.25 + (0.05 * skill->value)))
{
return true;
}
if (blocked_checkplat(self, dist))
{
return true;

View file

@ -753,9 +753,38 @@ parasite_blocked(edict_t *self, float dist)
return false;
}
if (blocked_checkshot(self, 0.25 + (0.05 * skill->value)))
if (self->enemy && self->enemy->client && random() >= (0.25 + (0.05 * skill->value)))
{
return true;
vec3_t f, r, offset, start, end;
AngleVectors(self->s.angles, f, r, NULL);
VectorSet(offset, 24, 0, 6);
G_ProjectSource(self->s.origin, offset, f, r, start);
VectorCopy(self->enemy->s.origin, end);
if (!parasite_drain_attack_ok(start, end))
{
end[2] = self->enemy->s.origin[2] + self->enemy->maxs[2] - 8;
if (!parasite_drain_attack_ok(start, end))
{
end[2] = self->enemy->s.origin[2] + self->enemy->mins[2] + 8;
if (!parasite_drain_attack_ok(start, end))
{
return false;
}
}
}
VectorCopy(self->enemy->s.origin, end);
if (visible(self, self->enemy))
{
parasite_attack(self);
return true;
}
}
if (blocked_checkjump(self, dist, 256, 68))

View file

@ -1182,11 +1182,6 @@ soldier_blocked(edict_t *self, float dist)
return false;
}
if (blocked_checkshot(self, 0.25 + (0.05 * skill->value)))
{
return true;
}
if (blocked_checkplat(self, dist))
{
return true;

View file

@ -1303,11 +1303,6 @@ stalker_blocked(edict_t *self, float dist)
if (!onCeiling)
{
if (blocked_checkshot(self, 0.25 + (0.05 * skill->value)))
{
return true;
}
if (visible(self, self->enemy))
{
stalker_do_pounce(self, self->enemy->s.origin);
@ -1327,11 +1322,7 @@ stalker_blocked(edict_t *self, float dist)
}
else
{
if (blocked_checkshot(self, 0.25 + (0.05 * skill->value)))
{
return true;
}
else if (stalker_ok_to_transition(self))
if (stalker_ok_to_transition(self))
{
self->gravityVector[2] = -1;
self->s.angles[2] += 180.0;

View file

@ -834,11 +834,6 @@ supertank_blocked(edict_t *self, float dist)
return false;
}
if (blocked_checkshot(self, 0.25 + (0.05 * skill->value)))
{
return true;
}
if (blocked_checkplat(self, dist))
{
return true;

View file

@ -1178,14 +1178,15 @@ tank_die(edict_t *self, edict_t *inflictor /* unused */, edict_t *attacker /* un
self->monsterinfo.currentmove = &tank_move_death;
}
qboolean tank_blocked(edict_t *self, float dist)
qboolean
tank_blocked(edict_t *self, float dist)
{
if (blocked_checkshot(self, 0.25 + (0.05 * skill->value) ))
if (!self)
{
return true;
return false;
}
if(blocked_checkplat(self, dist))
if (blocked_checkplat(self, dist))
{
return true;
}

View file

@ -1765,11 +1765,6 @@ widow_blocked(edict_t *self, float dist)
return true;
}
if (blocked_checkshot(self, 0.25 + (0.05 * skill->value)))
{
return true;
}
return false;
}

View file

@ -1105,7 +1105,6 @@ extern edict_t * hintpath_findstart ( edict_t * ent ) ;
extern qboolean blocked_checknewenemy ( edict_t * self ) ;
extern qboolean blocked_checkjump ( edict_t * self , float dist , float maxDown , float maxUp ) ;
extern qboolean blocked_checkplat ( edict_t * self , float dist ) ;
extern qboolean blocked_checkshot ( edict_t * self , float shotChance ) ;
extern void monster_done_dodge ( edict_t * self ) ;
extern void stationarymonster_start ( edict_t * self ) ;
extern void stationarymonster_start_go ( edict_t * self ) ;

View file

@ -1105,7 +1105,6 @@
{"blocked_checknewenemy", (byte *)blocked_checknewenemy},
{"blocked_checkjump", (byte *)blocked_checkjump},
{"blocked_checkplat", (byte *)blocked_checkplat},
{"blocked_checkshot", (byte *)blocked_checkshot},
{"monster_done_dodge", (byte *)monster_done_dodge},
{"stationarymonster_start", (byte *)stationarymonster_start},
{"stationarymonster_start_go", (byte *)stationarymonster_start_go},