diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 9b280fe9df..5a2ac72e25 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,5 @@ September 14, 2009 (Changes by Graf Zahl) +- Added PinkSilver's A_LookEx fix. - added resources needed for MBF support. - removed unused score items from DECORATE file. - Fixed: Argument count for UsePuzzleItem was wrong. diff --git a/src/p_enemy_a_lookex.cpp b/src/p_enemy_a_lookex.cpp index 1eaa2c23d9..4c68fcbf26 100644 --- a/src/p_enemy_a_lookex.cpp +++ b/src/p_enemy_a_lookex.cpp @@ -782,12 +782,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) } } } - - if (targ && targ->player && (targ->player->cheats & CF_NOTARGET)) - { - return; - } - } + } + + if (targ && targ->player && (targ->player->cheats & CF_NOTARGET)) + { + return; + } } // [RH] Andy Baker's stealth monsters @@ -811,36 +811,40 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) } // Let the self wander around aimlessly looking for a fight - if (self->SeeState != NULL) - { - if (!(self->flags & MF_INCHASE)) - { - if (seestate) - { - self->SetState (seestate); - } - else - { - self->SetState (self->SeeState); - } - } - } - else - { - CALL_ACTION(A_Wander, self); - } + if (!(self->flags & MF_INCHASE)) + { + if (seestate) + { + self->SetState (seestate); + } + else + { + if (self->SeeState != NULL) + { + self->SetState (self->SeeState); + } + else + { + CALL_ACTION(A_Wander, self); + } + } + } } } else { self->target = targ; //We already have a target? + + // [KS] The target can become ourselves in rare circumstances (like + // if we committed suicide), so if that's the case, just ignore it. + if (self->target == self) self->target = NULL; - if (targ != NULL) + if (self->target != NULL) { if (self->flags & MF_AMBUSH) { - dist = P_AproxDistance (targ->x - self->x, - targ->y - self->y); + dist = P_AproxDistance (self->target->x - self->x, + self->target->y - self->y); if (P_CheckSight (self, self->target, 2) && (!minseedist || dist > minseedist) && (!maxseedist || dist < maxseedist)) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index a3abb7c065..7c3dd9ee82 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -2139,6 +2139,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn) { AActor *defs = self->GetDefault(); self->health = defs->health; + + // [KS] Don't keep target, because it could be self if the monster committed suicide + self->target = NULL; + self->LastHeard = NULL; self->flags = (defs->flags & ~MF_FRIENDLY) | (self->flags & MF_FRIENDLY); self->flags2 = defs->flags2;