From b87c91cd1c9e6df890385b0317c65b4a10e1982b Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 2 Jun 2022 12:28:39 +1000 Subject: [PATCH] Adjust the way monsters test their target to make them less likely to drop them and find them again immediately, fixes some cases of spammy behaviour --- qcsrc/common/monsters/sv_monsters.qc | 37 +++++++++++++++++----------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index 483f6a1ac..fc1681a91 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -590,20 +590,6 @@ vector Monster_Move_Target(entity this, entity targ) { vector targ_origin = ((this.enemy.absmin + this.enemy.absmax) * 0.5); targ_origin = WarpZone_RefSys_TransformOrigin(this.enemy, this, targ_origin); // origin of target as seen by the monster (us) - WarpZone_TraceLine(this.origin, targ_origin, MOVE_NOMONSTERS, this); - - // cases where the enemy may have changed their state (don't need to check everything here) - if( (IS_DEAD(this.enemy) || GetResource(this.enemy, RES_HEALTH) < 1) - || (STAT(FROZEN, this.enemy)) - || (this.enemy.flags & FL_NOTARGET) - || (this.enemy.alpha < 0.5 && this.enemy.alpha != 0) - || (this.enemy.takedamage == DAMAGE_NO) - || (vdist(this.origin - targ_origin, >, this.target_range)) - || ((trace_fraction < 1) && (trace_ent != this.enemy)) - ) - { - this.enemy = NULL; - } if(this.enemy) { @@ -1202,7 +1188,28 @@ void Monster_Frozen_Think(entity this) void Monster_Enemy_Check(entity this) { if(this.enemy) - return; + { + vector targ_origin = ((this.enemy.absmin + this.enemy.absmax) * 0.5); + targ_origin = WarpZone_RefSys_TransformOrigin(this.enemy, this, targ_origin); // origin of target as seen by the monster (us) + WarpZone_TraceLine(this.origin, targ_origin, MOVE_NOMONSTERS, this); + + // cases where the enemy may have changed their state (don't need to check everything here) + if( (IS_DEAD(this.enemy) || GetResource(this.enemy, RES_HEALTH) < 1) + || (STAT(FROZEN, this.enemy)) + || (this.enemy.flags & FL_NOTARGET) + || (this.enemy.alpha < 0.5 && this.enemy.alpha != 0) + || (this.enemy.takedamage == DAMAGE_NO) + || (vdist(this.origin - targ_origin, >, this.target_range)) + || ((trace_fraction < 1) && (trace_ent != this.enemy)) + ) + { + this.enemy = NULL; + } + else + { + return; + } + } this.enemy = Monster_FindTarget(this); if(this.enemy) -- 2.39.2