7 return sin(x) / cos(x);
\r
9 float atan2(float y, float x)
\r
12 v = '1 0 0' * x + '0 1 0' * y;
\r
14 return v_y * 0.01745329251994329576;
\r
17 vector GetCurrentFov()
\r
19 float zoomspeed, zoomfactor, zoomdir;
\r
21 zoomfactor = cvar("cl_zoomfactor");
\r
22 if(zoomfactor < 1 || zoomfactor > 16)
\r
24 zoomspeed = cvar("cl_zoomspeed");
\r
26 if(zoomspeed < 0.5 || zoomspeed > 16)
\r
29 zoomdir = button_zoom;
\r
30 if(activeweapon == 7 && !minstagib)
\r
31 zoomdir += button_attack2;
\r
38 current_viewzoom = min(1, current_viewzoom + drawframetime);
\r
42 if(zoomspeed < 0) // instant zoom
\r
45 current_viewzoom = 1 / zoomfactor;
\r
47 current_viewzoom = 1;
\r
52 current_viewzoom = 1 / bound(1, 1 / current_viewzoom + drawframetime * zoomspeed * (zoomfactor - 1), zoomfactor);
\r
54 current_viewzoom = bound(1 / zoomfactor, current_viewzoom + drawframetime * zoomspeed * (1 - 1 / zoomfactor), 1);
\r
58 float frustumx, frustumy, fovx, fovy;
\r
59 frustumy = tan(cvar("fov") * 0.00872664625997164788) * 0.75 * current_viewzoom;
\r
60 frustumx = frustumy * cvar("vid_width") / cvar("vid_height") / cvar("vid_pixelheight");
\r
61 fovx = atan2(frustumx, 1) / 0.00872664625997164788;
\r
62 fovy = atan2(frustumy, 1) / 0.00872664625997164788;
\r
64 return '1 0 0' * fovx + '0 1 0' * fovy;
\r
67 void CSQC_common_hud(void);
\r
69 void CSQC_kh_hud(void);
\r
70 void CSQC_ctf_hud(void);
\r
71 void PostInit(void);
\r
72 float Sbar_WouldDrawScoreboard ();
\r
73 void CSQC_UpdateView(void)
\r
77 drawframetime = time - drawtime;
\r
80 // watch for gametype changes here...
\r
81 // in ParseStuffCMD the cmd isn't executed yet :/
\r
82 // might even be better to add the gametype to TE_CSQC_INIT...?
\r
86 sbar_alpha_fg = cvar("sbar_alpha_fg" );
\r
87 sbar_hudselector = cvar("sbar_hudselector");
\r
88 activeweapon = getstati(STAT_ACTIVEWEAPON);
\r
89 teamplay = cvar("teamplay");
\r
91 if(last_weapon != activeweapon) {
\r
93 last_weapon = activeweapon;
\r
96 // ALWAYS Clear Current Scene First
\r
99 // Assign Standard Viewflags
\r
100 // Draw the World (and sky)
\r
101 R_SetView(VF_DRAWWORLD, 1);
\r
103 R_SetView(VF_FOV, GetCurrentFov());
\r
105 // Draw the Crosshair
\r
106 R_SetView(VF_DRAWCROSSHAIR, !Sbar_WouldDrawScoreboard());
\r
108 // Draw the Engine Status Bar (the default Quake HUD)
\r
109 draw_enginesbar = !cvar("sbar_usecsqc");
\r
110 R_SetView(VF_DRAWENGINESBAR, draw_enginesbar);
\r
112 // Set the console size vars
\r
113 vid_conwidth = cvar("vid_conwidth");
\r
114 vid_conheight = cvar("vid_conheight");
\r
116 // Update the mouse position
\r
118 mousepos_x = vid_conwidth;
\r
119 mousepos_y = vid_conheight;
\r
120 mousepos = mousepos*0.5 + getmousepos();
\r
123 R_AddEntities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
\r
125 // Render the Scene
\r
127 view_origin = pmove_org + '0 0 1' * getstati(STAT_VIEWHEIGHT);
\r
128 view_angles = input_angles;
\r
129 makevectors(view_angles);
\r
130 view_forward = v_forward;
\r
131 view_right = v_right;
\r
135 for(self = world; (self = nextent(self)); )
\r
141 // Draw the mouse cursor
\r
142 // NOTE: drawpic must happen after R_RenderScene for some reason
\r
143 //drawpic(getmousepos(), "gfx/cursor.tga", '11 14 0', '1 1 1', 1, 0);
\r
144 //drawstring('50 50', ftos(game), '10 10 0', '1 1 1', 1, 0);
\r
145 //self = edict_num(player_localnum);
\r
146 //drawstring('0 0', vtos(pmove_org), '8 8 0', '1 1 1', 1, 0);
\r
147 //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
148 // as long as the ctf part isn't in, this is useless
\r
152 /*if(gametype == GAME_CTF)
\r
156 if(!draw_enginesbar)
\r
161 if(gametype == GAME_ONSLAUGHT)
\r
163 //drawstring('0 0', minimapname, '8 8 0', '1 1 1', 1, 0);
\r
164 //drawsetcliparea(0,0,800,600);
\r
166 //drawresetcliparea();
\r
171 void CSQC_common_hud(void)
\r
173 // Sbar_SortFrags(); done in Sbar_Draw
\r
177 // KeyHunt HUD by victim
\r
178 void CSQC_kh_hud(void)
\r
180 // HUD 0 has the weapons on the right hand side - temporarily shown when needed
\r
181 // HUD 1 has the weapons on the bottom - permanently
\r
183 // use the following two binds to check the icons move correctly
\r
184 // bind g "toggle sbar_flagstatus_right; echo Menu right $sbar_flagstatus_right" // move the icons
\r
185 // bind h "toggle sbar_hudselector; echo HUD $sbar_hudselector" // change the HUD
\r
187 float kh_keys, kh_keys_status, kh_teams_set;
\r
188 float kh_margin_x, kh_margin_y, kh_key_box;
\r
189 string kh_carrying, kh_outline;
\r
190 vector red_pos, blue_pos, yellow_pos, pink_pos, kh_size;
\r
191 vector red, blue, yellow, pink;
\r
193 kh_keys = getstati(STAT_KH_KEYS);
\r
194 kh_keys_status = kh_keys / 256;
\r
195 kh_teams_set = cvar("_teams_available"); // set in keyhunt.qc
\r
198 kh_margin_x = (cvar("sbar_flagstatus_right") * sbar_hudselector * (vid_conwidth - 67)) + 10;
\r
199 // sbar_flagstatus_right 0/1; sbar_hudselector 0/1; screen width - key width + margin
\r
201 red_pos_x = blue_pos_x = yellow_pos_x = pink_pos_x = kh_margin_x;
\r
205 pink_pos_y = kh_margin_y + 0; // top
\r
206 yellow_pos_y = kh_margin_y + kh_key_box;
\r
207 blue_pos_y = kh_margin_y + kh_key_box * 2;
\r
208 red_pos_y = kh_margin_y + kh_key_box * 3; //bottom
\r
215 kh_size = '0 0 0'; // don't resize the image
\r
217 kh_carrying = "gfx/sb_kh_full";
\r
218 kh_outline = "gfx/sb_kh_outline";
\r
220 // drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag)
\r
221 // vector position = '0 0'; // 'x y' 0 0 (the origin) is the top left. X 0 - 799, Y 0 - 599
\r
223 // vector size = '0 0'; // 'x y' changes the x & y dimensions. '0 0' gives the default pic size
\r
224 // vector rgb = '0 0 0'; // 'r g b' range 0 - 1
\r
226 if (kh_keys_status & 1) // red
\r
227 drawpic (red_pos, kh_carrying, kh_size, red, 0.2, 0); // show 20% alpha key
\r
229 drawpic (red_pos, kh_outline, kh_size, red, 0.4, 0); // show key outline 40% alpha
\r
232 drawpic (red_pos, kh_carrying, kh_size, red, 1.0, 0); // show solid key 100% alpha
\r
235 if (kh_keys_status & 2) // blue
\r
236 drawpic (blue_pos, kh_carrying, kh_size, blue, 0.2, 0);
\r
238 drawpic (blue_pos, kh_outline, kh_size, blue, 0.4, 0);
\r
241 drawpic (blue_pos, kh_carrying, kh_size, blue, 1.0, 0);
\r
244 if (kh_teams_set & 4) // yellow
\r
246 if (kh_keys_status & 4)
\r
247 drawpic (yellow_pos, kh_carrying, kh_size, yellow, 0.2, 0);
\r
249 drawpic (yellow_pos, kh_outline, kh_size, yellow, 0.4, 0);
\r
252 drawpic (yellow_pos, kh_carrying, kh_size, yellow, 1.0, 0);
\r
256 if (kh_teams_set & 8) // pink
\r
258 if (kh_keys_status & 8)
\r
259 drawpic (pink_pos, kh_carrying, kh_size, pink, 0.2, 0);
\r
261 drawpic (pink_pos, kh_outline, kh_size, pink, 0.4, 0);
\r
264 drawpic (pink_pos, kh_carrying, kh_size, pink, 1.0, 0);
\r