Fix monsters getting stuck when resurrected by a medic.

While in baseq2 monsters had the abillity to duck it wasn't used
often. The same goes for medics, there are only a few throughout the
whole single player campaign. In rogue things are differed. Due to
some AI changes like support for dodging monsters duck more often and
there a a lot of medics and even it's improved version, the medic
commander.

When a monster dies it's mmove_t is set to the death animation and
it's AI flags are left as they are. When a monster is resurrected by
a medic, the AI flags are reset to 0 and it's spawn function is
called again. Normally this is totally save. But when there're two
medics and both try to resurrect there monster there's a small window
for the monster being respawned without the AI flags reset.

In this case the mmove_t is set to the monsters standard animation,
while the AI flags may be still contain AI_DUCK. When AI_DUCK is set,
but the current animation is not one of the duck animations, the
monster may get stuck. There's even a comment in the code for that
case. ;) Solve this problem by resetting AI_DUCK as soon as the
monster dies.

With this change applied I was unable to reproduce any problem in
regard to medics, medic commanders, resurrection and spwaning of new
monsters.

This closes issue #6.
This commit is contained in:
Yamagi Burmeister 2017-01-20 16:32:00 +01:00
parent 7720887274
commit 1776ec3d31

View file

@ -133,6 +133,14 @@ Killed(edict_t *targ, edict_t *inflictor, edict_t *attacker,
targ->health = -999;
}
/* Reset AI flag for being ducked. This fixes a corner case
were the monster is ressurected by a medic and get's stuck
in the next frame for mmove_t not matching the AI state. */
if (targ->monsterinfo.aiflags & AI_DUCKED)
{
targ->monsterinfo.aiflags &= ~AI_DUCKED;
}
if (targ->monsterinfo.aiflags & AI_MEDIC)
{
if (targ->enemy)