Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
teamradar.qc File Reference
Include dependency graph for teamradar.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void draw_teamradar_background (float fg)
void draw_teamradar_icon (vector coord, entity icon, entity pingdata, vector rgb, float a)
void draw_teamradar_link (vector start, vector end, int colors)
void draw_teamradar_player (vector coord3d, vector pangles, vector rgb)
 NET_HANDLE (ENT_CLIENT_RADARLINK, bool isnew)
vector teamradar_2dcoord_to_texcoord (vector in)
vector teamradar_3dcoord_to_texcoord (vector in)
void teamradar_loadcvars ()
vector teamradar_texcoord_to_2dcoord (vector in)
vector teamradar_texcoord_to_3dcoord (vector in, float oz)

Function Documentation

◆ draw_teamradar_background()

void draw_teamradar_background ( float fg)

Definition at line 59 of file teamradar.qc.

60{
61 float fga;
62 vector fgc;
63
64 if(fg > 0 && minimapname != "")
65 {
66 fga = 1;
67 fgc = '1 1 1' * fg;
68 R_BeginPolygon(minimapname, DRAWFLAG_SCREEN | DRAWFLAG_MIPMAP, true);
69 if(v_flipped)
70 {
75 }
76 else
77 {
82 }
83 R_EndPolygon();
84 }
85}
string minimapname
Definition main.qh:40
vector mi_pictexcoord2
Definition util.qh:135
vector mi_pictexcoord3
Definition util.qh:136
vector mi_pictexcoord0
Definition util.qh:133
vector mi_pictexcoord1
Definition util.qh:134
const float DRAWFLAG_SCREEN
const float DRAWFLAG_MIPMAP
vector
Definition self.qh:92
vector teamradar_texcoord_to_2dcoord(vector in)
Definition teamradar.qc:17
float v_flipped
Definition teamradar.qh:18
#define yinvert(v)
Definition vector.qh:115

References DRAWFLAG_MIPMAP, DRAWFLAG_SCREEN, mi_pictexcoord0, mi_pictexcoord1, mi_pictexcoord2, mi_pictexcoord3, minimapname, teamradar_texcoord_to_2dcoord(), v_flipped, vector, and yinvert.

Referenced by HUD_Radar().

◆ draw_teamradar_icon()

void draw_teamradar_icon ( vector coord,
entity icon,
entity pingdata,
vector rgb,
float a )

Definition at line 127 of file teamradar.qc.

128{
130 drawpic_builtin(coord - '4 4 0', strcat("gfx/teamradar_icon_", ftos(icon.m_radaricon)), '8 8 0', rgb, a, 0);
131
132 if(pingdata)
133 {
134 for(int i = 0; i < MAX_TEAMRADAR_TIMES; ++i)
135 {
136 float dt = pingdata.(teamradar_times[i]);
137 if(dt == 0)
138 continue;
139 dt = time - dt;
140 if(dt >= 1 || dt <= 0)
141 continue;
142 vector v = '2 2 0' * teamradar_size * dt;
143 drawpic_builtin(coord - 0.5 * v, "gfx/teamradar_ping", v, '1 1 1', (1 - dt) * a, DRAWFLAG_ADDITIVE);
144 }
145 }
146}
const float DRAWFLAG_ADDITIVE
float time
string ftos(float f)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
vector teamradar_3dcoord_to_texcoord(vector in)
Definition teamradar.qc:8
const int MAX_TEAMRADAR_TIMES
Definition teamradar.qh:3
float teamradar_size
Definition teamradar.qh:17

References DRAWFLAG_ADDITIVE, entity(), ftos(), MAX_TEAMRADAR_TIMES, strcat(), teamradar_3dcoord_to_texcoord(), teamradar_size, teamradar_texcoord_to_2dcoord(), time, and vector.

Referenced by HUD_Radar().

◆ draw_teamradar_link()

void draw_teamradar_link ( vector start,
vector end,
int colors )

Definition at line 148 of file teamradar.qc.

149{
150 TC(int, colors);
151 vector c0, c1, norm;
152
155 norm = normalize(start - end);
156 norm.z = norm.x;
157 norm.x = -norm.y;
158 norm.y = norm.z;
159 norm.z = 0;
160
161 c0 = colormapPaletteColor(colors & 0x0F, false);
162 c1 = colormapPaletteColor((colors & 0xF0) / 0x10, false);
163
164 R_BeginPolygon("", 0, true);
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);
169 R_EndPolygon();
170}
#define colormapPaletteColor(c, isPants)
Definition color.qh:5
float panel_fg_alpha
Definition hud.qh:169
#define TC(T, sym)
Definition _all.inc:82
vector normalize(vector v)

References colormapPaletteColor, normalize(), panel_fg_alpha, TC, teamradar_3dcoord_to_texcoord(), teamradar_texcoord_to_2dcoord(), and vector.

Referenced by HUD_Radar().

◆ draw_teamradar_player()

void draw_teamradar_player ( vector coord3d,
vector pangles,
vector rgb )

Definition at line 87 of file teamradar.qc.

88{
89 vector coord, rgb2;
90
92
93 vector forward, right, up;
94 MAKE_VECTORS(pangles - '0 1 0' * (teamradar_angle * RAD2DEG), forward, right, up);
95 if(v_flipped)
96 {
97 forward.x = -forward.x;
98 right.x = -right.x;
99 up.x = -up.x; // TODO: unused!
100 }
101 forward.z = 0;
102 forward = normalize(forward);
103 forward.y *= -1.0;
104 right.x = -forward.y;
105 right.y = forward.x;
106
107 if(rgb == '1 1 1')
108 rgb2 = '0 0 0';
109 else
110 rgb2 = '1 1 1';
111
112 R_BeginPolygon("", 0, true);
113 R_PolygonVertex(coord+forward*3, '0 0 0', rgb2, panel_fg_alpha);
114 R_PolygonVertex(coord+right*4-forward*2.5, '0 1 0', rgb2, panel_fg_alpha);
115 R_PolygonVertex(coord-forward*2, '1 0 0', rgb2, panel_fg_alpha);
116 R_PolygonVertex(coord-right*4-forward*2.5, '1 1 0', rgb2, panel_fg_alpha);
117 R_EndPolygon();
118
119 R_BeginPolygon("", 0, true);
120 R_PolygonVertex(coord+forward*2, '0 0 0', rgb, panel_fg_alpha);
121 R_PolygonVertex(coord+right*3-forward*2, '0 1 0', rgb, panel_fg_alpha);
122 R_PolygonVertex(coord-forward, '1 0 0', rgb, panel_fg_alpha);
123 R_PolygonVertex(coord-right*3-forward*2, '1 1 0', rgb, panel_fg_alpha);
124 R_EndPolygon();
125}
float RAD2DEG
#define MAKE_VECTORS(angles, forward, right, up)
Same as the makevectors builtin but uses the provided locals instead of the v_* globals.
float teamradar_angle
Definition teamradar.qh:12

References MAKE_VECTORS, normalize(), panel_fg_alpha, RAD2DEG, teamradar_3dcoord_to_texcoord(), teamradar_angle, teamradar_texcoord_to_2dcoord(), v_flipped, and vector.

◆ NET_HANDLE()

NET_HANDLE ( ENT_CLIENT_RADARLINK ,
bool isnew )

Definition at line 197 of file teamradar.qc.

198{
199 int sendflags = ReadByte();
200
202
204 if (isnew) IL_PUSH(g_radarlinks, this);
205
206 if(sendflags & 1)
207 {
208 this.origin = ReadVector();
209 setorigin(this, this.origin);
210 }
211
212 if(sendflags & 2)
213 {
214 this.velocity = ReadVector();
215 }
216
217 if(sendflags & 4)
218 {
219 this.team = ReadByte();
220 }
221
222 return = true;
223
225}
IntrusiveList g_radarlinks
Definition main.qh:94
int team
Definition main.qh:188
vector velocity
vector origin
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 ReadVector()
Definition net.qh:367
int ReadByte()

References g_radarlinks, IFLAG_ORIGIN, IFLAG_VELOCITY, iflags, IL_PUSH(), InterpolateOrigin_Note(), InterpolateOrigin_Undo(), origin, ReadByte(), ReadVector, team, and velocity.

◆ teamradar_2dcoord_to_texcoord()

vector teamradar_2dcoord_to_texcoord ( vector in)

Definition at line 32 of file teamradar.qc.

33{
34 vector out;
35 out = in;
36
37 out -= teamradar_origin2d;
38 if(v_flipped)
39 out.x = -out.x;
40 out /= teamradar_size;
41
42 out_y = -out.y; // screen space is reversed
43 out = Rotate(out, -teamradar_angle);
44
46
47 return out;
48}
vector teamradar_origin2d
Definition teamradar.qh:14
vector teamradar_origin3d_in_texcoord
Definition teamradar.qh:13
ERASEABLE vector Rotate(vector v, float a)
Definition vector.qh:105

References Rotate(), teamradar_angle, teamradar_origin2d, teamradar_origin3d_in_texcoord, teamradar_size, v_flipped, and vector.

Referenced by HUD_Radar_Mouse().

◆ teamradar_3dcoord_to_texcoord()

vector teamradar_3dcoord_to_texcoord ( vector in)

Definition at line 8 of file teamradar.qc.

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}
vector mi_picmin
Definition util.qh:131
vector mi_picmax
Definition util.qh:132

References mi_picmax, mi_picmin, and vector.

Referenced by draw_teamradar_icon(), draw_teamradar_link(), draw_teamradar_player(), and HUD_Radar().

◆ teamradar_loadcvars()

void teamradar_loadcvars ( )

Definition at line 172 of file teamradar.qc.

173{
177 {
180 }
186
187 // others default to 0
188 // match this to default hud cfg file!
193}
bool hud_panel_radar_maximized
Definition hud.qh:70
bool autocvar__hud_configure
Definition hud_config.qh:3
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 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
int hud_panel_radar_rotation
Definition teamradar.qh:22
float hud_panel_radar_scale
Definition teamradar.qh:20
float hud_panel_radar_foreground_alpha
Definition teamradar.qh:21
bool autocvar_v_flipped
Definition view.qh:73

References autocvar__hud_configure, autocvar_hud_panel_radar_foreground_alpha, autocvar_hud_panel_radar_maximized_rotation, autocvar_hud_panel_radar_maximized_scale, autocvar_hud_panel_radar_maximized_zoommode, autocvar_hud_panel_radar_rotation, autocvar_hud_panel_radar_scale, autocvar_hud_panel_radar_zoommode, autocvar_v_flipped, hud_panel_radar_foreground_alpha, hud_panel_radar_maximized, hud_panel_radar_maximized_rotation, hud_panel_radar_maximized_zoommode, hud_panel_radar_rotation, hud_panel_radar_scale, hud_panel_radar_size, hud_panel_radar_zoommode, panel_fg_alpha, and v_flipped.

Referenced by HUD_Radar().

◆ teamradar_texcoord_to_2dcoord()

vector teamradar_texcoord_to_2dcoord ( vector in)

Definition at line 17 of file teamradar.qc.

18{
19 vector out;
21
22 out = Rotate(in, teamradar_angle);
23 out.y = -out.y; // screen space is reversed
24
25 out *= teamradar_size;
26 if(v_flipped)
27 out.x = -out.x;
28 out += teamradar_origin2d;
29 return out;
30}

References Rotate(), teamradar_angle, teamradar_origin2d, teamradar_origin3d_in_texcoord, teamradar_size, v_flipped, and vector.

Referenced by draw_teamradar_background(), draw_teamradar_icon(), draw_teamradar_link(), and draw_teamradar_player().

◆ teamradar_texcoord_to_3dcoord()

vector teamradar_texcoord_to_3dcoord ( vector in,
float oz )

Definition at line 50 of file teamradar.qc.

51{
52 vector out;
53 out.x = in.x * (mi_picmax.x - mi_picmin.x) + mi_picmin.x;
54 out.y = in.y * (mi_picmax.y - mi_picmin.y) + mi_picmin.y;
55 out.z = oz;
56 return out;
57}

References mi_picmax, mi_picmin, and vector.

Referenced by HUD_Radar_Mouse().