From a19daa9ff9643efd139c7ef8507306478679b878 Mon Sep 17 00:00:00 2001 From: terencehill Date: Wed, 18 Apr 2018 20:14:53 +0200 Subject: [PATCH] Bot AI: implement real-time detection of revival of target frozen players so bot can immediately find another goal --- qcsrc/server/bot/default/havocbot/havocbot.qc | 8 ++++++-- qcsrc/server/bot/default/navigation.qc | 2 ++ qcsrc/server/bot/default/navigation.qh | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 7ce6efa45..9d4ef6336 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -801,10 +801,14 @@ void havocbot_movetogoal(entity this) navigation_shortenpath(this); + bool goalcurrent_can_be_removed = false; if (IS_MOVABLE(this.goalcurrent)) { - if (IS_DEAD(this.goalcurrent)) + // if is movable => not frozen + if (IS_DEAD(this.goalcurrent) || (this.goalentity_shouldbefrozen && this.goalentity == this.goalcurrent)) { + goalcurrent_can_be_removed = true; + // don't remove if not visible if (checkpvs(this.origin + this.view_ofs, this.goalcurrent)) { navigation_goalrating_timeout_force(this); @@ -832,7 +836,7 @@ void havocbot_movetogoal(entity this) { if (this.goalcurrent) { - if (IS_MOVABLE(this.goalcurrent) && IS_DEAD(this.goalcurrent)) + if (goalcurrent_can_be_removed) { // remove even if not visible navigation_goalrating_timeout_force(this); diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index c79ed40a4..3625b4693 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -731,6 +731,7 @@ void navigation_clearroute(entity this) this.goalcurrent_distance_z = FLOAT_MAX; this.goalcurrent_distance_time = 0; this.goalentity_lock_timeout = 0; + this.goalentity_shouldbefrozen = false; this.goalentity = NULL; this.goalcurrent = NULL; this.goalstack01 = NULL; @@ -1770,6 +1771,7 @@ void navigation_goalrating_end(entity this) this.aistatus |= AI_STATUS_STUCK; } } + this.goalentity_shouldbefrozen = boolean(STAT(FROZEN, this.goalentity)); } void botframe_updatedangerousobjects(float maxupdate) diff --git a/qcsrc/server/bot/default/navigation.qh b/qcsrc/server/bot/default/navigation.qh index f3103cc4f..80498b691 100644 --- a/qcsrc/server/bot/default/navigation.qh +++ b/qcsrc/server/bot/default/navigation.qh @@ -30,6 +30,7 @@ entity navigation_bestgoal; .float goalcurrent_distance_time; .float goalentity_lock_timeout; +.bool goalentity_shouldbefrozen; .entity nearestwaypoint; .float nearestwaypointtimeout; -- 2.39.2