]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_player.qc
Merge remote-tracking branch 'origin/terencehill/newpanelhud' into fruitiex/panelhud
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_player.qc
index 5f0a08ef78eeddd1d590103222942f86f7b36cbf..3e507f4ab644b2bb25f1d2eced3a7a3363e4b178 100644 (file)
@@ -188,6 +188,7 @@ void player_setupanimsformodel()
        self.anim_forwardleft = '20 1 1';
        self.anim_backright = '21 1 1';
        self.anim_backleft  = '22 1 1';
+       self.anim_melee = '23 1 1';
        animparseerror = FALSE;
        animfilename = strcat(self.model, ".animinfo");
        animfile = fopen(animfilename, FILE_READ);
@@ -214,6 +215,7 @@ void player_setupanimsformodel()
                self.anim_forwardleft  = animparseline(animfile);
                self.anim_backright    = animparseline(animfile);
                self.anim_backleft     = animparseline(animfile);
+               self.anim_melee        = animparseline(animfile);
                fclose(animfile);
 
                // derived anims
@@ -625,6 +627,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
                frag_inflictor = inflictor;
                frag_target = self;
                MUTATOR_CALLHOOK(PlayerDies);
+               weapon_action(self.weapon, WR_PLAYERDEATH);
 
                if(self.flagcarried)
                {
@@ -732,21 +735,22 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
        }
 }
 
-.float the_entnum;
-// sendflags use: 1 = origin, 2 = health/armor, 0x80 = same team (includes health)
+// sendflags use: 1 = origin, 2 = health (0 or 1 for dead/alive on enemies), 4 = armor, 0x80 = same team (includes health)
 float SendEntity_ShowNames(entity to, float sendflags)
 {
-    if(vlen(to.origin - self.origin) < autocvar_sv_shownames_cull_distance) // distance cull
-        return FALSE;
+    float the_health;
+    the_health = self.health;
 
     WriteByte(MSG_ENTITY, ENT_CLIENT_SHOWNAMES);
+    WriteByte(MSG_ENTITY, num_for_edict(self.owner));
+
     sendflags = sendflags & 127;
     if(teams_matter && self.owner.team == to.team)
         sendflags |= 128;
-    else
-        sendflags &~= 2;
+    else if(self.owner.health >= 1)
+        the_health = 1;
+
     WriteByte(MSG_ENTITY, sendflags);
-    WriteByte(MSG_ENTITY, self.the_entnum);
     if(sendflags & 1)
     {
         WriteShort(MSG_ENTITY, rint(self.origin_x));
@@ -755,32 +759,48 @@ float SendEntity_ShowNames(entity to, float sendflags)
     }
     if(sendflags & 2)
     {
-        WriteByte(MSG_ENTITY, self.health);
+        WriteByte(MSG_ENTITY, the_health);
+    }
+    if(sendflags & 4)
+    {
         WriteByte(MSG_ENTITY, self.armorvalue);
     }
     return TRUE;
 }
 
+const vector SHOWNAMES_ORIGIN_OFFSET = '0 0 48';
 void shownames_think()
 {
-    if(self.origin != self.owner.origin)
+    if(self.origin - SHOWNAMES_ORIGIN_OFFSET != self.owner.origin)
     {
-        setorigin(self, self.owner.origin);
+        setorigin(self, self.owner.origin + SHOWNAMES_ORIGIN_OFFSET);
         self.SendFlags |= 1;
     }
-    if(self.health != floor(self.owner.health) || self.armorvalue != floor(self.owner.armorvalue))
+    if(self.health != max(0, floor(self.owner.health)) || self.armorvalue != max(0, floor(self.owner.armorvalue)))
     {
-        self.health = floor(self.owner.health);
-        self.armorvalue = floor(self.owner.armorvalue);
+        self.health = max(0, floor(self.owner.health));
+        self.armorvalue = max(0, floor(self.owner.armorvalue));
         self.SendFlags |= 2;
     }
-    if(self.the_entnum != num_for_edict(self.owner))
+    if(self.armorvalue != max(0, floor(self.owner.armorvalue)))
     {
-        self.the_entnum = num_for_edict(self.owner);
+        self.armorvalue = max(0, floor(self.owner.armorvalue));
+        self.SendFlags |= 4;
     }
     self.nextthink = time;
 }
 
+float shownames_customize()
+{
+    if(self.owner.classname == "player") // only send players, no spectators!
+    if(self.owner != other) // no need to spam own coordinates
+    if(vlen(other.origin - self.origin) < autocvar_sv_shownames_cull_distance) // distance cull
+    if(self.owner.team == other.team || (self.owner.team != other.team && checkpvs(self.origin, other)))
+        return TRUE;
+
+    return FALSE;
+}
+
 .float muted; // to be used by prvm_edictset server playernumber muted 1
 float Say(entity source, float teamsay, entity privatesay, string msgin, float floodcontrol)
 // message "": do not say, just test flood control