From 86a07d1432100fa0dc18216056382b1dafa52c4b Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Thu, 9 Sep 2010 14:48:39 +0300 Subject: [PATCH] Share some duplicated code instead --- data/qcsrc/server/bot/havocbot/vore_ai.qc | 19 +++---------------- data/qcsrc/server/vore.qc | 4 ++-- data/qcsrc/server/vore.qh | 3 ++- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/data/qcsrc/server/bot/havocbot/vore_ai.qc b/data/qcsrc/server/bot/havocbot/vore_ai.qc index 3e74edff..dbe702b3 100644 --- a/data/qcsrc/server/bot/havocbot/vore_ai.qc +++ b/data/qcsrc/server/bot/havocbot/vore_ai.qc @@ -1,22 +1,9 @@ -.float status_teamhealing; // 0 = can't team heal, 1 = can team heal, 2 = team healing currently - -entity Swallow_distance_check_bot(entity e) -{ - // check if we can swallow a player instead of firing our weapon - vector w_shotorg, w_shotdir; - w_shotorg = self.origin + self.view_ofs; - w_shotdir = v_forward; - - WarpZone_traceline_antilag(e, w_shotorg, w_shotorg + w_shotdir * cvar("g_balance_vore_swallow_range"), FALSE, e, ANTILAG_LATENCY(e)); - if(trace_fraction < 1) - if(trace_ent.classname == "player") - return trace_ent; - return world; -} +.float status_teamhealing; // 0 = can't team heal, 1 = can team heal, 2 = team healing right now float Swallow_condition_check_bot(entity prey) { // checks the necessary conditions for a bot to swallow another player + if(prey != self && prey.classname == "player" && prey.predator.classname != "player" && prey.deadflag == DEAD_NO && !prey.BUTTON_CHAT) // we can't swallow someone who's already in someone else's stomach if(self.predator.classname != "player" && self.stomach_load < cvar("g_balance_vore_swallow_limit") && self.deadflag == DEAD_NO) // we can't swallow players while inside someone's stomach ourselves if not(cvar("g_vore_biggergut") && prey.stomach_load > self.stomach_load) @@ -110,7 +97,7 @@ void Vore_AI() float random_try; float decide_prey, decide_pred; - prey = Swallow_distance_check_bot(self); + prey = Swallow_player_check(); // check if we should run the Teamhealing AI rather than continuing with the normal vore Vore_AI_Teamheal(prey); diff --git a/data/qcsrc/server/vore.qc b/data/qcsrc/server/vore.qc index fdbff4d9..ea2e82b1 100644 --- a/data/qcsrc/server/vore.qc +++ b/data/qcsrc/server/vore.qc @@ -8,7 +8,7 @@ const float complain_delay_time = 1; const float button_delay_time = 0.5; const float steptime = 0.1; -entity Swallow_distance_check() +entity Swallow_player_check() { // check if we can swallow a player instead of firing our weapon @@ -331,7 +331,7 @@ void Vore() // -------------------------------- entity prey; - prey = Swallow_distance_check(); + prey = Swallow_player_check(); // attempt to swallow our new prey if we pressed the attack button, and there's any in range if(self.BUTTON_ATCK && !self.BUTTON_REGURGITATE && self.swallow_delay < time) diff --git a/data/qcsrc/server/vore.qh b/data/qcsrc/server/vore.qh index 5d7c6625..dc55cd13 100644 --- a/data/qcsrc/server/vore.qh +++ b/data/qcsrc/server/vore.qh @@ -1,2 +1,3 @@ void Vore(); -void Vore_Disconnect(); \ No newline at end of file +void Vore_Disconnect(); +entity Swallow_player_check(); \ No newline at end of file -- 2.39.2