From 7d99fb180b0b154a56021205d267fb410038c837 Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Mon, 28 Feb 2011 20:24:49 +0200 Subject: [PATCH] Canswallow indicator for crosshair. When enabled, the crosshair will turn into a ! or ? symbol to indicate you can swallow an enemy or team mate. Still some work to be done here. --- data/defaultVoretournament.cfg | 2 ++ data/qcsrc/client/View.qc | 21 ++++++++++++++++++--- data/qcsrc/common/constants.qh | 3 ++- data/qcsrc/server/cl_client.qc | 1 + data/qcsrc/server/defs.qh | 2 +- data/qcsrc/server/g_world.qc | 1 + data/qcsrc/server/vore.qc | 13 +++++++++++-- 7 files changed, 36 insertions(+), 7 deletions(-) diff --git a/data/defaultVoretournament.cfg b/data/defaultVoretournament.cfg index ef386e39..df15ab56 100644 --- a/data/defaultVoretournament.cfg +++ b/data/defaultVoretournament.cfg @@ -112,6 +112,8 @@ seta crosshair_pickup 1 seta crosshair_pickup_speed 4 seta crosshair_ring_alpha 0.5 seta crosshair_ring_size 3 +seta crosshair_swallowindicator 1 +seta crosshair_swallowindicator_size 4 seta crosshair_effect_speed 0.25 "how fast (in seconds) some crosshair effects should take place, 0 = instant, -1 = 2x weapon switch time" seta crosshair_effect_scalefade 1 "use scaling and fading for crosshair effects" seta crosshair_hittest 1.25 "do a crosshair hit evaluation; also, the crosshair is scaled by the given number when aiming at an enemy, and blurred when aiming at a team mate" diff --git a/data/qcsrc/client/View.qc b/data/qcsrc/client/View.qc index dec78f34..1daa4cb4 100644 --- a/data/qcsrc/client/View.qc +++ b/data/qcsrc/client/View.qc @@ -892,6 +892,12 @@ void CSQC_UpdateView(float w, float h) Sbar_DrawCenterPrint(); // draw centerprint messages even if viewsize >= 120 } + float weapon_clipload, weapon_clipsize, ring_scale; + + float swallow_indicator; + if(cvar("crosshair_swallowindicator")) + swallow_indicator = getstati(STAT_VORE_CANSWALLOW); + float hud; hud = getstati(STAT_HUD); @@ -909,6 +915,7 @@ void CSQC_UpdateView(float w, float h) wcross_origin = project_3d_to_2d(view_origin + MAX_SHOT_DISTANCE * view_forward); wcross_origin_z = 0; if(cvar("crosshair_hittest")) + if(!swallow_indicator) { vector wcross_oldorigin; wcross_oldorigin = wcross_origin; @@ -927,10 +934,14 @@ void CSQC_UpdateView(float w, float h) else shottype = SHOTTYPE_HITWORLD; - float weapon_clipload, weapon_clipsize, ring_scale; - string wcross_style; - wcross_style = cvar_string("crosshair"); + + if(swallow_indicator > 1) + wcross_style = "_canswallow_team.tga"; + else if(swallow_indicator > 0) + wcross_style = "_canswallow.tga"; + else + wcross_style = cvar_string("crosshair"); if (wcross_style != "0") { vector wcross_color, wcross_size; @@ -1061,10 +1072,14 @@ void CSQC_UpdateView(float w, float h) CROSSHAIR_DRAW(wcross_resolution, wcross_name, wcross_alpha * f); wcross_name_alpha_goal_prev = f; + if(swallow_indicator) + wcross_size *= cvar("crosshair_swallowindicator_size"); + // ring around crosshair representing bullets left in weapon clip weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD); a = cvar("crosshair_ring_alpha"); if (weapon_clipload && a) + if (!swallow_indicator) { weapon_clipsize = getstati(STAT_WEAPON_CLIPSIZE); ring_scale = cvar("crosshair_ring_size"); diff --git a/data/qcsrc/common/constants.qh b/data/qcsrc/common/constants.qh index c0e402d8..a01cafda 100644 --- a/data/qcsrc/common/constants.qh +++ b/data/qcsrc/common/constants.qh @@ -284,11 +284,12 @@ const float STAT_VORE_LOAD = 52; const float STAT_VORE_DIGESTING = 53; const float STAT_VORE_EATEN = 54; const float STAT_VORE_CANLEAVE = 55; +const float STAT_VORE_CANSWALLOW = 56; const float CTF_STATE_ATTACK = 1; const float CTF_STATE_DEFEND = 2; const float CTF_STATE_COMMANDER = 3; -const float STAT_HUD = 56; +const float STAT_HUD = 57; const float HUD_NORMAL = 0; // moved that here so the client knows the max. diff --git a/data/qcsrc/server/cl_client.qc b/data/qcsrc/server/cl_client.qc index 937a73d6..845ad8be 100644 --- a/data/qcsrc/server/cl_client.qc +++ b/data/qcsrc/server/cl_client.qc @@ -2056,6 +2056,7 @@ void SpectateCopy(entity spectatee) { self.stat_stomachload = spectatee.stat_stomachload; self.stat_digesting = spectatee.stat_digesting; self.stat_canleave = spectatee.stat_canleave; + self.stat_canswallow = spectatee.stat_canswallow; setorigin(self, spectatee.origin); setsize(self, spectatee.mins, spectatee.maxs); SetZoomState(spectatee.zoomstate); diff --git a/data/qcsrc/server/defs.qh b/data/qcsrc/server/defs.qh index 64025012..7bba8ff3 100644 --- a/data/qcsrc/server/defs.qh +++ b/data/qcsrc/server/defs.qh @@ -71,7 +71,7 @@ float maxclients; .float stomach_load; .float weapon_delay; .float fakeprey; -.float stat_eaten, stat_stomachload, stat_digesting, stat_canleave; +.float stat_eaten, stat_stomachload, stat_digesting, stat_canleave, stat_canswallow; // Fields diff --git a/data/qcsrc/server/g_world.qc b/data/qcsrc/server/g_world.qc index e1174dd2..7a065d43 100644 --- a/data/qcsrc/server/g_world.qc +++ b/data/qcsrc/server/g_world.qc @@ -659,6 +659,7 @@ void spawnfunc_worldspawn (void) addstat(STAT_LAST_PICKUP, AS_FLOAT, last_pickup); addstat(STAT_WINNING, AS_FLOAT, winning); addstat(STAT_VORE_LOAD, AS_INT, stat_stomachload); + addstat(STAT_VORE_CANSWALLOW, AS_INT, stat_canswallow); addstat(STAT_VORE_DIGESTING, AS_INT, stat_digesting); addstat(STAT_VORE_EATEN, AS_INT, stat_eaten); addstat(STAT_VORE_CANLEAVE, AS_INT, stat_canleave); diff --git a/data/qcsrc/server/vore.qc b/data/qcsrc/server/vore.qc index ae066df9..3f80c605 100644 --- a/data/qcsrc/server/vore.qc +++ b/data/qcsrc/server/vore.qc @@ -534,9 +534,18 @@ void Vore() 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.stat_canswallow = 0; if(Swallow_condition_check(prey)) - Vore_Swallow(prey); + { + // canswallow stat, used by the HUD + if(teams_matter && prey.team == self.team) + self.stat_canswallow = 2; + else + self.stat_canswallow = 1; + + if(self.BUTTON_ATCK) + Vore_Swallow(prey); + } // toggle digestion, if the player has someone in their stomach if(self.BUTTON_DIGEST && cvar("g_vore_digestion")) -- 2.39.2