X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fphysics.qc;h=aab87365408e9c139caf783d20b0b69fec6b6e7d;hb=8adaa8e23fddd40d2ef9bfb7ff764966554f80b8;hp=f42d06ed2f3230df4605d7625f23f97cdc4fc273;hpb=206456c572a467a5e6ff1d7e423a8a19558288b1;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/physics.qc b/qcsrc/common/physics.qc index f42d06ed2..aab873654 100644 --- a/qcsrc/common/physics.qc +++ b/qcsrc/common/physics.qc @@ -73,9 +73,6 @@ void Physics_AddStats() addstat(STAT_MOVEVARS_CL_TRACK_CANJUMP, AS_INT, cvar_cl_movement_track_canjump); addstat(STAT_MOVEVARS_TRACK_CANJUMP, AS_INT, stat_sv_track_canjump); - // double jump - addstat(STAT_DOUBLEJUMP, AS_INT, stat_doublejump); - // jump speed caps addstat(STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS, AS_INT, stat_jumpspeedcap_disable_onramps); @@ -129,8 +126,6 @@ void Physics_UpdateStats(float 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; - self.stat_jetpack_antigravity = PHYS_JETPACK_ANTIGRAVITY; self.stat_jetpack_accel_up = PHYS_JETPACK_ACCEL_UP; self.stat_jetpack_accel_side = PHYS_JETPACK_ACCEL_SIDE; @@ -297,9 +292,14 @@ void PM_ClientMovement_UpdateStatus(entity this, bool ground) pmove_waterjumptime = 0; } -void PM_ClientMovement_Move() -{SELFPARAM(); +void PM_ClientMovement_Move(entity this) +{ #ifdef CSQC + + PM_ClientMovement_UpdateStatus(this, false); + if(autocvar_cl_movement == 3) + return; + int bump; float t; float f; @@ -318,13 +318,11 @@ void PM_ClientMovement_Move() vector trace2_plane_normal = '0 0 0'; vector trace3_plane_normal = '0 0 0'; - - PM_ClientMovement_UpdateStatus(this, false); - primalvelocity = self.velocity; - for(bump = 0, t = PHYS_INPUT_TIMELENGTH; bump < 8 && (self.velocity * self.velocity) > 0; bump++) + primalvelocity = this.velocity; + for(bump = 0, t = PHYS_INPUT_TIMELENGTH; bump < 8 && (this.velocity * this.velocity) > 0; bump++) { - neworigin = self.origin + t * self.velocity; - tracebox(self.origin, self.mins, self.maxs, neworigin, MOVE_NORMAL, self); + neworigin = this.origin + t * this.velocity; + tracebox(this.origin, this.mins, this.maxs, neworigin, MOVE_NORMAL, this); trace1_endpos = trace_endpos; trace1_fraction = trace_fraction; trace1_plane_normal = trace_plane_normal; @@ -332,11 +330,11 @@ void PM_ClientMovement_Move() { // may be a step or wall, try stepping up // first move forward at a higher level - currentorigin2 = self.origin; + currentorigin2 = this.origin; currentorigin2_z += PHYS_STEPHEIGHT; neworigin2 = neworigin; neworigin2_z += PHYS_STEPHEIGHT; - tracebox(currentorigin2, self.mins, self.maxs, neworigin2, MOVE_NORMAL, self); + tracebox(currentorigin2, this.mins, this.maxs, neworigin2, MOVE_NORMAL, this); trace2_endpos = trace_endpos; trace2_fraction = trace_fraction; trace2_plane_normal = trace_plane_normal; @@ -345,8 +343,8 @@ void PM_ClientMovement_Move() // then move down from there currentorigin2 = trace2_endpos; neworigin2 = trace2_endpos; - neworigin2_z = self.origin_z; - tracebox(currentorigin2, self.mins, self.maxs, neworigin2, MOVE_NORMAL, self); + neworigin2_z = this.origin_z; + tracebox(currentorigin2, this.mins, this.maxs, neworigin2, MOVE_NORMAL, this); trace3_endpos = trace_endpos; trace3_fraction = trace_fraction; trace3_plane_normal = trace_plane_normal; @@ -363,7 +361,7 @@ void PM_ClientMovement_Move() // check if it moved at all if(trace1_fraction >= 0.001) - setorigin(self, trace1_endpos); + setorigin(this, trace1_endpos); // check if it moved all the way if(trace1_fraction == 1) @@ -374,15 +372,15 @@ void PM_ClientMovement_Move() // 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(trace1_plane_normal_z > 0.7) - SET_ONGROUND(self); + SET_ONGROUND(this); t -= t * trace1_fraction; - f = (self.velocity * trace1_plane_normal); - self.velocity = self.velocity + -f * trace1_plane_normal; + f = (this.velocity * trace1_plane_normal); + this.velocity = this.velocity + -f * trace1_plane_normal; } if(pmove_waterjumptime > 0) - self.velocity = primalvelocity; + this.velocity = primalvelocity; #endif } @@ -542,10 +540,6 @@ bool PlayerJump () bool doublejump = false; float mjumpheight = PHYS_JUMPVELOCITY; -#ifdef CSQC - player_multijump = doublejump; - player_jumpheight = mjumpheight; -#endif if (MUTATOR_CALLHOOK(PlayerJump, doublejump, mjumpheight)) return true; @@ -553,21 +547,6 @@ bool PlayerJump () doublejump = player_multijump; mjumpheight = player_jumpheight; - if (PHYS_DOUBLEJUMP) - { - 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.7) - { - doublejump = true; - - // we MUST clip velocity here! - float f; - f = self.velocity * trace_plane_normal; - if (f < 0) - self.velocity -= f * trace_plane_normal; - } - } - if (self.waterlevel >= WATERLEVEL_SWIMMING) { self.velocity_z = PHYS_MAXSPEED(self) * 0.7; @@ -685,8 +664,6 @@ void CheckWaterJump() #define JETPACK_JUMP(s) autocvar_cl_jetpack_jump #endif .float jetpack_stopped; -// Hack: shouldn't need to know about this -.float multijump_count; void CheckPlayerJump() {SELFPARAM(); #ifdef SVQC @@ -697,7 +674,7 @@ void CheckPlayerJump() if(PHYS_INPUT_BUTTON_JUMP(self) || PHYS_INPUT_BUTTON_JETPACK(self)) { - float air_jump = !PlayerJump() || self.multijump_count > 0; // PlayerJump() has important side effects + float air_jump = !PlayerJump() || player_multijump; // 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 = !PHYS_JETPACK_FUEL || PHYS_AMMO_FUEL(self) || ITEMS_STAT(self) & IT_UNLIMITED_WEAPON_AMMO; @@ -747,224 +724,14 @@ float racecar_angle(float forward, float down) return ret * angle_mult; } -void RaceCarPhysics() -{SELFPARAM(); -#ifdef SVQC - // using this move type for "big rigs" - // the engine does not push the entity! - - vector rigvel; - - vector angles_save = self.angles; - 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) - { - if (accel < 0) - { - // back accel is DIGITAL - // to prevent speedhack - if (accel < -0.5) - accel = -1; - else - accel = 0; - } - } - - self.angles_x = 0; - self.angles_z = 0; - makevectors(self.angles); // new forward direction! - - if (IS_ONGROUND(self) || g_bugrigs_air_steering) - { - float myspeed = self.velocity * v_forward; - float upspeed = self.velocity * v_up; - - // responsiveness factor for steering and acceleration - float f = 1 / (1 + pow(max(-myspeed, myspeed) / g_bugrigs_speed_ref, g_bugrigs_speed_pow)); - //MAXIMA: f(v) := 1 / (1 + (v / g_bugrigs_speed_ref) ^ g_bugrigs_speed_pow); - - float steerfactor; - if (myspeed < 0 && g_bugrigs_reverse_spinning) - steerfactor = -myspeed * g_bugrigs_steer; - else - steerfactor = -myspeed * f * g_bugrigs_steer; - - float accelfactor; - if (myspeed < 0 && g_bugrigs_reverse_speeding) - accelfactor = g_bugrigs_accel; - else - accelfactor = f * g_bugrigs_accel; - //MAXIMA: accel(v) := f(v) * g_bugrigs_accel; - - if (accel < 0) - { - if (myspeed > 0) - { - myspeed = max(0, myspeed - PHYS_INPUT_TIMELENGTH * (g_bugrigs_friction_floor - g_bugrigs_friction_brake * accel)); - } - else - { - if (!g_bugrigs_reverse_speeding) - myspeed = min(0, myspeed + PHYS_INPUT_TIMELENGTH * g_bugrigs_friction_floor); - } - } - else - { - if (myspeed >= 0) - { - myspeed = max(0, myspeed - PHYS_INPUT_TIMELENGTH * g_bugrigs_friction_floor); - } - else - { - if (g_bugrigs_reverse_stopping) - myspeed = 0; - else - myspeed = min(0, myspeed + PHYS_INPUT_TIMELENGTH * (g_bugrigs_friction_floor + g_bugrigs_friction_brake * accel)); - } - } - // terminal velocity = velocity at which 50 == accelfactor, that is, 1549 units/sec - //MAXIMA: friction(v) := g_bugrigs_friction_floor; - - self.angles_y += steer * PHYS_INPUT_TIMELENGTH * steerfactor; // apply steering - makevectors(self.angles); // new forward direction! - - myspeed += accel * accelfactor * PHYS_INPUT_TIMELENGTH; - - rigvel = myspeed * v_forward + '0 0 1' * upspeed; - } - else - { - float myspeed = vlen(self.velocity); - - // responsiveness factor for steering and acceleration - float f = 1 / (1 + pow(max(0, myspeed / g_bugrigs_speed_ref), g_bugrigs_speed_pow)); - float steerfactor = -myspeed * f; - self.angles_y += steer * PHYS_INPUT_TIMELENGTH * steerfactor; // apply steering - - rigvel = self.velocity; - makevectors(self.angles); // new forward direction! - } - - rigvel *= max(0, 1 - vlen(rigvel) * g_bugrigs_friction_air * PHYS_INPUT_TIMELENGTH); - //MAXIMA: airfriction(v) := v * v * g_bugrigs_friction_air; - //MAXIMA: total_acceleration(v) := accel(v) - friction(v) - airfriction(v); - //MAXIMA: solve(total_acceleration(v) = 0, v); - - if (g_bugrigs_planar_movement) - { - vector rigvel_xy, neworigin, up; - float mt; - - rigvel_z -= PHYS_INPUT_TIMELENGTH * PHYS_GRAVITY; // 4x gravity plays better - rigvel_xy = vec2(rigvel); - - if (g_bugrigs_planar_movement_car_jumping) - mt = MOVE_NORMAL; - else - mt = MOVE_NOMONSTERS; - - tracebox(self.origin, self.mins, self.maxs, self.origin + '0 0 1024', mt, self); - up = trace_endpos - self.origin; - - // BUG RIGS: align the move to the surface instead of doing collision testing - // can we move? - tracebox(trace_endpos, self.mins, self.maxs, trace_endpos + rigvel_xy * PHYS_INPUT_TIMELENGTH, mt, self); - - // align to surface - tracebox(trace_endpos, self.mins, self.maxs, trace_endpos - up + '0 0 1' * rigvel_z * PHYS_INPUT_TIMELENGTH, mt, self); - - if (trace_fraction < 0.5) - { - trace_fraction = 1; - neworigin = self.origin; - } - else - neworigin = trace_endpos; - - if (trace_fraction < 1) - { - // now set angles_x so that the car points parallel to the surface - self.angles = vectoangles( - '1 0 0' * v_forward_x * trace_plane_normal_z - + - '0 1 0' * v_forward_y * trace_plane_normal_z - + - '0 0 1' * -(v_forward_x * trace_plane_normal_x + v_forward_y * trace_plane_normal_y) - ); - SET_ONGROUND(self); - } - else - { - // now set angles_x so that the car points forward, but is tilted in velocity direction - UNSET_ONGROUND(self); - } - - self.velocity = (neworigin - self.origin) * (1.0 / PHYS_INPUT_TIMELENGTH); - self.movetype = MOVETYPE_NOCLIP; - } - else - { - rigvel_z -= PHYS_INPUT_TIMELENGTH * PHYS_GRAVITY; // 4x gravity plays better - self.velocity = rigvel; - self.movetype = MOVETYPE_FLY; - } - - trace_fraction = 1; - tracebox(self.origin, self.mins, self.maxs, self.origin - '0 0 4', MOVE_NORMAL, self); - if (trace_fraction != 1) - { - self.angles = vectoangles2( - '1 0 0' * v_forward_x * trace_plane_normal_z - + - '0 1 0' * v_forward_y * trace_plane_normal_z - + - '0 0 1' * -(v_forward_x * trace_plane_normal_x + v_forward_y * trace_plane_normal_y), - trace_plane_normal - ); - } - else - { - vector vel_local; - - vel_local_x = v_forward * self.velocity; - vel_local_y = v_right * self.velocity; - vel_local_z = v_up * self.velocity; - - self.angles_x = racecar_angle(vel_local_x, vel_local_z); - self.angles_z = racecar_angle(-vel_local_y, vel_local_z); - } - - // smooth the angles - vector vf1, vu1, smoothangles; - makevectors(self.angles); - float f = bound(0, PHYS_INPUT_TIMELENGTH * g_bugrigs_angle_smoothing, 1); - if (f == 0) - f = 1; - vf1 = v_forward * f; - vu1 = v_up * f; - makevectors(angles_save); - vf1 = vf1 + v_forward * (1 - f); - vu1 = vu1 + v_up * (1 - f); - smoothangles = vectoangles2(vf1, vu1); - self.angles_x = -smoothangles_x; - self.angles_z = smoothangles_z; -#endif -} - string specialcommand = "xwxwxsxsxaxdxaxdx1x "; .float specialcommand_pos; void SpecialCommand() { #ifdef SVQC -#ifdef TETRIS - TetrisImpulse(); -#else if (!CheatImpulse(99)) LOG_INFO("A hollow voice says \"Plugh\".\n"); #endif -#endif } float PM_check_specialcommand(float buttons) @@ -1049,18 +816,6 @@ void PM_check_punch() #endif } -void PM_check_spider() -{SELFPARAM(); -#ifdef SVQC - if (time >= self.spider_slowness) - return; - PHYS_MAXSPEED(self) *= 0.5; // half speed while slow from spider - PHYS_MAXAIRSPEED(self) *= 0.5; - PHYS_AIRSPEEDLIMIT_NONQW(self) *= 0.5; - PHYS_AIRSTRAFEACCELERATE(self) *= 0.5; -#endif -} - // predict frozen movement, as frozen players CAN move in some cases void PM_check_frozen() {SELFPARAM(); @@ -1118,22 +873,6 @@ void PM_check_blocked() #endif } -void PM_check_vortex() -{SELFPARAM(); -#ifdef SVQC - // WEAPONTODO - float xyspeed = vlen(vec2(self.velocity)); - 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)); - float f = (xyspeed - WEP_CVAR(vortex, charge_minspeed)) / (WEP_CVAR(vortex, charge_maxspeed) - WEP_CVAR(vortex, charge_minspeed)); - // add the extra charge - self.vortex_charge = min(1, self.vortex_charge + WEP_CVAR(vortex, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH); - } -#endif -} - void PM_fly(float maxspd_mod) {SELFPARAM(); // noclipping or flying @@ -1152,7 +891,7 @@ void PM_fly(float maxspd_mod) if (time >= self.teleport_time) #endif PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0); - PM_ClientMovement_Move(); + PM_ClientMovement_Move(self); } void PM_swim(float maxspd_mod) @@ -1235,7 +974,7 @@ void PM_swim(float maxspd_mod) } // water acceleration PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE * maxspd_mod, 1, 0, 0, 0); - PM_ClientMovement_Move(); + PM_ClientMovement_Move(self); } void PM_ladder(float maxspd_mod) @@ -1288,7 +1027,7 @@ void PM_ladder(float maxspd_mod) #endif // water acceleration PM_Accelerate(wishdir, wishspeed, wishspeed, PHYS_ACCELERATE*maxspd_mod, 1, 0, 0, 0); - PM_ClientMovement_Move(); + PM_ClientMovement_Move(self); } void PM_jetpack(float maxspd_mod) @@ -1396,14 +1135,20 @@ void PM_jetpack(float maxspd_mod) #ifdef CSQC float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(self) * PHYS_INPUT_TIMELENGTH; - if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE) - self.velocity_z -= g * 0.5; - else - self.velocity_z -= g; - PM_ClientMovement_Move(); - if (!IS_ONGROUND(self) || !(GAMEPLAYFIX_NOGRAVITYONGROUND)) + if(autocvar_cl_movement != 3) + { if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE) self.velocity_z -= g * 0.5; + else + self.velocity_z -= g; + } + PM_ClientMovement_Move(self); + if(autocvar_cl_movement != 3) + { + if (!IS_ONGROUND(self) || !(GAMEPLAYFIX_NOGRAVITYONGROUND)) + if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE) + self.velocity_z -= g * 0.5; + } #endif } @@ -1479,14 +1224,22 @@ void PM_walk(entity this, float maxspd_mod) const float accelspeed = min(PHYS_ACCELERATE * PHYS_INPUT_TIMELENGTH * wishspeed, addspeed); this.velocity += accelspeed * wishdir; } +#ifdef CSQC const float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(this) * PHYS_INPUT_TIMELENGTH; - if (!(GAMEPLAYFIX_NOGRAVITYONGROUND)) - this.velocity_z -= g * (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1); + if(autocvar_cl_movement != 3) + { + if (!(GAMEPLAYFIX_NOGRAVITYONGROUND)) + this.velocity_z -= g * (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE ? 0.5 : 1); + } if (vdist(this.velocity, >, 0)) - PM_ClientMovement_Move(); - if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE) - if (!IS_ONGROUND(this) || !GAMEPLAYFIX_NOGRAVITYONGROUND) - this.velocity_z -= g * 0.5; + PM_ClientMovement_Move(self); + if(autocvar_cl_movement != 3) + { + if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE) + if (!IS_ONGROUND(this) || !GAMEPLAYFIX_NOGRAVITYONGROUND) + this.velocity_z -= g * 0.5; + } +#endif } void PM_air(float buttons_prev, float maxspd_mod) @@ -1551,15 +1304,21 @@ void PM_air(float buttons_prev, float maxspd_mod) if (PHYS_AIRCONTROL) CPM_PM_Aircontrol(wishdir, wishspeed2); } +#ifdef CSQC float g = PHYS_GRAVITY * PHYS_ENTGRAVITY(self) * PHYS_INPUT_TIMELENGTH; + if(autocvar_cl_movement != 3) if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE) self.velocity_z -= g * 0.5; else self.velocity_z -= g; - PM_ClientMovement_Move(); +#endif + PM_ClientMovement_Move(self); +#ifdef CSQC + if(autocvar_cl_movement != 3) if (!IS_ONGROUND(self) || !(GAMEPLAYFIX_NOGRAVITYONGROUND)) if (GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE) self.velocity_z -= g * 0.5; +#endif } // used for calculating airshots @@ -1670,8 +1429,6 @@ void PM_Main(entity this) viewloc_PlayerPhysics(); - PM_check_spider(); - PM_check_frozen(); PM_check_blocked(); @@ -1750,7 +1507,7 @@ void PM_Main(entity this) } #ifdef SVQC - if (!this.fixangle && !g_bugrigs) + if (!this.fixangle) this.angles = '0 1 0' * this.v_angle.y; #endif @@ -1773,10 +1530,8 @@ void PM_Main(entity this) } } -#ifdef SVQC - else if (g_bugrigs && IS_PLAYER(this)) - RaceCarPhysics(); -#endif + else if (MUTATOR_CALLHOOK(PM_Physics, maxspeed_mod)) + { } else if (this.movetype == MOVETYPE_NOCLIP || this.movetype == MOVETYPE_FLY || this.movetype == MOVETYPE_FLY_WORLDONLY || MUTATOR_CALLHOOK(IsFlying, this)) PM_fly(maxspeed_mod); @@ -1796,8 +1551,6 @@ void PM_Main(entity this) else PM_air(buttons_prev, maxspeed_mod); - PM_check_vortex(); - :end if (IS_ONGROUND(this)) this.lastground = time;