Don't apply fall tilting when flying or noclip mode.

This commit is contained in:
UnknownShadow200 2016-06-25 20:35:04 +10:00
parent 513e330337
commit 6fe8991f33
2 changed files with 68 additions and 72 deletions

View file

@ -17,7 +17,7 @@ namespace ClassicalSharp.Entities {
public float legXRot, armXRot, armZRot;
public float bobbingHor, bobbingVer, tiltX, tiltY;
public float walkTime, swing, intensity = 1;
public float walkTime, swing, bobStrength = 1;
internal float walkTimeO, walkTimeN, swingO, swingN;
internal float leftXRot, leftZRot, rightXRot, rightZRot;
@ -63,10 +63,10 @@ namespace ClassicalSharp.Entities {
bobbingVer = (float)(Math.Abs( Math.Sin( walkTime ) ) * swing * (2.5f/16f));
if( !game.ViewBobbing || !entity.onGround )
intensity *= 0.9f;
bobStrength *= 0.9f;
else
intensity += 0.1f;
Utils.Clamp( ref intensity, 0, 1 );
bobStrength += 0.1f;
Utils.Clamp( ref bobStrength, 0, 1 );
tiltX = (float)Math.Cos( walkTime ) * swing * (0.15f * Utils.Deg2Rad);
tiltY = (float)Math.Sin( walkTime ) * swing * (0.15f * Utils.Deg2Rad);

View file

@ -112,21 +112,18 @@ namespace ClassicalSharp {
UpdateMouseRotation();
}
protected void CalcVelocityTilt(double delta, float t) {
protected void CalcViewBobbing( double delta, float t, bool velTilt ) {
LocalPlayer p = game.LocalPlayer;
float tiltAmount = (-p.Velocity.Y - 0.08F);
float tiltAmount2 = 0;
tiltAmount2 = Utils.Lerp(p.OldVelocity.Y, player.Velocity.Y, t);
tiltM = Matrix4.RotateZ( -p.anim.tiltX * p.anim.bobStrength );
tiltM = tiltM * Matrix4.RotateX( Math.Abs( p.anim.tiltY ) * 3 * p.anim.bobStrength );
tiltM = tiltM * Matrix4.RotateX( (float)(-tiltAmount2 * 0.05F) );
}
protected void CalcViewBobbing( double delta ) {
LocalPlayer p = game.LocalPlayer;
tiltM = Matrix4.RotateZ( -p.anim.tiltX * p.anim.intensity );
tiltM = tiltM * Matrix4.RotateX( Math.Abs( p.anim.tiltY ) * 3 * p.anim.intensity );
bobbingHor = (p.anim.bobbingHor * 0.3f) * p.anim.bobStrength;
bobbingVer = (p.anim.bobbingVer * 0.6f) * p.anim.bobStrength;
bobbingHor = (p.anim.bobbingHor * 0.3f) * p.anim.intensity;
bobbingVer = (p.anim.bobbingVer * 0.6f) * p.anim.intensity;
if( !velTilt || p.Hacks.Noclip || p.Hacks.Flying ) return;
float vel = Utils.Lerp( p.OldVelocity.Y + 0.08f, p.Velocity.Y + 0.08f, t );
Utils.Clamp( ref vel, -1, 1 );
tiltM = tiltM * Matrix4.RotateX( -vel * 0.05f );
}
}
@ -146,7 +143,7 @@ namespace ClassicalSharp {
}
public override Matrix4 GetView( double delta, float t ) {
CalcViewBobbing( delta );
CalcViewBobbing( delta, t, false );
Vector3 eyePos = player.EyePosition;
eyePos.Y += bobbingVer;
@ -183,7 +180,7 @@ namespace ClassicalSharp {
}
public override Matrix4 GetView( double delta, float t ) {
CalcViewBobbing( delta );
CalcViewBobbing( delta, t, false );
Vector3 eyePos = player.EyePosition;
eyePos.Y += bobbingVer;
@ -214,8 +211,7 @@ namespace ClassicalSharp {
}
public override Matrix4 GetView( double delta, float t ) {
CalcViewBobbing( delta );
CalcVelocityTilt( delta, t );
CalcViewBobbing( delta, t, true );
Vector3 eyePos = player.EyePosition;
eyePos.Y += bobbingVer;
Vector3 cameraDir = Utils.GetDirVector( player.HeadYawRadians,