]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
new options for r_showbboxes: also show the player headshot box
authorRudolf Polzer <divverent@alientrap.org>
Mon, 10 May 2010 07:31:11 +0000 (09:31 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Mon, 10 May 2010 07:31:11 +0000 (09:31 +0200)
qcsrc/server/cl_client.qc
qcsrc/server/g_damage.qc

index ba363f0c0a273e32914981baea57a9b7fa30cd1c..c5acd3ebf8151dbdc349b9f5a62ea0033960d05f 100644 (file)
@@ -2836,6 +2836,18 @@ Called every frame for each client after the physics are run
 =============
 */
 .float idlekick_lasttimeleft;
+.entity showheadshotbbox;
+void showheadshotbbox_think()
+{
+       if(self.owner.showheadshotbbox != self)
+       {
+               remove(self);
+               return;
+       }
+       self.nextthink = time;
+       setorigin(self, self.owner.origin);
+       setsize(self, GetHeadshotMins(self.owner), GetHeadshotMaxs(self.owner));
+}
 void PlayerPostThink (void)
 {
        // Savage: Check for nameless players
@@ -2937,6 +2949,26 @@ void PlayerPostThink (void)
        if(self.waypointsprite_attachedforcarrier)
                WaypointSprite_UpdateHealth(self.waypointsprite_attachedforcarrier, '1 0 0' * healtharmor_maxdamage(self.health, self.armorvalue, cvar("g_balance_armor_blockpercent")));
        
+       if(self.classname == "player" && self.deadflag == DEAD_NO && cvar("r_showbboxes"))
+       {
+               if(!self.showheadshotbbox)
+               {
+                       self.showheadshotbbox = spawn();
+                       self.showheadshotbbox.classname = "headshotbbox";
+                       self.showheadshotbbox.owner = self;
+                       self.showheadshotbbox.think = showheadshotbbox_think;
+                       self.showheadshotbbox.nextthink = time;
+                       self = self.showheadshotbbox;
+                       self.think();
+                       self = self.owner;
+               }
+       }
+       else
+       {
+               if(self.showheadshotbbox)
+                       remove(self.showheadshotbbox);
+       }
+
        playerdemo_write();
 
        /*
index 0c446484d2a21d753aa8a7f4a744da7cbd529620..505b2e7688a659d890b36faa422a41228ce66c61 100644 (file)
@@ -86,6 +86,15 @@ float IsFlying(entity a)
        return 1;
 }
 
+vector GetHeadshotMins(entity targ)
+{
+       return '0.6 0 0' * targ.mins_x + '0 0.6 0' * targ.mins_y + '0 0 1' * (1.3 * targ.view_ofs_z - 0.3 * targ.maxs_z);
+}
+vector GetHeadshotMaxs(entity targ)
+{
+       return '0.6 0 0' * targ.maxs_x + '0 0.6 0' * targ.maxs_y + '0 0 1' * targ.maxs_z;
+}
+
 void UpdateFrags(entity player, float f)
 {
        PlayerTeamScore_AddScore(player, f);
@@ -872,8 +881,8 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float
                                // if above view_ofs and below maxs, and also in the middle half of the bbox, it is head shot
                                vector headmins, headmaxs, org;
                                org = antilag_takebackorigin(targ, time - ANTILAG_LATENCY(attacker));
-                               headmins = org + '0.6 0 0' * targ.mins_x + '0 0.6 0' * targ.mins_y + '0 0 1' * (1.3 * targ.view_ofs_z - 0.3 * targ.maxs_z);
-                               headmaxs = org + '0.6 0 0' * targ.maxs_x + '0 0.6 0' * targ.maxs_y + '0 0 1' * targ.maxs_z;
+                               headmins = org + GetHeadshotMins(targ);
+                               headmaxs = org + GetHeadshotMaxs(targ);
                                if(trace_hits_box(railgun_start, railgun_end, headmins, headmaxs))
                                {
                                        deathtype |= HITTYPE_HEADSHOT;