@@ -43,6 +43,20 @@ var string camera_item_name = "none";
4343var string team_shader = "" ;
4444var string enemy_shader = "" ;
4545
46+ var float autocvar_pip_debug = 0 ;
47+ var float autocvar_pip_enabled = 1 ;
48+ var float autocvar_pip_camera_intro = 5.0 ;
49+ var float autocvar_pip_camera_outro = 3.5 ;
50+ var float autocvar_pip_camera_transition = 0.8 ;
51+ var vector autocvar_pip_bg_quad_color = '0.2 0.2 0.5' ;
52+ var vector autocvar_pip_bg_pent_color = '0.5 0.2 0.2' ;
53+
54+ var float autocvar_pip_xray = 1 ;
55+ var float autocvar_pip_xray_alpha = 0.3 ;
56+ var float autocvar_pip_xray_distance = 512 ;
57+ var vector autocvar_pip_xray_color_team = '0 1 0' ;
58+ var vector autocvar_pip_xray_color_enemy = '1 0 0' ;
59+
4660float (float x) easeInExpo =
4761{
4862 if (x == 0.0 ) {
@@ -92,9 +106,9 @@ void() SelectNextCamera =
92106 }
93107 if (candidate_index != -1 ) {
94108 // Reload any cvar changes
95- camera_intro = cvar( "pip_camera_intro" ) ;
96- camera_outro = cvar( "pip_camera_outro" ) ;
97- camera_transition = cvar( "pip_camera_transition" ) ;
109+ camera_intro = autocvar_pip_camera_intro ;
110+ camera_outro = autocvar_pip_camera_outro ;
111+ camera_transition = autocvar_pip_camera_transition ;
98112
99113 camera_index = candidate_index;
100114 camera_start = max(match_start_time, candidate_respawn - camera_intro);
@@ -104,11 +118,11 @@ void() SelectNextCamera =
104118
105119 switch (candidate_type) {
106120 case IT_QUAD:
107- camera_bg_color = stov(cvar_string( "pip_bg_quad_color" )) ;
121+ camera_bg_color = autocvar_pip_bg_quad_color ;
108122 camera_item_name = "Quad" ;
109123 break ;
110124 case IT_PENT:
111- camera_bg_color = stov(cvar_string( "pip_bg_pent_color" )) ;
125+ camera_bg_color = autocvar_pip_bg_pent_color ;
112126 camera_item_name = "Pent" ;
113127 break ;
114128 default :
@@ -206,20 +220,6 @@ float(string cmd) CSQC_ConsoleCommand =
206220
207221void (float apilevel, string enginename, float engineversion) CSQC_Init =
208222{
209- // Toggle if cameras are enabled, the timing data will be recorded either way
210- // to allow toggling it mid game
211- registercvar("pip_enabled" , "1" );
212- registercvar("pip_debug" , "0" );
213- registercvar("pip_camera_intro" , "5.0" );
214- registercvar("pip_camera_outro" , "3.5" );
215- registercvar("pip_camera_transition" , "0.8" );
216- registercvar("pip_bg_quad_color" , "0.2 0.2 0.5" );
217- registercvar("pip_bg_pent_color" , "0.5 0.2 0.2" );
218- registercvar("pip_xray" , "1" );
219- registercvar("pip_xray_alpha" , "0.3" );
220- registercvar("pip_xray_distance" , "512" );
221- registercvar("pip_xray_color_team" , "0 1 0" );
222- registercvar("pip_xray_color_enemy" , "1 0 0" );
223223 registercommand("pip" );
224224};
225225
@@ -235,7 +235,7 @@ void(entity ent) PipResetPlayer =
235235float (float isnew) PipNewPlayer =
236236{
237237
238- if (self. entnum == player_localentnum || ! cvar( "pip_xray" ) ) {
238+ if (self. entnum == player_localentnum || ! autocvar_pip_xray ) {
239239 PipResetPlayer(self);
240240 return isnew;
241241 }
@@ -248,7 +248,7 @@ float(float isnew) PipNewPlayer =
248248 }
249249
250250 vector org = getviewprop(VF_ORIGIN);
251- float cutoff = cvar( "pip_xray_distance" ) ;
251+ float cutoff = autocvar_pip_xray_distance ;
252252
253253 float distance = vlen(org - self. origin);
254254 if (distance > cutoff) {
@@ -266,16 +266,16 @@ float(float isnew) PipNewPlayer =
266266
267267 self. effects |= EF_NODEPTHTEST | EF_ADDITIVE;
268268 self. drawmask = MASK_XRAY;
269- self. alpha = cvar( "pip_xray_alpha" ) * distanceFactor;
269+ self. alpha = autocvar_pip_xray_alpha * distanceFactor;
270270 self. fatness = 2 ;
271271
272272 string pov_team = getplayerkeyvalue(player_localentnum-1 , "team" );
273273 string ent_team = getplayerkeyvalue(pnum, "team" );
274274
275275 if (pov_team != ent_team) {
276- self. forceshader = shaderforname("xrayenemy " , enemy_shader);
276+ self. forceshader = shaderforname("xray-enemy " , enemy_shader);
277277 } else {
278- self. forceshader = shaderforname("xrayteam " , team_shader);
278+ self. forceshader = shaderforname("xray-team " , team_shader);
279279 }
280280
281281 return isnew;
@@ -285,20 +285,20 @@ float(float isnew) PipNewPlayer =
285285
286286void () CSQC_WorldLoaded =
287287{
288- if (cvar( "pip_xray" ) ) {
288+ if (autocvar_pip_xray ) {
289289 team_shader = sprintf(R"({
290290 {
291291 map $whiteimage
292- rgbgen const %s
292+ rgbgen const %v
293293 }
294- }) ", cvar_string(" pip_xray_color_team ") );
294+ }) ", autocvar_pip_xray_color_team );
295295
296296 enemy_shader = sprintf(R" ({
297297 {
298298 map $whiteimage
299- rgbgen const % s
299+ rgbgen const % v
300300 }
301- })", cvar_string(" pip_xray_color_enemy ") );
301+ })", autocvar_pip_xray_color_enemy );
302302
303303 deltalisten(" progs/ player. mdl", PipNewPlayer, RSES_NOLERP | RSES_NOROTATE);
304304 }
@@ -352,7 +352,7 @@ void(float vwidth, float vheight, float notmenu) CSQC_UpdateView =
352352 return;
353353 }
354354
355- if (!cvar(" pip_enabled ") ) {
355+ if (!autocvar_pip_enabled ) {
356356 return;
357357 }
358358
0 commit comments