From 4050c4740065e6c7aef5b45ec099489dc10f3aa1 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 5 Apr 2015 20:55:37 +1000 Subject: [PATCH] For completeness, port step and follow movetypes (untested) --- qcsrc/common/movetypes/follow.qc | 31 +++++++++++++++++++++++++++++ qcsrc/common/movetypes/include.qc | 2 ++ qcsrc/common/movetypes/movetypes.qc | 4 ++-- qcsrc/common/movetypes/movetypes.qh | 7 +++++++ qcsrc/common/movetypes/step.qc | 23 +++++++++++++++++++++ qcsrc/common/physics.qc | 4 ++++ qcsrc/common/stats.qh | 2 +- qcsrc/server/autocvars.qh | 1 + 8 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 qcsrc/common/movetypes/follow.qc create mode 100644 qcsrc/common/movetypes/step.qc diff --git a/qcsrc/common/movetypes/follow.qc b/qcsrc/common/movetypes/follow.qc new file mode 100644 index 000000000..6cf28d6f1 --- /dev/null +++ b/qcsrc/common/movetypes/follow.qc @@ -0,0 +1,31 @@ +void _Movetype_Physics_Follow() // SV_Physics_Follow +{ + entity e = self.move_aiment; // TODO: networking? + + // LordHavoc: implemented rotation on MOVETYPE_FOLLOW objects + if(self.move_angles == self.move_punchangle) + { + self.move_origin = e.move_origin + self.view_ofs; + } + else + { + vector ang, v; + ang_x = -self.move_punchangle_x; + ang_y = self.move_punchangle_y; + ang_z = self.move_punchangle_z; + makevectors(ang); + v_x = self.view_ofs_x * v_forward_x + self.view_ofs_y * v_right_x + self.view_ofs_z * v_up_x; + v_y = self.view_ofs_x * v_forward_y + self.view_ofs_y * v_right_y + self.view_ofs_z * v_up_y; + v_z = self.view_ofs_x * v_forward_z + self.view_ofs_y * v_right_z + self.view_ofs_z * v_up_z; + ang_x = -e.move_angles_x; + ang_y = e.move_angles_y; + ang_z = e.move_angles_z; + makevectors(ang); + self.move_origin_x = v_x * v_forward_x + v_y * v_forward_y + v_z * v_forward_z + e.move_origin_x; + self.move_origin_x = v_x * v_right_x + v_y * v_right_y + v_z * v_right_z + e.move_origin_y; + self.move_origin_x = v_x * v_up_x + v_y * v_up_y + v_z * v_up_z + e.move_origin_z; + } + + self.move_angles = e.move_angles + self.v_angle; + _Movetype_LinkEdict(false); +} diff --git a/qcsrc/common/movetypes/include.qc b/qcsrc/common/movetypes/include.qc index 64d92d4a9..322b3c4de 100644 --- a/qcsrc/common/movetypes/include.qc +++ b/qcsrc/common/movetypes/include.qc @@ -1,5 +1,7 @@ #include "push.qc" #include "toss.qc" #include "walk.qc" +#include "step.qc" +#include "follow.qc" #include "movetypes.qc" diff --git a/qcsrc/common/movetypes/movetypes.qc b/qcsrc/common/movetypes/movetypes.qc index a7351ac66..3dd286e00 100644 --- a/qcsrc/common/movetypes/movetypes.qc +++ b/qcsrc/common/movetypes/movetypes.qc @@ -575,7 +575,7 @@ void _Movetype_Physics_Frame(float movedt) case MOVETYPE_NONE: break; case MOVETYPE_FOLLOW: - error("SV_Physics_Follow not implemented"); + _Movetype_Physics_Follow(); break; case MOVETYPE_NOCLIP: _Movetype_CheckWater(self); @@ -584,7 +584,7 @@ void _Movetype_Physics_Frame(float movedt) _Movetype_LinkEdict(false); break; case MOVETYPE_STEP: - error("SV_Physics_Step not implemented"); + _Movetype_Physics_Step(movedt); break; case MOVETYPE_WALK: _Movetype_Physics_Walk(movedt); diff --git a/qcsrc/common/movetypes/movetypes.qh b/qcsrc/common/movetypes/movetypes.qh index 88b545fe1..67cd51e16 100644 --- a/qcsrc/common/movetypes/movetypes.qh +++ b/qcsrc/common/movetypes/movetypes.qh @@ -21,15 +21,22 @@ .float move_bounce_stopspeed; .float move_nomonsters; // -1 for MOVE_NORMAL, otherwise a MOVE_ constant +.entity move_aiment; +.vector move_punchangle; + // should match sv_gameplayfix_fixedcheckwatertransition float autocvar_cl_gameplayfix_fixedcheckwatertransition = 1; #ifdef SVQC +.int stat_gameplayfix_upvelocityclearsonground; + #define GRAVITY_UNAFFECTED_BY_TICRATE autocvar_sv_gameplayfix_gravityunaffectedbyticrate +#define UPWARD_VELOCITY_CLEARS_ONGROUND autocvar_sv_gameplayfix_upwardvelocityclearsongroundflag #define TICRATE sys_frametime #elif defined(CSQC) #define GRAVITY_UNAFFECTED_BY_TICRATE (getstati(STAT_MOVEFLAGS) & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE) +#define UPWARD_VELOCITY_CLEARS_ONGROUND getstati(STAT_GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND) #define TICRATE ticrate #endif diff --git a/qcsrc/common/movetypes/step.qc b/qcsrc/common/movetypes/step.qc new file mode 100644 index 000000000..822bf0935 --- /dev/null +++ b/qcsrc/common/movetypes/step.qc @@ -0,0 +1,23 @@ +void _Movetype_Physics_Step(float dt) // SV_Physics_Step +{ + if(self.move_flags & FL_ONGROUND) + { + if(self.velocity_z >= (1.0 / 32.0) && UPWARD_VELOCITY_CLEARS_ONGROUND) + { + self.move_flags &= ~FL_ONGROUND; + _Movetype_CheckVelocity(); + _Movetype_FlyMove(dt, true, '0 0 0', 0); + _Movetype_LinkEdict(true); + } + } + else + { + _Movetype_CheckVelocity(); + _Movetype_FlyMove(dt, true, '0 0 0', 0); + _Movetype_LinkEdict(true); + + // TODO? movetypesteplandevent + } + + _Movetype_CheckWaterTransition(self); +} diff --git a/qcsrc/common/physics.qc b/qcsrc/common/physics.qc index d2a9b1d37..0a8d5e0c7 100644 --- a/qcsrc/common/physics.qc +++ b/qcsrc/common/physics.qc @@ -79,6 +79,8 @@ void Physics_AddStats() addstat(STAT_MOVEVARS_STOPSPEED, AS_FLOAT, stat_sv_stopspeed); addstat(STAT_MOVEVARS_AIRACCELERATE, AS_FLOAT, stat_sv_airaccelerate); addstat(STAT_MOVEVARS_AIRSTOPACCELERATE, AS_FLOAT, stat_sv_airstopaccelerate); + + addstat(STAT_GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND, AS_INT, stat_gameplayfix_upvelocityclearsonground); } void Physics_UpdateStats(float maxspd_mod) @@ -133,6 +135,8 @@ void Physics_UpdateStats(float maxspd_mod) self.stat_sv_airaccelerate = Physics_ClientOption(self, "airaccelerate"); self.stat_sv_airstopaccelerate = Physics_ClientOption(self, "airstopaccelerate"); self.stat_sv_jumpvelocity = Physics_ClientOption(self, "jumpvelocity"); + + self.stat_gameplayfix_upvelocityclearsonground = UPWARD_VELOCITY_CLEARS_ONGROUND; } #endif diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index d668862d2..edbe4ecde 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -194,7 +194,7 @@ const int STAT_VIP_PINK = 104; // 163 empty? // 164 empty? // 165 empty? -// 166 empty? +const int STAT_GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND = 166; const int STAT_MULTIJUMP_MAXSPEED = 167; const int STAT_JETPACK_REVERSE_THRUST = 168; const int STAT_BUGRIGS_REVERSE_STOPPING = 169; diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 6934d3ca3..d545963cf 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -736,6 +736,7 @@ float autocvar_timelimit_suddendeath; #define autocvar_utf8_enable cvar("utf8_enable") float autocvar_waypoint_benchmark; float autocvar_sv_gameplayfix_gravityunaffectedbyticrate; +float autocvar_sv_gameplayfix_upwardvelocityclearsongroundflag; float autocvar_g_trueaim_minrange; float autocvar_g_debug_defaultsounds; float autocvar_g_grab_range; -- 2.39.2