for better handling of stuff like chase_active, view bob.
Authors of the csqcplayers branch, please look at this, it may help using the
engine's viewbob etc. for csqc players!
void CSQC_SPIDER_HUD();
void CSQC_RAPTOR_HUD();
-vector freeze_pmove_org, freeze_input_angles;
+vector freeze_org, freeze_ang;
entity nightvision_noise, nightvision_noise2;
float pickup_crosshair_time, pickup_crosshair_size;
ticrate = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
vo = '0 0 1' * getstati(STAT_VIEWHEIGHT);
- warpzone_fixview_origin = pmove_org + vo;
- warpzone_fixview_cl_viewangles = input_angles;
- warpzone_fixview_angles = view_angles;
- WarpZone_FixView();
- pmove_org = warpzone_fixview_origin - vo;
- input_angles = warpzone_fixview_cl_viewangles;
- view_angles = warpzone_fixview_angles;
-
if(autocvar_cl_lockview || (autocvar__hud_configure && spectatee_status <= 0) || intermission > 1)
{
- pmove_org = freeze_pmove_org;
- input_angles = view_angles = freeze_input_angles;
- R_SetView(VF_ORIGIN, pmove_org + vo);
- R_SetView(VF_ANGLES, view_angles);
- //R_SetView(VF_CL_VIEWANGLES, input_angles);
+ R_SetView(VF_ORIGIN, freeze_org);
+ R_SetView(VF_ANGLES, freeze_ang);
+ }
+ else
+ {
+ freeze_org = R_SetView3fv(VF_ORIGIN);
+ freeze_ang = R_SetView3fv(VF_ANGLES);
}
- freeze_pmove_org = pmove_org;
- freeze_input_angles = input_angles;
// event chase camera
if(autocvar_chase_active <= 0) // greater than 0 means it's enabled manually, and this code is skipped
vector eventchase_target_origin;
makevectors(view_angles);
// pass 1, used to check where the camera would go and obtain the trace_fraction
- eventchase_target_origin = pmove_org - v_forward * eventchase_current_distance;
+ eventchase_target_origin = freeze_org - v_forward * eventchase_current_distance;
- WarpZone_TraceLine(pmove_org, eventchase_target_origin, MOVE_WORLDONLY, self);
+ WarpZone_TraceLine(freeze_org, eventchase_target_origin, MOVE_WORLDONLY, self);
// pass 2, also multiplying view_forward with trace_fraction, to prevent the camera from going through walls
// The 0.1 subtraction is to not limit the camera precisely at the wall surface, as that allows the view to poke through
- eventchase_target_origin = pmove_org - v_forward * eventchase_current_distance * (trace_fraction - 0.1);
- WarpZone_TraceLine(pmove_org, eventchase_target_origin, MOVE_WORLDONLY, self);
+ eventchase_target_origin = freeze_org - v_forward * eventchase_current_distance * (trace_fraction - 0.1);
+ WarpZone_TraceLine(freeze_org, eventchase_target_origin, MOVE_WORLDONLY, self);
R_SetView(VF_ORIGIN, trace_endpos);
R_SetView(VF_ANGLES, WarpZone_TransformVAngles(WarpZone_trace_transform, view_angles));
-
- vector o, corner0, corner1, corner2, corner3, nearclip;
- nearclip = '0 0 1' * (cvar("r_nearclip") * 1.125);
- corner0 = cs_unproject('0 0 0' + nearclip);
- corner1 = cs_unproject('1 0 0' * cvar("vid_conwidth") + nearclip);
- corner2 = cs_unproject('0 1 0' * cvar("vid_conheight") + nearclip);
- corner3 = cs_unproject('1 0 0' * cvar("vid_conwidth") + '0 1 0' * cvar("vid_conheight") + nearclip);
- o = trace_endpos;
- o = o + WarpZone_FixNearClip(trace_endpos, corner0, corner1, corner2, corner3);
- R_SetView(VF_ORIGIN, o);
}
else if(autocvar_chase_active < 0) // time to disable chase_active if it was set by this code
{
}
}
+ WarpZone_FixView();
+ //WarpZone_FixPMove();
+
// Render the Scene
view_origin = R_SetView3fv(VF_ORIGIN);
view_angles = R_SetView3fv(VF_ANGLES);
drawpic(splash_pos, "gfx/blood", splash_size, stov(autocvar_hud_damage_color), bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL);
}
- // Draw the mouse cursor
- // NOTE: drawpic must happen after R_RenderScene for some reason
- //drawpic(getmousepos(), "gfx/cursor.tga", '11 14 0', '1 1 1', 1, 0);
- //drawstring('50 50', ftos(game), '10 10 0', '1 1 1', 1, 0);
- //self = edict_num(player_localnum);
- //drawstring('0 0', vtos(pmove_org), '8 8 0', '1 1 1', 1, 0);
- //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);
- // as long as the ctf part isn't in, this is useless
if(menu_visible)
menu_show();
float warpzone_fixingview;
float warpzone_fixingview_drawexteriormodel;
-//float warpzone_fixingview_sidespeed;
-//float warpzone_fixingview_forwardspeed;
-void WarpZone_Inside()
+void WarpZone_View_Inside()
{
if(warpzone_fixingview)
return;
warpzone_fixingview = 1;
warpzone_fixingview_drawexteriormodel = cvar("r_drawexteriormodel");
- //warpzone_fixingview_sidespeed = cvar("cl_sidespeed");
- //warpzone_fixingview_forwardspeed = cvar("cl_forwardspeed");
cvar_set("r_drawexteriormodel", "0");
- //cvar_set("cl_sidespeed", ftos(warpzone_fixingview_sidespeed / 100)); // just keep a bit of it in case player gets stuck
- //cvar_set("cl_forwardspeed", ftos(warpzone_fixingview_forwardspeed / 100)); // just keep a bit of it in case player gets stuck
}
-void WarpZone_Outside()
+void WarpZone_View_Outside()
{
if(!warpzone_fixingview)
return;
return '0 0 0';
}
-float warpzone_saved;
-vector warpzone_saved_origin;
-vector warpzone_saved_angles;
-vector warpzone_saved_cl_viewangles;
+void WarpZone_FixPMove()
+{
+ entity e;
+ e = WarpZone_Find(pmove_org, pmove_org);
+ if(e)
+ {
+ pmove_org = WarpZone_TransformOrigin(e, pmove_org);
+ input_angles = WarpZone_TransformVAngles(e, input_angles);
+ }
+}
+
#ifndef KEEP_ROLL
var float autocvar_cl_rollkillspeed = 10;
#endif
void WarpZone_FixView()
{
- float f;
- vector o;
entity e;
- vector corner0, corner1, corner2, corner3, nearclip;
-
- warpzone_saved = 0;
- warpzone_saved_origin = warpzone_fixview_origin;
- warpzone_saved_angles = warpzone_fixview_angles;
- warpzone_saved_cl_viewangles = warpzone_fixview_cl_viewangles;
-
- nearclip = '0 0 1' * (cvar("r_nearclip") * 1.125);
- corner0 = cs_unproject('0 0 0' + nearclip);
- corner1 = cs_unproject('1 0 0' * cvar("vid_conwidth") + nearclip);
- corner2 = cs_unproject('0 1 0' * cvar("vid_conheight") + nearclip);
- corner3 = cs_unproject('1 0 0' * cvar("vid_conwidth") + '0 1 0' * cvar("vid_conheight") + nearclip);
+ vector org, ang, nearclip, corner0, corner1, corner2, corner3, o;
+ float f;
-#ifndef KEEP_ROLL
- if(warpzone_fixview_angles_z != 0 || warpzone_fixview_cl_viewangles_z != 0)
- {
- if(autocvar_cl_rollkillspeed)
- f = max(0, (1 - frametime * autocvar_cl_rollkillspeed));
- else
- f = 0;
- warpzone_fixview_angles_z *= f;
- warpzone_fixview_cl_viewangles_z *= f;
- warpzone_saved_angles_z *= f; // PERMANENTLY apply that change!
- warpzone_saved_cl_viewangles_z *= f; // PERMANENTLY apply that change!
- warpzone_saved = 2;
- R_SetView(VF_CL_VIEWANGLES_Z, warpzone_fixview_angles_z);
- }
-#endif
+ org = R_SetView3fv(VF_ORIGIN);
+ ang = R_SetView3fv(VF_ANGLES);
- e = WarpZone_Find(warpzone_fixview_origin, warpzone_fixview_origin);
+ e = WarpZone_Find(org, org);
if(e)
{
- warpzone_saved = 1;
- warpzone_fixview_origin = WarpZone_TransformOrigin(e, warpzone_fixview_origin);
- corner0 = WarpZone_TransformOrigin(e, corner0);
- corner1 = WarpZone_TransformOrigin(e, corner1);
- corner2 = WarpZone_TransformOrigin(e, corner2);
- corner3 = WarpZone_TransformOrigin(e, corner3);
- warpzone_fixview_angles = WarpZone_TransformVAngles(e, warpzone_fixview_angles);
- warpzone_fixview_cl_viewangles = WarpZone_TransformVAngles(e, warpzone_fixview_cl_viewangles);
- WarpZone_Inside();
+ org = WarpZone_TransformOrigin(e, org);
+ ang = WarpZone_TransformVAngles(e, ang);
+ WarpZone_View_Inside();
}
else
- WarpZone_Outside();
+ WarpZone_View_Outside();
- // if we are near any warpzone planes - MOVE AWAY (work around nearclip)
- o = WarpZone_FixNearClip(warpzone_fixview_origin, corner0, corner1, corner2, corner3);
- if(o != '0 0 0')
- {
- warpzone_saved = 1;
- warpzone_fixview_origin += o;
- }
+#ifndef KEEP_ROLL
+ float rick;
+ if(autocvar_cl_rollkillspeed)
+ f = max(0, (1 - frametime * autocvar_cl_rollkillspeed));
+ else
+ f = 0;
- if(warpzone_saved == 1)
- {
- R_SetView(VF_ORIGIN, warpzone_fixview_origin);
- R_SetView(VF_ANGLES, warpzone_fixview_cl_viewangles);
- }
-}
-void WarpZone_UnFixView()
-{
- if(warpzone_saved)
- {
- warpzone_fixview_origin = warpzone_saved_origin;
- warpzone_fixview_angles = warpzone_saved_angles;
- warpzone_fixview_cl_viewangles = warpzone_saved_cl_viewangles;
- R_SetView(VF_ORIGIN, warpzone_fixview_origin);
- R_SetView(VF_ANGLES, warpzone_fixview_angles);
- R_SetView(VF_CL_VIEWANGLES, warpzone_fixview_cl_viewangles);
- }
+ rick = R_SetView(VF_CL_VIEWANGLES_Z);
+ rick *= f;
+ R_SetView(VF_CL_VIEWANGLES_Z, rick);
+
+ ang_z *= f;
+#endif
+
+ R_SetView(VF_ORIGIN, org);
+ R_SetView(VF_ANGLES, ang);
+
+ nearclip = '0 0 1' * (cvar("r_nearclip") * 1.125);
+ corner0 = cs_unproject('0 0 0' + nearclip);
+ corner1 = cs_unproject('1 0 0' * cvar("vid_conwidth") + nearclip);
+ corner2 = cs_unproject('0 1 0' * cvar("vid_conheight") + nearclip);
+ corner3 = cs_unproject('1 0 0' * cvar("vid_conwidth") + '0 1 0' * cvar("vid_conheight") + nearclip);
+ o = WarpZone_FixNearClip(org, corner0, corner1, corner2, corner3);
+ if(o != '0 0 0')
+ R_SetView(VF_ORIGIN, org + o);
}
void WarpZone_Init()
void WarpZone_Shutdown()
{
- WarpZone_Outside();
+ WarpZone_View_Outside();
}
void WarpZone_Camera_Read(float bIsNewEntity);
void WarpZone_Teleported_Read(float bIsNewEntity);
-vector warpzone_fixview_origin;
-vector warpzone_fixview_angles;
-vector warpzone_fixview_cl_viewangles;
-void WarpZone_FixView(); // this saves the previous values
-void WarpZone_UnFixView(); // and restores them
-vector WarpZone_FixNearClip(vector o, vector c0, vector c1, vector c2, vector c3);
+void WarpZone_FixPMove();
+void WarpZone_FixView();
void WarpZone_Init();
void WarpZone_Shutdown();