Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
teamradar.qc
Go to the documentation of this file.
1#include "teamradar.qh"
2
3#include <client/hud/_mod.qh>
4#include <client/view.qh>
7
9{
10 vector out;
11 out.x = (in.x - mi_picmin.x) / (mi_picmax.x - mi_picmin.x);
12 out.y = (in.y - mi_picmin.y) / (mi_picmax.y - mi_picmin.y);
13 out.z = 0;
14 return out;
15}
16
18{
20
21 vector out = Rotate(in, teamradar_angle);
22 out.y = -out.y; // screen space is reversed
23
24 out *= teamradar_size;
25 if(v_flipped)
26 out.x = -out.x;
27 out += teamradar_origin2d;
28 return out;
29}
30
32{
33 vector out = in;
34
35 out -= teamradar_origin2d;
36 if(v_flipped)
37 out.x = -out.x;
38 out /= teamradar_size;
39
40 out.y = -out.y; // screen space is reversed
41 out = Rotate(out, -teamradar_angle);
42
44
45 return out;
46}
47
49{
50 vector out;
51 out.x = in.x * (mi_picmax.x - mi_picmin.x) + mi_picmin.x;
52 out.y = in.y * (mi_picmax.y - mi_picmin.y) + mi_picmin.y;
53 out.z = oz;
54 return out;
55}
56
58{
59 if(fg > 0 && minimapname != "")
60 {
61 vector fgc = '1 1 1' * fg;
62 float fga = 1;
63 R_BeginPolygon(minimapname, DRAWFLAG_SCREEN | DRAWFLAG_MIPMAP, true);
64 if(v_flipped)
65 {
70 }
71 else
72 {
77 }
78 R_EndPolygon();
79 }
80}
81
82void draw_teamradar_player(vector coord3d, vector pangles, vector rgb)
83{
85
86 vector forward, right, up;
87 MAKE_VECTORS(pangles - '0 1 0' * (teamradar_angle * RAD2DEG), forward, right, up);
88 if(v_flipped)
89 {
90 forward.x = -forward.x;
91 right.x = -right.x;
92 up.x = -up.x; // TODO: unused!
93 }
94 forward.z = 0;
95 forward = normalize(forward);
96 forward.y *= -1.0;
97 right.x = -forward.y;
98 right.y = forward.x;
99
100 vector rgb2;
101 if(rgb == '1 1 1')
102 rgb2 = '0 0 0';
103 else
104 rgb2 = '1 1 1';
105
106 R_BeginPolygon("", 0, true);
107 R_PolygonVertex(coord+forward*3, '0 0 0', rgb2, panel_fg_alpha);
108 R_PolygonVertex(coord+right*4-forward*2.5, '0 1 0', rgb2, panel_fg_alpha);
109 R_PolygonVertex(coord-forward*2, '1 0 0', rgb2, panel_fg_alpha);
110 R_PolygonVertex(coord-right*4-forward*2.5, '1 1 0', rgb2, panel_fg_alpha);
111 R_EndPolygon();
112
113 R_BeginPolygon("", 0, true);
114 R_PolygonVertex(coord+forward*2, '0 0 0', rgb, panel_fg_alpha);
115 R_PolygonVertex(coord+right*3-forward*2, '0 1 0', rgb, panel_fg_alpha);
116 R_PolygonVertex(coord-forward, '1 0 0', rgb, panel_fg_alpha);
117 R_PolygonVertex(coord-right*3-forward*2, '1 1 0', rgb, panel_fg_alpha);
118 R_EndPolygon();
119}
120
121void draw_teamradar_icon(vector coord, entity icon, entity pingdata, vector rgb, float a)
122{
124 drawpic_builtin(coord - '4 4 0', strcat("gfx/teamradar_icon_", ftos(icon.m_radaricon)), '8 8 0', rgb, a, 0);
125
126 if(pingdata)
127 {
128 for(int i = 0; i < MAX_TEAMRADAR_TIMES; ++i)
129 {
130 float dt = pingdata.(teamradar_times[i]);
131 if(dt == 0)
132 continue;
133 dt = time - dt;
134 if(dt >= 1 || dt <= 0)
135 continue;
136 vector v = '2 2 0' * teamradar_size * dt;
137 drawpic_builtin(coord - 0.5 * v, "gfx/teamradar_ping", v, '1 1 1', (1 - dt) * a, DRAWFLAG_ADDITIVE);
138 }
139 }
140}
141
142void draw_teamradar_link(vector start, vector end, int colors)
143{
144 TC(int, colors);
145
148 vector norm = normalize(start - end);
149 norm.z = norm.x;
150 norm.x = -norm.y;
151 norm.y = norm.z;
152 norm.z = 0;
153
154 vector c0 = colormapPaletteColor(colors & 0x0F, false);
155 vector c1 = colormapPaletteColor((colors & 0xF0) / 0x10, false);
156
157 R_BeginPolygon("", 0, true);
158 R_PolygonVertex(start - norm, '0 0 0', c0, panel_fg_alpha);
159 R_PolygonVertex(start + norm, '0 1 0', c0, panel_fg_alpha);
160 R_PolygonVertex(end + norm, '1 1 0', c1, panel_fg_alpha);
161 R_PolygonVertex(end - norm, '1 0 0', c1, panel_fg_alpha);
162 R_EndPolygon();
163}
164
187
188// radar links
189
190NET_HANDLE(ENT_CLIENT_RADARLINK, bool isnew)
191{
192 int sendflags = ReadByte();
193
195
197 if (isnew) IL_PUSH(g_radarlinks, this);
198
199 if(sendflags & 1)
200 {
201 this.origin = ReadVector();
202 setorigin(this, this.origin);
203 }
204
205 if(sendflags & 2)
206 {
207 this.velocity = ReadVector();
208 }
209
210 if(sendflags & 4)
211 {
212 this.team = ReadByte();
213 }
214
215 return = true;
216
218}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
IntrusiveList g_radarlinks
Definition main.qh:94
int team
Definition main.qh:188
string minimapname
Definition main.qh:40
#define colormapPaletteColor(c, isPants)
Definition color.qh:5
vector mi_picmin
Definition util.qh:131
vector mi_pictexcoord2
Definition util.qh:135
vector mi_pictexcoord3
Definition util.qh:136
vector mi_pictexcoord0
Definition util.qh:133
vector mi_picmax
Definition util.qh:132
vector mi_pictexcoord1
Definition util.qh:134
float RAD2DEG
const float DRAWFLAG_ADDITIVE
vector velocity
const float DRAWFLAG_SCREEN
float time
vector origin
const float DRAWFLAG_MIPMAP
#define MAKE_VECTORS(angles, forward, right, up)
Same as the makevectors builtin but uses the provided locals instead of the v_* globals.
float panel_fg_alpha
Definition hud.qh:169
bool hud_panel_radar_maximized
Definition hud.qh:70
bool autocvar__hud_configure
Definition hud_config.qh:3
void InterpolateOrigin_Undo(entity this)
snap origin to iorigin2 (actual origin)
void InterpolateOrigin_Note(entity this)
const int IFLAG_VELOCITY
const int IFLAG_ORIGIN
int iflags
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define TC(T, sym)
Definition _all.inc:82
#define NET_HANDLE(id, param)
Definition net.qh:15
#define ReadVector()
Definition net.qh:350
int ReadByte()
vector normalize(vector v)
string ftos(float f)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
float autocvar_hud_panel_radar_foreground_alpha
Definition radar.qh:6
float autocvar_hud_panel_radar_rotation
Definition radar.qh:9
float autocvar_hud_panel_radar_scale
Definition radar.qh:10
float autocvar_hud_panel_radar_maximized_rotation
Definition radar.qh:12
int autocvar_hud_panel_radar_maximized_zoommode
Definition radar.qh:13
int autocvar_hud_panel_radar_zoommode
Definition radar.qh:11
float autocvar_hud_panel_radar_maximized_scale
Definition radar.qh:7
vector
Definition self.qh:92
vector teamradar_texcoord_to_3dcoord(vector in, float oz)
Definition teamradar.qc:48
void draw_teamradar_player(vector coord3d, vector pangles, vector rgb)
Definition teamradar.qc:82
void draw_teamradar_background(float fg)
Definition teamradar.qc:57
vector teamradar_3dcoord_to_texcoord(vector in)
Definition teamradar.qc:8
vector teamradar_texcoord_to_2dcoord(vector in)
Definition teamradar.qc:17
void draw_teamradar_icon(vector coord, entity icon, entity pingdata, vector rgb, float a)
Definition teamradar.qc:121
void teamradar_loadcvars()
Definition teamradar.qc:165
vector teamradar_2dcoord_to_texcoord(vector in)
Definition teamradar.qc:31
void draw_teamradar_link(vector start, vector end, int colors)
Definition teamradar.qc:142
const int MAX_TEAMRADAR_TIMES
Definition teamradar.qh:3
float v_flipped
Definition teamradar.qh:18
vector hud_panel_radar_size
Definition teamradar.qh:23
int hud_panel_radar_maximized_rotation
Definition teamradar.qh:26
int hud_panel_radar_zoommode
Definition teamradar.qh:24
int hud_panel_radar_maximized_zoommode
Definition teamradar.qh:25
float teamradar_size
Definition teamradar.qh:17
int hud_panel_radar_rotation
Definition teamradar.qh:22
float hud_panel_radar_scale
Definition teamradar.qh:20
vector teamradar_origin2d
Definition teamradar.qh:14
float teamradar_angle
Definition teamradar.qh:12
vector teamradar_origin3d_in_texcoord
Definition teamradar.qh:13
float hud_panel_radar_foreground_alpha
Definition teamradar.qh:21
#define yinvert(v)
Definition vector.qh:115
ERASEABLE vector Rotate(vector v, float a)
Definition vector.qh:105
bool autocvar_v_flipped
Definition view.qh:73