X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcl_physics.qc;h=337342333c0b0230b6d2362d5c1a4119b79d350a;hb=165d542813201a21cb6152ea5d22454e43e117c7;hp=43c7be517958e718b864f25bbf46e699b741c90d;hpb=34ddb935433f04eb7679c27ec17fae9bc2541c0d;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/cl_physics.qc b/qcsrc/server/cl_physics.qc index 43c7be517..337342333 100644 --- a/qcsrc/server/cl_physics.qc +++ b/qcsrc/server/cl_physics.qc @@ -1,3 +1,29 @@ +#if defined(CSQC) +#elif defined(MENUQC) +#elif defined(SVQC) + #include "../dpdefs/progsdefs.qh" + #include "../dpdefs/dpextensions.qh" + #include "../warpzonelib/mathlib.qh" + #include "../warpzonelib/server.qh" + #include "../common/constants.qh" + #include "../common/util.qh" + #include "../common/animdecide.qh" + #include "../common/monsters/sv_monsters.qh" + #include "../common/weapons/weapons.qh" + #include "t_items.qh" + #include "autocvars.qh" + #include "defs.qh" + #include "../common/notifications.qh" + #include "mutators/mutators_include.qh" + #include "../common/mapinfo.qh" + #include "../csqcmodellib/sv_model.qh" + #include "anticheat.qh" + #include "cheats.qh" + #include "g_hook.qh" + #include "race.qh" + #include "playerdemo.qh" +#endif + .float race_penalty; .float restart_jump; @@ -5,7 +31,7 @@ .entity ladder_entity; .float gravity; .float swamp_slowdown; -.float lastflags; +.int lastflags; .float lastground; .float wasFlying; .float spectatorspeed; @@ -15,29 +41,34 @@ PlayerJump When you press the jump key +returns true if handled ============= */ -void PlayerJump (void) +float PlayerJump (void) { + if(self.frozen) + return true; // no jumping in freezetag when frozen + if(self.player_blocked) - return; // no jumping while blocked + return true; // no jumping while blocked - float doublejump = FALSE; + float doublejump = false; + float mjumpheight = autocvar_sv_jumpvelocity; player_multijump = doublejump; + player_jumpheight = mjumpheight; if(MUTATOR_CALLHOOK(PlayerJump)) - return; + return true; doublejump = player_multijump; - - float mjumpheight; + mjumpheight = player_jumpheight; if (autocvar_sv_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) + if (trace_fraction < 1 && trace_plane_normal.z > 0.7) { - doublejump = TRUE; + doublejump = true; // we MUST clip velocity here! float f; @@ -47,20 +78,19 @@ void PlayerJump (void) } } - mjumpheight = autocvar_sv_jumpvelocity; if (self.waterlevel >= WATERLEVEL_SWIMMING) { self.velocity_z = self.stat_sv_maxspeed * 0.7; - return; + return true; } if (!doublejump) if (!(self.flags & FL_ONGROUND)) - return; + return !(self.flags & FL_JUMPRELEASED); if(self.cvar_cl_movement_track_canjump) if (!(self.flags & FL_JUMPRELEASED)) - return; + return true; // sv_jumpspeedcap_min/sv_jumpspeedcap_max act as baseline // velocity bounds. Final velocity is bound between (jumpheight * @@ -72,8 +102,8 @@ void PlayerJump (void) minjumpspeed = mjumpheight * stof(autocvar_sv_jumpspeedcap_min); - if (self.velocity_z < minjumpspeed) - mjumpheight += minjumpspeed - self.velocity_z; + if (self.velocity.z < minjumpspeed) + mjumpheight += minjumpspeed - self.velocity.z; } if(autocvar_sv_jumpspeedcap_max != "") @@ -81,14 +111,14 @@ void PlayerJump (void) // 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 && autocvar_sv_jumpspeedcap_max_disable_on_ramps)) + if(!(trace_fraction < 1 && trace_plane_normal.z < 0.98 && autocvar_sv_jumpspeedcap_max_disable_on_ramps)) { float maxjumpspeed; maxjumpspeed = mjumpheight * stof(autocvar_sv_jumpspeedcap_max); - if (self.velocity_z > maxjumpspeed) - mjumpheight -= self.velocity_z - maxjumpspeed; + if (self.velocity.z > maxjumpspeed) + mjumpheight -= self.velocity.z - maxjumpspeed; } } @@ -106,19 +136,20 @@ void PlayerJump (void) self.jumppadcount = 0; } - self.velocity_z = self.velocity_z + mjumpheight; - self.oldvelocity_z = self.velocity_z; + self.velocity_z = self.velocity.z + mjumpheight; + self.oldvelocity_z = self.velocity.z; self.flags &= ~FL_ONGROUND; self.flags &= ~FL_JUMPRELEASED; - animdecide_setaction(self, ANIMACTION_JUMP, TRUE); + animdecide_setaction(self, ANIMACTION_JUMP, true); if(autocvar_g_jump_grunt) PlayerSound(playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND); self.restart_jump = -1; // restart jump anim next time // value -1 is used to not use the teleport bit (workaround for tiny hitch when re-jumping) + return true; } void CheckWaterJump() { @@ -127,17 +158,17 @@ void CheckWaterJump() // check for a jump-out-of-water makevectors (self.angles); start = self.origin; - start_z = start_z + 8; - v_forward_z = 0; + start.z = start.z + 8; + v_forward.z = 0; normalize(v_forward); end = start + v_forward*24; - traceline (start, end, TRUE, self); + traceline (start, end, true, self); if (trace_fraction < 1) { // solid at waist - start_z = start_z + self.maxs_z - 8; + start.z = start.z + self.maxs.z - 8; end = start + v_forward*24; self.movedir = trace_plane_normal * -50; - traceline (start, end, TRUE, self); + traceline (start, end, true, self); if (trace_fraction == 1) { // open at eye level self.flags |= FL_WATERJUMP; @@ -148,11 +179,42 @@ void CheckWaterJump() } } } + +.float jetpack_stopped; +// Hack: shouldn't need to know about this +.float multijump_count; void CheckPlayerJump() { - if (self.BUTTON_JUMP) - PlayerJump (); + float was_flying = self.items & IT_USING_JETPACK; + + if (self.cvar_cl_jetpack_jump < 2) + self.items &= ~IT_USING_JETPACK; + + if (self.BUTTON_JUMP || self.BUTTON_JETPACK) + { + float air_jump = !PlayerJump() || self.multijump_count > 0; // PlayerJump() has important side effects + float activate = self.cvar_cl_jetpack_jump && air_jump && self.BUTTON_JUMP || self.BUTTON_JETPACK; + float has_fuel = !autocvar_g_jetpack_fuel || self.ammo_fuel || self.items & IT_UNLIMITED_WEAPON_AMMO; + if (!(self.items & IT_JETPACK)) { } + else if (self.jetpack_stopped) { } + else if (!has_fuel) + { + if (was_flying) // TODO: ran out of fuel message + Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_JETPACK_NOFUEL); + else if (activate) + Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_JETPACK_NOFUEL); + self.jetpack_stopped = true; + self.items &= ~IT_USING_JETPACK; + } + else if (activate && !self.frozen) + self.items |= IT_USING_JETPACK; + } else + { + self.jetpack_stopped = false; + self.items &= ~IT_USING_JETPACK; + } + if (!self.BUTTON_JUMP) self.flags |= FL_JUMPRELEASED; if (self.waterlevel == WATERLEVEL_SWIMMING) @@ -188,8 +250,8 @@ void RaceCarPhysics() vector angles_save, rigvel; angles_save = self.angles; - accel = bound(-1, self.movement_x / self.stat_sv_maxspeed, 1); - steer = bound(-1, self.movement_y / self.stat_sv_maxspeed, 1); + accel = bound(-1, self.movement.x / self.stat_sv_maxspeed, 1); + steer = bound(-1, self.movement.y / self.stat_sv_maxspeed, 1); if(g_bugrigs_reverse_speeding) { @@ -289,7 +351,7 @@ void RaceCarPhysics() vector rigvel_xy, neworigin, up; float mt; - rigvel_z -= frametime * autocvar_sv_gravity; // 4x gravity plays better + rigvel.z -= frametime * autocvar_sv_gravity; // 4x gravity plays better rigvel_xy = vec2(rigvel); if(g_bugrigs_planar_movement_car_jumping) @@ -305,7 +367,7 @@ void RaceCarPhysics() tracebox(trace_endpos, self.mins, self.maxs, trace_endpos + rigvel_xy * frametime, mt, self); // align to surface - tracebox(trace_endpos, self.mins, self.maxs, trace_endpos - up + '0 0 1' * rigvel_z * frametime, mt, self); + tracebox(trace_endpos, self.mins, self.maxs, trace_endpos - up + '0 0 1' * rigvel.z * frametime, mt, self); if(trace_fraction < 0.5) { @@ -319,11 +381,11 @@ void RaceCarPhysics() { // 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 + '1 0 0' * v_forward.x * trace_plane_normal.z + - '0 1 0' * v_forward_y * 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) + '0 0 1' * -(v_forward.x * trace_plane_normal.x + v_forward.y * trace_plane_normal.y) ); self.flags |= FL_ONGROUND; } @@ -338,7 +400,7 @@ void RaceCarPhysics() } else { - rigvel_z -= frametime * autocvar_sv_gravity; // 4x gravity plays better + rigvel.z -= frametime * autocvar_sv_gravity; // 4x gravity plays better self.velocity = rigvel; self.movetype = MOVETYPE_FLY; } @@ -348,11 +410,11 @@ void RaceCarPhysics() if(trace_fraction != 1) { self.angles = vectoangles2( - '1 0 0' * v_forward_x * trace_plane_normal_z + '1 0 0' * v_forward.x * trace_plane_normal.z + - '0 1 0' * v_forward_y * 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), + '0 0 1' * -(v_forward.x * trace_plane_normal.x + v_forward.y * trace_plane_normal.y), trace_plane_normal ); } @@ -360,12 +422,12 @@ void RaceCarPhysics() { vector vel_local; - vel_local_x = v_forward * self.velocity; - vel_local_y = v_right * self.velocity; - vel_local_z = v_up * self.velocity; + 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); + 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 @@ -380,15 +442,15 @@ void RaceCarPhysics() 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; + self.angles_x = -smoothangles.x; + self.angles_z = smoothangles.z; } float IsMoveInDirection(vector mv, float angle) // key mix factor { - if(mv_x == 0 && mv_y == 0) + if(mv.x == 0 && mv.y == 0) return 0; // avoid division by zero - angle -= RAD2DEG * atan2(mv_y, mv_x); + angle -= RAD2DEG * atan2(mv.y, mv.x); angle = remainder(angle, 360) / 45; if(angle > 1) return 0; @@ -422,7 +484,7 @@ void CPM_PM_Aircontrol(vector wishdir, float wishspeed) #if 0 // this doesn't play well with analog input - if(self.movement_x == 0 || self.movement_y != 0) + if(self.movement_x == 0 || self.movement.y != 0) return; // can't control movement if not moving forward or backward k = 32; #else @@ -433,7 +495,7 @@ void CPM_PM_Aircontrol(vector wishdir, float wishspeed) k *= bound(0, wishspeed / autocvar_sv_maxairspeed, 1); - zspeed = self.velocity_z; + zspeed = self.velocity.z; self.velocity_z = 0; xyspeed = vlen(self.velocity); self.velocity = normalize(self.velocity); @@ -464,7 +526,7 @@ float AdjustAirAccelQW(float accelqw, float factor) void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float accel, float accelqw, float stretchfactor, float sidefric, float speedlimit) { float vel_straight; - float vel_z; + float velZ; vector vel_perpend; float step; @@ -487,7 +549,7 @@ void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float acce wishspeed0 = wishspeed; vel_straight = self.velocity * wishdir; - vel_z = self.velocity_z; + velZ = self.velocity.z; vel_xy = vec2(self.velocity); vel_perpend = vel_xy - vel_straight * wishdir; @@ -535,7 +597,7 @@ void PM_Accelerate(vector wishdir, float wishspeed, float wishspeed0, float acce } } - self.velocity = vel_xy + vel_z * '0 0 1'; + self.velocity = vel_xy + velZ * '0 0 1'; } void PM_AirAccelerate(vector wishdir, float wishspeed) @@ -548,7 +610,7 @@ void PM_AirAccelerate(vector wishdir, float wishspeed) return; curvel = self.velocity; - curvel_z = 0; + curvel.z = 0; curspeed = vlen(curvel); if(wishspeed > curspeed * 1.01) @@ -631,7 +693,7 @@ void SV_PlayerPhysics() vector wishvel, wishdir, v; float wishspeed, f, maxspd_mod, spd, maxairspd, airaccel, swampspd_mod, buttons; string temps; - float buttons_prev; + int buttons_prev; float not_allowed_to_move; string c; @@ -666,7 +728,7 @@ void SV_PlayerPhysics() anticheat_physics(); - buttons = self.BUTTON_ATCK + 2 * self.BUTTON_JUMP + 4 * self.BUTTON_ATCK2 + 8 * self.BUTTON_ZOOM + 16 * self.BUTTON_CROUCH + 32 * self.BUTTON_HOOK + 64 * self.BUTTON_USE + 128 * (self.movement_x < 0) + 256 * (self.movement_x > 0) + 512 * (self.movement_y < 0) + 1024 * (self.movement_y > 0); + buttons = self.BUTTON_ATCK + 2 * self.BUTTON_JUMP + 4 * self.BUTTON_ATCK2 + 8 * self.BUTTON_ZOOM + 16 * self.BUTTON_CROUCH + 32 * self.BUTTON_HOOK + 64 * self.BUTTON_USE + 128 * (self.movement.x < 0) + 256 * (self.movement.x > 0) + 512 * (self.movement.y < 0) + 1024 * (self.movement.y > 0); if(!buttons) c = "x"; @@ -720,7 +782,7 @@ void SV_PlayerPhysics() self.angles_x = random() * 360; self.angles_y = random() * 360; // at least I'm not forcing retardedview by also assigning to angles_z - self.fixangle = TRUE; + self.fixangle = true; } } @@ -749,8 +811,6 @@ void SV_PlayerPhysics() bot_think(); } - self.items &= ~IT_USING_JETPACK; - if(IS_PLAYER(self)) { if(self.race_penalty) @@ -760,7 +820,6 @@ void SV_PlayerPhysics() not_allowed_to_move = 0; if(self.race_penalty) not_allowed_to_move = 1; - if(!autocvar_sv_ready_restart_after_countdown) if(time < game_starttime) not_allowed_to_move = 1; @@ -792,6 +851,28 @@ void SV_PlayerPhysics() self.stat_sv_airspeedlimit_nonqw *= 0.5; } + if(self.frozen) + { + if(autocvar_sv_dodging_frozen && IS_REAL_CLIENT(self)) + { + 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 + self.movement = '0 0 0'; + self.disableclientprediction = 1; + + vector midpoint = ((self.absmin + self.absmax) * 0.5); + if(pointcontents(midpoint) == CONTENT_WATER) + { + self.velocity = self.velocity * 0.5; + + if(pointcontents(midpoint + '0 0 16') == CONTENT_WATER) + { self.velocity_z = 200; } + } + } + MUTATOR_CALLHOOK(PlayerPhysics); if(self.player_blocked) @@ -855,7 +936,7 @@ void SV_PlayerPhysics() if (!self.fixangle && !g_bugrigs) { self.angles_x = 0; - self.angles_y = self.v_angle_y; + self.angles_y = self.v_angle.y; self.angles_z = 0; } @@ -890,8 +971,8 @@ void SV_PlayerPhysics() if (self.flags & FL_WATERJUMP ) { - self.velocity_x = self.movedir_x; - self.velocity_y = self.movedir_y; + 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; @@ -910,7 +991,7 @@ void SV_PlayerPhysics() self.velocity = self.velocity * (1 - frametime * autocvar_sv_friction); makevectors(self.v_angle); //wishvel = v_forward * self.movement_x + v_right * self.movement_y + v_up * self.movement_z; - wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z; + wishvel = v_forward * self.movement.x + v_right * self.movement.y + '0 0 1' * self.movement.z; // acceleration wishdir = normalize(wishvel); wishspeed = vlen(wishvel); @@ -926,7 +1007,7 @@ void SV_PlayerPhysics() makevectors(self.v_angle); //wishvel = v_forward * self.movement_x + v_right * self.movement_y + v_up * self.movement_z; - wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z; + 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 @@ -960,7 +1041,7 @@ void SV_PlayerPhysics() self.velocity = self.velocity * (1 - frametime * autocvar_sv_friction); makevectors(self.v_angle); //wishvel = v_forward * self.movement_x + v_right * self.movement_y + v_up * self.movement_z; - wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z; + 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") { @@ -969,12 +1050,12 @@ void SV_PlayerPhysics() wishvel = wishvel * (self.ladder_entity.speed / f); self.watertype = self.ladder_entity.skin; - f = self.ladder_entity.origin_z + self.ladder_entity.maxs_z; - if ((self.origin_z + self.view_ofs_z) < f) + f = self.ladder_entity.origin.z + self.ladder_entity.maxs.z; + if ((self.origin.z + self.view_ofs.z) < f) self.waterlevel = WATERLEVEL_SUBMERGED; - else if ((self.origin_z + (self.mins_z + self.maxs_z) * 0.5) < f) + else if ((self.origin.z + (self.mins.z + self.maxs.z) * 0.5) < f) self.waterlevel = WATERLEVEL_SWIMMING; - else if ((self.origin_z + self.mins_z + 1) < f) + else if ((self.origin.z + self.mins.z + 1) < f) self.waterlevel = WATERLEVEL_WETFEET; else { @@ -993,20 +1074,20 @@ void SV_PlayerPhysics() PM_Accelerate(wishdir, wishspeed, wishspeed, autocvar_sv_accelerate*maxspd_mod, 1, 0, 0, 0); } } - else if ((self.items & IT_JETPACK) && self.BUTTON_HOOK && (!autocvar_g_jetpack_fuel || self.ammo_fuel >= 0.01 || self.items & IT_UNLIMITED_WEAPON_AMMO) && !self.freezetag_frozen) + else if (self.items & IT_USING_JETPACK) { //makevectors(self.v_angle_y * '0 1 0'); makevectors(self.v_angle); - wishvel = v_forward * self.movement_x + v_right * self.movement_y; + wishvel = v_forward * self.movement.x + v_right * self.movement.y; // add remaining speed as Z component maxairspd = autocvar_sv_maxairspeed*max(1, maxspd_mod); // fix speedhacks :P wishvel = normalize(wishvel) * min(vlen(wishvel) / maxairspd, 1); // add the unused velocity as up component - wishvel_z = 0; + wishvel.z = 0; // if(self.BUTTON_JUMP) - wishvel_z = sqrt(max(0, 1 - wishvel * wishvel)); + wishvel.z = sqrt(max(0, 1 - wishvel * wishvel)); // it is now normalized, so... float a_side, a_up, a_add, a_diff; @@ -1014,10 +1095,10 @@ void SV_PlayerPhysics() a_up = autocvar_g_jetpack_acceleration_up; a_add = autocvar_g_jetpack_antigravity * autocvar_sv_gravity; - wishvel_x *= a_side; - wishvel_y *= a_side; - wishvel_z *= a_up; - wishvel_z += a_add; + wishvel.x *= a_side; + wishvel.y *= a_side; + wishvel.z *= a_up; + wishvel.z += a_add; float best; best = 0; @@ -1060,18 +1141,17 @@ void SV_PlayerPhysics() //print("best possible acceleration: ", ftos(best), "\n"); float fxy, fz; - fxy = bound(0, 1 - (self.velocity * normalize(wishvel_x * '1 0 0' + wishvel_y * '0 1 0')) / autocvar_g_jetpack_maxspeed_side, 1); - if(wishvel_z - autocvar_sv_gravity > 0) - fz = bound(0, 1 - self.velocity_z / autocvar_g_jetpack_maxspeed_up, 1); + fxy = bound(0, 1 - (self.velocity * normalize(wishvel.x * '1 0 0' + wishvel.y * '0 1 0')) / autocvar_g_jetpack_maxspeed_side, 1); + if(wishvel.z - autocvar_sv_gravity > 0) + fz = bound(0, 1 - self.velocity.z / autocvar_g_jetpack_maxspeed_up, 1); else - fz = bound(0, 1 + self.velocity_z / autocvar_g_jetpack_maxspeed_up, 1); + fz = bound(0, 1 + self.velocity.z / autocvar_g_jetpack_maxspeed_up, 1); - float fvel; - fvel = vlen(wishvel); - wishvel_x *= fxy; - wishvel_y *= fxy; - wishvel_z = (wishvel_z - autocvar_sv_gravity) * fz + autocvar_sv_gravity; + wishvel.x *= fxy; + wishvel.y *= fxy; + wishvel.z = (wishvel.z - autocvar_sv_gravity) * fz + autocvar_sv_gravity; + float fvel; fvel = min(1, vlen(wishvel) / best); if(autocvar_g_jetpack_fuel && !(self.items & IT_UNLIMITED_WEAPON_AMMO)) f = min(1, self.ammo_fuel / (autocvar_g_jetpack_fuel * frametime * fvel)); @@ -1096,11 +1176,11 @@ void SV_PlayerPhysics() { // we get here if we ran out of ammo if((self.items & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32) && self.ammo_fuel < 0.01) - sprint(self, "You don't have any fuel for the ^2Jetpack\n"); + Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_JETPACK_NOFUEL); // walking - makevectors(self.v_angle_y * '0 1 0'); - wishvel = v_forward * self.movement_x + v_right * self.movement_y; + makevectors(self.v_angle.y * '0 1 0'); + wishvel = v_forward * self.movement.x + v_right * self.movement.y; if(!(self.lastflags & FL_ONGROUND)) { @@ -1113,22 +1193,8 @@ void SV_PlayerPhysics() self.jumppadcount = 0; } -#ifdef LETS_TEST_FTEQCC - if(self.velocity_x || self.velocity_y) - { - // good - } - else - { - if(self.velocity_x) - checkclient(); - if(self.velocity_y) - checkclient(); - } -#endif - v = self.velocity; - v_z = 0; + v.z = 0; f = vlen(v); if(f > 0) { @@ -1179,7 +1245,7 @@ void SV_PlayerPhysics() float wishspeed0; // we get here if we ran out of ammo if((self.items & IT_JETPACK) && self.BUTTON_HOOK && !(buttons_prev & 32) && self.ammo_fuel < 0.01) - sprint(self, "You don't have any fuel for the ^2Jetpack\n"); + Send_Notification(NOTIF_ONE, self, MSG_INFO, INFO_JETPACK_NOFUEL); if(maxspd_mod < 1) { @@ -1192,8 +1258,8 @@ void SV_PlayerPhysics() airaccel = autocvar_sv_airaccelerate; } // airborn - makevectors(self.v_angle_y * '0 1 0'); - wishvel = v_forward * self.movement_x + v_right * self.movement_y; + makevectors(self.v_angle.y * '0 1 0'); + wishvel = v_forward * self.movement.x + v_right * self.movement.y; // acceleration wishdir = normalize(wishvel); wishspeed = wishspeed0 = vlen(wishvel); @@ -1219,7 +1285,7 @@ void SV_PlayerPhysics() { vector curdir; curdir = self.velocity; - curdir_z = 0; + curdir.z = 0; curdir = normalize(curdir); airaccel = airaccel + (autocvar_sv_airstopaccelerate*maxspd_mod - airaccel) * max(0, -(curdir * wishdir)); } @@ -1240,7 +1306,7 @@ void SV_PlayerPhysics() airaccelqw = copysign(1-GeomLerp(1-fabs(self.stat_sv_airaccel_qw), strafity, 1-fabs(self.stat_sv_airstrafeaccel_qw)), ((strafity > 0.5) ? self.stat_sv_airstrafeaccel_qw : self.stat_sv_airaccel_qw)); // !CPM - if(autocvar_sv_warsowbunny_turnaccel && accelerating && self.movement_y == 0 && self.movement_x != 0) + if(autocvar_sv_warsowbunny_turnaccel && accelerating && self.movement_y == 0 && self.movement.x != 0) PM_AirAccelerate(wishdir, wishspeed); else PM_Accelerate(wishdir, wishspeed, wishspeed0, airaccel, airaccelqw, autocvar_sv_airaccel_qw_stretchfactor, autocvar_sv_airaccel_sideways_friction / maxairspd, self.stat_sv_airspeedlimit_nonqw); @@ -1250,22 +1316,22 @@ void SV_PlayerPhysics() } } - if((g_cts || g_race) && !IS_OBSERVER(self)) { - if(vlen(self.velocity - self.velocity_z * '0 0 1') > speedaward_speed) { - speedaward_speed = vlen(self.velocity - self.velocity_z * '0 0 1'); + if((g_cts || g_race) && !IS_OBSERVER(self)) + { + if(vlen(self.velocity - self.velocity.z * '0 0 1') > speedaward_speed) + { + speedaward_speed = vlen(self.velocity - self.velocity.z * '0 0 1'); speedaward_holder = self.netname; speedaward_uid = self.crypto_idfp; speedaward_lastupdate = time; } - if(speedaward_speed > speedaward_lastsent && time - speedaward_lastupdate > 1) { - string rr; - if(g_cts) - rr = CTS_RECORD; - else - rr = RACE_RECORD; + if(speedaward_speed > speedaward_lastsent && time - speedaward_lastupdate > 1) + { + string rr = (g_cts) ? CTS_RECORD : RACE_RECORD; race_send_speedaward(MSG_ALL); speedaward_lastsent = speedaward_speed; - if (speedaward_speed > speedaward_alltimebest && speedaward_uid != "") { + if (speedaward_speed > speedaward_alltimebest && speedaward_uid != "") + { speedaward_alltimebest = speedaward_speed; speedaward_alltimebest_holder = speedaward_holder; speedaward_alltimebest_uid = speedaward_uid; @@ -1276,15 +1342,16 @@ void SV_PlayerPhysics() } } + // WEAPONTODO float xyspeed; - xyspeed = vlen('1 0 0' * self.velocity_x + '0 1 0' * self.velocity_y); - if(self.weapon == WEP_NEX && autocvar_g_balance_nex_charge && autocvar_g_balance_nex_charge_velocity_rate && xyspeed > autocvar_g_balance_nex_charge_minspeed) + xyspeed = vlen('1 0 0' * self.velocity.x + '0 1 0' * self.velocity.y); + if(self.weapon == WEP_VORTEX && 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, autocvar_g_balance_nex_charge_maxspeed); - f = (xyspeed - autocvar_g_balance_nex_charge_minspeed) / (autocvar_g_balance_nex_charge_maxspeed - autocvar_g_balance_nex_charge_minspeed); + xyspeed = min(xyspeed, WEP_CVAR(vortex, charge_maxspeed)); + f = (xyspeed - WEP_CVAR(vortex, charge_minspeed)) / (WEP_CVAR(vortex, charge_maxspeed) - WEP_CVAR(vortex, charge_minspeed)); // add the extra charge - self.nex_charge = min(1, self.nex_charge + autocvar_g_balance_nex_charge_velocity_rate * f * frametime); + self.vortex_charge = min(1, self.vortex_charge + WEP_CVAR(vortex, charge_velocity_rate) * f * frametime); } :end if(self.flags & FL_ONGROUND)