From 4d983e31f78ef6ee7513fd03da49c8977bea8f0e Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Fri, 25 Feb 2011 20:23:00 +0200 Subject: [PATCH] Port crosshair pickup effect from Xonotic --- data/qcsrc/client/View.qc | 17 +++++++++++++++++ data/qcsrc/common/constants.qh | 9 +++++---- data/qcsrc/server/cl_client.qc | 1 + data/qcsrc/server/defs.qh | 2 ++ data/qcsrc/server/g_world.qc | 1 + data/qcsrc/server/t_items.qc | 2 ++ 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/data/qcsrc/client/View.qc b/data/qcsrc/client/View.qc index ff0d8b68..9ae5a03b 100644 --- a/data/qcsrc/client/View.qc +++ b/data/qcsrc/client/View.qc @@ -252,6 +252,7 @@ float view_set; float camera_mode; float chase_active_old; float artwork_fade; +float pickup_crosshair_time, pickup_crosshair_size; string artwork_image; string intermission_song; string NextFrameCommand; @@ -645,6 +646,22 @@ void CSQC_UpdateView(float w, float h) wcross_scale = 1; } + if(cvar("crosshair_pickup")) + { + if(pickup_crosshair_time < getstatf(STAT_LAST_PICKUP)) + { + pickup_crosshair_size = 1; + pickup_crosshair_time = getstatf(STAT_LAST_PICKUP); + } + + if(pickup_crosshair_size > 0) + pickup_crosshair_size -= cvar("crosshair_pickup_speed") * frametime; + else + pickup_crosshair_size = 0; + + wcross_scale += sin(pickup_crosshair_size) * cvar("crosshair_pickup"); + } + if(shottype == SHOTTYPE_HITENEMY) wcross_scale *= cvar("crosshair_hittest"); // is not queried if hittest is 0 if(shottype == SHOTTYPE_HITTEAM) diff --git a/data/qcsrc/common/constants.qh b/data/qcsrc/common/constants.qh index 53362b4c..c13b426e 100644 --- a/data/qcsrc/common/constants.qh +++ b/data/qcsrc/common/constants.qh @@ -277,10 +277,11 @@ const float STAT_NB_METERSTART = 45; const float STAT_SHOTORG = 46; // compressShotOrigin const float STAT_LEADLIMIT = 47; const float STAT_WINNING = 48; -const float STAT_VORE_LOAD = 49; -const float STAT_VORE_DIGESTING = 50; -const float STAT_VORE_EATEN = 51; -const float STAT_VORE_CANLEAVE = 52; +const float STAT_LAST_PICKUP = 49; +const float STAT_VORE_LOAD = 50; +const float STAT_VORE_DIGESTING = 51; +const float STAT_VORE_EATEN = 52; +const float STAT_VORE_CANLEAVE = 53; const float CTF_STATE_ATTACK = 1; const float CTF_STATE_DEFEND = 2; const float CTF_STATE_COMMANDER = 3; diff --git a/data/qcsrc/server/cl_client.qc b/data/qcsrc/server/cl_client.qc index 26021e44..5eff6c80 100644 --- a/data/qcsrc/server/cl_client.qc +++ b/data/qcsrc/server/cl_client.qc @@ -2007,6 +2007,7 @@ void SpectateCopy(entity spectatee) { self.health = spectatee.health; self.impulse = 0; self.items = spectatee.items; + self.last_pickup = spectatee.last_pickup; self.strength_finished = spectatee.strength_finished; self.invincible_finished = spectatee.invincible_finished; self.pressedkeys = spectatee.pressedkeys; diff --git a/data/qcsrc/server/defs.qh b/data/qcsrc/server/defs.qh index 099096ce..8bfb0ac9 100644 --- a/data/qcsrc/server/defs.qh +++ b/data/qcsrc/server/defs.qh @@ -587,6 +587,8 @@ string matchid; .float hitplotfh; .string noise4; +.float last_pickup; + .float stat_hit; .float stat_fired; .float stat_count; diff --git a/data/qcsrc/server/g_world.qc b/data/qcsrc/server/g_world.qc index 9a8db612..82186ec3 100644 --- a/data/qcsrc/server/g_world.qc +++ b/data/qcsrc/server/g_world.qc @@ -654,6 +654,7 @@ void spawnfunc_worldspawn (void) addstat(STAT_DAMAGE_FIRED, AS_INT, stat_fired); addstat(STAT_SHOTORG, AS_INT, stat_shotorg); addstat(STAT_LEADLIMIT, AS_FLOAT, stat_leadlimit); + 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_DIGESTING, AS_INT, stat_digesting); diff --git a/data/qcsrc/server/t_items.qc b/data/qcsrc/server/t_items.qc index 1048dfba..3505039f 100644 --- a/data/qcsrc/server/t_items.qc +++ b/data/qcsrc/server/t_items.qc @@ -355,6 +355,8 @@ void Item_Touch (void) if(!Item_GiveTo(self, other)) return; + other.last_pickup = time; + pointparticles(particleeffectnum("item_pickup"), self.origin, '0 0 0', 1); if (self.classname == "droppedweapon") -- 2.39.2