]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a visual indicator for when you hit someone. Maybe could be expanded later, or...
authorSamual <samual@xonotic.org>
Fri, 11 Feb 2011 16:15:10 +0000 (11:15 -0500)
committerSamual <samual@xonotic.org>
Fri, 11 Feb 2011 16:15:10 +0000 (11:15 -0500)
defaultXonotic.cfg
qcsrc/client/View.qc
qcsrc/client/autocvars.qh
qcsrc/common/constants.qh
qcsrc/server/cl_client.qc
qcsrc/server/defs.qh
qcsrc/server/g_damage.qc
qcsrc/server/g_world.qc

index 05cc6c8931286d0ee81988f4a697f6eaaad336d9..c5e6872a629fc06b89fdd0e8c1b2bc3761467e63 100644 (file)
@@ -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"
index 2e1a1c3d321da58c5a7006809970659745dbd718..6feab40b7ba2daebc26423a53996de2a591ad572 100644 (file)
@@ -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
index df78b4f35c3a2dda7f61af5ccef302cb7e48b09d..c2fff2e83c959ba06d2dc16dad675d4ea72db447 100644 (file)
@@ -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;
index 90376b5b96bf9691c69ed98057e403282e7cec3c..d6752cca4c11a56fca1d316b548aca46a9af991c 100644 (file)
@@ -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;
index dbdaddded549e4d687f1ebb07a151eb5fdeec022..71584d350379869717ce8e3cd1ca6a2a3ce47f24 100644 (file)
@@ -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;
index 944dcc4ce0a249ce877681f01682219cbc38250e..5dcd9078e290513587197b209f494ce133682db2 100644 (file)
@@ -605,6 +605,8 @@ string matchid;
 
 .float last_pickup;
 
+.float hit_time; 
+
 .float stat_leadlimit;
 
 float radar_showennemies;
index e1ee5706856c05e98fd49c717c20bb6dee0277eb..60b0bd408d05adb5a0d70b83d84df2a8c117f7ad 100644 (file)
@@ -798,6 +798,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;
index 6c74ec83954d03455c3e73f8b8dd9a690bb8bea4..996b89b45add77861b00f6590328e84adc3ee700 100644 (file)
@@ -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);