mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-23 17:43:08 -05:00
Fix HackControl resetting jump height to default of 1.2 blocks, not user's jump height on non -hax maps.
This commit is contained in:
parent
777d3a829b
commit
fd879b0b00
5 changed files with 12 additions and 6 deletions
|
@ -31,7 +31,7 @@ namespace ClassicalSharp.Gui {
|
|||
|
||||
MakeOpt( -1, 0, "Jump height", OnWidgetClick,
|
||||
g => g.LocalPlayer.JumpHeight.ToString( "F3" ),
|
||||
(g, v) => g.LocalPlayer.physics.CalculateJumpVelocity( Single.Parse( v ) ) ),
|
||||
(g, v) => g.LocalPlayer.physics.CalculateJumpVelocity( true, Single.Parse( v ) ) ),
|
||||
|
||||
MakeBool( -1, 50, "Double jump", OptionsKey.DoubleJump,
|
||||
OnWidgetClick, g => g.LocalPlayer.Hacks.DoubleJump,
|
||||
|
|
|
@ -70,6 +70,8 @@ namespace ClassicalSharp.Entities {
|
|||
/// <summary> Whether the player is currently walking at base speed * 0.5 * speed multiplier. </summary>
|
||||
public bool HalfSpeeding;
|
||||
|
||||
public bool CanJumpHigher { get { return Enabled && CanAnyHacks && CanSpeed; } }
|
||||
|
||||
/// <summary> Parses hack flags specified in the motd and/or name of the server. </summary>
|
||||
/// <remarks> Recognises +/-hax, +/-fly, +/-noclip, +/-speed, +/-respawn, +/-ophax, and horspeed=xyz </remarks>
|
||||
public void ParseHackFlags( string name, string motd ) {
|
||||
|
|
|
@ -13,7 +13,8 @@ namespace ClassicalSharp.Entities {
|
|||
Entity entity;
|
||||
Game game;
|
||||
BlockInfo info;
|
||||
internal float jumpVel = 0.42f, serverJumpVel = 0.42f;
|
||||
|
||||
internal float jumpVel = 0.42f, userJumpVel = 0.42f, serverJumpVel = 0.42f;
|
||||
internal HacksComponent hacks;
|
||||
internal CollisionsComponent collisions;
|
||||
|
||||
|
@ -233,7 +234,7 @@ namespace ClassicalSharp.Entities {
|
|||
|
||||
/// <summary> Calculates the jump velocity required such that when a client presses
|
||||
/// the jump binding they will be able to jump up to the given height. </summary>
|
||||
internal void CalculateJumpVelocity( float jumpHeight ) {
|
||||
internal void CalculateJumpVelocity( bool userVel, float jumpHeight ) {
|
||||
jumpVel = 0;
|
||||
if( jumpHeight >= 256 ) jumpVel = 10.0f;
|
||||
if( jumpHeight >= 512 ) jumpVel = 16.5f;
|
||||
|
@ -241,6 +242,7 @@ namespace ClassicalSharp.Entities {
|
|||
|
||||
while( GetMaxHeight( jumpVel ) <= jumpHeight )
|
||||
jumpVel += 0.001f;
|
||||
if( userVel ) userJumpVel = jumpVel;
|
||||
}
|
||||
|
||||
public static double GetMaxHeight( float u ) {
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace ClassicalSharp.Entities {
|
|||
/// <summary> Disables any hacks if their respective CanHackX value is set to false. </summary>
|
||||
public void CheckHacksConsistency() {
|
||||
Hacks.CheckHacksConsistency();
|
||||
if( !Hacks.Enabled || !Hacks.CanAnyHacks || !Hacks.CanSpeed )
|
||||
if( !Hacks.CanJumpHigher )
|
||||
physics.jumpVel = physics.serverJumpVel;
|
||||
}
|
||||
|
||||
|
|
|
@ -299,8 +299,10 @@ namespace ClassicalSharp.Network {
|
|||
p.CheckHacksConsistency();
|
||||
|
||||
float jumpHeight = reader.ReadInt16() / 32f;
|
||||
if( jumpHeight < 0 ) p.physics.jumpVel = 0.42f;
|
||||
else p.physics.CalculateJumpVelocity( jumpHeight );
|
||||
if( jumpHeight < 0 )
|
||||
p.physics.jumpVel = p.Hacks.CanJumpHigher ? p.physics.userJumpVel : 0.42f;
|
||||
else
|
||||
p.physics.CalculateJumpVelocity( false, jumpHeight );
|
||||
p.physics.serverJumpVel = p.physics.jumpVel;
|
||||
game.Events.RaiseHackPermissionsChanged();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue