X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fphysics.qc;h=6c0bd616bcfee30c402a41cc118f921946dfe62a;hb=4c7352309564fc88b28216e0aa9ac509ce4d3dc6;hp=e77184750eeb1117d092a05769c22acb3c8e4ecc;hpb=6dc9591eba337374f2b4348a6a6deaa1cb6887d0;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/physics.qc b/qcsrc/common/physics.qc index e77184750..6c0bd616b 100644 --- a/qcsrc/common/physics.qc +++ b/qcsrc/common/physics.qc @@ -1,11 +1,67 @@ #include "physics.qh" #include "triggers/trigger/swamp.qh" #include "triggers/trigger/jumppads.qh" +#include "viewloc.qh" #ifdef SVQC +#include "../server/miscfunctions.qh" +#include "triggers/trigger/viewloc.qh" + +// client side physics +bool Physics_Valid(string thecvar) +{ + if(!autocvar_g_physics_clientselect) { return false; } + + string l = strcat(" ", autocvar_g_physics_clientselect_options, " "); + + if(strstrofs(l, strcat(" ", thecvar, " "), 0) >= 0) + return true; + + return false; +} + +float Physics_ClientOption(entity pl, string option) +{ + if(Physics_Valid(pl.cvar_cl_physics)) + { + string var = sprintf("g_physics_%s_%s", pl.cvar_cl_physics, option); + if(cvar_type(var) & CVAR_TYPEFLAG_EXISTS) + return cvar(var); + } + if(autocvar_g_physics_clientselect && autocvar_g_physics_clientselect_default) + { + string var = sprintf("g_physics_%s_%s", autocvar_g_physics_clientselect_default, option); + if(cvar_type(var) & CVAR_TYPEFLAG_EXISTS) + return cvar(var); + } + return cvar(strcat("sv_", option)); +} + void Physics_AddStats() { + // static view offset and hitbox vectors + // networked for all you bandwidth pigs out there + addstat(STAT_PL_VIEW_OFS1, AS_FLOAT, stat_pl_view_ofs_x); + addstat(STAT_PL_VIEW_OFS2, AS_FLOAT, stat_pl_view_ofs_y); + addstat(STAT_PL_VIEW_OFS3, AS_FLOAT, stat_pl_view_ofs_z); + addstat(STAT_PL_CROUCH_VIEW_OFS1, AS_FLOAT, stat_pl_crouch_view_ofs_x); + addstat(STAT_PL_CROUCH_VIEW_OFS2, AS_FLOAT, stat_pl_crouch_view_ofs_y); + addstat(STAT_PL_CROUCH_VIEW_OFS3, AS_FLOAT, stat_pl_crouch_view_ofs_z); + + addstat(STAT_PL_MIN1, AS_FLOAT, stat_pl_min_x); + addstat(STAT_PL_MIN2, AS_FLOAT, stat_pl_min_y); + addstat(STAT_PL_MIN3, AS_FLOAT, stat_pl_min_z); + addstat(STAT_PL_MAX1, AS_FLOAT, stat_pl_max_x); + addstat(STAT_PL_MAX2, AS_FLOAT, stat_pl_max_y); + addstat(STAT_PL_MAX3, AS_FLOAT, stat_pl_max_z); + addstat(STAT_PL_CROUCH_MIN1, AS_FLOAT, stat_pl_crouch_min_x); + addstat(STAT_PL_CROUCH_MIN2, AS_FLOAT, stat_pl_crouch_min_y); + addstat(STAT_PL_CROUCH_MIN3, AS_FLOAT, stat_pl_crouch_min_z); + addstat(STAT_PL_CROUCH_MAX1, AS_FLOAT, stat_pl_crouch_max_x); + addstat(STAT_PL_CROUCH_MAX2, AS_FLOAT, stat_pl_crouch_max_y); + addstat(STAT_PL_CROUCH_MAX3, AS_FLOAT, stat_pl_crouch_max_z); + // g_movementspeed hack addstat(STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW, AS_FLOAT, stat_sv_airspeedlimit_nonqw); addstat(STAT_MOVEVARS_MAXSPEED, AS_FLOAT, stat_sv_maxspeed); @@ -28,24 +84,56 @@ void Physics_AddStats() addstat(STAT_DOUBLEJUMP, AS_INT, stat_doublejump); // jump speed caps - addstat(STAT_MOVEVARS_JUMPSPEEDCAP_MIN, AS_FLOAT, stat_jumpspeedcap_min); - addstat(STAT_MOVEVARS_JUMPSPEEDCAP_MIN, AS_FLOAT, stat_jumpspeedcap_min); addstat(STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS, AS_INT, stat_jumpspeedcap_disable_onramps); // hacks addstat(STAT_MOVEVARS_FRICTION_ONLAND, AS_FLOAT, stat_sv_friction_on_land); addstat(STAT_MOVEVARS_FRICTION_SLICK, AS_FLOAT, stat_sv_friction_slick); + addstat(STAT_GAMEPLAYFIX_EASIERWATERJUMP, AS_INT, stat_gameplayfix_easierwaterjump); + + // new properties + addstat(STAT_MOVEVARS_JUMPVELOCITY, AS_FLOAT, stat_sv_jumpvelocity); + addstat(STAT_MOVEVARS_AIRACCEL_QW_STRETCHFACTOR, AS_FLOAT, stat_sv_airaccel_qw_stretchfactor); + addstat(STAT_MOVEVARS_MAXAIRSTRAFESPEED, AS_FLOAT, stat_sv_maxairstrafespeed); + addstat(STAT_MOVEVARS_MAXAIRSPEED, AS_FLOAT, stat_sv_maxairspeed); + addstat(STAT_MOVEVARS_AIRSTRAFEACCELERATE, AS_FLOAT, stat_sv_airstrafeaccelerate); + addstat(STAT_MOVEVARS_WARSOWBUNNY_TURNACCEL, AS_FLOAT, stat_sv_warsowbunny_turnaccel); + addstat(STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION, AS_FLOAT, stat_sv_airaccel_sideways_friction); + addstat(STAT_MOVEVARS_AIRCONTROL, AS_FLOAT, stat_sv_aircontrol); + addstat(STAT_MOVEVARS_AIRCONTROL_POWER, AS_FLOAT, stat_sv_aircontrol_power); + addstat(STAT_MOVEVARS_AIRCONTROL_PENALTY, AS_FLOAT, stat_sv_aircontrol_penalty); + addstat(STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL, AS_FLOAT, stat_sv_warsowbunny_airforwardaccel); + addstat(STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED, AS_FLOAT, stat_sv_warsowbunny_topspeed); + addstat(STAT_MOVEVARS_WARSOWBUNNY_ACCEL, AS_FLOAT, stat_sv_warsowbunny_accel); + addstat(STAT_MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO, AS_FLOAT, stat_sv_warsowbunny_backtosideratio); + addstat(STAT_MOVEVARS_FRICTION, AS_FLOAT, stat_sv_friction); + addstat(STAT_MOVEVARS_ACCELERATE, AS_FLOAT, stat_sv_accelerate); + 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) { - self.stat_sv_airaccel_qw = AdjustAirAccelQW(autocvar_sv_airaccel_qw, maxspd_mod); - if (autocvar_sv_airstrafeaccel_qw) - self.stat_sv_airstrafeaccel_qw = AdjustAirAccelQW(autocvar_sv_airstrafeaccel_qw, maxspd_mod); + // blah + self.stat_pl_view_ofs = PL_VIEW_OFS; + self.stat_pl_crouch_view_ofs = PL_CROUCH_VIEW_OFS; + + self.stat_pl_min = PL_MIN; + self.stat_pl_max = PL_MAX; + self.stat_pl_crouch_min = PL_CROUCH_MIN; + self.stat_pl_crouch_max = PL_CROUCH_MAX; + + + self.stat_sv_airaccel_qw = AdjustAirAccelQW(Physics_ClientOption(self, "airaccel_qw"), maxspd_mod); + if(Physics_ClientOption(self, "airstrafeaccel_qw")) + self.stat_sv_airstrafeaccel_qw = AdjustAirAccelQW(Physics_ClientOption(self, "airstrafeaccel_qw"), maxspd_mod); else self.stat_sv_airstrafeaccel_qw = 0; - self.stat_sv_airspeedlimit_nonqw = autocvar_sv_airspeedlimit_nonqw * maxspd_mod; - self.stat_sv_maxspeed = autocvar_sv_maxspeed * maxspd_mod; // also slow walking + self.stat_sv_airspeedlimit_nonqw = Physics_ClientOption(self, "airspeedlimit_nonqw") * maxspd_mod; + self.stat_sv_maxspeed = Physics_ClientOption(self, "maxspeed") * maxspd_mod; // also slow walking self.stat_movement_highspeed = PHYS_HIGHSPEED; // TODO: remove this! self.stat_doublejump = PHYS_DOUBLEJUMP; @@ -57,22 +145,47 @@ void Physics_UpdateStats(float maxspd_mod) self.stat_jetpack_maxspeed_up = PHYS_JETPACK_MAXSPEED_UP; self.stat_jetpack_fuel = PHYS_JETPACK_FUEL; - self.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MIN; - self.stat_jumpspeedcap_max = PHYS_JUMPSPEEDCAP_MAX; self.stat_jumpspeedcap_disable_onramps = PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS; self.stat_sv_friction_on_land = PHYS_FRICTION_ONLAND; self.stat_sv_friction_slick = PHYS_FRICTION_SLICK; + + self.stat_gameplayfix_easierwaterjump = GAMEPLAYFIX_EASIERWATERJUMP; + + + // old stats + // fix some new settings + self.stat_sv_airaccel_qw_stretchfactor = Physics_ClientOption(self, "airaccel_qw_stretchfactor"); + self.stat_sv_maxairstrafespeed = Physics_ClientOption(self, "maxairstrafespeed"); + self.stat_sv_maxairspeed = Physics_ClientOption(self, "maxairspeed"); + self.stat_sv_airstrafeaccelerate = Physics_ClientOption(self, "airstrafeaccelerate"); + self.stat_sv_warsowbunny_turnaccel = Physics_ClientOption(self, "warsowbunny_turnaccel"); + self.stat_sv_airaccel_sideways_friction = Physics_ClientOption(self, "airaccel_sideways_friction"); + self.stat_sv_aircontrol = Physics_ClientOption(self, "aircontrol"); + self.stat_sv_aircontrol_power = Physics_ClientOption(self, "aircontrol_power"); + self.stat_sv_aircontrol_penalty = Physics_ClientOption(self, "aircontrol_penalty"); + self.stat_sv_warsowbunny_airforwardaccel = Physics_ClientOption(self, "warsowbunny_airforwardaccel"); + self.stat_sv_warsowbunny_topspeed = Physics_ClientOption(self, "warsowbunny_topspeed"); + self.stat_sv_warsowbunny_accel = Physics_ClientOption(self, "warsowbunny_accel"); + self.stat_sv_warsowbunny_backtosideratio = Physics_ClientOption(self, "warsowbunny_backtosideratio"); + self.stat_sv_friction = Physics_ClientOption(self, "friction"); + self.stat_sv_accelerate = Physics_ClientOption(self, "accelerate"); + self.stat_sv_stopspeed = Physics_ClientOption(self, "stopspeed"); + 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 -float IsMoveInDirection(vector mv, float angle) // key mix factor +float IsMoveInDirection(vector mv, float ang) // key mix factor { if (mv_x == 0 && mv_y == 0) return 0; // avoid division by zero - angle -= RAD2DEG * atan2(mv_y, mv_x); - angle = remainder(angle, 360) / 45; - return angle > 1 ? 0 : angle < -1 ? 0 : 1 - fabs(angle); + ang -= RAD2DEG * atan2(mv_y, mv_x); + ang = remainder(ang, 360) / 45; + return ang > 1 ? 0 : ang < -1 ? 0 : 1 - fabs(ang); } float GeomLerp(float a, float lerp, float b) @@ -117,13 +230,13 @@ void PM_ClientMovement_Unstick() tracebox(neworigin, PL_CROUCH_MIN, PL_CROUCH_MAX, neworigin, MOVE_NORMAL, self); if (!trace_startsolid) { - self.origin = neworigin; + setorigin(self, neworigin); return;// true; } } } -void PM_ClientMovement_UpdateStatus() +void PM_ClientMovement_UpdateStatus(bool ground) { // make sure player is not stuck PM_ClientMovement_Unstick(); @@ -151,35 +264,41 @@ void PM_ClientMovement_UpdateStatus() vector origin1 = self.origin + '0 0 1'; vector origin2 = self.origin - '0 0 1'; - tracebox(origin1, self.mins, self.maxs, origin2, MOVE_NORMAL, self); - if (trace_fraction < 1 && trace_plane_normal_z > 0.7) + if(ground) { - SET_ONGROUND(self); + tracebox(origin1, self.mins, self.maxs, origin2, MOVE_NORMAL, self); + if (trace_fraction < 1.0 && trace_plane_normal_z > 0.7) + { + SET_ONGROUND(self); - // this code actually "predicts" an impact; so let's clip velocity first - float f = self.velocity * trace_plane_normal; - if (f < 0) // only if moving downwards actually + // this code actually "predicts" an impact; so let's clip velocity first + float f = self.velocity * trace_plane_normal; self.velocity -= f * trace_plane_normal; + } + else + UNSET_ONGROUND(self); } - else - UNSET_ONGROUND(self); // set watertype/waterlevel origin1 = self.origin; origin1_z += self.mins_z + 1; self.waterlevel = WATERLEVEL_NONE; - self.watertype = (pointcontents(origin1) == CONTENT_WATER); + int thepoint = pointcontents(origin1); + + self.watertype = (thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME); if(self.watertype) { self.waterlevel = WATERLEVEL_WETFEET; origin1_z = self.origin_z + (self.mins_z + self.maxs_z) * 0.5; - if(pointcontents(origin1) == CONTENT_WATER) + thepoint = pointcontents(origin1); + if(thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME) { self.waterlevel = WATERLEVEL_SWIMMING; origin1_z = self.origin_z + 22; - if(pointcontents(origin1) == CONTENT_WATER) + thepoint = pointcontents(origin1); + if(thepoint == CONTENT_WATER || thepoint == CONTENT_LAVA || thepoint == CONTENT_SLIME) self.waterlevel = WATERLEVEL_SUBMERGED; } } @@ -191,83 +310,99 @@ void PM_ClientMovement_UpdateStatus() void PM_ClientMovement_Move() { #ifdef CSQC - float t = PHYS_INPUT_TIMELENGTH; - vector primalvelocity = self.velocity; - PM_ClientMovement_UpdateStatus(); - float bump = 0; - for (bump = 0; bump < 8 && self.velocity * self.velocity > 0; bump++) + int bump; + float t; + float f; + vector neworigin; + vector currentorigin2; + vector neworigin2; + vector primalvelocity; + + vector trace1_endpos = '0 0 0'; + vector trace2_endpos = '0 0 0'; + vector trace3_endpos = '0 0 0'; + float trace1_fraction = 0; + float trace2_fraction = 0; + float trace3_fraction = 0; + vector trace1_plane_normal = '0 0 0'; + vector trace2_plane_normal = '0 0 0'; + vector trace3_plane_normal = '0 0 0'; + + + PM_ClientMovement_UpdateStatus(false); + primalvelocity = self.velocity; + for(bump = 0, t = PHYS_INPUT_TIMELENGTH; bump < 8 && (self.velocity * self.velocity) > 0; bump++) { - vector neworigin = self.origin + t * self.velocity; + neworigin = self.origin + t * self.velocity; tracebox(self.origin, self.mins, self.maxs, neworigin, MOVE_NORMAL, self); - float old_trace1_fraction = trace_fraction; - vector old_trace1_endpos = trace_endpos; - vector old_trace1_plane_normal = trace_plane_normal; - if (trace_fraction < 1 && trace_plane_normal_z == 0) + trace1_endpos = trace_endpos; + trace1_fraction = trace_fraction; + trace1_plane_normal = trace_plane_normal; + if(trace1_fraction < 1 && trace1_plane_normal_z == 0) { // may be a step or wall, try stepping up // first move forward at a higher level - vector currentorigin2 = self.origin; + currentorigin2 = self.origin; currentorigin2_z += PHYS_STEPHEIGHT; - vector neworigin2 = neworigin; - neworigin2_z = self.origin_z + PHYS_STEPHEIGHT; + neworigin2 = neworigin; + neworigin2_z += PHYS_STEPHEIGHT; tracebox(currentorigin2, self.mins, self.maxs, neworigin2, MOVE_NORMAL, self); - if (!trace_startsolid) + trace2_endpos = trace_endpos; + trace2_fraction = trace_fraction; + trace2_plane_normal = trace_plane_normal; + if(!trace_startsolid) { // then move down from there - currentorigin2 = trace_endpos; - neworigin2 = trace_endpos; + currentorigin2 = trace2_endpos; + neworigin2 = trace2_endpos; neworigin2_z = self.origin_z; - float old_trace2_fraction = trace_fraction; - vector old_trace2_plane_normal = trace_plane_normal; tracebox(currentorigin2, self.mins, self.maxs, neworigin2, MOVE_NORMAL, self); + trace3_endpos = trace_endpos; + trace3_fraction = trace_fraction; + trace3_plane_normal = trace_plane_normal; // accept the new trace if it made some progress - if (fabs(trace_endpos_x - old_trace1_endpos_x) >= 0.03125 || fabs(trace_endpos_y - old_trace1_endpos_y) >= 0.03125) + if(fabs(trace3_endpos_x - trace1_endpos_x) >= 0.03125 || fabs(trace3_endpos_y - trace1_endpos_y) >= 0.03125) { - trace_fraction = old_trace2_fraction; - trace_endpos = trace_endpos; - trace_plane_normal = old_trace2_plane_normal; - } - else - { - trace_fraction = old_trace1_fraction; - trace_endpos = old_trace1_endpos; - trace_plane_normal = old_trace1_plane_normal; + trace1_endpos = trace2_endpos; + trace1_fraction = trace2_fraction; + trace1_plane_normal = trace2_plane_normal; + trace1_endpos = trace3_endpos; } } } // check if it moved at all - if (trace_fraction >= 0.001) - self.origin = trace_endpos; + if(trace1_fraction >= 0.001) + setorigin(self, trace1_endpos); // check if it moved all the way - if (trace_fraction == 1) + if(trace1_fraction == 1) break; // this is only really needed for nogravityonground combined with gravityunaffectedbyticrate // I'm pretty sure I commented it out solely because it seemed redundant // this got commented out in a change that supposedly makes the code match QW better - // so if this is broken, maybe put it in an if (cls.protocol != PROTOCOL_QUAKEWORLD) block - if (trace_plane_normal_z > 0.7) + // so if this is broken, maybe put it in an if(cls.protocol != PROTOCOL_QUAKEWORLD) block + if(trace1_plane_normal_z > 0.7) SET_ONGROUND(self); - t -= t * trace_fraction; + t -= t * trace1_fraction; - float f = self.velocity * trace_plane_normal; - self.velocity -= f * trace_plane_normal; + f = (self.velocity * trace1_plane_normal); + self.velocity = self.velocity + -f * trace1_plane_normal; } - if (pmove_waterjumptime > 0) + if(pmove_waterjumptime > 0) self.velocity = primalvelocity; #endif } void CPM_PM_Aircontrol(vector wishdir, float wishspeed) { - float k = 32 * (2 * IsMoveInDirection(PHYS_INPUT_MOVEVALUES(self), 0) - 1); + float k = 32 * (2 * IsMoveInDirection(self.movement, 0) - 1); if (k <= 0) return; - k *= bound(0, wishspeed / PHYS_MAXAIRSPEED, 1); + k *= bound(0, wishspeed / PHYS_MAXAIRSPEED(self), 1); float zspeed = self.velocity_z; self.velocity_z = 0; @@ -278,7 +413,7 @@ void CPM_PM_Aircontrol(vector wishdir, float wishspeed) if (dot > 0) // we can't change direction while slowing down { - k *= pow(dot, PHYS_AIRCONTROL_POWER)*PHYS_INPUT_TIMELENGTH; + k *= pow(dot, PHYS_AIRCONTROL_POWER) * PHYS_INPUT_TIMELENGTH; xyspeed = max(0, xyspeed - PHYS_AIRCONTROL_PENALTY * sqrt(max(0, 1 - dot*dot)) * k/32); k *= PHYS_AIRCONTROL; self.velocity = normalize(self.velocity * xyspeed + wishdir * k); @@ -405,7 +540,7 @@ When you press the jump key returns true if handled ============= */ -float PlayerJump (void) +bool PlayerJump (void) { if (PHYS_FROZEN(self)) return true; // no jumping in freezetag when frozen @@ -415,15 +550,15 @@ float PlayerJump (void) return true; // no jumping while blocked #endif - float doublejump = false; + bool doublejump = false; float mjumpheight = PHYS_JUMPVELOCITY; - player_multijump = doublejump; - player_jumpheight = mjumpheight; #ifdef SVQC - if (MUTATOR_CALLHOOK(PlayerJump)) + if (MUTATOR_CALLHOOK(PlayerJump, doublejump, mjumpheight)) #elif defined(CSQC) - if(PM_multijump_checkjump()) + player_multijump = doublejump; + player_jumpheight = mjumpheight; + if (PM_multijump_checkjump()) #endif return true; @@ -463,22 +598,22 @@ float PlayerJump (void) // velocity bounds. Final velocity is bound between (jumpheight * // min + jumpheight) and (jumpheight * max + jumpheight); - if(PHYS_JUMPSPEEDCAP_MIN) + if(PHYS_JUMPSPEEDCAP_MIN != "") { - float minjumpspeed = mjumpheight * PHYS_JUMPSPEEDCAP_MIN; + float minjumpspeed = mjumpheight * stof(PHYS_JUMPSPEEDCAP_MIN); if (self.velocity_z < minjumpspeed) mjumpheight += minjumpspeed - self.velocity_z; } - if(PHYS_JUMPSPEEDCAP_MAX) + if(PHYS_JUMPSPEEDCAP_MAX != "") { // don't do jump speedcaps on ramps to preserve old xonotic ramjump style tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self); if (!(trace_fraction < 1 && trace_plane_normal_z < 0.98 && PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS)) { - float maxjumpspeed = mjumpheight * PHYS_JUMPSPEEDCAP_MAX; + float maxjumpspeed = mjumpheight * stof(PHYS_JUMPSPEEDCAP_MAX); if (self.velocity_z > maxjumpspeed) mjumpheight -= self.velocity_z - maxjumpspeed; @@ -487,16 +622,20 @@ float PlayerJump (void) if (!WAS_ONGROUND(self)) { +#ifdef SVQC if(autocvar_speedmeter) dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n")); +#endif if(self.lastground < time - 0.3) { self.velocity_x *= (1 - PHYS_FRICTION_ONLAND); self.velocity_y *= (1 - PHYS_FRICTION_ONLAND); } +#ifdef SVQC if(self.jumppadcount > 1) dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n")); self.jumppadcount = 0; +#endif } self.velocity_z += mjumpheight; @@ -519,7 +658,7 @@ float PlayerJump (void) void CheckWaterJump() { // check for a jump-out-of-water - makevectors(PHYS_INPUT_ANGLES(self)); + makevectors(self.v_angle); vector start = self.origin; start_z += 8; v_forward_z = 0; @@ -535,10 +674,12 @@ void CheckWaterJump() if (trace_fraction == 1) { // open at eye level self.velocity_z = 225; -#ifdef SVQC self.flags |= FL_WATERJUMP; SET_JUMP_HELD(self); +#ifdef SVQC self.teleport_time = time + 2; // safety net +#elif defined(CSQC) + pmove_waterjumptime = time + 2; #endif } } @@ -557,24 +698,18 @@ void CheckWaterJump() void CheckPlayerJump() { #ifdef SVQC - float was_flying = ITEMS(self) & IT_USING_JETPACK; + float was_flying = ITEMS_STAT(self) & IT_USING_JETPACK; #endif if (JETPACK_JUMP(self) < 2) -#ifdef SVQC - ITEMS(self) &= ~IT_USING_JETPACK; -#endif + ITEMS_STAT(self) &= ~IT_USING_JETPACK; if(PHYS_INPUT_BUTTON_JUMP(self) || PHYS_INPUT_BUTTON_JETPACK(self)) { -#ifdef SVQC float air_jump = !PlayerJump() || self.multijump_count > 0; // PlayerJump() has important side effects float activate = JETPACK_JUMP(self) && air_jump && PHYS_INPUT_BUTTON_JUMP(self) || PHYS_INPUT_BUTTON_JETPACK(self); - float has_fuel = !autocvar_g_jetpack_fuel || self.ammo_fuel || ITEMS(self) & IT_UNLIMITED_WEAPON_AMMO; -#else - PlayerJump(); // Client only - float has_fuel = true; // TODO -#endif - if (!(ITEMS(self) & IT_JETPACK)) { } + float has_fuel = !PHYS_JETPACK_FUEL || PHYS_AMMO_FUEL(self) || ITEMS_STAT(self) & IT_UNLIMITED_WEAPON_AMMO; + + if (!(ITEMS_STAT(self) & ITEM_Jetpack.m_itemid)) { } else if (self.jetpack_stopped) { } else if (!has_fuel) { @@ -585,21 +720,15 @@ void CheckPlayerJump() Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_JETPACK_NOFUEL); #endif self.jetpack_stopped = true; -#ifdef SVQC - ITEMS(self) &= ~IT_USING_JETPACK; -#endif + ITEMS_STAT(self) &= ~IT_USING_JETPACK; } -#ifdef SVQC else if (activate && !PHYS_FROZEN(self)) - ITEMS(self) |= IT_USING_JETPACK; -#endif + ITEMS_STAT(self) |= IT_USING_JETPACK; } else { self.jetpack_stopped = false; -#ifdef SVQC - ITEMS(self) &= ~IT_USING_JETPACK; -#endif + ITEMS_STAT(self) &= ~IT_USING_JETPACK; } if (!PHYS_INPUT_BUTTON_JUMP(self)) UNSET_JUMP_HELD(self); @@ -635,8 +764,8 @@ void RaceCarPhysics() vector rigvel; vector angles_save = self.angles; - float accel = bound(-1, PHYS_INPUT_MOVEVALUES(self).x / PHYS_MAXSPEED(self), 1); - float steer = bound(-1, PHYS_INPUT_MOVEVALUES(self).y / PHYS_MAXSPEED(self), 1); + float accel = bound(-1, self.movement.x / PHYS_MAXSPEED(self), 1); + float steer = bound(-1, self.movement.y / PHYS_MAXSPEED(self), 1); if (g_bugrigs_reverse_speeding) { @@ -911,13 +1040,13 @@ void PM_check_nickspam(void) if (self.nickspamcount >= autocvar_g_nick_flood_penalty_yellow) { // slight annoyance for nick change scripts - PHYS_INPUT_MOVEVALUES(self) = -1 * PHYS_INPUT_MOVEVALUES(self); + self.movement = -1 * self.movement; self.BUTTON_ATCK = self.BUTTON_JUMP = self.BUTTON_ATCK2 = self.BUTTON_ZOOM = self.BUTTON_CROUCH = self.BUTTON_HOOK = self.BUTTON_USE = 0; if (self.nickspamcount >= autocvar_g_nick_flood_penalty_red) // if you are persistent and the slight annoyance above does not stop you, I'll show you! { - PHYS_INPUT_ANGLES(self)_x = random() * 360; - PHYS_INPUT_ANGLES(self)_y = random() * 360; + self.v_angle_x = random() * 360; + self.v_angle_y = random() * 360; // at least I'm not forcing retardedview by also assigning to angles_z self.fixangle = true; } @@ -954,7 +1083,9 @@ void PM_check_spider(void) if (time >= self.spider_slowness) return; PHYS_MAXSPEED(self) *= 0.5; // half speed while slow from spider - self.stat_sv_airspeedlimit_nonqw *= 0.5; + PHYS_MAXAIRSPEED(self) *= 0.5; + PHYS_AIRSPEEDLIMIT_NONQW(self) *= 0.5; + PHYS_AIRSTRAFEACCELERATE(self) *= 0.5; #endif } @@ -969,12 +1100,12 @@ void PM_check_frozen(void) #endif ) { - PHYS_INPUT_MOVEVALUES(self)_x = bound(-5, PHYS_INPUT_MOVEVALUES(self).x, 5); - PHYS_INPUT_MOVEVALUES(self)_y = bound(-5, PHYS_INPUT_MOVEVALUES(self).y, 5); - PHYS_INPUT_MOVEVALUES(self)_z = bound(-5, PHYS_INPUT_MOVEVALUES(self).z, 5); + self.movement_x = bound(-5, self.movement.x, 5); + self.movement_y = bound(-5, self.movement.y, 5); + self.movement_z = bound(-5, self.movement.z, 5); } else - PHYS_INPUT_MOVEVALUES(self) = '0 0 0'; + self.movement = '0 0 0'; vector midpoint = ((self.absmin + self.absmax) * 0.5); if (pointcontents(midpoint) == CONTENT_WATER) @@ -986,12 +1117,39 @@ void PM_check_frozen(void) } } +void PM_check_hitground() +{ +#ifdef SVQC + if (IS_ONGROUND(self)) + if (IS_PLAYER(self)) // no fall sounds for observers thank you very much + if (self.wasFlying) + { + self.wasFlying = 0; + if (self.waterlevel < WATERLEVEL_SWIMMING) + if (time >= self.ladder_time) + if (!self.hook) + { + self.nextstep = time + 0.3 + random() * 0.1; + trace_dphitq3surfaceflags = 0; + tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self); + if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)) + { + if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS) + GlobalSound(globalsound_metalfall, CH_PLAYER, VOICETYPE_PLAYERSOUND); + else + GlobalSound(globalsound_fall, CH_PLAYER, VOICETYPE_PLAYERSOUND); + } + } + } +#endif +} + void PM_check_blocked(void) { #ifdef SVQC if (!self.player_blocked) return; - PHYS_INPUT_MOVEVALUES(self) = '0 0 0'; + self.movement = '0 0 0'; self.disableclientprediction = 1; #endif } @@ -999,12 +1157,11 @@ void PM_check_blocked(void) #ifdef SVQC float speedaward_lastsent; float speedaward_lastupdate; -string GetMapname(void); #endif void PM_check_race(void) { #ifdef SVQC - if not(g_cts || g_race) + if(!(g_cts || g_race)) return; if (vlen(self.velocity - self.velocity_z * '0 0 1') > speedaward_speed) { @@ -1036,7 +1193,7 @@ void PM_check_vortex(void) #ifdef SVQC // WEAPONTODO float xyspeed = vlen(vec2(self.velocity)); - if (self.weapon == WEP_VORTEX && WEP_CVAR(vortex, charge) && WEP_CVAR(vortex, charge_velocity_rate) && xyspeed > WEP_CVAR(vortex, charge_minspeed)) + if (self.weapon == WEP_VORTEX.m_id && WEP_CVAR(vortex, charge) && WEP_CVAR(vortex, charge_velocity_rate) && xyspeed > WEP_CVAR(vortex, charge_minspeed)) { // add a maximum of charge_velocity_rate when going fast (f = 1), gradually increasing from minspeed (f = 0) to maxspeed xyspeed = min(xyspeed, WEP_CVAR(vortex, charge_maxspeed)); @@ -1053,16 +1210,19 @@ void PM_fly(float maxspd_mod) UNSET_ONGROUND(self); self.velocity = self.velocity * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION); - makevectors(PHYS_INPUT_ANGLES(self)); - //wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x + v_right * PHYS_INPUT_MOVEVALUES(self).y + v_up * PHYS_INPUT_MOVEVALUES(self).z; - vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x - + v_right * PHYS_INPUT_MOVEVALUES(self).y - + '0 0 1' * PHYS_INPUT_MOVEVALUES(self).z; + makevectors(self.v_angle); + //wishvel = v_forward * self.movement.x + v_right * self.movement.y + v_up * self.movement.z; + vector wishvel = v_forward * self.movement.x + + v_right * self.movement.y + + '0 0 1' * self.movement.z; // acceleration vector wishdir = normalize(wishvel); float wishspeed = min(vlen(wishvel), PHYS_MAXSPEED(self) * maxspd_mod); +#ifdef SVQC if (time >= self.teleport_time) +#endif PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0); + PM_ClientMovement_Move(); } void PM_swim(float maxspd_mod) @@ -1075,7 +1235,7 @@ void PM_swim(float maxspd_mod) // this mimics quakeworld code if (jump && self.waterlevel == WATERLEVEL_SWIMMING && self.velocity_z >= -180) { - vector yawangles = '0 1 0' * PHYS_INPUT_ANGLES(self).y; + vector yawangles = '0 1 0' * self.v_angle.y; makevectors(yawangles); vector forward = v_forward; vector spot = self.origin + 24 * forward; @@ -1095,11 +1255,11 @@ void PM_swim(float maxspd_mod) } } } - makevectors(PHYS_INPUT_ANGLES(self)); - //wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x + v_right * PHYS_INPUT_MOVEVALUES(self).y + v_up * PHYS_INPUT_MOVEVALUES(self).z; - vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x - + v_right * PHYS_INPUT_MOVEVALUES(self).y - + '0 0 1' * PHYS_INPUT_MOVEVALUES(self).z; + makevectors(self.v_angle); + //wishvel = v_forward * self.movement.x + v_right * self.movement.y + v_up * self.movement.z; + vector wishvel = v_forward * self.movement.x + + v_right * self.movement.y + + '0 0 1' * self.movement.z; if (wishvel == '0 0 0') wishvel = '0 0 -60'; // drift towards bottom @@ -1143,9 +1303,9 @@ void PM_swim(float maxspd_mod) #endif } } - PM_ClientMovement_Move(); // water acceleration PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0); + PM_ClientMovement_Move(); } void PM_ladder(float maxspd_mod) @@ -1164,11 +1324,11 @@ void PM_ladder(float maxspd_mod) } self.velocity = self.velocity * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION); - makevectors(PHYS_INPUT_ANGLES(self)); - //wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x + v_right * PHYS_INPUT_MOVEVALUES(self).y + v_up * PHYS_INPUT_MOVEVALUES(self).z; - vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self)_x - + v_right * PHYS_INPUT_MOVEVALUES(self)_y - + '0 0 1' * PHYS_INPUT_MOVEVALUES(self)_z; + makevectors(self.v_angle); + //wishvel = v_forward * self.movement.x + v_right * self.movement.y + v_up * self.movement.z; + vector wishvel = v_forward * self.movement_x + + v_right * self.movement_y + + '0 0 1' * self.movement_z; self.velocity_z += g; if (self.ladder_entity.classname == "func_water") { @@ -1193,22 +1353,22 @@ void PM_ladder(float maxspd_mod) // acceleration vector wishdir = normalize(wishvel); float wishspeed = min(vlen(wishvel), PHYS_MAXSPEED(self) * maxspd_mod); - PM_ClientMovement_Move(); #ifdef SVQC if (time >= self.teleport_time) #endif // water acceleration PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE*maxspd_mod, 1, 0, 0, 0); + PM_ClientMovement_Move(); } void PM_jetpack(float maxspd_mod) { - //makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0'); - makevectors(PHYS_INPUT_ANGLES(self)); - vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self)_x - + v_right * PHYS_INPUT_MOVEVALUES(self)_y; + //makevectors(self.v_angle.y * '0 1 0'); + makevectors(self.v_angle); + vector wishvel = v_forward * self.movement_x + + v_right * self.movement_y; // add remaining speed as Z component - float maxairspd = PHYS_MAXAIRSPEED * max(1, maxspd_mod); + float maxairspd = PHYS_MAXAIRSPEED(self) * max(1, maxspd_mod); // fix speedhacks :P wishvel = normalize(wishvel) * min(1, vlen(wishvel) / maxairspd); // add the unused velocity as up component @@ -1281,7 +1441,7 @@ void PM_jetpack(float maxspd_mod) wishvel_z = (wishvel_z - PHYS_GRAVITY) * fz + PHYS_GRAVITY; fvel = min(1, vlen(wishvel) / best); - if (PHYS_JETPACK_FUEL && !(ITEMS(self) & IT_UNLIMITED_WEAPON_AMMO)) + if (PHYS_JETPACK_FUEL && !(ITEMS_STAT(self) & IT_UNLIMITED_WEAPON_AMMO)) f = min(1, PHYS_AMMO_FUEL(self) / (PHYS_JETPACK_FUEL * PHYS_INPUT_TIMELENGTH * fvel)); else f = 1; @@ -1294,10 +1454,10 @@ void PM_jetpack(float maxspd_mod) UNSET_ONGROUND(self); #ifdef SVQC - if (!(ITEMS(self) & IT_UNLIMITED_WEAPON_AMMO)) + if (!(ITEMS_STAT(self) & IT_UNLIMITED_WEAPON_AMMO)) self.ammo_fuel -= PHYS_JETPACK_FUEL * PHYS_INPUT_TIMELENGTH * fvel * f; - ITEMS(self) |= IT_USING_JETPACK; + ITEMS_STAT(self) |= IT_USING_JETPACK; // jetpack also inhibits health regeneration, but only for 1 second self.pauseregen_finished = max(self.pauseregen_finished, time + autocvar_g_balance_pause_fuel_regen); @@ -1316,200 +1476,28 @@ void PM_jetpack(float maxspd_mod) self.velocity_z -= g * 0.5; #endif } -#ifdef SVQC -void SV_WalkMove () -{ - // if PHYS_INPUT_TIMELENGTH is 0 (due to client sending the same timestamp twice), - // don't move - if (PHYS_INPUT_TIMELENGTH <= 0) - return; - -// if (autocvar_sv_gameplayfix_unstickplayers) -// SV_CheckStuck (self); - -// applygravity = !SV_CheckWater(self) && self.movetype == MOVETYPE_WALK && !(self.flags & FL_WATERJUMP); - -// hitsupercontentsmask = SV_GenericHitSuperContentsMask(self); - -// SV_CheckVelocity(self); - - // do a regular slide move unless it looks like you ran into a step -// float oldonground = self.flags & FL_ONGROUND; - - vector start_origin = self.origin; - vector start_velocity = self.velocity; - - float clip = 0; -// clip = SV_FlyMove (self, PHYS_INPUT_TIMELENGTH, applygravity, NULL, hitsupercontentsmask, sv_gameplayfix_stepmultipletimes.integer ? sv_stepheight.value : 0); - -// if(sv_gameplayfix_downtracesupportsongroundflag.integer) -// if(!(clip & 1)) - { - // only try this if there was no floor in the way in the trace (no, - // this check seems to be not REALLY necessary, because if clip & 1, - // our trace will hit that thing too) - vector upmove = self.origin; - upmove_z++; - vector downmove = self.origin; - upmove_z--; - float type; - if (self.movetype == MOVETYPE_FLYMISSILE) - type = MOVE_MISSILE; - else if (self.movetype == MOVETYPE_FLY_WORLDONLY) - type = MOVE_WORLDONLY; - else if (self.solid == SOLID_TRIGGER || self.solid == SOLID_NOT) - type = MOVE_NOMONSTERS; // only clip against bmodels - else - type = MOVE_NORMAL; - vector entmins = self.mins; - vector entmaxs = self.maxs; - tracebox(upmove, entmins, entmaxs, downmove, type, self); - if(trace_fraction < 1 && trace_plane_normal_z > 0.7) - clip |= 1; // but we HAVE found a floor - } - - // if the move did not hit the ground at any point, we're not on ground -// if(!(clip & 1)) -// self.flags = self.flags & ~FL_ONGROUND; - -// SV_CheckVelocity(self); -// SV_LinkEdict(self); -// SV_LinkEdict_TouchAreaGrid(self); - - if(clip & 8) // teleport - return; - - if (self.flags & FL_WATERJUMP) - return; - -// if (autocvar_sv_nostep) -// return; - - vector originalmove_origin = self.origin; - vector originalmove_velocity = self.velocity; - float originalmove_flags = self.flags; - entity originalmove_groundentity = self.groundentity; - - // if move didn't block on a step, return - if (clip & 2) - { - // if move was not trying to move into the step, return - if (fabs(start_velocity_x) < 0.03125 && fabs(start_velocity_y) < 0.03125) - return; - - if (self.movetype != MOVETYPE_FLY) - { - // return if gibbed by a trigger - if (self.movetype != MOVETYPE_WALK) - return; - - // return if attempting to jump while airborn (unless sv_jumpstep) -// if (!autocvar_sv_jumpstep) -// if (!oldonground && PRVM_serveredictfloat(self, waterlevel) == 0) -// return; - } - - // try moving up and forward to go up a step - // back to start pos - self.origin = start_origin; - self.velocity = start_velocity; - - // move up - vector upmove = '0 0 0'; - upmove_z = autocvar_sv_stepheight; -// if(!SV_PushEntity(&trace, self, upmove, true)) -// { -// // we got teleported when upstepping... must abort the move -// return; -// } - - // move forward - self.velocity_z = 0; -// clip = SV_FlyMove (self, PHYS_INPUT_TIMELENGTH, applygravity, stepnormal, hitsupercontentsmask, 0); - self.velocity_z += start_velocity_z; -// if(clip & 8) -// { -// // we got teleported when upstepping... must abort the move -// // note that z velocity handling may not be what QC expects here, but we cannot help it -// return; -// } - -// SV_CheckVelocity(self); -// SV_LinkEdict(self); -// SV_LinkEdict_TouchAreaGrid(self); - - // check for stuckness, possibly due to the limited precision of floats - // in the clipping hulls - if (clip - && fabs(originalmove_origin_y - self.origin_y < 0.03125) - && fabs(originalmove_origin_x - self.origin_x < 0.03125)) - { - //Con_Printf("wall\n"); - // stepping up didn't make any progress, revert to original move - self.origin = originalmove_origin; - self.velocity = originalmove_velocity; - self.flags = originalmove_flags; - self.groundentity = originalmove_groundentity; - return; - } - - //Con_Printf("step - "); - - // extra friction based on view angle -// if (clip & 2 && sv_wallfriction.integer) -// SV_WallFriction (self, stepnormal); - } - // don't do the down move if stepdown is disabled, moving upward, not in water, or the move started offground or ended onground -// else if (!autocvar_sv_gameplayfix_stepdown || self.waterlevel >= 3 || start_velocity_z >= (1.0 / 32.0) || !oldonground || (self.flags & FL_ONGROUND)) -// return; - // move down - vector downmove = '0 0 0'; - downmove_z = -autocvar_sv_stepheight + start_velocity_z*PHYS_INPUT_TIMELENGTH; -// if(!SV_PushEntity (&downtrace, self, downmove, true)) -// { -// // we got teleported when downstepping... must abort the move -// return; -// } - - if (trace_fraction < 1 && trace_plane_normal_z > 0.7) - { - // this has been disabled so that you can't jump when you are stepping - // up while already jumping (also known as the Quake2 double jump bug) - } - else - { - //Con_Printf("slope\n"); - // if the push down didn't end up on good ground, use the move without - // the step up. This happens near wall / slope combinations, and can - // cause the player to hop up higher on a slope too steep to climb - self.origin = originalmove_origin; - self.velocity = originalmove_velocity; - self.flags = originalmove_flags; - self.groundentity = originalmove_groundentity; - } - -// SV_CheckVelocity(self); -// SV_LinkEdict(self); -// SV_LinkEdict_TouchAreaGrid(self); -} -#endif void PM_walk(float buttons_prev, float maxspd_mod) { if (!WAS_ONGROUND(self)) { +#ifdef SVQC if (autocvar_speedmeter) dprint(strcat("landing velocity: ", vtos(self.velocity), " (abs: ", ftos(vlen(self.velocity)), ")\n")); +#endif if (self.lastground < time - 0.3) self.velocity *= (1 - PHYS_FRICTION_ONLAND); +#ifdef SVQC if (self.jumppadcount > 1) dprint(strcat(ftos(self.jumppadcount), "x jumppad combo\n")); self.jumppadcount = 0; +#endif } + // walking - makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0'); - vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x - + v_right * PHYS_INPUT_MOVEVALUES(self).y; + makevectors(self.v_angle.y * '0 1 0'); + vector wishvel = v_forward * self.movement.x + + v_right * self.movement.y; // acceleration vector wishdir = normalize(wishvel); float wishspeed = vlen(wishvel); @@ -1576,9 +1564,9 @@ void PM_walk(float buttons_prev, float maxspd_mod) void PM_air(float buttons_prev, float maxspd_mod) { - makevectors(PHYS_INPUT_ANGLES(self).y * '0 1 0'); - vector wishvel = v_forward * PHYS_INPUT_MOVEVALUES(self).x - + v_right * PHYS_INPUT_MOVEVALUES(self).y; + makevectors(self.v_angle.y * '0 1 0'); + vector wishvel = v_forward * self.movement.x + + v_right * self.movement.y; // acceleration vector wishdir = normalize(wishvel); float wishspeed = vlen(wishvel); @@ -1589,7 +1577,7 @@ void PM_air(float buttons_prev, float maxspd_mod) if (pmove_waterjumptime <= 0) #endif { - float maxairspd = PHYS_MAXAIRSPEED * min(maxspd_mod, 1); + float maxairspd = PHYS_MAXAIRSPEED(self) * min(maxspd_mod, 1); // apply air speed limit float airaccelqw = PHYS_AIRACCEL_QW(self); @@ -1616,11 +1604,11 @@ void PM_air(float buttons_prev, float maxspd_mod) // dv/dt = accel * maxspeed * (1 - accelqw) (when fast) // log dv/dt = logaccel + logmaxspeed (when slow) // log dv/dt = logaccel + logmaxspeed + log(1 - accelqw) (when fast) - float strafity = IsMoveInDirection(PHYS_INPUT_MOVEVALUES(self), -90) + IsMoveInDirection(PHYS_INPUT_MOVEVALUES(self), +90); // if one is nonzero, other is always zero + float strafity = IsMoveInDirection(self.movement, -90) + IsMoveInDirection(self.movement, +90); // if one is nonzero, other is always zero if (PHYS_MAXAIRSTRAFESPEED) - wishspeed = min(wishspeed, GeomLerp(PHYS_MAXAIRSPEED*maxspd_mod, strafity, PHYS_MAXAIRSTRAFESPEED*maxspd_mod)); - if (PHYS_AIRSTRAFEACCELERATE) - airaccel = GeomLerp(airaccel, strafity, PHYS_AIRSTRAFEACCELERATE*maxspd_mod); + wishspeed = min(wishspeed, GeomLerp(PHYS_MAXAIRSPEED(self)*maxspd_mod, strafity, PHYS_MAXAIRSTRAFESPEED*maxspd_mod)); + if (PHYS_AIRSTRAFEACCELERATE(self)) + airaccel = GeomLerp(airaccel, strafity, PHYS_AIRSTRAFEACCELERATE(self)*maxspd_mod); if (PHYS_AIRSTRAFEACCEL_QW(self)) airaccelqw = (((strafity > 0.5 ? PHYS_AIRSTRAFEACCEL_QW(self) : PHYS_AIRACCEL_QW(self)) >= 0) ? +1 : -1) @@ -1628,7 +1616,7 @@ void PM_air(float buttons_prev, float maxspd_mod) (1 - GeomLerp(1 - fabs(PHYS_AIRACCEL_QW(self)), strafity, 1 - fabs(PHYS_AIRSTRAFEACCEL_QW(self)))); // !CPM - if (PHYS_WARSOWBUNNY_TURNACCEL && accelerating && PHYS_INPUT_MOVEVALUES(self).y == 0 && PHYS_INPUT_MOVEVALUES(self).x != 0) + if (PHYS_WARSOWBUNNY_TURNACCEL && accelerating && self.movement.y == 0 && self.movement.x != 0) PM_AirAccelerate(wishdir, wishspeed2); else PM_Accelerate(wishdir, wishspeed, wishspeed0, airaccel, airaccelqw, PHYS_AIRACCEL_QW_STRETCHFACTOR(self), PHYS_AIRACCEL_SIDEWAYS_FRICTION / maxairspd, PHYS_AIRSPEEDLIMIT_NONQW(self)); @@ -1648,26 +1636,39 @@ void PM_air(float buttons_prev, float maxspd_mod) } // used for calculating airshots -float PM_is_flying() +bool IsFlying(entity a) { - if (IS_ONGROUND(self)) - return 0; - if (self.waterlevel >= WATERLEVEL_SWIMMING) - return 0; - traceline(self.origin, self.origin - '0 0 48', MOVE_NORMAL, self); - return trace_fraction >= 1; + if(IS_ONGROUND(a)) + return false; + if(a.waterlevel >= WATERLEVEL_SWIMMING) + return false; + traceline(a.origin, a.origin - '0 0 48', MOVE_NORMAL, a); + if(trace_fraction < 1) + return false; + return true; } void PM_Main() { - float buttons = PHYS_INPUT_BUTTON_MASK(self); + int buttons = PHYS_INPUT_BUTTON_MASK(self); #ifdef CSQC + self.items = getstati(STAT_ITEMS, 0, 24); + + self.movement = PHYS_INPUT_MOVEVALUES(self); + + vector oldv_angle = self.v_angle; + vector oldangles = self.angles; // we need to save these, as they're abused by other code + self.v_angle = PHYS_INPUT_ANGLES(self); + self.angles = PHYS_WORLD_ANGLES(self); + self.team = myteam + 1; // is this correct? if (!(PHYS_INPUT_BUTTON_JUMP(self))) // !jump UNSET_JUMP_HELD(self); // canjump = true pmove_waterjumptime -= PHYS_INPUT_TIMELENGTH; + + PM_ClientMovement_UpdateStatus(true); #endif - PM_ClientMovement_UpdateStatus(); + #ifdef SVQC WarpZone_PlayerPhysics_FixVAngle(); @@ -1694,14 +1695,14 @@ void PM_Main() #ifdef SVQC if (sv_maxidle > 0) { - if (buttons != self.buttons_old || PHYS_INPUT_MOVEVALUES(self) != self.movement_old || PHYS_INPUT_ANGLES(self) != self.v_angle_old) + if (buttons != self.buttons_old || self.movement != self.movement_old || self.v_angle != self.v_angle_old) self.parm_idlesince = time; } #endif - float buttons_prev = self.buttons_old; + int buttons_prev = self.buttons_old; self.buttons_old = buttons; - self.movement_old = PHYS_INPUT_MOVEVALUES(self); - self.v_angle_old = PHYS_INPUT_ANGLES(self); + self.movement_old = self.movement; + self.v_angle_old = self.v_angle; PM_check_nickspam(); @@ -1723,14 +1724,14 @@ void PM_Main() self.race_penalty = 0; #endif - float not_allowed_to_move = 0; + bool not_allowed_to_move = false; #ifdef SVQC if (self.race_penalty) - not_allowed_to_move = 1; + not_allowed_to_move = true; #endif #ifdef SVQC if (time < game_starttime) - not_allowed_to_move = 1; + not_allowed_to_move = true; #endif if (not_allowed_to_move) @@ -1759,6 +1760,8 @@ void PM_Main() self.disableclientprediction = 0; #endif + viewloc_PlayerPhysics(); + PM_check_spider(); PM_check_frozen(); @@ -1794,7 +1797,7 @@ void PM_Main() #ifdef SVQC if (!IS_PLAYER(self)) { - maxspeed_mod *= autocvar_sv_spectator_speed_multiplier; + maxspeed_mod = autocvar_sv_spectator_speed_multiplier; if (!self.spectatorspeed) self.spectatorspeed = maxspeed_mod; if (self.impulse && self.impulse <= 19 || (self.impulse >= 200 && self.impulse <= 209) || (self.impulse >= 220 && self.impulse <= 229)) @@ -1812,61 +1815,67 @@ void PM_Main() } // otherwise just clear self.impulse = 0; } - maxspeed_mod *= self.spectatorspeed; + maxspeed_mod = self.spectatorspeed; } -#endif -#ifdef SVQC - // if dead, behave differently - // in CSQC, physics don't handle dead player - if (self.deadflag) - goto end; -#endif + float spd = max(PHYS_MAXSPEED(self), PHYS_MAXAIRSPEED(self)) * maxspeed_mod; + if(self.speed != spd) + { + self.speed = spd; + string temps = ftos(spd); + stuffcmd(self, strcat("cl_forwardspeed ", temps, "\n")); + stuffcmd(self, strcat("cl_backspeed ", temps, "\n")); + stuffcmd(self, strcat("cl_sidespeed ", temps, "\n")); + stuffcmd(self, strcat("cl_upspeed ", temps, "\n")); + } -#ifdef SVQC - if (!self.fixangle && !g_bugrigs) - self.angles = '0 1 0' * PHYS_INPUT_ANGLES(self).y; + if(self.stat_jumpspeedcap_min != PHYS_JUMPSPEEDCAP_MIN) + { + self.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MIN; + stuffcmd(self, strcat("cl_jumpspeedcap_min ", PHYS_JUMPSPEEDCAP_MIN, "\n")); + } + if(self.stat_jumpspeedcap_max != PHYS_JUMPSPEEDCAP_MAX) + { + self.stat_jumpspeedcap_min = PHYS_JUMPSPEEDCAP_MAX; + stuffcmd(self, strcat("cl_jumpspeedcap_max ", PHYS_JUMPSPEEDCAP_MAX, "\n")); + } #endif -#ifdef SVQC - if (IS_ONGROUND(self)) - if (IS_PLAYER(self)) // no fall sounds for observers thank you very much - if (self.wasFlying) + if(PHYS_DEAD(self)) { - self.wasFlying = 0; - if (self.waterlevel < WATERLEVEL_SWIMMING) - if (time >= self.ladder_time) - if (!self.hook) + // handle water here + vector midpoint = ((self.absmin + self.absmax) * 0.5); + if(pointcontents(midpoint) == CONTENT_WATER) { - self.nextstep = time + 0.3 + random() * 0.1; - trace_dphitq3surfaceflags = 0; - tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 1', MOVE_NOMONSTERS, self); - if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)) - { - if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS) - GlobalSound(globalsound_metalfall, CH_PLAYER, VOICETYPE_PLAYERSOUND); - else - GlobalSound(globalsound_fall, CH_PLAYER, VOICETYPE_PLAYERSOUND); - } + self.velocity = self.velocity * 0.5; + + // do we want this? + //if(pointcontents(midpoint + '0 0 2') == CONTENT_WATER) + //{ self.velocity_z = 70; } } + goto end; } + +#ifdef SVQC + if (!self.fixangle && !g_bugrigs) + self.angles = '0 1 0' * self.v_angle.y; #endif - if (PM_is_flying()) + PM_check_hitground(); + + if(IsFlying(self)) self.wasFlying = 1; -#ifdef SVQC if (IS_PLAYER(self)) -#endif CheckPlayerJump(); - if (self.flags & /* FL_WATERJUMP */ 2048) + if (self.flags & FL_WATERJUMP) { self.velocity_x = self.movedir_x; self.velocity_y = self.movedir_y; if (time > self.teleport_time || self.waterlevel == WATERLEVEL_NONE) { - self.flags &= ~/* FL_WATERJUMP */ 2048; + self.flags &= ~FL_WATERJUMP; self.teleport_time = 0; } } @@ -1876,7 +1885,7 @@ void PM_Main() RaceCarPhysics(); #endif - else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY || self.movetype == MOVETYPE_FLY_WORLDONLY) + else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY || self.movetype == MOVETYPE_FLY_WORLDONLY || (BUFFS_STAT(self) & BUFF_FLIGHT.m_itemid)) PM_fly(maxspeed_mod); else if (self.waterlevel >= WATERLEVEL_SWIMMING) @@ -1885,16 +1894,14 @@ void PM_Main() else if (time < self.ladder_time) PM_ladder(maxspeed_mod); - else if (ITEMS(self) & IT_USING_JETPACK) + else if (ITEMS_STAT(self) & IT_USING_JETPACK) PM_jetpack(maxspeed_mod); + else if (IS_ONGROUND(self)) + PM_walk(buttons_prev, maxspeed_mod); + else - { - if (IS_ONGROUND(self)) - PM_walk(buttons_prev, maxspeed_mod); - else - PM_air(buttons_prev, maxspeed_mod); - } + PM_air(buttons_prev, maxspeed_mod); #ifdef SVQC if (!IS_OBSERVER(self)) @@ -1907,16 +1914,17 @@ void PM_Main() self.lastground = time; // conveyors: then break velocity again - if (self.conveyor.state) + if(self.conveyor.state) self.velocity += self.conveyor.movedir; -#ifdef SVQC self.lastflags = self.flags; -#elif defined(CSQC) - self.lastflags = self.pmove_flags; -#endif self.lastclassname = self.classname; + +#ifdef CSQC + self.v_angle = oldv_angle; + self.angles = oldangles; +#endif } #ifdef SVQC @@ -1926,4 +1934,11 @@ void CSQC_ClientMovement_PlayerMove_Frame(void) #endif { PM_Main(); + +#ifdef CSQC + self.pmove_flags = + ((self.flags & FL_DUCKED) ? PMF_DUCKED : 0) | + (!(self.flags & FL_JUMPRELEASED) ? 0 : PMF_JUMP_HELD) | + ((self.flags & FL_ONGROUND) ? PMF_ONGROUND : 0); +#endif }