]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/waypointsprites.qc
Replace `vector_[xyz]` with `vector.[xyz]` where possible
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / waypointsprites.qc
index f821bd897a290c94281d62fa2f2f7682f6bfdbaa..9390396b8536b6cb821ea8a741c2ff28400da59f 100644 (file)
@@ -31,7 +31,7 @@ float waypointsprite_alpha;
 .float lifetime;
 .float fadetime;
 .float maxdistance;
-.float hideflags;
+.int hideflags;
 .float spawntime;
 .float health;
 .float build_started;
@@ -55,9 +55,9 @@ void drawrotpic(vector org, float rot, string pic, vector sz, vector hotspot, ve
 
        // hotspot-relative coordinates of the corners
        v1 = hotspot;
-       v2 = hotspot + '1 0 0' * sz_x;
-       v3 = hotspot + '1 0 0' * sz_x + '0 1 0' * sz_y;
-       v4 = hotspot                  + '0 1 0' * sz_y;
+       v2 = hotspot + '1 0 0' * sz.x;
+       v3 = hotspot + '1 0 0' * sz.x + '0 1 0' * sz.y;
+       v4 = hotspot                  + '0 1 0' * sz.y;
 
        // rotate them, and make them absolute
        rot = -rot; // rotate by the opposite angle, as our coordinate system is reversed
@@ -103,7 +103,7 @@ void drawhealthbar(vector org, float rot, float h, vector sz, vector hotspot, fl
        up = rotate(up, rot);
 
        owidth = width + 2 * border;
-       o = o - up * (margin + border + height) + ri * (sz_x - owidth) * 0.5;
+       o = o - up * (margin + border + height) + ri * (sz.x - owidth) * 0.5;
 
        drawquad(o - up * border,                               ri * owidth,    up * border, "", rgb,  a,  f);
        drawquad(o + up * height,                               ri * owidth,    up * border, "", rgb,  a,  f);
@@ -115,39 +115,31 @@ void drawhealthbar(vector org, float rot, float h, vector sz, vector hotspot, fl
 // returns location of sprite text
 vector drawspritearrow(vector o, float ang, vector rgb, float a, float t)
 {
-       float SQRT2 = 1.414;
-       float BORDER; BORDER = 1.5 * t;
-       float TSIZE; TSIZE = 8 * t;
-       float RLENGTH; RLENGTH = 8 * t;
-       float RWIDTH; RWIDTH = 4 * t;
-       float MLENGTH; MLENGTH = 4 * t;
+       float size   = 9.0 * t;
+       float border = 1.5 * t;
+       float margin = 4.0 * t;
+
+       float borderDiag = border * 1.414;
+       vector arrowX  = eX * size;
+       vector arrowY  = eY * (size+borderDiag);
+       vector borderX = eX * (size+borderDiag);
+       vector borderY = eY * (size+borderDiag+border);
 
        R_BeginPolygon("", DRAWFLAG_NORMAL);
-       R_PolygonVertex(o + rotate(eX * -(TSIZE + BORDER * (1 + SQRT2)) + eY * (TSIZE + BORDER), ang), '0 0 0', '0 0 0', a);
-       R_PolygonVertex(o + rotate(eX *  (TSIZE + BORDER * (1 + SQRT2)) + eY * (TSIZE + BORDER), ang), '0 0 0', '0 0 0', a);
-       R_PolygonVertex(o + rotate(eY * -(        BORDER *      SQRT2),                          ang), '0 0 0', '0 0 0', a);
-       R_EndPolygon();
-       R_BeginPolygon("", DRAWFLAG_NORMAL);
-       R_PolygonVertex(o + rotate(eX * -(RWIDTH + BORDER) + eY * (TSIZE           + BORDER), ang), '0 0 0', '0 0 0', a);
-       R_PolygonVertex(o + rotate(eX * -(RWIDTH + BORDER) + eY * (TSIZE + RLENGTH + BORDER), ang), '0 0 0', '0 0 0', a);
-       R_PolygonVertex(o + rotate(eX *  (RWIDTH + BORDER) + eY * (TSIZE + RLENGTH + BORDER), ang), '0 0 0', '0 0 0', a);
-       R_PolygonVertex(o + rotate(eX *  (RWIDTH + BORDER) + eY * (TSIZE           + BORDER), ang), '0 0 0', '0 0 0', a);
+       R_PolygonVertex(o,                                  '0 0 0', '0 0 0', a);
+       R_PolygonVertex(o + rotate(arrowY  - borderX, ang), '0 0 0', '0 0 0', a);
+       R_PolygonVertex(o + rotate(borderY - borderX, ang), '0 0 0', '0 0 0', a);
+       R_PolygonVertex(o + rotate(borderY + borderX, ang), '0 0 0', '0 0 0', a);
+       R_PolygonVertex(o + rotate(arrowY  + borderX, ang), '0 0 0', '0 0 0', a);
        R_EndPolygon();
 
        R_BeginPolygon("", DRAWFLAG_ADDITIVE);
-       R_PolygonVertex(o + rotate(eX * -TSIZE + eY * TSIZE, ang), '0 0 0', rgb, a);
-       R_PolygonVertex(o + rotate(eX *  TSIZE + eY * TSIZE, ang), '0 0 0', rgb, a);
-       R_PolygonVertex(o + rotate('0 0 0',                  ang), '0 0 0', rgb, a);
-       R_EndPolygon();
-       R_BeginPolygon("", DRAWFLAG_ADDITIVE);
-       R_PolygonVertex(o + rotate(eX * -RWIDTH + eY *  TSIZE,            ang), '0 0 0', rgb, a);
-       R_PolygonVertex(o + rotate(eX * -RWIDTH + eY * (TSIZE + RLENGTH), ang), '0 0 0', rgb, a);
-       R_PolygonVertex(o + rotate(eX *  RWIDTH + eY * (TSIZE + RLENGTH), ang), '0 0 0', rgb, a);
-       R_PolygonVertex(o + rotate(eX *  RWIDTH + eY *  TSIZE,            ang), '0 0 0', rgb, a);
+       R_PolygonVertex(o + rotate(eY * borderDiag, ang), '0 0 0', rgb, a);
+       R_PolygonVertex(o + rotate(arrowY - arrowX, ang), '0 0 0', rgb, a);
+       R_PolygonVertex(o + rotate(arrowY + arrowX, ang), '0 0 0', rgb, a);
        R_EndPolygon();
 
-       return
-               o + rotate(eY * (TSIZE + RLENGTH + MLENGTH), ang);
+       return o + rotate(eY * (borderDiag+size+margin), ang);
 }
 
 // returns location of sprite healthbar
@@ -162,7 +154,7 @@ vector drawspritetext(vector o, float ang, float minwidth, vector rgb, float a,
                w = sw;
        else
                w = minwidth;
-       h = fontsize_y;
+       h = fontsize.y;
 
        // how do corners work?
        aspect = vid_conwidth / vid_conheight;
@@ -180,25 +172,25 @@ vector drawspritetext(vector o, float ang, float minwidth, vector rgb, float a,
        }
 
        // align
-       o_x -= w * algnx;
-       o_y -= h * algny;
+       o.x -= w * algnx;
+       o.y -= h * algny;
 
        // we want to be onscreen
-       if(o_x < 0)
+       if(o.x < 0)
                o_x = 0;
-       if(o_y < 0)
+       if(o.y < 0)
                o_y = 0;
-       if(o_x > vid_conwidth - w)
+       if(o.x > vid_conwidth - w)
                o_x = vid_conwidth - w;
-       if(o_y > vid_conheight - h)
+       if(o.y > vid_conheight - h)
                o_x = vid_conheight - h;
 
-       o_x += 0.5 * (w - sw);
+       o.x += 0.5 * (w - sw);
 
        drawstring(o, s, fontsize, rgb, a, DRAWFLAG_NORMAL);
 
-       o_x += 0.5 * sw;
-       o_y += 0.5 * h;
+       o.x += 0.5 * sw;
+       o.y += 0.5 * h;
 
        return o;
 }
@@ -225,30 +217,20 @@ float spritelookupblinkvalue(string s)
 }
 vector spritelookupcolor(string s, vector def)
 {
+       if(substring(s, 0, 4) == "wpn-")
+               return (get_weaponinfo(stof(substring(s, 4, strlen(s)))).wpcolor);
+
        switch(s)
        {
                case "keycarrier-friend": return '0 1 0';
-               case "wpn-laser":         return '1 0.5 0.5';
-               case "wpn-shotgun":       return '0.5 0.25 0';
-               case "wpn-uzi":           return '1 1 0';
-               case "wpn-gl":            return '1 0 0';
-               case "wpn-electro":       return '0 0.5 1';
-               case "wpn-crylink":       return '1 0.5 1';
-               case "wpn-nex":           return '0.5 1 1';
-               case "wpn-hagar":         return '1 1 0.5';
-               case "wpn-rl":            return '1 1 0';
-               case "wpn-porto":         return '0.5 0.5 0.5';
-               case "wpn-minstanex":     return '0.5 1 1';
-               case "wpn-hookgun":       return '0 0.5 0';
-               case "wpn-fireball":      return '1 0.5 0';
-               case "wpn-hlac":          return '0 1 0';
-               case "wpn-campingrifle":  return '0.5 1 0';
-               case "wpn-minelayer":     return '0.75 1 0';
                default:                  return def;
        }
 }
 string spritelookuptext(string s)
 {
+       if(substring(s, 0, 4) == "wpn-") { return (get_weaponinfo(stof(substring(s, 4, strlen(s)))).message); }
+       if(substring(s, 0, 5) == "buff-") { return Buff_PrettyName(Buff_Type_FromSprite(s)); }
+
        switch(s)
        {
                case "as-push": return _("Push");
@@ -285,27 +267,10 @@ string spritelookuptext(string s)
                case "race-finish": return _("Finish");
                case "race-start": return _("Start");
                case "race-start-finish": return (race_checkpointtime || race_mycheckpointtime) ? _("Finish") : _("Start");
+               case "goal": return _("Goal");
                case "nb-ball": return _("Ball");
                case "ka-ball": return _("Ball");
                case "ka-ballcarrier": return _("Ball carrier");
-               case "wpn-laser": return _("Laser");
-               case "wpn-shotgun": return _("Shotgun");
-               case "wpn-uzi": return _("Machine Gun");
-               case "wpn-gl": return _("Mortar");
-               case "wpn-electro": return _("Electro");
-               case "wpn-crylink": return _("Crylink");
-               case "wpn-nex": return _("Nex");
-               case "wpn-hagar": return _("Hagar");
-               case "wpn-rl": return _("Rocket Launcher");
-               case "wpn-porto": return _("Port-O-Launch");
-               case "wpn-minstanex": return _("Minstanex");
-               case "wpn-hookgun": return _("Hook");
-               case "wpn-fireball": return _("Fireball");
-               case "wpn-hlac": return _("HLAC");
-               case "wpn-campingrifle": return _("Rifle");
-               case "wpn-minelayer": return _("Mine Layer");
-               case "wpn-ok_hmg": return _("Heavy Machine Gun");
-               case "wpn-ok_rl": return _("Rocket-Propelled Chainsaw");
                case "dom-neut": return _("Control point");
                case "dom-red": return _("Control point");
                case "dom-blue": return _("Control point");
@@ -318,7 +283,7 @@ string spritelookuptext(string s)
                case "item-shield": return _("Shield");
                case "item-fuelregen": return _("Fuel regen");
                case "item-jetpack": return _("Jet Pack");
-               case "freezetag_frozen": return _("Frozen!");
+               case "frozen": return _("Frozen!");
                case "tagged-target": return _("Tagged");
                case "vehicle": return _("Vehicle");
                default: return s;
@@ -332,51 +297,51 @@ vector fixrgbexcess_move(vector rgb, vector src, vector dst)
 }
 vector fixrgbexcess(vector rgb)
 {
-       if(rgb_x > 1)
+       if(rgb.x > 1)
        {
                rgb = fixrgbexcess_move(rgb, '1 0 0', '0 1 1');
-               if(rgb_y > 1)
+               if(rgb.y > 1)
                {
                        rgb = fixrgbexcess_move(rgb, '0 1 0', '0 0 1');
-                       if(rgb_z > 1)
+                       if(rgb.z > 1)
                                rgb_z = 1;
                }
-               else if(rgb_z > 1)
+               else if(rgb.z > 1)
                {
                        rgb = fixrgbexcess_move(rgb, '0 0 1', '0 1 0');
-                       if(rgb_y > 1)
+                       if(rgb.y > 1)
                                rgb_y = 1;
                }
        }
-       else if(rgb_y > 1)
+       else if(rgb.y > 1)
        {
                rgb = fixrgbexcess_move(rgb, '0 1 0', '1 0 1');
-               if(rgb_x > 1)
+               if(rgb.x > 1)
                {
                        rgb = fixrgbexcess_move(rgb, '1 0 0', '0 0 1');
-                       if(rgb_z > 1)
+                       if(rgb.z > 1)
                                rgb_z = 1;
                }
-               else if(rgb_z > 1)
+               else if(rgb.z > 1)
                {
                        rgb = fixrgbexcess_move(rgb, '0 0 1', '1 0 0');
-                       if(rgb_x > 1)
+                       if(rgb.x > 1)
                                rgb_x = 1;
                }
        }
-       else if(rgb_z > 1)
+       else if(rgb.z > 1)
        {
                rgb = fixrgbexcess_move(rgb, '0 0 1', '1 1 0');
-               if(rgb_x > 1)
+               if(rgb.x > 1)
                {
                        rgb = fixrgbexcess_move(rgb, '1 0 0', '0 1 0');
-                       if(rgb_y > 1)
+                       if(rgb.y > 1)
                                rgb_y = 1;
                }
-               else if(rgb_y > 1)
+               else if(rgb.y > 1)
                {
                        rgb = fixrgbexcess_move(rgb, '0 1 0', '1 0 0');
-                       if(rgb_x > 1)
+                       if(rgb.x > 1)
                                rgb_x = 1;
                }
        }
@@ -485,27 +450,27 @@ void Draw_WaypointSprite()
        float ang;
 
        o = project_3d_to_2d(self.origin);
-       if(o_z < 0
-       || o_x < (vid_conwidth * waypointsprite_edgeoffset_left)
-       || o_y < (vid_conheight * waypointsprite_edgeoffset_top)
-       || o_x > (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right))
-       || o_y > (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)))
+       if(o.z < 0
+       || o.x < (vid_conwidth * waypointsprite_edgeoffset_left)
+       || o.y < (vid_conheight * waypointsprite_edgeoffset_top)
+       || o.x > (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right))
+       || o.y > (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)))
        {
                // scale it to be just in view
                vector d;
                float f1, f2;
 
                d = o - '0.5 0 0' * vid_conwidth - '0 0.5 0' * vid_conheight;
-               ang = atan2(-d_x, -d_y);
-               if(o_z < 0)
+               ang = atan2(-d.x, -d.y);
+               if(o.z < 0)
                        ang += M_PI;
 
-               f1 = d_x / vid_conwidth;
-               f2 = d_y / vid_conheight;
+               f1 = d.x / vid_conwidth;
+               f2 = d.y / vid_conheight;
 
                if(max(f1, -f1) > max(f2, -f2))
                {
-                       if(d_z * f1 > 0)
+                       if(d.z * f1 > 0)
                        {
                                // RIGHT edge
                                d = d * ((0.5 - waypointsprite_edgeoffset_right) / f1);
@@ -518,7 +483,7 @@ void Draw_WaypointSprite()
                }
                else
                {
-                       if(d_z * f2 > 0)
+                       if(d.z * f2 > 0)
                        {
                                // BOTTOM edge
                                d = d * ((0.5 - waypointsprite_edgeoffset_bottom) / f2);
@@ -539,21 +504,21 @@ void Draw_WaypointSprite()
 #else
                vector d;
                d = o - '0.5 0 0' * vid_conwidth - '0 0.5 0' * vid_conheight;
-               ang = atan2(-d_x, -d_y);
+               ang = atan2(-d.x, -d.y);
 #endif
        }
        o_z = 0;
 
        float edgedistance_min, crosshairdistance;
-               edgedistance_min = min((o_y - (vid_conheight * waypointsprite_edgeoffset_top)),
-       (o_x - (vid_conwidth * waypointsprite_edgeoffset_left)),
-       (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right)) - o_x,
-       (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)) - o_y);
+               edgedistance_min = min((o.y - (vid_conheight * waypointsprite_edgeoffset_top)),
+       (o.x - (vid_conwidth * waypointsprite_edgeoffset_left)),
+       (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right)) - o.x,
+       (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)) - o.y);
 
        float vidscale;
        vidscale = max(vid_conwidth / vid_width, vid_conheight / vid_height);
 
-       crosshairdistance = sqrt( pow(o_x - vid_conwidth/2, 2) + pow(o_y - vid_conheight/2, 2) );
+       crosshairdistance = sqrt( pow(o.x - vid_conwidth/2, 2) + pow(o.y - vid_conheight/2, 2) );
 
        t = waypointsprite_scale * vidscale;
        a *= waypointsprite_alpha;
@@ -649,7 +614,7 @@ void Ent_RemoveWaypointSprite()
 
 void Ent_WaypointSprite()
 {
-       float sendflags, f, t;
+       int sendflags, f, t;
        sendflags = ReadByte();
 
        if(!self.spawntime)
@@ -736,7 +701,7 @@ void Ent_WaypointSprite()
                if(f & 0x80)
                {
                        self.(teamradar_times[self.teamradar_time_index]) = time;
-                       self.teamradar_time_index = mod(self.teamradar_time_index + 1, MAX_TEAMRADAR_TIMES);
+                       self.teamradar_time_index = (self.teamradar_time_index + 1) % MAX_TEAMRADAR_TIMES;
                }
                self.teamradar_color_x = ReadByte() / 255.0;
                self.teamradar_color_y = ReadByte() / 255.0;