1 float angles_held_status[24];
\r
2 vector angles_held[24];
\r
3 void Net_ReadHoldAngles()
\r
9 angles_held_status[wpn] = ReadByte();
\r
10 if(angles_held_status[wpn])
\r
15 angles_held[wpn] = v;
\r
22 vector v0, v1, v2, dir, ang;
\r
24 if(activeweapon != WEP_PORTO)
\r
29 if(angles_held_status[WEP_PORTO-1])
\r
31 makevectors(angles_held[WEP_PORTO-1]);
\r
36 traceline(v0, v0 + 65536 * dir, TRUE, world);
\r
37 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
\r
41 dir = dir - 2 * (dir * trace_plane_normal) * trace_plane_normal; // mirror dir at trace_plane_normal
\r
43 ang = vectoangles(trace_plane_normal, dir);
\r
46 if(!CheckWireframeBox(porto, v1 - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward))
\r
49 traceline(v1, v1 + 65536 * dir, TRUE, world);
\r
50 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
\r
54 ang = vectoangles(trace_plane_normal, -1 * dir);
\r
57 if(!CheckWireframeBox(porto, v2 - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward))
\r
60 Draw_CylindricLine(v1, v2, 4, "", 1, 0, '1 0 0', 0.5, DRAWFLAG_NORMAL);
\r
62 float DPCONTENTS_SOLID = 1; // hit a bmodel, not a bounding box
\r
63 float DPCONTENTS_BODY = 32; // hit a bounding box, not a bmodel
\r
64 float DPCONTENTS_PLAYERCLIP = 256; // blocks player movement
\r
68 porto.classname = "porto";
\r
69 porto.draw = Porto_Draw;
\r
70 porto.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
\r
77 return sin(x) / cos(x);
\r
79 float atan2(float y, float x)
\r
82 v = '1 0 0' * x + '0 1 0' * y;
\r
84 return v_y * 0.01745329251994329576;
\r
87 vector GetCurrentFov(float fov)
\r
89 float zoomsensitivity, zoomspeed, zoomfactor, zoomdir;
\r
91 zoomsensitivity = cvar("cl_zoomsensitivity");
\r
92 zoomfactor = cvar("cl_zoomfactor");
\r
93 if(zoomfactor < 1 || zoomfactor > 16)
\r
95 zoomspeed = cvar("cl_zoomspeed");
\r
97 if(zoomspeed < 0.5 || zoomspeed > 16)
\r
100 zoomdir = button_zoom;
\r
101 if(activeweapon == WEP_NEX)
\r
102 zoomdir += button_attack2;
\r
103 if(spectatee_status > 0 || isdemo())
\r
105 if(spectatorbutton_zoom)
\r
106 zoomdir = 0 + !zoomdir;
\r
107 // do not even THINK about removing this 0
\r
108 // _I_ know what I am doing
\r
117 current_viewzoom = min(1, current_viewzoom + drawframetime);
\r
121 if(zoomspeed < 0) // instant zoom
\r
124 current_viewzoom = 1 / zoomfactor;
\r
126 current_viewzoom = 1;
\r
131 current_viewzoom = 1 / bound(1, 1 / current_viewzoom + drawframetime * zoomspeed * (zoomfactor - 1), zoomfactor);
\r
133 current_viewzoom = bound(1 / zoomfactor, current_viewzoom + drawframetime * zoomspeed * (1 - 1 / zoomfactor), 1);
\r
137 if(zoomsensitivity < 1)
\r
138 setsensitivityscale(pow(current_viewzoom, 1 - zoomsensitivity));
\r
140 setsensitivityscale(1);
\r
142 float frustumx, frustumy, fovx, fovy;
\r
143 frustumy = tan(fov * 0.00872664625997164788) * 0.75 * current_viewzoom;
\r
144 frustumx = frustumy * cvar("vid_width") / cvar("vid_height") / cvar("vid_pixelheight");
\r
145 fovx = atan2(frustumx, 1) / 0.00872664625997164788;
\r
146 fovy = atan2(frustumy, 1) / 0.00872664625997164788;
\r
148 return '1 0 0' * fovx + '0 1 0' * fovy;
\r
151 void CSQC_common_hud(void);
\r
153 void CSQC_kh_hud(void);
\r
154 void CSQC_ctf_hud(void);
\r
155 void PostInit(void);
\r
156 float Sbar_WouldDrawScoreboard ();
\r
157 float zoomscript_caught;
\r
158 void CSQC_UpdateView(void)
\r
163 drawframetime = max(0.000001, time - drawtime);
\r
166 // watch for gametype changes here...
\r
167 // in ParseStuffCMD the cmd isn't executed yet :/
\r
168 // might even be better to add the gametype to TE_CSQC_INIT...?
\r
173 if(button_zoom || fov <= 59.5)
\r
175 if(!zoomscript_caught)
\r
177 localcmd("+button4\n");
\r
178 zoomscript_caught = 1;
\r
179 ignore_plus_zoom += 1;
\r
184 if(zoomscript_caught)
\r
186 localcmd("-button4\n");
\r
187 zoomscript_caught = 0;
\r
188 ignore_minus_zoom += 1;
\r
192 sbar_alpha_fg = cvar("sbar_alpha_fg" );
\r
193 sbar_hudselector = cvar("sbar_hudselector");
\r
194 activeweapon = getstati(STAT_SWITCHWEAPON);
\r
195 teamplay = cvar("teamplay");
\r
197 if(last_weapon != activeweapon) {
\r
199 last_weapon = activeweapon;
\r
202 // ALWAYS Clear Current Scene First
\r
205 // Assign Standard Viewflags
\r
206 // Draw the World (and sky)
\r
207 R_SetView(VF_DRAWWORLD, 1);
\r
209 R_SetView(VF_FOV, GetCurrentFov(fov));
\r
211 // Draw the Crosshair
\r
212 R_SetView(VF_DRAWCROSSHAIR, !Sbar_WouldDrawScoreboard());
\r
214 // Draw the Engine Status Bar (the default Quake HUD)
\r
215 draw_enginesbar = !cvar("sbar_usecsqc");
\r
216 R_SetView(VF_DRAWENGINESBAR, draw_enginesbar);
\r
218 // Set the console size vars
\r
219 vid_conwidth = cvar("vid_conwidth");
\r
220 vid_conheight = cvar("vid_conheight");
\r
222 // Update the mouse position
\r
224 mousepos_x = vid_conwidth;
\r
225 mousepos_y = vid_conheight;
\r
226 mousepos = mousepos*0.5 + getmousepos();
\r
229 R_AddEntities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
\r
231 // Render the Scene
\r
233 view_origin = pmove_org + '0 0 1' * getstati(STAT_VIEWHEIGHT);
\r
234 view_angles = input_angles;
\r
235 makevectors(view_angles);
\r
236 view_forward = v_forward;
\r
237 view_right = v_right;
\r
241 for(self = world; (self = nextent(self)); )
\r
247 // Draw the mouse cursor
\r
248 // NOTE: drawpic must happen after R_RenderScene for some reason
\r
249 //drawpic(getmousepos(), "gfx/cursor.tga", '11 14 0', '1 1 1', 1, 0);
\r
250 //drawstring('50 50', ftos(game), '10 10 0', '1 1 1', 1, 0);
\r
251 //self = edict_num(player_localnum);
\r
252 //drawstring('0 0', vtos(pmove_org), '8 8 0', '1 1 1', 1, 0);
\r
253 //drawstring('0 8', strcat("ORG: ", vtos(self.origin), " state: ", ftos(self.ctf_state), " HP: ", ftos(self.health)), '8 8 0', '1 1 1', 1, 0);
\r
254 // as long as the ctf part isn't in, this is useless
\r
258 /*if(gametype == GAME_CTF)
\r
262 if(!draw_enginesbar)
\r
267 if(gametype == GAME_ONSLAUGHT)
\r
269 //drawstring('0 0', minimapname, '8 8 0', '1 1 1', 1, 0);
\r
270 //drawsetcliparea(0,0,800,600);
\r
272 //drawresetcliparea();
\r
277 void CSQC_common_hud(void)
\r
279 // Sbar_SortFrags(); done in Sbar_Draw
\r
283 // KeyHunt HUD by victim
\r
284 void CSQC_kh_hud(void)
\r
286 // HUD 0 has the weapons on the right hand side - temporarily shown when needed
\r
287 // HUD 1 has the weapons on the bottom - permanently
\r
289 // use the following two binds to check the icons move correctly
\r
290 // bind g "toggle sbar_flagstatus_right; echo Menu right $sbar_flagstatus_right" // move the icons
\r
291 // bind h "toggle sbar_hudselector; echo HUD $sbar_hudselector" // change the HUD
\r
293 float kh_keys, kh_keys_status, kh_teams_set;
\r
294 float kh_margin_x, kh_margin_y, kh_key_box;
\r
295 string kh_carrying, kh_outline;
\r
296 vector red_pos, blue_pos, yellow_pos, pink_pos, kh_size;
\r
297 vector red, blue, yellow, pink;
\r
299 kh_keys = getstati(STAT_KH_KEYS);
\r
300 kh_keys_status = kh_keys / 256;
\r
301 kh_teams_set = cvar("_teams_available"); // set in keyhunt.qc
\r
304 kh_margin_x = (cvar("sbar_flagstatus_right") * sbar_hudselector * (vid_conwidth - 67)) + 10;
\r
305 // sbar_flagstatus_right 0/1; sbar_hudselector 0/1; screen width - key width + margin
\r
307 red_pos_x = blue_pos_x = yellow_pos_x = pink_pos_x = kh_margin_x;
\r
311 pink_pos_y = kh_margin_y + 0; // top
\r
312 yellow_pos_y = kh_margin_y + kh_key_box;
\r
313 blue_pos_y = kh_margin_y + kh_key_box * 2;
\r
314 red_pos_y = kh_margin_y + kh_key_box * 3; //bottom
\r
321 kh_size = '0 0 0'; // don't resize the image
\r
323 kh_carrying = "gfx/sb_kh_full";
\r
324 kh_outline = "gfx/sb_kh_outline";
\r
326 // drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag)
\r
327 // vector position = '0 0'; // 'x y' 0 0 (the origin) is the top left. X 0 - 799, Y 0 - 599
\r
329 // vector size = '0 0'; // 'x y' changes the x & y dimensions. '0 0' gives the default pic size
\r
330 // vector rgb = '0 0 0'; // 'r g b' range 0 - 1
\r
332 if (kh_keys_status & 1) // red
\r
333 drawpic (red_pos, kh_carrying, kh_size, red, 0.2, 0); // show 20% alpha key
\r
335 drawpic (red_pos, kh_outline, kh_size, red, 0.4, 0); // show key outline 40% alpha
\r
338 drawpic (red_pos, kh_carrying, kh_size, red, 1.0, 0); // show solid key 100% alpha
\r
341 if (kh_keys_status & 2) // blue
\r
342 drawpic (blue_pos, kh_carrying, kh_size, blue, 0.2, 0);
\r
344 drawpic (blue_pos, kh_outline, kh_size, blue, 0.4, 0);
\r
347 drawpic (blue_pos, kh_carrying, kh_size, blue, 1.0, 0);
\r
350 if (kh_teams_set & 4) // yellow
\r
352 if (kh_keys_status & 4)
\r
353 drawpic (yellow_pos, kh_carrying, kh_size, yellow, 0.2, 0);
\r
355 drawpic (yellow_pos, kh_outline, kh_size, yellow, 0.4, 0);
\r
358 drawpic (yellow_pos, kh_carrying, kh_size, yellow, 1.0, 0);
\r
362 if (kh_teams_set & 8) // pink
\r
364 if (kh_keys_status & 8)
\r
365 drawpic (pink_pos, kh_carrying, kh_size, pink, 0.2, 0);
\r
367 drawpic (pink_pos, kh_outline, kh_size, pink, 0.4, 0);
\r
370 drawpic (pink_pos, kh_carrying, kh_size, pink, 1.0, 0);
\r