1 #include "teamradar.qh"
5 #include "../common/mutators/mutator/waypoints/all.qh"
7 #include "../lib/csqcmodel/interpolate.qh"
9 vector teamradar_3dcoord_to_texcoord(vector in)
12 out.x = (in.x - mi_picmin.x) / (mi_picmax.x - mi_picmin.x);
13 out.y = (in.y - mi_picmin.y) / (mi_picmax.y - mi_picmin.y);
18 vector teamradar_texcoord_to_2dcoord(vector in)
21 in -= teamradar_origin3d_in_texcoord;
23 out = rotate(in, teamradar_angle * DEG2RAD);
24 out.y = - out.y; // screen space is reversed
26 out = out * teamradar_size;
29 out += teamradar_origin2d;
34 vector teamradar_2dcoord_to_texcoord(vector in)
39 out -= teamradar_origin2d;
42 out = out / teamradar_size;
44 out_y = - out_y; // screen space is reversed
45 out = rotate(out, -teamradar_angle * DEG2RAD);
47 out += teamradar_origin3d_in_texcoord;
52 vector teamradar_texcoord_to_3dcoord(vector in,float z)
55 out_x = in_x * (mi_picmax_x - mi_picmin_x) + mi_picmin_x;
56 out_y = in_y * (mi_picmax_y - mi_picmin_y) + mi_picmin_y;
61 void draw_teamradar_background(float fg)
66 if(fg > 0 && minimapname != "")
70 R_BeginPolygon(minimapname, DRAWFLAG_SCREEN | DRAWFLAG_MIPMAP);
73 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord3), yinvert(mi_pictexcoord3), fgc, fga);
74 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord2), yinvert(mi_pictexcoord2), fgc, fga);
75 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord1), yinvert(mi_pictexcoord1), fgc, fga);
76 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord0), yinvert(mi_pictexcoord0), fgc, fga);
80 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord0), yinvert(mi_pictexcoord0), fgc, fga);
81 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord1), yinvert(mi_pictexcoord1), fgc, fga);
82 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord2), yinvert(mi_pictexcoord2), fgc, fga);
83 R_PolygonVertex(teamradar_texcoord_to_2dcoord(mi_pictexcoord3), yinvert(mi_pictexcoord3), fgc, fga);
89 void draw_teamradar_player(vector coord3d, vector pangles, vector rgb)
93 coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(coord3d));
95 makevectors(pangles - '0 1 0' * teamradar_angle);
98 v_forward.x = -v_forward.x;
99 v_right.x = -v_right.x;
103 v_forward = normalize(v_forward);
105 v_right.x = -v_forward.y;
106 v_right.y = v_forward.x;
113 R_BeginPolygon("", 0);
114 R_PolygonVertex(coord+v_forward*3, '0 0 0', rgb2, panel_fg_alpha);
115 R_PolygonVertex(coord+v_right*4-v_forward*2.5, '0 1 0', rgb2, panel_fg_alpha);
116 R_PolygonVertex(coord-v_forward*2, '1 0 0', rgb2, panel_fg_alpha);
117 R_PolygonVertex(coord-v_right*4-v_forward*2.5, '1 1 0', rgb2, panel_fg_alpha);
120 R_BeginPolygon("", 0);
121 R_PolygonVertex(coord+v_forward*2, '0 0 0', rgb, panel_fg_alpha);
122 R_PolygonVertex(coord+v_right*3-v_forward*2, '0 1 0', rgb, panel_fg_alpha);
123 R_PolygonVertex(coord-v_forward, '1 0 0', rgb, panel_fg_alpha);
124 R_PolygonVertex(coord-v_right*3-v_forward*2, '1 1 0', rgb, panel_fg_alpha);
128 void draw_teamradar_icon(vector coord, entity icon, entity pingdata, vector rgb, float a)
130 coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(coord));
131 drawpic(coord - '4 4 0', strcat("gfx/teamradar_icon_", ftos(icon.m_radaricon)), '8 8 0', rgb, a, 0);
135 for(int i = 0; i < MAX_TEAMRADAR_TIMES; ++i)
137 float dt = pingdata.(teamradar_times[i]);
141 if(dt >= 1 || dt <= 0)
143 vector v = '2 2 0' * teamradar_size * dt;
144 drawpic(coord - 0.5 * v, "gfx/teamradar_ping", v, '1 1 1', (1 - dt) * a, DRAWFLAG_ADDITIVE);
149 void draw_teamradar_link(vector start, vector end, int colors)
153 start = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(start));
154 end = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(end));
155 norm = normalize(start - end);
161 c0 = colormapPaletteColor(colors & 0x0F, false);
162 c1 = colormapPaletteColor((colors & 0xF0) / 0x10, false);
164 R_BeginPolygon("", 0);
165 R_PolygonVertex(start - norm, '0 0 0', c0, panel_fg_alpha);
166 R_PolygonVertex(start + norm, '0 1 0', c0, panel_fg_alpha);
167 R_PolygonVertex(end + norm, '1 1 0', c1, panel_fg_alpha);
168 R_PolygonVertex(end - norm, '1 0 0', c1, panel_fg_alpha);
172 void teamradar_loadcvars()
174 v_flipped = autocvar_v_flipped;
175 hud_panel_radar_scale = autocvar_hud_panel_radar_scale;
176 if (hud_panel_radar_maximized && !autocvar__hud_configure)
178 if (autocvar_hud_panel_radar_maximized_scale > 0)
179 hud_panel_radar_scale = autocvar_hud_panel_radar_maximized_scale;
181 hud_panel_radar_foreground_alpha = autocvar_hud_panel_radar_foreground_alpha * panel_fg_alpha;
182 hud_panel_radar_rotation = autocvar_hud_panel_radar_rotation;
183 hud_panel_radar_zoommode = autocvar_hud_panel_radar_zoommode;
184 hud_panel_radar_maximized_rotation = autocvar_hud_panel_radar_maximized_rotation;
185 hud_panel_radar_maximized_zoommode = autocvar_hud_panel_radar_maximized_zoommode;
187 // others default to 0
188 // match this to defaultXonotic.cfg!
189 if(!hud_panel_radar_scale) hud_panel_radar_scale = 4096;
190 if(!hud_panel_radar_foreground_alpha) hud_panel_radar_foreground_alpha = 0.8 * panel_fg_alpha;
191 if(!hud_panel_radar_size.x) hud_panel_radar_size.x = 128;
192 if(!hud_panel_radar_size.y) hud_panel_radar_size.y = hud_panel_radar_size.x;
197 NET_HANDLE(ENT_CLIENT_RADARLINK, bool isnew)
199 int sendflags = ReadByte();
201 InterpolateOrigin_Undo(self);
203 self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN;
204 self.classname = "radarlink";
208 self.origin_x = ReadCoord();
209 self.origin_y = ReadCoord();
210 self.origin_z = ReadCoord();
211 setorigin(self, self.origin);
216 self.velocity_x = ReadCoord();
217 self.velocity_y = ReadCoord();
218 self.velocity_z = ReadCoord();
223 self.team = ReadByte();
228 InterpolateOrigin_Note(this);