Merge pull request #4635 from Abextm/camera-pitch-fix

mixins: Fix camera pitch relaxer not fully relaxing after a screen shake
This commit is contained in:
Adam
2018-08-05 09:57:29 -04:00
committed by GitHub
2 changed files with 29 additions and 3 deletions

View File

@@ -49,6 +49,8 @@ public abstract class CameraMixin implements RSClient
@Inject
static int lastPitch = 128;
@Inject
static int lastPitchTarget = 128;
@Inject
public void setCameraPitchRelaxerEnabled(boolean enabled)
@@ -68,12 +70,33 @@ public abstract class CameraMixin implements RSClient
}
}
@FieldHook("cameraPitchTarget")
@Inject
static void onCameraPitchTargetChanged(int idx)
{
int newPitch = client.getCameraPitchTarget();
int pitch = newPitch;
if (pitchRelaxEnabled)
{
// This works because the vanilla camera movement code only moves %2
if (lastPitchTarget > STANDARD_PITCH_MAX && newPitch == STANDARD_PITCH_MAX)
{
pitch = lastPitchTarget;
if (pitch > NEW_PITCH_MAX)
{
pitch = NEW_PITCH_MAX;
}
client.setCameraPitchTarget(pitch);
}
}
lastPitchTarget = pitch;
}
@FieldHook("cameraPitch")
@Inject
static void onCameraPitchChanged(int idx)
{
int newPitch = client.getCameraPitchTarget();
int newPitch = client.getCameraPitch();
int pitch = newPitch;
if (pitchRelaxEnabled)
{
@@ -85,7 +108,7 @@ public abstract class CameraMixin implements RSClient
{
pitch = NEW_PITCH_MAX;
}
client.setCameraPitchTarget(pitch);
client.setCameraPitch(pitch);
}
}
lastPitch = pitch;

View File

@@ -55,6 +55,9 @@ public interface RSClient extends RSGameEngine, Client
@Override
int getCameraPitch();
@Import("cameraPitch")
void setCameraPitch(int cameraPitch);
@Import("cameraYaw")
@Override
int getCameraYaw();