]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/shownames.qc
do some restructuring according to div0s suggestions... now the branch name is accura...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / shownames.qc
1 // self.isactive = player is in range and coordinates/status (health and armor) are up to date
2 // self.origin = player origin TODO: should maybe move this so it's the origin of the shownames tag already in SSQC for culling?
3 // self.healthvalue
4 // self.armorvalue
5 // self.sameteam = player is on same team as local client
6 //
7 void Draw_ShowNames()
8 {
9     if(!autocvar_hud_shownames)
10         return;
11
12     if(self.sameteam || (!self.sameteam && autocvar_hud_shownames_enemies))
13     {
14         float a;
15         a = autocvar_hud_panel_fg_alpha;
16
17         InterpolateOrigin_Do();
18
19         // draw the sprite image
20         vector o;
21         o = project_3d_to_2d(self.origin);
22
23         o_z = 0;
24
25         vector myPos, mySize;
26         mySize = (eX * autocvar_hud_shownames_aspect + eY) * autocvar_hud_shownames_height;
27         myPos = o - '0.5 0 0' * mySize_x - '0 1 0' * mySize_y;
28
29         vector iconpos, iconsize;
30         vector namepos, namesize;
31
32         iconpos = myPos;
33
34         if(autocvar_hud_shownames_status)
35         {
36             if(self.sameteam)
37             {
38                 iconsize = eX * 2 * mySize_y + eY * mySize_y;
39                 // "ghost" backgrounds
40                 drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '0 0 0', a * 0.5, DRAWFLAG_NORMAL);
41                 drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '0 0 0', a * 0.5, DRAWFLAG_NORMAL);
42
43                 drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, self.healthvalue/autocvar_hud_panel_healtharmor_maxhealth), vid_conwidth, myPos_y + iconsize_y);
44                 drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '1 1 1', a, DRAWFLAG_NORMAL);
45
46                 drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, self.armorvalue/autocvar_hud_panel_healtharmor_maxarmor), vid_conwidth, myPos_y + iconsize_y);
47                 drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '1 1 1', a, DRAWFLAG_NORMAL);
48                 drawresetcliparea();
49             }
50             else if(autocvar_hud_shownames_status == 2)
51             {
52                 iconsize = eX * 2 * mySize_y + eY * mySize_y;
53                 drawpic_aspect_skin(iconpos, "health_unknown", '1 1 0' * iconsize_y, '0 0 0', a, DRAWFLAG_NORMAL);
54                 drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor_unknown", '1 1 0' * iconsize_y, '0 0 0', a, DRAWFLAG_NORMAL);
55             }
56         }
57
58         namepos = myPos + eX * 2 * iconsize_y;
59         namesize = eX * mySize_x - eX * 2 * iconsize_y + eY * mySize_y;
60
61         drawcolorcodedstring_aspect(namepos, GetPlayerName(self.the_entnum), namesize, a, DRAWFLAG_NORMAL);
62
63         /* Or maybe a health bar instead?
64          *
65         if(self.health >= 0)
66         {
67             float align;
68             if(self.build_finished)
69                 align = 0.5;
70             else
71                 align = 0;
72             drawhealthbar(o, rot * 90 * DEG2RAD, self.health, SPRITE_SIZE * t, SPRITE_HOTSPOT * t, SPRITE_HEALTHBAR_WIDTH * t, SPRITE_HEALTHBAR_HEIGHT * t, SPRITE_HEALTHBAR_MARGIN * t, SPRITE_HEALTHBAR_BORDER * t, align, self.teamradar_color, a * SPRITE_HEALTHBAR_BORDERALPHA, self.teamradar_color, a * SPRITE_HEALTHBAR_HEALTHALPHA, DRAWFLAG_NORMAL);
73         }
74         */
75     }
76 }
77
78 void ShowNames_Think()
79 {
80
81
82 }