From 1776ec3d31cbf22f699d28f020d7732500ca93bd Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Fri, 20 Jan 2017 16:32:00 +0100 Subject: [PATCH] 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. --- src/g_combat.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/g_combat.c b/src/g_combat.c index 5647d3a..fc6bac7 100644 --- a/src/g_combat.c +++ b/src/g_combat.c @@ -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)