1 vector angles_held[24];
\r
2 void Net_ReadHoldAngles()
\r
8 angles_held_status[wpn] = ReadByte();
\r
9 if(angles_held_status[wpn])
\r
14 angles_held[wpn] = v;
\r
19 vector polyline[16];
\r
20 float Q3SURFACEFLAG_SLICK = 2; // low friction surface
\r
23 vector p, dir, ang, q, nextdir;
\r
24 float idx, portal_number, portal1_idx;
\r
26 if(activeweapon != WEP_PORTO)
\r
31 if(angles_held_status[WEP_PORTO-1])
\r
33 makevectors(angles_held[WEP_PORTO-1]);
\r
47 traceline(p, p + 65536 * dir, TRUE, world);
\r
48 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
\r
50 nextdir = dir - 2 * (dir * trace_plane_normal) * trace_plane_normal; // mirror dir at trace_plane_normal
\r
56 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK)
\r
59 ang = vectoangles(trace_plane_normal, dir);
\r
62 if(!CheckWireframeBox(porto, p - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward))
\r
64 if(portal_number == 1)
\r
66 if(portal_number >= 2)
\r
72 p = polyline[idx-2];
\r
73 q = polyline[idx-1];
\r
75 p = p - view_up * 16;
\r
76 if(idx-1 >= portal1_idx)
\r
78 Draw_CylindricLine(p, q, 4, "", 1, 0, '0 0 1', 0.5, DRAWFLAG_NORMAL);
\r
82 Draw_CylindricLine(p, q, 4, "", 1, 0, '1 0 0', 0.5, DRAWFLAG_NORMAL);
\r
88 float DPCONTENTS_SOLID = 1; // hit a bmodel, not a bounding box
\r
89 float DPCONTENTS_BODY = 32; // hit a bounding box, not a bmodel
\r
90 float DPCONTENTS_PLAYERCLIP = 256; // blocks player movement
\r
94 porto.classname = "porto";
\r
95 porto.draw = Porto_Draw;
\r
96 porto.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
\r
103 return sin(x) / cos(x);
\r
105 float atan2(float y, float x)
\r
108 v = '1 0 0' * x + '0 1 0' * y;
\r
109 v = vectoangles(v);
\r
110 return v_y * 0.01745329251994329576;
\r
113 vector GetCurrentFov(float fov)
\r
115 float zoomsensitivity, zoomspeed, zoomfactor, zoomdir;
\r
117 zoomsensitivity = cvar("cl_zoomsensitivity");
\r
118 zoomfactor = cvar("cl_zoomfactor");
\r
119 if(zoomfactor < 1 || zoomfactor > 16)
\r
121 zoomspeed = cvar("cl_zoomspeed");
\r
123 if(zoomspeed < 0.5 || zoomspeed > 16)
\r
126 zoomdir = button_zoom;
\r
127 if(activeweapon == WEP_NEX)
\r
128 zoomdir += button_attack2;
\r
129 if(spectatee_status > 0 || isdemo())
\r
131 if(spectatorbutton_zoom)
\r
132 zoomdir = 0 + !zoomdir;
\r
133 // do not even THINK about removing this 0
\r
134 // _I_ know what I am doing
\r
143 current_viewzoom = min(1, current_viewzoom + drawframetime);
\r
147 if(zoomspeed < 0) // instant zoom
\r
150 current_viewzoom = 1 / zoomfactor;
\r
152 current_viewzoom = 1;
\r
157 current_viewzoom = 1 / bound(1, 1 / current_viewzoom + drawframetime * zoomspeed * (zoomfactor - 1), zoomfactor);
\r
159 current_viewzoom = bound(1 / zoomfactor, current_viewzoom + drawframetime * zoomspeed * (1 - 1 / zoomfactor), 1);
\r
163 if(zoomsensitivity < 1)
\r
164 setsensitivityscale(pow(current_viewzoom, 1 - zoomsensitivity));
\r
166 setsensitivityscale(1);
\r
168 float frustumx, frustumy, fovx, fovy;
\r
169 frustumy = tan(fov * 0.00872664625997164788) * 0.75 * current_viewzoom;
\r
170 frustumx = frustumy * cvar("vid_width") / cvar("vid_height") / cvar("vid_pixelheight");
\r
171 fovx = atan2(frustumx, 1) / 0.00872664625997164788;
\r
172 fovy = atan2(frustumy, 1) / 0.00872664625997164788;
\r
174 return '1 0 0' * fovx + '0 1 0' * fovy;
\r
177 void CSQC_common_hud(void);
\r
179 void CSQC_kh_hud(void);
\r
180 void CSQC_ctf_hud(void);
\r
181 void PostInit(void);
\r
182 float Sbar_WouldDrawScoreboard ();
\r
183 float zoomscript_caught;
\r
184 void CSQC_UpdateView(void)
\r
189 drawframetime = max(0.000001, time - drawtime);
\r
192 // watch for gametype changes here...
\r
193 // in ParseStuffCMD the cmd isn't executed yet :/
\r
194 // might even be better to add the gametype to TE_CSQC_INIT...?
\r
199 if(button_zoom || fov <= 59.5)
\r
201 if(!zoomscript_caught)
\r
203 localcmd("+button4\n");
\r
204 zoomscript_caught = 1;
\r
205 ignore_plus_zoom += 1;
\r
210 if(zoomscript_caught)
\r
212 localcmd("-button4\n");
\r
213 zoomscript_caught = 0;
\r
214 ignore_minus_zoom += 1;
\r
218 sbar_alpha_fg = cvar("sbar_alpha_fg" );
\r
219 sbar_hudselector = cvar("sbar_hudselector");
\r
220 activeweapon = getstati(STAT_SWITCHWEAPON);
\r
221 teamplay = cvar("teamplay");
\r
223 if(last_weapon != activeweapon) {
\r
225 last_weapon = activeweapon;
\r
228 // ALWAYS Clear Current Scene First
\r
231 // Assign Standard Viewflags
\r
232 // Draw the World (and sky)
\r
233 R_SetView(VF_DRAWWORLD, 1);
\r
235 R_SetView(VF_FOV, GetCurrentFov(fov));
\r
237 // Draw the Crosshair
\r
238 R_SetView(VF_DRAWCROSSHAIR, !Sbar_WouldDrawScoreboard());
\r
240 // Draw the Engine Status Bar (the default Quake HUD)
\r
241 draw_enginesbar = !cvar("sbar_usecsqc");
\r
242 R_SetView(VF_DRAWENGINESBAR, draw_enginesbar);
\r
244 // Set the console size vars
\r
245 vid_conwidth = cvar("vid_conwidth");
\r
246 vid_conheight = cvar("vid_conheight");
\r
248 // Update the mouse position
\r
250 mousepos_x = vid_conwidth;
\r
251 mousepos_y = vid_conheight;
\r
252 mousepos = mousepos*0.5 + getmousepos();
\r
255 R_AddEntities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
\r
257 // Render the Scene
\r
259 view_origin = pmove_org + '0 0 1' * getstati(STAT_VIEWHEIGHT);
\r
260 view_angles = input_angles;
\r
261 makevectors(view_angles);
\r
262 view_forward = v_forward;
\r
263 view_right = v_right;
\r
267 for(self = world; (self = nextent(self)); )
\r
273 // Draw the mouse cursor
\r
274 // NOTE: drawpic must happen after R_RenderScene for some reason
\r
275 //drawpic(getmousepos(), "gfx/cursor.tga", '11 14 0', '1 1 1', 1, 0);
\r
276 //drawstring('50 50', ftos(game), '10 10 0', '1 1 1', 1, 0);
\r
277 //self = edict_num(player_localnum);
\r
278 //drawstring('0 0', vtos(pmove_org), '8 8 0', '1 1 1', 1, 0);
\r
279 //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
280 // as long as the ctf part isn't in, this is useless
\r
284 /*if(gametype == GAME_CTF)
\r
288 if(!draw_enginesbar)
\r
293 if(gametype == GAME_ONSLAUGHT)
\r
295 //drawstring('0 0', minimapname, '8 8 0', '1 1 1', 1, 0);
\r
296 //drawsetcliparea(0,0,800,600);
\r
298 //drawresetcliparea();
\r
303 void CSQC_common_hud(void)
\r
305 // Sbar_SortFrags(); done in Sbar_Draw
\r
309 // KeyHunt HUD by victim
\r
310 void CSQC_kh_hud(void)
\r
312 // HUD 0 has the weapons on the right hand side - temporarily shown when needed
\r
313 // HUD 1 has the weapons on the bottom - permanently
\r
315 // use the following two binds to check the icons move correctly
\r
316 // bind g "toggle sbar_flagstatus_right; echo Menu right $sbar_flagstatus_right" // move the icons
\r
317 // bind h "toggle sbar_hudselector; echo HUD $sbar_hudselector" // change the HUD
\r
319 float kh_keys, kh_keys_status, kh_teams_set;
\r
320 float kh_margin_x, kh_margin_y, kh_key_box;
\r
321 string kh_carrying, kh_outline;
\r
322 vector red_pos, blue_pos, yellow_pos, pink_pos, kh_size;
\r
323 vector red, blue, yellow, pink;
\r
325 kh_keys = getstati(STAT_KH_KEYS);
\r
326 kh_keys_status = kh_keys / 256;
\r
327 kh_teams_set = cvar("_teams_available"); // set in keyhunt.qc
\r
330 kh_margin_x = (cvar("sbar_flagstatus_right") * sbar_hudselector * (vid_conwidth - 67)) + 10;
\r
331 // sbar_flagstatus_right 0/1; sbar_hudselector 0/1; screen width - key width + margin
\r
333 red_pos_x = blue_pos_x = yellow_pos_x = pink_pos_x = kh_margin_x;
\r
337 pink_pos_y = kh_margin_y + 0; // top
\r
338 yellow_pos_y = kh_margin_y + kh_key_box;
\r
339 blue_pos_y = kh_margin_y + kh_key_box * 2;
\r
340 red_pos_y = kh_margin_y + kh_key_box * 3; //bottom
\r
347 kh_size = '0 0 0'; // don't resize the image
\r
349 kh_carrying = "gfx/sb_kh_full";
\r
350 kh_outline = "gfx/sb_kh_outline";
\r
352 // drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag)
\r
353 // vector position = '0 0'; // 'x y' 0 0 (the origin) is the top left. X 0 - 799, Y 0 - 599
\r
355 // vector size = '0 0'; // 'x y' changes the x & y dimensions. '0 0' gives the default pic size
\r
356 // vector rgb = '0 0 0'; // 'r g b' range 0 - 1
\r
358 if (kh_keys_status & 1) // red
\r
359 drawpic (red_pos, kh_carrying, kh_size, red, 0.2, 0); // show 20% alpha key
\r
361 drawpic (red_pos, kh_outline, kh_size, red, 0.4, 0); // show key outline 40% alpha
\r
364 drawpic (red_pos, kh_carrying, kh_size, red, 1.0, 0); // show solid key 100% alpha
\r
367 if (kh_keys_status & 2) // blue
\r
368 drawpic (blue_pos, kh_carrying, kh_size, blue, 0.2, 0);
\r
370 drawpic (blue_pos, kh_outline, kh_size, blue, 0.4, 0);
\r
373 drawpic (blue_pos, kh_carrying, kh_size, blue, 1.0, 0);
\r
376 if (kh_teams_set & 4) // yellow
\r
378 if (kh_keys_status & 4)
\r
379 drawpic (yellow_pos, kh_carrying, kh_size, yellow, 0.2, 0);
\r
381 drawpic (yellow_pos, kh_outline, kh_size, yellow, 0.4, 0);
\r
384 drawpic (yellow_pos, kh_carrying, kh_size, yellow, 1.0, 0);
\r
388 if (kh_teams_set & 8) // pink
\r
390 if (kh_keys_status & 8)
\r
391 drawpic (pink_pos, kh_carrying, kh_size, pink, 0.2, 0);
\r
393 drawpic (pink_pos, kh_outline, kh_size, pink, 0.4, 0);
\r
396 drawpic (pink_pos, kh_carrying, kh_size, pink, 1.0, 0);
\r