Skip to content

Commit

Permalink
SERVER: Lighten restrictions for Melee and ADS while Sprinting
Browse files Browse the repository at this point in the history
  • Loading branch information
MotoLegacy committed Jun 11, 2024
1 parent 10baffe commit 29c1be1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
3 changes: 1 addition & 2 deletions source/server/weapons/bouncing_betty.qc
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ void() W_PrimeBetty =

// Prevent the Player from Sprinting and also avoid issues with
// the equipment being completely cancelled..
if (self.sprinting)
W_SprintStop();
W_SprintStop();

W_HideCrosshair(self);

Expand Down
42 changes: 28 additions & 14 deletions source/server/weapons/weapon_core.qc
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,20 @@ void() W_AimIn =
if (IsDualWeapon(self.weapon) ||
self.reload_delay > time ||
self.knife_delay > time ||
self.sprinting ||
self.new_anim_stop) {
return;
}

if (self.sprinting) {
W_SprintStop();

// FIXME: When we eventually allow custom delay values
// for every weapon animation, this hardcoded frame
// timer can be removed.
float sprint_fire_delay = fabs(GetFrame(self.weapon, SPRINT_OUT_END) - GetFrame(self.weapon, SPRINT_OUT_START))/10;
self.fire_delay = self.fire_delay2 = time + sprint_fire_delay;
}

float ads_frame = GetFrame(self.weapon, AIM_IN);
if (ads_frame != 0 && self.fire_delay < time) {
self.weaponframe_end = self.weaponframe = ads_frame;
Expand Down Expand Up @@ -167,23 +176,21 @@ void() W_AimOut =

void() W_SprintStop =
{
if (self.sprinting)
{
self.sprint_stop_time = time;
self.sprint_duration = self.sprint_timer;
}

if (self.isBuying || !self.sprinting)
return;

Weapon_PlayViewModelAnimation(ANIM_SPRINT_STOP, ReturnWeaponModel, 0);

// Run Walk for a few frames to simulate an ease in velocity
PAnim_Walk6();

self.zoom = 0;
self.tp_anim_time = 0;
PAnim_Walk6(); // Run Walk for a few frames to simulate an ease in velocity
self.sprinting = 0;
self.into_sprint = 0;
self.reload_delay2 = self.fire_delay2 = self.reload_delay = self.fire_delay = 0;
self.sprint_stop_time = time;
self.sprint_duration = self.sprint_timer;
}


Expand Down Expand Up @@ -1172,7 +1179,7 @@ void() WeaponCore_Melee =
// Do not trigger if we're Aiming down the Sight, or
// already melee-ing, or doing some other action.
if (self.knife_delay > time || self.new_anim_stop ||
self.new_anim2_stop || self.zoom || !(self.flags & FL_ONGROUND))
self.new_anim2_stop || self.zoom)
return;

// Perform the third person animation if standing
Expand All @@ -1183,8 +1190,7 @@ void() WeaponCore_Melee =
W_HideCrosshair(self);

// Stop sprinting if we are
if (self.sprinting)
W_SprintStop();
W_SprintStop();

vector applied_velocity = '0 0 0'; // The lunge velocity we intend to apply to the player.
float melee_range = WepDef_GetWeaponMeleeRange(self.weapon); // Returns the range of the traceline to perform for hit detection.
Expand Down Expand Up @@ -1268,7 +1274,7 @@ void() WeaponCore_Melee =
self.knife_delay = anim_duration + time;

// Now apply the lunge velocity, but only if we're Standing.
if (self.stance == PLAYER_STANCE_STAND)
if (self.stance == PLAYER_STANCE_STAND && did_lunge)
self.velocity = applied_velocity;
}

Expand Down Expand Up @@ -1450,8 +1456,7 @@ void() W_Grenade =

// Prevent the Player from Sprinting and also avoid issues with
// the equipment being completely cancelled..
if (self.sprinting)
W_SprintStop();
W_SprintStop();

W_HideCrosshair(self);
Set_W_Frame (0, 2, 0.6, 0, GRENADE, checkHold, "models/weapons/grenade/v_grenade.mdl", true, S_RIGHT);
Expand Down Expand Up @@ -2124,6 +2129,15 @@ void() WeaponCore_MeleeButtonPressed =
if (self.semi_actions & SEMIACTION_MELEE)
return;

#ifdef FTE

// On FTE, we should resort to standard CoD
// behavior where pressing melee should cancel
// sprinting.
W_SprintStop();

#endif // FTE

WeaponCore_Melee();
self.semi_actions |= SEMIACTION_MELEE;
};
Expand Down

0 comments on commit 29c1be1

Please sign in to comment.