Merge remote branch 'origin/samual/hitindication'
authorRudolf Polzer <divVerent@xonotic.org>
Mon, 14 Feb 2011 17:46:06 +0000 (18:46 +0100)
committerRudolf Polzer <divVerent@xonotic.org>
Mon, 14 Feb 2011 17:46:06 +0000 (18:46 +0100)
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 05cc6c8..c5e6872 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 2e1a1c3..6feab40 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 df78b4f..c2fff2e 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 90376b5..d6752cc 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 dbdaddd..71584d3 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 944dcc4..5dcd907 100644 (file)
@@ -605,6 +605,8 @@ string matchid;
 
 .float last_pickup;
 
+.float hit_time; 
+
 .float stat_leadlimit;
 
 float radar_showennemies;
index 68be349..d27c31a 100644 (file)
@@ -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;
index 6c74ec8..996b89b 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);