diff --git a/source/client/gui/components/OptionList.cpp b/source/client/gui/components/OptionList.cpp index 24127636f..62892db62 100644 --- a/source/client/gui/components/OptionList.cpp +++ b/source/client/gui/components/OptionList.cpp @@ -329,6 +329,7 @@ void OptionList::initDefaultMenu() OPTION(Boolean, m_bInvertMouse, "Invert Y-axis"); OPTION(Boolean, m_bSplitControls, "Split controls"); idxSplit = currentIndex; OPTION(Boolean, m_bFlyCheat, "Flight hax"); + OPTION(Boolean, m_bFlyNoclip, "Flight noclip"); } HEADER("Multiplayer"); diff --git a/source/client/options/Options.cpp b/source/client/options/Options.cpp index 6158c2a58..41b97c22d 100644 --- a/source/client/options/Options.cpp +++ b/source/client/options/Options.cpp @@ -42,6 +42,7 @@ void Options::_initDefaultValues() field_23E = 0; m_fMasterVolume = 1.0f; m_bFlyCheat = false; + m_bFlyNoclip = false; field_241 = 0; field_8 = 0.5f; field_24C = 0; diff --git a/source/client/options/Options.hpp b/source/client/options/Options.hpp index 8f5d4f357..228b16b66 100644 --- a/source/client/options/Options.hpp +++ b/source/client/options/Options.hpp @@ -116,6 +116,7 @@ class Options bool m_bThirdPerson; uint8_t field_23E; bool m_bFlyCheat; + bool m_bFlyNoclip; uint8_t field_240; uint8_t field_241; float field_244; diff --git a/source/client/player/input/ControllerTurnInput.cpp b/source/client/player/input/ControllerTurnInput.cpp index e1d7b1089..83e205c37 100644 --- a/source/client/player/input/ControllerTurnInput.cpp +++ b/source/client/player/input/ControllerTurnInput.cpp @@ -75,7 +75,7 @@ TurnDelta ControllerTurnInput::getTurnDelta() deltaX = deltaTime * xt; deltaY = deltaTime * -yt; } - else if (field_8 != 2 || (!field_18 && !isTouched)) + else if (field_8 != 2 || (!field_18 && !isTouched)) { deltaX = 0.0f; deltaY = -0.0f; diff --git a/source/client/player/input/IMoveInput.cpp b/source/client/player/input/IMoveInput.cpp index 3ad063a76..03f047cfd 100644 --- a/source/client/player/input/IMoveInput.cpp +++ b/source/client/player/input/IMoveInput.cpp @@ -11,6 +11,7 @@ IMoveInput::IMoveInput() : m_horzInput(0.0f), m_vertInput(0.0f), + m_flyInput(0.0f), field_C(false), m_bJumpButton(false), m_bSneakButton(false) diff --git a/source/client/player/input/IMoveInput.hpp b/source/client/player/input/IMoveInput.hpp index 89c3e7329..c36c0e20b 100644 --- a/source/client/player/input/IMoveInput.hpp +++ b/source/client/player/input/IMoveInput.hpp @@ -18,6 +18,8 @@ enum INPUT_RIGHT, INPUT_JUMP, INPUT_SNEAK, + INPUT_FLY_UP, + INPUT_FLY_DOWN, }; class IMoveInput @@ -35,6 +37,7 @@ class IMoveInput public: float m_horzInput; float m_vertInput; + float m_flyInput; bool field_C; bool m_bJumpButton; bool m_bSneakButton; diff --git a/source/client/player/input/KeyboardInput.cpp b/source/client/player/input/KeyboardInput.cpp index 8217b569e..61d264378 100644 --- a/source/client/player/input/KeyboardInput.cpp +++ b/source/client/player/input/KeyboardInput.cpp @@ -32,12 +32,14 @@ void KeyboardInput::setKey(int keyCode, bool b) { int index = -1; - if (m_pOptions->getKey(KM_FORWARD) == keyCode) index = 0; - if (m_pOptions->getKey(KM_BACKWARD) == keyCode) index = 1; - if (m_pOptions->getKey(KM_LEFT) == keyCode) index = 2; - if (m_pOptions->getKey(KM_RIGHT) == keyCode) index = 3; - if (m_pOptions->getKey(KM_JUMP) == keyCode) index = 4; - if (m_pOptions->getKey(KM_SNEAK) == keyCode) index = 5; + if (m_pOptions->getKey(KM_FORWARD) == keyCode) index = INPUT_FORWARD; + if (m_pOptions->getKey(KM_BACKWARD) == keyCode) index = INPUT_BACKWARD; + if (m_pOptions->getKey(KM_LEFT) == keyCode) index = INPUT_LEFT; + if (m_pOptions->getKey(KM_RIGHT) == keyCode) index = INPUT_RIGHT; + if (m_pOptions->getKey(KM_JUMP) == keyCode) index = INPUT_JUMP; + if (m_pOptions->getKey(KM_SNEAK) == keyCode) index = INPUT_SNEAK; + if (m_pOptions->getKey(KM_FLY_UP) == keyCode) index = INPUT_FLY_UP; + if (m_pOptions->getKey(KM_FLY_DOWN) == keyCode) index = INPUT_FLY_DOWN; if (index == -1) return; @@ -49,11 +51,14 @@ void KeyboardInput::tick(Player* pPlayer) { m_horzInput = 0.0f; m_vertInput = 0.0f; + m_flyInput = 0.0f; if (m_keys[INPUT_FORWARD]) m_vertInput += 1.0f; if (m_keys[INPUT_BACKWARD]) m_vertInput -= 1.0f; if (m_keys[INPUT_LEFT]) m_horzInput += 1.0f; if (m_keys[INPUT_RIGHT]) m_horzInput -= 1.0f; + if (m_keys[INPUT_FLY_UP]) m_flyInput += 0.2f; + if (m_keys[INPUT_FLY_DOWN]) m_flyInput -= 0.2f; m_bJumpButton = m_keys[INPUT_JUMP]; m_bSneakButton = m_keys[INPUT_SNEAK]; diff --git a/source/client/player/input/TouchscreenInput_TestFps.cpp b/source/client/player/input/TouchscreenInput_TestFps.cpp index 6eb6420a3..55e438062 100644 --- a/source/client/player/input/TouchscreenInput_TestFps.cpp +++ b/source/client/player/input/TouchscreenInput_TestFps.cpp @@ -15,8 +15,10 @@ TouchscreenInput_TestFps::TouchscreenInput_TestFps(Minecraft* pMinecraft, Options* pOptions) : m_rectArea(0.0f, 0.0f, 1.0f, 1.0f), m_pOptions(pOptions), - field_40(false), - m_bJumpBeingHeld(false), + m_bForwardHeld(false), + m_bJumpingHeld(false), + m_bFlyActive(false), + m_jumpTick(0), m_pMinecraft(pMinecraft), m_pAreaLeft(nullptr), m_pAreaRight(nullptr), @@ -38,6 +40,7 @@ void TouchscreenInput_TestFps::releaseAllKeys() { m_horzInput = 0.0f; m_vertInput = 0.0f; + m_flyInput = 0.0f; for (int i = 0; i < 5; i++) field_6C[i] = false; } @@ -135,6 +138,7 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer) { m_horzInput = 0.0f; m_vertInput = 0.0f; + m_flyInput = 0.0f; m_bJumpButton = false; for (int i = 0; i < 5; i++) @@ -143,7 +147,7 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer) const int* activePointers; int activePointerCount = Multitouch::getActivePointerIds(&activePointers); - bool bJumpPressed = false, bForwardPressed = false; + bool bJumpPressed = false, bForwardPressed = false, bBackwardPressed = false; for (int i = 0; i < activePointerCount; i++) { @@ -167,13 +171,26 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer) if (pointerId == 100 + INPUT_JUMP) // jump { - if (pPlayer->isInWater()) + if (Multitouch::isPressed(finger)) + { m_bJumpButton = true; - else if (Multitouch::isPressed(finger)) + int tick = getTimeMs(); + if (tick - m_jumpTick < 300) + { + m_jumpTick = 0; + m_bFlyActive = !m_bFlyActive; + m_pMinecraft->getOptions()->m_bFlyCheat = m_bFlyActive; + m_bJumpButton = false; + } + else m_jumpTick = tick; + } + else if (m_bFlyActive) + bJumpPressed = true; + else if (pPlayer->isInWater()) m_bJumpButton = true; - else if (field_40) + else if (m_bForwardHeld) { - pointerId = 100; // forward + pointerId = 100 + INPUT_FORWARD; bJumpPressed = true; m_vertInput += 1.0f; } @@ -182,7 +199,7 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer) switch (pointerId) { case 100 + INPUT_FORWARD: - if (pPlayer->isInWater()) + if (pPlayer->isInWater() && !m_bFlyActive) m_bJumpButton = true; else bForwardPressed = true; @@ -191,6 +208,7 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer) break; case 100 + INPUT_BACKWARD: + bBackwardPressed = true; m_vertInput -= 1.0f; break; @@ -204,20 +222,29 @@ void TouchscreenInput_TestFps::tick(Player* pPlayer) } } - field_40 = bForwardPressed; + m_bForwardHeld = bForwardPressed; if (bJumpPressed) { // Don't allow the player to hold jump to repeatedly jump. // Only let them jump once - have them jump again - if (!m_bJumpBeingHeld) + if (!m_bJumpingHeld && !m_bFlyActive) m_bJumpButton = true; - m_bJumpBeingHeld = true; + m_bJumpingHeld = true; + } + else if (m_bFlyActive && m_bJumpingHeld && (bForwardPressed || bBackwardPressed)) + { + if (bForwardPressed) + m_flyInput += 0.2f; + if (bBackwardPressed) + m_flyInput -= 0.2f; + + m_vertInput = 0.0f; } else { - m_bJumpBeingHeld = false; + m_bJumpingHeld = false; } } diff --git a/source/client/player/input/TouchscreenInput_TestFps.hpp b/source/client/player/input/TouchscreenInput_TestFps.hpp index ce3588c49..65ac24e2c 100644 --- a/source/client/player/input/TouchscreenInput_TestFps.hpp +++ b/source/client/player/input/TouchscreenInput_TestFps.hpp @@ -36,8 +36,10 @@ class TouchscreenInput_TestFps : public IMoveInput, public GuiComponent RectangleArea m_rectArea; bool field_30[10]; Options* m_pOptions; - bool field_40; - bool m_bJumpBeingHeld; + bool m_bForwardHeld; + bool m_bJumpingHeld; + bool m_bFlyActive; + int m_jumpTick; TouchAreaModel m_touchAreaModel; Minecraft* m_pMinecraft; PolygonArea* m_pAreaLeft; diff --git a/source/world/entity/LocalPlayer.cpp b/source/world/entity/LocalPlayer.cpp index 0163ce726..c0f98a22c 100644 --- a/source/world/entity/LocalPlayer.cpp +++ b/source/world/entity/LocalPlayer.cpp @@ -64,18 +64,12 @@ void LocalPlayer::animateRespawn() void LocalPlayer::calculateFlight(float x, float y, float z) { - float f1 = m_pMinecraft->getOptions()->field_244; + float f1 = m_pMinecraft->getOptions()->field_8; + float f2 = f1 * 0.35f; float x1 = f1 * x; float z1 = f1 * z; - float y1 = 0.0f; - if (Keyboard::isKeyDown(m_pMinecraft->getOptions()->getKey(KM_FLY_UP))) - y1 = f1 * 0.2f; - if (Keyboard::isKeyDown(m_pMinecraft->getOptions()->getKey(KM_FLY_DOWN))) - y1 = f1 * -0.2f; - field_BFC += x1; - float f2 = m_pMinecraft->getOptions()->field_8 * 0.35f; float f3 = f2 * (field_BFC - field_C00); float f4 = field_C04 + 0.5f * (f3 - field_C04); field_C04 = f4; @@ -84,7 +78,7 @@ void LocalPlayer::calculateFlight(float x, float y, float z) field_C00 += f4; field_BF0 = f4 * 10.0f; - field_C08 += y1; + field_C08 += m_pMoveInput->m_flyInput * f1; float f5 = f2 * (field_C08 - field_C0C); float f6 = field_C10 + 0.5f * (f5 - field_C10); field_C10 = f6; @@ -127,7 +121,7 @@ int LocalPlayer::move(float x, float y, float z) if (Minecraft::DEADMAU5_CAMERA_CHEATS && pLP == this && m_pMinecraft->getOptions()->m_bFlyCheat) { //@HUH: Using m_pMinecraft->m_pLocalPlayer instead of this, even though they're the same - pLP->m_bNoCollision = true; + pLP->m_bNoCollision = m_pMinecraft->getOptions()->m_bFlyNoclip; float field_94_old = field_94;