Skip to content

Commit

Permalink
add a speedboost limiter tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
mwinkens committed Feb 26, 2025
1 parent 2b3faab commit d780dc9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/game/client/prediction/entities/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,15 +700,21 @@ void CCharacter::HandleSkippableTiles(int Index)
}
else if(Type == TILE_SPEED_BOOST)
{
constexpr float MaxSpeedScale = 5.0f;
if(GetTuning(GetOverriddenTuneZone())->m_SpeedBoostMaxSpeed > 0 && MaxSpeed == 0)
{
MaxSpeed = GetTuning(GetOverriddenTuneZone())->m_SpeedBoostMaxSpeed * MaxSpeedScale;
}

if(MaxSpeed == 0)
{
TempVel += Direction * Force;
}
else
{
// hardest to understand
// (signed) length of projection
float CurrentDirectionalSpeed = dot(Direction, m_Core.m_Vel);
float TempMaxSpeed = MaxSpeed / 5.0f;
float TempMaxSpeed = MaxSpeed / MaxSpeedScale;
if(CurrentDirectionalSpeed + Force > TempMaxSpeed)
TempVel += Direction * (TempMaxSpeed - CurrentDirectionalSpeed);
else
Expand Down
8 changes: 7 additions & 1 deletion src/game/server/entities/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,12 @@ void CCharacter::HandleSkippableTiles(int Index)
}
else if(Type == TILE_SPEED_BOOST)
{
constexpr float MaxSpeedScale = 5.0f;
if(GetTuning(m_TuneZone)->m_SpeedBoostMaxSpeed > 0 && MaxSpeed == 0)
{
MaxSpeed = GetTuning(m_TuneZone)->m_SpeedBoostMaxSpeed * MaxSpeedScale;
}

if(MaxSpeed == 0)
{
TempVel += Direction * Force;
Expand All @@ -1484,7 +1490,7 @@ void CCharacter::HandleSkippableTiles(int Index)
{
// hardest to understand
float CurrentDirectionalSpeed = dot(Direction, m_Core.m_Vel);
float TempMaxSpeed = MaxSpeed / 5.0f;
float TempMaxSpeed = MaxSpeed / MaxSpeedScale;
if(CurrentDirectionalSpeed + Force > TempMaxSpeed)
TempVel += Direction * (TempMaxSpeed - CurrentDirectionalSpeed);
else
Expand Down
2 changes: 2 additions & 0 deletions src/game/tuning.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ MACRO_TUNING_PARAM(HammerHitFireDelay, hammer_hit_fire_delay, 320, "Delay of ham

MACRO_TUNING_PARAM(GroundElasticityX, ground_elasticity_x, 0, "Wall elasticity")
MACRO_TUNING_PARAM(GroundElasticityY, ground_elasticity_y, 0, "Ground/ceiling elasticity")

MACRO_TUNING_PARAM(SpeedBoostMaxSpeed, speed_boost_max_speed, 118, "Max speed a speedtile can give you, 0 = unlimited (Does not apply to old speed boosts)")

0 comments on commit d780dc9

Please sign in to comment.