From: Rudolf Polzer Date: Mon, 14 Feb 2011 17:46:06 +0000 (+0100) Subject: Merge remote branch 'origin/samual/hitindication' X-Git-Tag: xonotic-v0.5.0~311^2~19 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=3f0620ef10b0c142cfb2f64d87af78c1243766c6;hp=1e80ce57f5d8f6f38ae19625d707db3b3c9db62a Merge remote branch 'origin/samual/hitindication' --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 05cc6c8931..c5e6872a62 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -103,6 +103,9 @@ seta crosshair_dot_size 0.600000 seta crosshair_dot_color "1 0 0" "when != 0, use custom color for the crosshair dot" seta crosshair_pickup 0.25 seta crosshair_pickup_speed 4 +seta crosshair_hitindication 0.5 +seta crosshair_hitindication_color "10 -10 -10" +seta crosshair_hitindication_speed 5 seta crosshair_per_weapon 0 "when 1, each gun will display a different crosshair" seta crosshair_color_per_weapon 1 "when 1, each gun will display the crosshair with a different color" seta crosshair_effect_speed -1 "how fast (in seconds) some crosshair effects should take place, 0 = instant, -1 = 2x weapon switch time" diff --git a/qcsrc/client/View.qc b/qcsrc/client/View.qc index 2e1a1c3d32..6feab40b7b 100644 --- a/qcsrc/client/View.qc +++ b/qcsrc/client/View.qc @@ -353,6 +353,7 @@ vector freeze_pmove_org, freeze_input_angles; entity nightvision_noise, nightvision_noise2; float pickup_crosshair_time, pickup_crosshair_size; +float hitindication_crosshair_time, hitindication_crosshair_size; float use_nex_chargepool; float myhealth, myhealth_prev; @@ -973,6 +974,27 @@ void CSQC_UpdateView(float w, float h) wcross_scale += sin(pickup_crosshair_size) * autocvar_crosshair_pickup; } + + vector hitindication_color; + if(autocvar_crosshair_hitindication) + { + hitindication_color = stov(autocvar_crosshair_hitindication_color); + if(hitindication_crosshair_time < getstatf(STAT_HIT_TIME)) + { + hitindication_crosshair_size = 1; + hitindication_crosshair_time = getstatf(STAT_HIT_TIME); + } + + if(hitindication_crosshair_size > 0) + hitindication_crosshair_size -= autocvar_crosshair_hitindication_speed * frametime; + else + hitindication_crosshair_size = 0; + + wcross_scale += sin(hitindication_crosshair_size) * autocvar_crosshair_hitindication; + wcross_color_x += sin(hitindication_crosshair_size) * hitindication_color_x; + wcross_color_y += sin(hitindication_crosshair_size) * hitindication_color_y; + wcross_color_z += sin(hitindication_crosshair_size) * hitindication_color_z; + } if(shottype == SHOTTYPE_HITENEMY) wcross_scale *= autocvar_crosshair_hittest; // is not queried if hittest is 0 diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index df78b4f35c..c2fff2e83c 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -99,6 +99,9 @@ string autocvar_crosshair_dot_color; float autocvar_crosshair_dot_size; float autocvar_crosshair_effect_scalefade; float autocvar_crosshair_effect_speed; +float autocvar_crosshair_hitindication; +string autocvar_crosshair_hitindication_color; +float autocvar_crosshair_hitindication_speed; float autocvar_crosshair_hittest; float autocvar_crosshair_hittest_blur; float autocvar_crosshair_hittest_showimpact; diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 90376b5b96..d6752cca4c 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -313,6 +313,7 @@ const float STAT_NEX_CHARGE = 49; const float STAT_LAST_PICKUP = 50; const float STAT_HUD = 51; const float STAT_NEX_CHARGEPOOL = 52; +const float STAT_HIT_TIME = 53; // see DP source, quakedef.h const float STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW = 222; diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index dbdaddded5..71584d3503 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2346,6 +2346,7 @@ void SpectateCopy(entity spectatee) { self.impulse = 0; self.items = spectatee.items; self.last_pickup = spectatee.last_pickup; + self.hit_time = spectatee.hit_time; self.metertime = spectatee.metertime; self.strength_finished = spectatee.strength_finished; self.invincible_finished = spectatee.invincible_finished; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 944dcc4ce0..5dcd9078e2 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -605,6 +605,8 @@ string matchid; .float last_pickup; +.float hit_time; + .float stat_leadlimit; float radar_showennemies; diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 68be349714..d27c31a6aa 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -797,6 +797,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float else attacker.hitsound += 1; attacker.prevhitsound = time; + attacker.hit_time = time; } damage_goodhits += 1; diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 6c74ec8395..996b89b45a 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -825,6 +825,7 @@ void spawnfunc_worldspawn (void) addstat(STAT_LEADLIMIT, AS_FLOAT, stat_leadlimit); addstat(STAT_BULLETS_LOADED, AS_INT, sniperrifle_bulletcounter); addstat(STAT_LAST_PICKUP, AS_FLOAT, last_pickup); + addstat(STAT_HIT_TIME, AS_FLOAT, hit_time); addstat(STAT_NEX_CHARGE, AS_FLOAT, nex_charge); addstat(STAT_NEX_CHARGEPOOL, AS_FLOAT, nex_chargepool_ammo);