From 96aaad87511d4e1a304ebce29396827d30bb8ca6 Mon Sep 17 00:00:00 2001 From: subject9x Date: Tue, 5 Nov 2024 16:04:30 -0500 Subject: [PATCH] update: more authentic movement profile for player mechs. + more visible accel/decel values. + leg playback speed matches player velocity. + legs will slow to stop better when player stops moving. --- client/main/client_playermovement.qc | 271 ++++++++++-------- client/model/mech_legs.qc | 99 +++++++ client/model/mech_legs.qh | 12 +- client/network/net_client.qc | 4 +- client/network/net_mech_ai.qc | 4 +- client/network/server_localcmd.qc | 2 +- common/data/defs/defs_unit.qc | 4 +- .../item/equip/data_equip_turbo_charger.qc | 10 +- common/data/mechs/data_balaket.qc | 4 - common/data/mechs/data_matok.qc | 4 - common/data/mechs/data_monitor.qc | 4 - common/data/mechs/data_sapper.qc | 3 - common/data/mechs/data_warden.qc | 5 - common/data/vehicles/data_dunerunner.qc | 1 - common/data/vehicles/data_foslager.qc | 1 - common/data/vehicles/data_onnek.qc | 1 - common/data/vehicles/data_sorcerer.qc | 1 - common/data/vehicles/data_trowel.qc | 1 - main/controllers/ctrl_mech.qc | 4 +- main/entityFactory_player.qc | 2 +- main/entityFactory_vehicles.qc | 2 - main/impulse.qc | 2 - main/sv/sv_client_api.qc | 1 - main/sv/sv_player_api.qc | 3 - main/sv/sv_playermovement.qc | 230 ++++++++------- 25 files changed, 390 insertions(+), 285 deletions(-) diff --git a/client/main/client_playermovement.qc b/client/main/client_playermovement.qc index 5c3db1455..17ed53bdd 100644 --- a/client/main/client_playermovement.qc +++ b/client/main/client_playermovement.qc @@ -51,9 +51,9 @@ void() CS_PlayerPhysics = }*/ // if dead, behave differently - if (self.deadflag) + if (self.deadflag){ return; - + } if (!self.fixangle) { // show 1/3 the pitch angle and all the roll angle @@ -96,74 +96,7 @@ void() CS_PlayerPhysics = } } } - else if (self.waterlevel >= 2) - { - // swimming - 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; - if (wishvel == '0 0 0'){ - wishvel = '0 0 -60'; // drift towards bottom - } - wishdir = normalize(wishvel); - wishspeed = vlen(wishvel); - if (wishspeed > cs_maxspeed){ - wishspeed = cs_maxspeed; - } - wishspeed = wishspeed * 0.7; - - // water friction - self.velocity = self.velocity * (1 - frametime * cs_friction); - - // water acceleration - f = wishspeed - (self.velocity * wishdir); - if (f > 0){ - self.velocity = self.velocity + wishdir * min(f, cs_accelerate * frametime * wishspeed); - } - } - else if (time < self.ladder_time) - { - // on a func_ladder or swimming in func_water - self.velocity = self.velocity * (1 - frametime * cs_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; - if (self.gravity) - self.velocity_z = self.velocity_z + self.gravity * cs_gravity * frametime; - else - self.velocity_z = self.velocity_z + cs_gravity * frametime; - if (self.ladder_entity.classname == "func_water") - { - f = vlen(wishvel); - if (f > self.ladder_entity.speed) - 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) - self.waterlevel = 3; - else if ((self.origin_z + (self.mins_z + self.maxs_z) * 0.5) < f) - self.waterlevel = 2; - else if ((self.origin_z + self.mins_z + 1) < f) - self.waterlevel = 1; - else - { - self.waterlevel = 0; - self.watertype = CONTENT_EMPTY; - } - } - // acceleration - wishdir = normalize(wishvel); - wishspeed = vlen(wishvel); - if (wishspeed > cs_maxspeed) - wishspeed = cs_maxspeed; - if (time >= self.teleport_time) - { - f = wishspeed - (self.velocity * wishdir); - if (f > 0) - self.velocity = self.velocity + wishdir * min(f, cs_accelerate * frametime * wishspeed); - } - } + // //MOVEMENT - RAM SHOCKS ACTIVE------------------------------------------------------------ else if( time < self.ramCharge ){ local float stopSpeedSlide; @@ -184,32 +117,32 @@ void() CS_PlayerPhysics = stopSpeedSlide = self.vec_size; frictionSlide = 0.5; accelerationSlide = cs_accelerate; - //ramming + //ramming self.movement = '0 0 0'; - makevectors(self.ramAngle_y * '0 1 0'); + makevectors(self.ramAngle_y * '0 1 0'); traceline(self.origin, self.origin + (v_up * (self.mins_z * 1.25)), MOVE_NORMAL, self); - wishvel = v_forward * self.ramPower_x + v_right * self.ramPower_y; - // friction - /*if (self.velocity_x || self.velocity_y) - { - v = self.velocity; - v_z = 0; - f = vlen(v); - if (f < stopSpeedSlide) - f = 1 - frametime * (stopSpeedSlide / f) * frictionSlide; - else - f = 1 - frametime * frictionSlide; - if (f > 0) - self.velocity = self.velocity * f; - else - self.velocity = '0 0 0'; - }*/ - // acceleration - wishdir = normalize(wishvel); - wishspeed = vlen(wishvel); - if (wishspeed > (self.data_speed_forward * (self.data_speed_accel * 2))){ - wishspeed = self.data_speed_forward * (self.data_speed_accel * 2); - } + wishvel = v_forward * self.ramPower_x + v_right * self.ramPower_y; + // friction + /*if (self.velocity_x || self.velocity_y) + { + v = self.velocity; + v_z = 0; + f = vlen(v); + if (f < stopSpeedSlide) + f = 1 - frametime * (stopSpeedSlide / f) * frictionSlide; + else + f = 1 - frametime * frictionSlide; + if (f > 0) + self.velocity = self.velocity * f; + else + self.velocity = '0 0 0'; + }*/ + // acceleration + wishdir = normalize(wishvel); + wishspeed = vlen(wishvel); + if (wishspeed > (self.data_speed_forward * (self.data_speed_sprint * 2))){ + wishspeed = self.data_speed_forward * (self.data_speed_sprint * 2); + } f = wishspeed - (self.ramVelocity * wishdir); if (f > 0){ self.ramVelocity = self.ramVelocity + wishdir * min(f, accelerationSlide * frametime * wishspeed); @@ -224,38 +157,42 @@ void() CS_PlayerPhysics = self.velocity_z = self.velocity_z + (self.ramPower_x * -0.3); } //MOVEMENT - REGULAR WALKING------------------------------------------------------------ - else if (self.flags & FL_ONGROUND) - { + else if (self.flags & FL_ONGROUND) + { local vector sprintMove; - makevectors(self.v_angle_y * '0 1 0'); + makevectors(self.v_angle_y * '0 1 0'); if( self.button8 ){ - sprintMove = v_forward * (self.movement_x * self.data_speed_accel); - sprintMove = sprintMove + v_right * (self.movement_y * self.data_speed_accel); + sprintMove = v_forward * (self.movement_x * self.data_speed_sprint); + sprintMove = sprintMove + v_right * (self.movement_y * self.data_speed_sprint); wishvel = sprintMove; } else{ wishvel = v_forward * self.movement_x + v_right * self.movement_y; } - // friction - if (self.velocity_x || self.velocity_y) - { - v = self.velocity; - v_z = 0; - f = vlen(v); - if (f < cs_stopspeed) - f = 1 - frametime * (cs_stopspeed / f) * cs_friction; - else - f = 1 - frametime * cs_friction; - if (f > 0) - self.velocity = self.velocity * f; - else - self.velocity = '0 0 0'; + // friction + if (self.velocity_x || self.velocity_y) + { + v = self.velocity; + v_z = 0; + f = vlen(v); + if (f < cs_stopspeed){ + f = 1 - frametime * (cs_stopspeed / f) * cs_friction; } - - // acceleration - wishdir = normalize(wishvel); - wishspeed = vlen(wishvel); + else{ + f = 1 - frametime * cs_friction; + } + if (f > 0){ + self.velocity = self.velocity * f; + } + else{ + self.velocity = '0 0 0'; + } + } + + // acceleration + wishdir = normalize(wishvel); + wishspeed = vlen(wishvel); //actual terrain test if( wishvel ){ @@ -280,15 +217,17 @@ void() CS_PlayerPhysics = //wishspeed = wishspeed + (wishspeed * (1.0 - (stepAngles_x / 360))); } } - - if (wishspeed > cs_maxspeed) - wishspeed = cs_maxspeed; - if (time >= self.teleport_time) - { - f = wishspeed - (self.velocity * wishdir); - if (f > 0) - self.velocity = self.velocity + wishdir * min(f, cs_accelerate * frametime * wishspeed); + + if (wishspeed > cs_maxspeed){ + wishspeed = cs_maxspeed; + } + if (time >= self.teleport_time) + { + f = wishspeed - (self.velocity * wishdir); + if (f > 0){ + self.velocity = self.velocity + wishdir * min(f, self.data_speed_accel * frametime * wishspeed); } + } } //MOVEMENT - AIR BORN------------------------------------------------------------ else @@ -298,14 +237,92 @@ void() CS_PlayerPhysics = // acceleration wishdir = normalize(wishvel); wishspeed = vlen(wishvel); - if (wishspeed > cs_maxairspeed) + if (wishspeed > cs_maxairspeed){ wishspeed = cs_maxairspeed; + } if (time >= self.teleport_time) { f = wishspeed - (self.velocity * wishdir); - if (f > 0) + if (f > 0){ self.velocity = self.velocity + wishdir * min(f, cs_accelerate * frametime * wishspeed); + } } } + // else if (self.waterlevel >= 2) + // { + // // swimming + // 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; + // if (wishvel == '0 0 0'){ + // wishvel = '0 0 -60'; // drift towards bottom + // } + // wishdir = normalize(wishvel); + // wishspeed = vlen(wishvel); + // if (wishspeed > cs_maxspeed){ + // wishspeed = cs_maxspeed; + // } + // wishspeed = wishspeed * 0.7; + + // // water friction + // self.velocity = self.velocity * (1 - frametime * cs_friction); + + // // water acceleration + // f = wishspeed - (self.velocity * wishdir); + // if (f > 0){ + // self.velocity = self.velocity + wishdir * min(f, cs_accelerate * frametime * wishspeed); + // } + // } + // else if (time < self.ladder_time) + // { + // // on a func_ladder or swimming in func_water + // self.velocity = self.velocity * (1 - frametime * cs_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; + // if (self.gravity){ + // self.velocity_z = self.velocity_z + self.gravity * cs_gravity * frametime; + // } + // else{ + // self.velocity_z = self.velocity_z + cs_gravity * frametime; + // } + + // if (self.ladder_entity.classname == "func_water") + // { + // f = vlen(wishvel); + // if (f > self.ladder_entity.speed) + // 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){ + // self.waterlevel = 3; + // } + // else if ((self.origin_z + (self.mins_z + self.maxs_z) * 0.5) < f){ + // self.waterlevel = 2; + // } + // else if ((self.origin_z + self.mins_z + 1) < f){ + // self.waterlevel = 1; + // } + // else + // { + // self.waterlevel = 0; + // self.watertype = CONTENT_EMPTY; + // } + // } + // // acceleration + // wishdir = normalize(wishvel); + // wishspeed = vlen(wishvel); + // if (wishspeed > cs_maxspeed){ + // wishspeed = cs_maxspeed; + // } + // if (time >= self.teleport_time) + // { + // f = wishspeed - (self.velocity * wishdir); + // if (f > 0){ + // self.velocity = self.velocity + wishdir * min(f, cs_accelerate * frametime * wishspeed); + // } + // } + // } self.prevMovement = self.movement; }; \ No newline at end of file diff --git a/client/model/mech_legs.qc b/client/model/mech_legs.qc index a4c90e1f2..c3675b2c7 100644 --- a/client/model/mech_legs.qc +++ b/client/model/mech_legs.qc @@ -13,6 +13,105 @@ void() predraw_legs={ local vector prevAngle; local float prevLerpFrac; + local float vel; + local float animRate; + + if(!self.unit_legs){ + return; + } + + self.legs_org = predraw_unit_part(self.legs_compOffset); + self.legs_angl = [0, self.legDir, 0]; + + vel = vlen([self.velocity_x, self.velocity_y, 0]); + animRate = min(vel / cvar("cl_maxfps") * 5, 20); + + if( self.moveState == MOVE_STAND ){ + if( vel == 0){ + self.unit_legs.lerpfrac = 0; + self.unit_legs.frame = 0; + } + else{ + self.unit_legs.lerpfrac = self.unit_legs.lerpfrac - (frametime * animRate); //animate at moveRate (legMoveRate or legRunRate) + while(self.unit_legs.lerpfrac < 0) //protects against sudden low framerates. + { + self.unit_legs.frame2 = self.unit_legs.frame; //if we're at 0, frame2 became redundant anyway + self.unit_legs.frame = self.unit_legs.frame + 1; //move on to the next frame + + if( (self.flags & FL_ONGROUND) ){ + if( rint(self.unit_legs.frame) == LEG_WALK_STEP_LEFT ){ + te_foot_stomp( self.rootOrigin, self.legs_angl, self.vec_size, self.mins, TRUE); + } + if( rint(self.legs_frame) == LEG_WALK_STEP_RIGHT ){ + te_foot_stomp( self.rootOrigin, self.legs_angl, self.vec_size, self.mins, FALSE); + } + } + + if (self.unit_legs.frame >= LEG_WALK_FIRSTFRAME+LEG_WALK_NUMFRAMES){//this should be relative to the current animation that should be shown + self.unit_legs.frame = LEG_WALK_FIRSTFRAME; //restart it. + } + self.unit_legs.lerpfrac = self.unit_legs.lerpfrac + 1; //go to the start of the frame + if( fabs(rint(self.unit_legs.frame)) <= LEG_WALK_FIRSTFRAME+1){ + self.unit_legs.frame = 0; + self.unit_legs.lerpfrac = 0; + break; + } + } + } + } + else if( self.moveState <= MOVE_SPRINT){ + + self.unit_legs.lerpfrac = self.unit_legs.lerpfrac - (frametime * animRate); //animate at moveRate (legMoveRate or legRunRate) + while(self.unit_legs.lerpfrac < 0) //protects against sudden low framerates. + { + self.unit_legs.frame2 = self.unit_legs.frame; //if we're at 0, frame2 became redundant anyway + self.unit_legs.frame = self.unit_legs.frame + 1; //move on to the next frame + + if (self.unit_legs.frame >= LEG_WALK_FIRSTFRAME+LEG_WALK_NUMFRAMES){//this should be relative to the current animation that should be shown + self.unit_legs.frame = LEG_WALK_FIRSTFRAME; //restart it. + } + else if(self.unit_legs.frame < LEG_WALK_FIRSTFRAME){ + self.unit_legs.frame = LEG_WALK_FIRSTFRAME+LEG_WALK_NUMFRAMES; //restart it. + } + + if( (self.flags & FL_ONGROUND) ){ + if( rint(self.unit_legs.frame) == LEG_WALK_STEP_LEFT ){ + te_foot_stomp( self.rootOrigin, self.legs_angl, self.vec_size, self.mins, TRUE); + } + if( rint(self.legs_frame) == LEG_WALK_STEP_RIGHT ){ + te_foot_stomp( self.rootOrigin, self.legs_angl, self.vec_size, self.mins, FALSE); + } + } + + self.unit_legs.lerpfrac = self.unit_legs.lerpfrac + 1; //go to the start of the frame + } + } + + + setmodel(self.unit_legs, self.legs_mdl); + if( (self.flags & FL_CLIENT) ){ + self.unit_legs.colormod = CLR_PLAYER_LIST[self.unitColorLG]; + } + else{ + self.unit_legs.colormod = CLR_DEF_WHITE; + } + self.unit_legs.colormod = self.unit_legs.colormod * (self.legs_hp / 100) * 2; + self.unit_legs.angles = self.legs_angl; + self.unit_legs.origin = self.legs_org; + self.legs_frame = self.unit_legs.frame; + addentity(self.unit_legs); + +}; + +/* + AI uses move-step, calculate movements, not realtime velocity. + They will use the 'old' walk animation system, which is good enough. +*/ +void() predraw_legs_nonclient={ + local float runMode; + local vector prevAngle; + local float prevLerpFrac; + if(!self.unit_legs){ return; } diff --git a/client/model/mech_legs.qh b/client/model/mech_legs.qh index 36d6ee666..e19f07268 100644 --- a/client/model/mech_legs.qh +++ b/client/model/mech_legs.qh @@ -6,9 +6,11 @@ Overview: synchronizing leg models to the client */ -float LEG_WALK_STEP_LEFT = 2; -float LEG_WALK_STEP_RIGHT = 6; -float LEG_WALK_FIRSTFRAME = 1; -float LEG_WALK_NUMFRAMES = 8; +#define LEG_STAND_FRAME 0 +#define LEG_WALK_STEP_LEFT 2 +#define LEG_WALK_STEP_RIGHT 6 +#define LEG_WALK_FIRSTFRAME 1 +#define LEG_WALK_NUMFRAMES 8 -void() predraw_legs; \ No newline at end of file +void() predraw_legs; +void() predraw_legs_nonclient; \ No newline at end of file diff --git a/client/network/net_client.qc b/client/network/net_client.qc index 2db5ead34..47ad2cb9a 100644 --- a/client/network/net_client.qc +++ b/client/network/net_client.qc @@ -560,14 +560,14 @@ void( float isNew, float changeFlags ) sendent_handle_client={ self.data_speed_forward = ReadFloat(); self.data_speed_strafe = ReadFloat(); self.data_speed_backward = ReadFloat(); - self.data_speed_accel = ReadFloat(); + self.data_speed_sprint = ReadFloat(); //genuine spawn event. if( self.isLocalPlayer ){ self.classname = "UI_ITEM"; //hack, investigate cvar_set( "cl_forwardspeed", ftos(self.data_speed_forward) ); cvar_set( "cl_sidespeed", ftos(self.data_speed_strafe) ); cvar_set( "cl_backspeed", ftos(self.data_speed_backward) ); - cvar_set( "cl_movespeedkey", ftos(self.data_speed_accel) ); + cvar_set( "cl_movespeedkey", ftos(self.data_speed_sprint) ); //MODELS - COCKPIT hud_model_cockpit_ini(); diff --git a/client/network/net_mech_ai.qc b/client/network/net_mech_ai.qc index c0815111a..05291c40c 100644 --- a/client/network/net_mech_ai.qc +++ b/client/network/net_mech_ai.qc @@ -295,7 +295,9 @@ void() interpolate_mech_ai={ setsize(self, self.cache_mins, self.cache_maxs); self.renderflags = 0; self.legs_org = self.rootOrigin + (v_right * self.legs_compOffset_x) + (v_forward * self.legs_compOffset_z) + (v_up * self.legs_compOffset_y); - predraw_legs(); + + predraw_legs_nonclient(); + self.origin = self.rootOrigin; self.angles = self.rootAngle; diff --git a/client/network/server_localcmd.qc b/client/network/server_localcmd.qc index 15e7f69c3..3d860cc34 100644 --- a/client/network/server_localcmd.qc +++ b/client/network/server_localcmd.qc @@ -335,7 +335,7 @@ void( entity mech, float turboMod ) cl_set_hud_vars={ cvar_set("cl_forwardspeed", ftos(mech.data_speed_forward)); cvar_set("cl_sidespeed", ftos(mech.data_speed_strafe)); cvar_set("cl_backspeed", ftos(mech.data_speed_backward)); - cvar_set("cl_movespeedkey", ftos(mech.data_speed_accel + turboMod)); + cvar_set("cl_movespeedkey", ftos(mech.data_speed_sprint + turboMod)); cvar_set("cl_rollangle", ftos(mech.hud_rollangle)); diff --git a/common/data/defs/defs_unit.qc b/common/data/defs/defs_unit.qc index 59d0206b8..2efbebb3c 100644 --- a/common/data/defs/defs_unit.qc +++ b/common/data/defs/defs_unit.qc @@ -55,8 +55,9 @@ Overview: .float data_speed_forward; //forward speed .float data_speed_strafe; //side strafe speed .float data_speed_backward; //backward speed -.float data_speed_accel; //cl_speedkey acceleration factor +.float data_speed_accel; //replaces cvar("sv_accel") rate in player_movement.qc .float data_speed_decel; //override sv_stopspeed for units. +.float data_speed_sprint; //cl_speedkey acceleration factor //subcomponents decomposed to field vars, reduce entity management .string torC_mdl; @@ -160,6 +161,7 @@ Overview: .float cache_speed_fwd; .float cache_speed_sid; .float cache_speed_back; +.float cache_speed_accel; .float turret_yaw_speed; diff --git a/common/data/item/equip/data_equip_turbo_charger.qc b/common/data/item/equip/data_equip_turbo_charger.qc index 8e436b2bc..889cfdfbd 100644 --- a/common/data/item/equip/data_equip_turbo_charger.qc +++ b/common/data/item/equip/data_equip_turbo_charger.qc @@ -22,7 +22,7 @@ void() data_ini_equip_turbo_charger_={ self.energyRate = 0.2; self.energyMax = 0; //will hold Unit's previous drain value; - self.data_speed_accel = 0; //will hold Unit's previous accel value. + self.data_speed_sprint = 0; //will hold Unit's previous accel value. self.w_range = 0; self.damageValue = 0; @@ -64,12 +64,12 @@ void() turbo_charger_upgrade_={ //save old values here self.evasionDrain = self.owner.evasionDrain; - self.data_speed_accel = self.owner.data_speed_accel; + self.data_speed_sprint = self.owner.data_speed_sprint; self.evasionDrain = self.owner.vec_size / 10; perc = 0.4 - self.evasionDrain; self.owner.evasionDrain = self.owner.evasionDrain + (self.owner.evasionDrain * self.evasionDrain); - self.owner.data_speed_accel = self.owner.data_speed_accel + perc; + self.owner.data_speed_sprint = self.owner.data_speed_sprint + perc; self.data_speed_forward = self.owner.data_speed_forward; @@ -88,13 +88,13 @@ void() turbo_charger_upgrade_={ void() turbo_charger_remove_={ local entity module; self.owner.evasionDrain = self.evasionDrain; - self.owner.data_speed_accel = self.data_speed_accel; + self.owner.data_speed_sprint = self.data_speed_sprint; self.owner.data_speed_forward = self.data_speed_forward; self.owner.SendFlags = self.owner.SendFlags | SENDFLAG_EFLAGS; if( (self.owner.flags & FL_CLIENT) ){ module = self; self = module.owner; - self.data_speed_accel = module.data_speed_accel; + self.data_speed_sprint = module.data_speed_sprint; self.ramUpMax = 4 - self.vec_size; self.ramUpMax = self.ramUpMax / 10; self.ramUpMax = self.data_speed_forward * self.ramUpMax; diff --git a/common/data/mechs/data_balaket.qc b/common/data/mechs/data_balaket.qc index e34cd365c..983c218e8 100644 --- a/common/data/mechs/data_balaket.qc +++ b/common/data/mechs/data_balaket.qc @@ -49,12 +49,9 @@ void() data_ini_balaket_={ self.data_speed_forward = 185.0; self.data_speed_strafe = 120.0; self.data_speed_backward = 90.0; - self.data_speed_accel = 2.0; - self.data_speed_decel = 10; self.ramUpMax = 2; self.ramCooldown = 6; #ifdef CSQC - //animation playback sync to player move speed. self.legMoveRate = 9.5; self.legRunRate = 12; #endif @@ -65,7 +62,6 @@ void() data_ini_balaket_={ self.turret_yaw_speed = 4.25; self.ai_angleLimits = '-175 175 0'; if( (self.flags & FL_MONSTER) ){ - self.data_speed_accel = 0.025; } #endif //===================================== diff --git a/common/data/mechs/data_matok.qc b/common/data/mechs/data_matok.qc index 5a79b9cc3..a8dd87003 100644 --- a/common/data/mechs/data_matok.qc +++ b/common/data/mechs/data_matok.qc @@ -50,12 +50,9 @@ void() data_ini_matok_={ self.data_speed_forward = 155.0; self.data_speed_strafe = 155.0; self.data_speed_backward = 80.0; - self.data_speed_accel = 1.45; - self.data_speed_decel = 33; self.ramUpMax = 1.5; self.ramCooldown = 3; #ifdef CSQC - //animation playback sync to player move speed. self.legMoveRate = 12; self.legRunRate = 18; #endif @@ -66,7 +63,6 @@ void() data_ini_matok_={ self.turret_yaw_speed = 3.75; self.ai_angleLimits = '-180 180 0'; if( (self.flags & FL_MONSTER) ){ - self.data_speed_accel = 0.015; } #endif //===================================== diff --git a/common/data/mechs/data_monitor.qc b/common/data/mechs/data_monitor.qc index e5d8b070a..ad5193a25 100644 --- a/common/data/mechs/data_monitor.qc +++ b/common/data/mechs/data_monitor.qc @@ -48,12 +48,9 @@ void() data_ini_monitor_={ self.data_speed_forward = 90.0; self.data_speed_strafe = 90.0; self.data_speed_backward = 90.0; - self.data_speed_accel = 2.0; - self.data_speed_decel = 15; self.ramUpMax = 1; self.ramCooldown = 2; #ifdef CSQC - //animation playback sync to player move speed. self.legMoveRate = 7.75; self.legRunRate = 11; #endif @@ -64,7 +61,6 @@ void() data_ini_monitor_={ self.turret_yaw_speed = 3; self.ai_angleLimits = '-150 150 0'; if( (self.flags & FL_MONSTER) ){ - self.data_speed_accel = 0.005; } #endif //===================================== diff --git a/common/data/mechs/data_sapper.qc b/common/data/mechs/data_sapper.qc index 72fb75a83..689ca5267 100644 --- a/common/data/mechs/data_sapper.qc +++ b/common/data/mechs/data_sapper.qc @@ -51,8 +51,6 @@ void() data_ini_sapper_={ self.data_speed_forward = 125.0; self.data_speed_strafe = 105.0; self.data_speed_backward = 100.0; - self.data_speed_accel = 2.25; - self.data_speed_decel = 50; self.ramUpMax = 1.75; self.ramCooldown = 3; #ifdef CSQC @@ -67,7 +65,6 @@ void() data_ini_sapper_={ self.turret_yaw_speed = 3.33; self.ai_angleLimits = '-120 120 0'; if( (self.flags & FL_MONSTER) ){ - self.data_speed_accel = 0.007; } #endif //===================================== diff --git a/common/data/mechs/data_warden.qc b/common/data/mechs/data_warden.qc index eef60cb84..cc8748411 100644 --- a/common/data/mechs/data_warden.qc +++ b/common/data/mechs/data_warden.qc @@ -31,7 +31,6 @@ void() data_ini_warden_={ self.max_health = 575; //Hitbox size, X width, Y Length, Z height. - self.mins = '-16 -16 -30.3'; self.maxs = '16 16 15'; //ENERGY AND SHIELDS=================== @@ -52,12 +51,9 @@ void() data_ini_warden_={ self.data_speed_forward = 165.0; self.data_speed_strafe = 165.0; self.data_speed_backward = 165.0; - self.data_speed_accel = 1.33; - self.data_speed_decel = 55; self.ramUpMax = 3; self.ramCooldown = 8; #ifdef CSQC - //animation playback sync to player move speed. self.legMoveRate = 12; self.legRunRate = 14; #endif @@ -68,7 +64,6 @@ void() data_ini_warden_={ self.turret_yaw_speed = 4.75; self.ai_angleLimits = '-180 180 0'; if( (self.flags & FL_MONSTER) ){ - self.data_speed_accel = 0.025; } #endif //===================================== diff --git a/common/data/vehicles/data_dunerunner.qc b/common/data/vehicles/data_dunerunner.qc index 3cb3d92ce..cec413ff1 100644 --- a/common/data/vehicles/data_dunerunner.qc +++ b/common/data/vehicles/data_dunerunner.qc @@ -40,7 +40,6 @@ void() data_ini_dunerunner_={ self.data_speed_forward = 167; self.data_speed_strafe = 113; self.data_speed_backward = 133; - self.data_speed_accel = 1; #ifdef SSQC self.yaw_speed = 5; //AI-only self.turret_yaw_speed = 4;//AI-only diff --git a/common/data/vehicles/data_foslager.qc b/common/data/vehicles/data_foslager.qc index f122790e4..617893030 100644 --- a/common/data/vehicles/data_foslager.qc +++ b/common/data/vehicles/data_foslager.qc @@ -40,7 +40,6 @@ void() data_ini_foslager_={ self.data_speed_forward = 50; self.data_speed_strafe = 20; self.data_speed_backward = 15; - self.data_speed_accel = 1; #ifdef SSQC self.yaw_speed = 3.75; //3.5; //AI-only self.turret_yaw_speed = 4.25; //3.75;//AI-only diff --git a/common/data/vehicles/data_onnek.qc b/common/data/vehicles/data_onnek.qc index e0385c547..98bb81079 100644 --- a/common/data/vehicles/data_onnek.qc +++ b/common/data/vehicles/data_onnek.qc @@ -40,7 +40,6 @@ void() data_ini_onnek_={ self.data_speed_forward = 33; self.data_speed_strafe = 20; self.data_speed_backward = 15; - self.data_speed_accel = 1; #ifdef SSQC self.yaw_speed = 2.75; //2.5; //AI-only #endif diff --git a/common/data/vehicles/data_sorcerer.qc b/common/data/vehicles/data_sorcerer.qc index 079936e97..d42cac680 100644 --- a/common/data/vehicles/data_sorcerer.qc +++ b/common/data/vehicles/data_sorcerer.qc @@ -40,7 +40,6 @@ void() data_ini_sorcerer_={ self.data_speed_forward = 66; self.data_speed_strafe = 40; self.data_speed_backward = 30; - self.data_speed_accel = 1; #ifdef SSQC self.yaw_speed = 2.5; //AI-only #endif diff --git a/common/data/vehicles/data_trowel.qc b/common/data/vehicles/data_trowel.qc index 9b1f937b2..ea82e5867 100644 --- a/common/data/vehicles/data_trowel.qc +++ b/common/data/vehicles/data_trowel.qc @@ -39,7 +39,6 @@ void() data_ini_trowel_={ self.data_speed_forward = 25; self.data_speed_strafe = 10; self.data_speed_backward = 10; - self.data_speed_accel = 1; #ifdef SSQC self.yaw_speed = 1.5;//1; //AI-only self.turret_yaw_speed = 2;//1.5;//AI-only diff --git a/main/controllers/ctrl_mech.qc b/main/controllers/ctrl_mech.qc index c44924e61..a011e1aa0 100644 --- a/main/controllers/ctrl_mech.qc +++ b/main/controllers/ctrl_mech.qc @@ -419,18 +419,20 @@ void() ctrl_mech_critical_hits={ self.cache_speed_fwd = self.data_speed_forward; self.cache_speed_sid = self.data_speed_strafe; self.cache_speed_back = self.data_speed_backward; + self.cache_speed_accel = self.data_speed_accel; if( (self.flags & FL_CLIENT) ){ self.data_speed_forward = self.data_speed_forward * 0.7; self.data_speed_strafe = self.data_speed_strafe * 0.8; self.data_speed_backward = self.data_speed_backward * 0.75; + self.data_speed_accel = self.data_speed_accel * 0.5; self.SendFlags = self.SendFlags | SENDFLAG_EFLAGS; } else{ //AI suffers way more for blown legs self.data_speed_forward = self.data_speed_forward * 0.5; - self.data_speed_strafe = self.data_speed_strafe * 0.67; self.data_speed_backward = self.data_speed_backward * 0.5; + self.data_speed_accel = self.data_speed_accel * 0.25; if( !(self.damageValue & M_LEGS) ){ self.damageValue = self.damageValue | M_LEGS; } diff --git a/main/entityFactory_player.qc b/main/entityFactory_player.qc index c50a4432d..61cb8f203 100644 --- a/main/entityFactory_player.qc +++ b/main/entityFactory_player.qc @@ -28,7 +28,7 @@ void() player_makeObserver={ self.data_speed_forward = 1000; self.data_speed_strafe = 1000; self.data_speed_backward = 1000; - self.data_speed_accel = 2; + self.data_speed_sprint = 2; self.canTarget = FALSE; self.deadflag = DEAD_NO; diff --git a/main/entityFactory_vehicles.qc b/main/entityFactory_vehicles.qc index a94d242b7..07568e5ee 100644 --- a/main/entityFactory_vehicles.qc +++ b/main/entityFactory_vehicles.qc @@ -331,14 +331,12 @@ void() build_unit_turret={ void() build_mech_legs={ /*self.laser_sight_org = '0 0 0'; self.laser_sight_timer = time + 0.5; - self.w_firerate = 0; //used to track data_speed_accel changes*/ self.legs_angl = self.angles; //we pack the unit's original speed values here, to allow us to restore them if the unit repairs its legs self.legs_speed_f = self.data_speed_forward; self.legs_speed_s = self.data_speed_strafe; self.legs_speed_b = self.data_speed_backward; - self.legs_speed_acc = self.data_speed_accel; self.legs_yawSpeed = self.yaw_speed * 2.5; self.legs_attackState = TR_NORM; self.legDir = self.angles_y; diff --git a/main/impulse.qc b/main/impulse.qc index 2c5ba2267..baa155f09 100644 --- a/main/impulse.qc +++ b/main/impulse.qc @@ -173,7 +173,6 @@ void() ImpulseCommands ={ if( self.ramUp >= self.ramUpMax ){ if( self.energy >= (self.energyMax * (self.ramUpMax / 25)) ){ self.ramCharge = time + (self.ramUp / 2); - self.ramPower_x = self.data_speed_forward * (self.data_speed_accel * 2); self.ramPower_y = 0; self.ramPower_z = -15; self.ramVelocity = self.velocity; @@ -291,7 +290,6 @@ void() ButtonCommands={ if( (self.movement_x || self.movement_y) ){ self.moveState = MOVE_SPRINT; } - //client_update_moveSpeed(self.data_speed_forward * self.data_speed_accel, self.data_speed_strafe * self.data_speed_accel, self.data_speed_backward * self.data_speed_accel, ftos(self.data_speed_accel), self.hud_rollangle); } } } diff --git a/main/sv/sv_client_api.qc b/main/sv/sv_client_api.qc index b101724a1..7b53510a4 100644 --- a/main/sv/sv_client_api.qc +++ b/main/sv/sv_client_api.qc @@ -110,7 +110,6 @@ float( entity to, float changeFlags ) send_client={ WriteFloat( MSG_ENTITY, self.data_speed_forward); WriteFloat( MSG_ENTITY, self.data_speed_strafe); WriteFloat( MSG_ENTITY, self.data_speed_backward); - WriteFloat( MSG_ENTITY, self.data_speed_accel); } /* EVENT - Client has changed their unit color settings.*/ diff --git a/main/sv/sv_player_api.qc b/main/sv/sv_player_api.qc index 8dcbe1d2f..d0d41c12c 100644 --- a/main/sv/sv_player_api.qc +++ b/main/sv/sv_player_api.qc @@ -273,17 +273,14 @@ void() PlayerPostThink = { if( self.energy > (self.energyMax * 0.15)){ if( !(self.criticalHits & M_LEGS) ){ if( self.ramUp < self.ramUpMax ){ - self.ramUp = self.ramUp + self.data_speed_accel * MOVE_RAM_SCALAR_UP; } } } } else{ - self.ramUp = self.ramUp - self.data_speed_accel * MOVE_RAM_SCALAR_DN; } } else{ - self.ramUp = self.ramUp - self.data_speed_accel * MOVE_RAM_SCALAR_DN; } if( self.ramUp < 0 ){ self.ramUp = 0; diff --git a/main/sv/sv_playermovement.qc b/main/sv/sv_playermovement.qc index 911a446ef..fd9e292b5 100644 --- a/main/sv/sv_playermovement.qc +++ b/main/sv/sv_playermovement.qc @@ -15,9 +15,9 @@ void() SV_PlayerPhysics = //if (clienttype(self) == CLIENTTYPE_BOT) //havocbot_think(); - if (self.movetype == MOVETYPE_NONE) + if (self.movetype == MOVETYPE_NONE){ return; - + } if (time != lastclientthink) { lastclientthink = time; @@ -66,17 +66,7 @@ void() SV_PlayerPhysics = self.angles_z = 0; } - if (self.flags & FL_WATERJUMP ) - { - self.velocity_x = self.movedir_x; - self.velocity_y = self.movedir_y; - if (time > self.teleport_time || self.waterlevel == 0) - { - self.flags = self.flags - (self.flags & FL_WATERJUMP); - self.teleport_time = 0; - } - } - else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY) + if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY) { // noclipping or flying self.velocity = self.velocity * (1 - frametime * sv_friction); @@ -96,80 +86,6 @@ void() SV_PlayerPhysics = self.velocity = self.velocity + wishdir * min(f, sv_accelerate * frametime * wishspeed); } } - } - else if (self.waterlevel >= 2) - { - // swimming - 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; - if (wishvel == '0 0 0') - wishvel = '0 0 -60'; // drift towards bottom - - wishdir = normalize(wishvel); - wishspeed = vlen(wishvel); - if (wishspeed > sv_maxspeed) - wishspeed = sv_maxspeed; - wishspeed = wishspeed * 0.7; - - // water friction - self.velocity = self.velocity * (1 - frametime * sv_friction); - - // water acceleration - f = wishspeed - (self.velocity * wishdir); - if (f > 0) - self.velocity = self.velocity + wishdir * min(f, sv_accelerate * frametime * wishspeed); - } - else if (time < self.ladder_time) - { - // on a func_ladder or swimming in func_water - self.velocity = self.velocity * (1 - frametime * 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; - if (self.gravity){ - self.velocity_z = self.velocity_z + self.gravity * sv_gravity * frametime; - } - else{ - self.velocity_z = self.velocity_z + sv_gravity * frametime; - } - if (self.ladder_entity.classname == "func_water") - { - f = vlen(wishvel); - if (f > self.ladder_entity.speed){ - 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){ - self.waterlevel = 3; - } - else if ((self.origin_z + (self.mins_z + self.maxs_z) * 0.5) < f){ - self.waterlevel = 2; - } - else if ((self.origin_z + self.mins_z + 1) < f){ - self.waterlevel = 1; - } - else - { - self.waterlevel = 0; - self.watertype = CONTENT_EMPTY; - } - } - // acceleration - wishdir = normalize(wishvel); - wishspeed = vlen(wishvel); - if (wishspeed > sv_maxspeed){ - wishspeed = sv_maxspeed; - } - if (time >= self.teleport_time) - { - f = wishspeed - (self.velocity * wishdir); - if (f > 0){ - self.velocity = self.velocity + wishdir * min(f, sv_accelerate * frametime * wishspeed); - } - } } //MOVEMENT - RAM SHOCKS ACTIVE------------------------------------------------------------ else if( time < self.ramCharge ){ @@ -214,8 +130,8 @@ void() SV_PlayerPhysics = // acceleration wishdir = normalize(wishvel); wishspeed = vlen(wishvel); - if (wishspeed > (self.data_speed_forward * (self.data_speed_accel * 2))){ - wishspeed = self.data_speed_forward * (self.data_speed_accel * 2); + if (wishspeed > (self.data_speed_forward * (self.data_speed_sprint * 2))){ + wishspeed = self.data_speed_forward * (self.data_speed_sprint * 2); } f = wishspeed - (self.ramVelocity * wishdir); if (f > 0){ @@ -233,13 +149,21 @@ void() SV_PlayerPhysics = //MOVEMENT - REGULAR WALKING------------------------------------------------------------ else if (self.flags & FL_ONGROUND) { - local vector sprintMove; - makevectors(self.v_angle_y * '0 1 0'); + local float avgTopSpeed; + local float decel; + local float friction; + makevectors(self.v_angle_y * '0 1 0'); wishvel = v_forward * self.movement_x + v_right * self.movement_y; if( self.button8 ){ - wishvel = wishvel * self.data_speed_accel; + wishvel = wishvel * self.data_speed_sprint; + } + decel = self.data_speed_decel; + friction = sv_friction; + if(vlen(wishvel) != 0){ + decel = decel * 0.5; + friction = friction * 0.5; } // friction @@ -248,11 +172,11 @@ void() SV_PlayerPhysics = v = self.velocity; v_z = 0; f = vlen(v); - if (f < sv_stopspeed){ - f = 1 - frametime * (self.data_speed_decel / f) * sv_friction; + if (f < decel){ + f = 1 - frametime * (decel / f) * friction; } else{ - f = 1 - frametime * sv_friction; + f = 1 - frametime * friction; } if (f > 0){ self.velocity = self.velocity * f; @@ -265,29 +189,33 @@ void() SV_PlayerPhysics = // acceleration wishdir = normalize(wishvel); wishspeed = vlen(wishvel); + if(self.data_speed_forward > self.data_speed_strafe){ + avgTopSpeed = self.data_speed_forward; + } + else{ + avgTopSpeed = (self.data_speed_forward + self.data_speed_strafe) / 2; + } + if( self.button8 ){ + avgTopSpeed = avgTopSpeed * self.data_speed_sprint; + } + if(wishspeed > avgTopSpeed){ + wishspeed = avgTopSpeed; + } //actual terrain test - if( wishvel ){ + if( (self.flags & FL_ONGROUND) ){ local vector stepOne, stepTwo, stepAngles, stepDir; stepDir = vectoangles(wishvel); makevectors(stepDir); + traceline(self.origin, self.origin + (v_up * -1024) + (v_forward * -128), MOVE_NORMAL, self); stepOne = trace_endpos; - - traceline(self.origin, self.origin + (v_up * -1024) + (v_forward * 512), MOVE_NORMAL, self); - stepTwo = trace_endpos; - + stepAngles = vectoangles(stepTwo - stepOne); - if( stepAngles_x > 1 && stepAngles_x <=90 ) { - //walking up-hill. + if( stepAngles_x > 1 && stepAngles_x <= 90 ) { stepAngles = vectoangles((stepTwo + (v_up * 2)) - stepOne); //relish factor wishspeed = wishspeed * (1.0 - (stepAngles_x / 90)); } - else if( stepAngles_x >= 340 && stepAngles_x < 360 ){ - //going dowhill - stepAngles = vectoangles((stepOne + (v_up * 1.05)) - stepTwo); //relish factor - //wishspeed = wishspeed + (wishspeed * (1.0 - (stepAngles_x / 360))); - } } if (wishspeed > sv_maxspeed){ @@ -297,7 +225,7 @@ void() SV_PlayerPhysics = { f = wishspeed - (self.velocity * wishdir); if (f > 0){ - self.velocity = self.velocity + wishdir * min(f, sv_accelerate * frametime * wishspeed); + self.velocity = self.velocity + wishdir * min(f, self.data_speed_accel * frametime * wishspeed); } } } @@ -320,5 +248,91 @@ void() SV_PlayerPhysics = } } } + // if (self.flags & FL_WATERJUMP ) + // { + // self.velocity_x = self.movedir_x; + // self.velocity_y = self.movedir_y; + // if (time > self.teleport_time || self.waterlevel == 0) + // { + // self.flags = self.flags - (self.flags & FL_WATERJUMP); + // self.teleport_time = 0; + // } + // } + // else + // else if (self.waterlevel >= 2) + // { + // // swimming + // 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; + // if (wishvel == '0 0 0'){ + // wishvel = '0 0 -60'; // drift towards bottom + // } + // wishdir = normalize(wishvel); + // wishspeed = vlen(wishvel); + // if (wishspeed > sv_maxspeed) + // wishspeed = sv_maxspeed; + // wishspeed = wishspeed * 0.7; + + // // water friction + // self.velocity = self.velocity * (1 - frametime * sv_friction); + + // // water acceleration + // f = wishspeed - (self.velocity * wishdir); + // if (f > 0){ + // self.velocity = self.velocity + wishdir * min(f, sv_accelerate * frametime * wishspeed); + // } + // } + // else if (time < self.ladder_time) + // { + // // on a func_ladder or swimming in func_water + // self.velocity = self.velocity * (1 - frametime * 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; + // if (self.gravity){ + // self.velocity_z = self.velocity_z + self.gravity * sv_gravity * frametime; + // } + // else{ + // self.velocity_z = self.velocity_z + sv_gravity * frametime; + // } + // if (self.ladder_entity.classname == "func_water") + // { + // f = vlen(wishvel); + // if (f > self.ladder_entity.speed){ + // 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){ + // self.waterlevel = 3; + // } + // else if ((self.origin_z + (self.mins_z + self.maxs_z) * 0.5) < f){ + // self.waterlevel = 2; + // } + // else if ((self.origin_z + self.mins_z + 1) < f){ + // self.waterlevel = 1; + // } + // else + // { + // self.waterlevel = 0; + // self.watertype = CONTENT_EMPTY; + // } + // } + // // acceleration + // wishdir = normalize(wishvel); + // wishspeed = vlen(wishvel); + // if (wishspeed > sv_maxspeed){ + // wishspeed = sv_maxspeed; + // } + // if (time >= self.teleport_time) + // { + // f = wishspeed - (self.velocity * wishdir); + // if (f > 0){ + // self.velocity = self.velocity + wishdir * min(f, sv_accelerate * frametime * wishspeed); + // } + // } + // } self.prevMovement = self.movement; }; \ No newline at end of file