From 4b75a8bbef74a8109bfd677208efd6e509d4d616 Mon Sep 17 00:00:00 2001 From: NRGJobro <85864573+NRGJobro@users.noreply.github.com> Date: Mon, 1 Aug 2022 15:38:35 -0400 Subject: [PATCH] Fix Build Errors --- Horion.vcxproj | 22 +- Horion/Module/Modules/Fly.cpp | 355 ++++++++++++++----------------- Horion/Module/Modules/Fly.h | 4 +- Horion/Module/Modules/NoFall.cpp | 6 +- Horion/Module/Modules/NoFall.h | 5 +- 5 files changed, 181 insertions(+), 211 deletions(-) diff --git a/Horion.vcxproj b/Horion.vcxproj index 604d227..793f2e2 100644 --- a/Horion.vcxproj +++ b/Horion.vcxproj @@ -279,7 +279,6 @@ - @@ -300,13 +299,12 @@ - + - - + @@ -320,13 +318,12 @@ - + - @@ -340,7 +337,7 @@ - + @@ -468,7 +465,6 @@ - @@ -489,13 +485,12 @@ - + - - + @@ -510,13 +505,12 @@ - + - @@ -530,7 +524,7 @@ - + diff --git a/Horion/Module/Modules/Fly.cpp b/Horion/Module/Modules/Fly.cpp index 04be86b..6232805 100644 --- a/Horion/Module/Modules/Fly.cpp +++ b/Horion/Module/Modules/Fly.cpp @@ -1,205 +1,180 @@ #include "Fly.h" -Fly::Fly() : IModule('F', Category::MOVEMENT, "Fly to the sky") -{ - mode = (*new SettingEnum(this)) - .addEntry(EnumEntry("Creative", 0)) - .addEntry(EnumEntry("CubeGlide", 1)) - .addEntry(EnumEntry("AirStuck", 2)) - .addEntry(EnumEntry("Jetpack", 3)) - .addEntry(EnumEntry("Jetpack2", 4)) - .addEntry(EnumEntry("Motion", 5)); - registerEnumSetting("Mode", &mode, 0); - registerFloatSetting("Horizontal Speed", &this->horizontalSpeed, this->horizontalSpeed, 0.1f, 10.f); - registerFloatSetting("Vertical Speed", &this->verticalSpeed, this->verticalSpeed, 0.1f, 10.f); +Fly::Fly() : IModule('F', Category::MOVEMENT, "Fly to the sky") { + mode = (*new SettingEnum(this)) + .addEntry(EnumEntry("Creative", 0)) + .addEntry(EnumEntry("CubeGlide", 1)) + .addEntry(EnumEntry("AirStuck", 2)) + .addEntry(EnumEntry("Jetpack", 3)) + .addEntry(EnumEntry("Jetpack2", 4)) + .addEntry(EnumEntry("Motion", 5)); + registerEnumSetting("Mode", &mode, 0); + registerFloatSetting("Horizontal Speed", &this->horizontalSpeed, this->horizontalSpeed, 0.1f, 10.f); + registerFloatSetting("Vertical Speed", &this->verticalSpeed, this->verticalSpeed, 0.1f, 10.f); } -Fly::~Fly() -{ +Fly::~Fly() { } -const char *Fly::getModuleName() -{ - return ("Fly"); +const char *Fly::getModuleName() { + return ("Fly"); } -void Fly::onEnable() -{ - switch (mode.selected) - { - case 5: - g_Data.getLocalPlayer()->setPos((*g_Data.getLocalPlayer()->getPos()).add(vec3_t(0, 1, 0))); - break; - } +void Fly::onEnable() { + switch (mode.selected) { + case 5: + g_Data.getLocalPlayer()->setPos((*g_Data.getLocalPlayer()->getPos()).add(vec3_t(0, 1, 0))); + break; + } } -void Fly::onTick(C_GameMode *gm) -{ - ++gameTick; - - switch (mode.selected) - { - case 0: - gm->player->canFly = true; - break; - case 1: - { - float calcYaw = (gm->player->yaw + 90) * (PI / 180); - - gameTick++; - - vec3_t pos = *g_Data.getLocalPlayer()->getPos(); - pos.y += 1.3f; - C_MovePlayerPacket a(g_Data.getLocalPlayer(), pos); - g_Data.getClientInstance()->loopbackPacketSender->sendToServer(&a); - pos.y -= 1.3f; - C_MovePlayerPacket a2(g_Data.getLocalPlayer(), pos); - g_Data.getClientInstance()->loopbackPacketSender->sendToServer(&a2); - - vec3_t moveVec; - moveVec.x = cos(calcYaw) * horizontalSpeed; - moveVec.z = sin(calcYaw) * horizontalSpeed; - - gm->player->lerpMotion(moveVec); - - if (gameTick >= 5) - { - gameTick = 0; - float yaw = gm->player->yaw * (PI / 180); - float length = 4.f; - - float x = -sin(yaw) * length; - float z = cos(yaw) * length; - - gm->player->setPos(pos.add(vec3_t(x, 0.5f, z))); - } - } - break; - case 2: - gm->player->velocity = vec3_t(0, 0, 0); - break; - - case 3: - { - float calcYaw = (gm->player->yaw + 90) * (PI / 180); - float calcPitch = (gm->player->pitch) * -(PI / 180); - - vec3_t moveVec; - moveVec.x = cos(calcYaw) * cos(calcPitch) * horizontalSpeed; - moveVec.y = sin(calcPitch) * horizontalSpeed; - moveVec.z = sin(calcYaw) * cos(calcPitch) * horizontalSpeed; - - gm->player->lerpMotion(moveVec); - } - break; - - case 4: - { - if (gameTick >= 5) - { - float calcYaw = (gm->player->yaw + 90) * (PI / 180); - float calcPitch = (gm->player->pitch) * -(PI / 180); - - vec3_t pos = *g_Data.getLocalPlayer()->getPos(); - C_MovePlayerPacket a(g_Data.getLocalPlayer(), pos); - g_Data.getClientInstance()->loopbackPacketSender->sendToServer(&a); - pos.y += 0.35f; - a = C_MovePlayerPacket(g_Data.getLocalPlayer(), pos); - g_Data.getClientInstance()->loopbackPacketSender->sendToServer(&a); - - gm->player->velocity.y = 0.465f; - vec3_t moveVec; - moveVec.x = cos(calcYaw) * cos(calcPitch) * horizontalSpeed; - moveVec.z = sin(calcYaw) * cos(calcPitch) * horizontalSpeed; - - gm->player->velocity.x = moveVec.x; - gm->player->velocity.z = moveVec.z; - - float teleportX = cos(calcYaw) * cos(calcPitch) * 0.00000005f; - float teleportZ = sin(calcYaw) * cos(calcPitch) * 0.00000005f; - - pos = *gm->player->getPos(); - g_Data.getLocalPlayer()->setPos(vec3_t(pos.x + teleportX, pos.y - 0.15f, pos.z + teleportZ)); - - gm->player->velocity.y -= 0.15f; - gameTick = 0; - } - } - case 5: - gm->player->velocity = vec3_t(0, 0, 0); - } +void Fly::onTick(C_GameMode *gm) { + ++gameTick; + + switch (mode.selected) { + case 0: + gm->player->canFly = true; + break; + case 1: { + float calcYaw = (gm->player->yaw + 90) * (PI / 180); + + gameTick++; + + vec3_t pos = *g_Data.getLocalPlayer()->getPos(); + pos.y += 1.3f; + C_MovePlayerPacket a(g_Data.getLocalPlayer(), pos); + g_Data.getClientInstance()->loopbackPacketSender->sendToServer(&a); + pos.y -= 1.3f; + C_MovePlayerPacket a2(g_Data.getLocalPlayer(), pos); + g_Data.getClientInstance()->loopbackPacketSender->sendToServer(&a2); + + vec3_t moveVec; + moveVec.x = cos(calcYaw) * horizontalSpeed; + moveVec.z = sin(calcYaw) * horizontalSpeed; + + gm->player->lerpMotion(moveVec); + + if (gameTick >= 5) { + gameTick = 0; + float yaw = gm->player->yaw * (PI / 180); + float length = 4.f; + + float x = -sin(yaw) * length; + float z = cos(yaw) * length; + + gm->player->setPos(pos.add(vec3_t(x, 0.5f, z))); + } + } break; + case 2: + gm->player->velocity = vec3_t(0, 0, 0); + break; + + case 3: { + float calcYaw = (gm->player->yaw + 90) * (PI / 180); + float calcPitch = (gm->player->pitch) * -(PI / 180); + + vec3_t moveVec; + moveVec.x = cos(calcYaw) * cos(calcPitch) * horizontalSpeed; + moveVec.y = sin(calcPitch) * horizontalSpeed; + moveVec.z = sin(calcYaw) * cos(calcPitch) * horizontalSpeed; + + gm->player->lerpMotion(moveVec); + } break; + + case 4: { + if (gameTick >= 5) { + float calcYaw = (gm->player->yaw + 90) * (PI / 180); + float calcPitch = (gm->player->pitch) * -(PI / 180); + + vec3_t pos = *g_Data.getLocalPlayer()->getPos(); + C_MovePlayerPacket a(g_Data.getLocalPlayer(), pos); + g_Data.getClientInstance()->loopbackPacketSender->sendToServer(&a); + pos.y += 0.35f; + a = C_MovePlayerPacket(g_Data.getLocalPlayer(), pos); + g_Data.getClientInstance()->loopbackPacketSender->sendToServer(&a); + + gm->player->velocity.y = 0.465f; + vec3_t moveVec; + moveVec.x = cos(calcYaw) * cos(calcPitch) * horizontalSpeed; + moveVec.z = sin(calcYaw) * cos(calcPitch) * horizontalSpeed; + + gm->player->velocity.x = moveVec.x; + gm->player->velocity.z = moveVec.z; + + float teleportX = cos(calcYaw) * cos(calcPitch) * 0.00000005f; + float teleportZ = sin(calcYaw) * cos(calcPitch) * 0.00000005f; + + pos = *gm->player->getPos(); + g_Data.getLocalPlayer()->setPos(vec3_t(pos.x + teleportX, pos.y - 0.15f, pos.z + teleportZ)); + + gm->player->velocity.y -= 0.15f; + gameTick = 0; + } + } + case 5: + gm->player->velocity = vec3_t(0, 0, 0); + } } -void Fly::onDisable() -{ - if (g_Data.getLocalPlayer() == nullptr) - return; - - switch (mode.selected) - { - case 0: - if (g_Data.getLocalPlayer()->gamemode != 1) - g_Data.getLocalPlayer()->canFly = false; - break; - case 1: - g_Data.getLocalPlayer()->velocity = vec3_t(0, 0, 0); - } +void Fly::onDisable() { + if (g_Data.getLocalPlayer() == nullptr) + return; + + switch (mode.selected) { + case 0: + if (g_Data.getLocalPlayer()->gamemode != 1) + g_Data.getLocalPlayer()->canFly = false; + break; + case 1: + g_Data.getLocalPlayer()->velocity = vec3_t(0, 0, 0); + } } -void Fly::onMove(C_MoveInputHandler *input) -{ - C_LocalPlayer *localPlayer = g_Data.getLocalPlayer(); - if (localPlayer == nullptr) - return; - - switch (mode.selected) - { - case 5: - { - vec3_t *localPlayerPos = localPlayer->getPos(); - - float yaw = localPlayer->yaw; - vec2_t moveVec2d = {input->forwardMovement, -input->sideMovement}; - bool pressed = moveVec2d.magnitude() > 0.01f; - - if (input->isJumping) - { - localPlayer->velocity.y += verticalSpeed; - localPlayer->fallDistance = 0.f; - } - if (input->isSneakDown) - { - localPlayer->velocity.y -= verticalSpeed; - localPlayer->fallDistance = 0.f; - } - if (input->right) - { - yaw += 90.f; - if (input->forward) - yaw -= 45.f; - else if (input->backward) - yaw += 45.f; - } - if (input->left) - { - yaw -= 90.f; - if (input->forward) - yaw += 45.f; - else if (input->backward) - yaw -= 45.f; - } - if (input->backward && !input->left && !input->right) - yaw += 180.f; - if (pressed) - { - float calcYaw = (yaw + 90.f) * (PI / 180.f); - vec3_t moveVec; - moveVec.x = cos(calcYaw) * horizontalSpeed; - moveVec.y = localPlayer->velocity.y; - moveVec.z = sin(calcYaw) * horizontalSpeed; - localPlayer->lerpMotion(moveVec); - } - } - break; - } +void Fly::onMove(C_MoveInputHandler *input) { + C_LocalPlayer *localPlayer = g_Data.getLocalPlayer(); + if (localPlayer == nullptr) + return; + + switch (mode.selected) { + case 5: { + vec3_t *localPlayerPos = localPlayer->getPos(); + + float yaw = localPlayer->yaw; + vec2_t moveVec2d = {input->forwardMovement, -input->sideMovement}; + bool pressed = moveVec2d.magnitude() > 0.01f; + + if (input->isJumping) { + localPlayer->velocity.y += verticalSpeed; + localPlayer->fallDistance = 0.f; + } + if (input->isSneakDown) { + localPlayer->velocity.y -= verticalSpeed; + localPlayer->fallDistance = 0.f; + } + if (input->right) { + yaw += 90.f; + if (input->forward) + yaw -= 45.f; + else if (input->backward) + yaw += 45.f; + } + if (input->left) { + yaw -= 90.f; + if (input->forward) + yaw += 45.f; + else if (input->backward) + yaw -= 45.f; + } + if (input->backward && !input->left && !input->right) + yaw += 180.f; + if (pressed) { + float calcYaw = (yaw + 90.f) * (PI / 180.f); + vec3_t moveVec; + moveVec.x = cos(calcYaw) * horizontalSpeed; + moveVec.y = localPlayer->velocity.y; + moveVec.z = sin(calcYaw) * horizontalSpeed; + localPlayer->lerpMotion(moveVec); + } + } break; + } } diff --git a/Horion/Module/Modules/Fly.h b/Horion/Module/Modules/Fly.h index 79a265c..e7a5382 100644 --- a/Horion/Module/Modules/Fly.h +++ b/Horion/Module/Modules/Fly.h @@ -6,7 +6,7 @@ class Fly : public IModule { private: float horizontalSpeed = 1.5f; float verticalSpeed = 0.5; - + int gameTick = 0; public: @@ -16,9 +16,9 @@ class Fly : public IModule { SettingEnum mode; // Inherited via IModule - virtual bool isFlashMode() override; virtual void onEnable() override; virtual const char* getModuleName() override; virtual void onTick(C_GameMode* gm) override; virtual void onDisable() override; + virtual void onMove(C_MoveInputHandler* input) override; }; diff --git a/Horion/Module/Modules/NoFall.cpp b/Horion/Module/Modules/NoFall.cpp index 4e5c485..44287f4 100644 --- a/Horion/Module/Modules/NoFall.cpp +++ b/Horion/Module/Modules/NoFall.cpp @@ -21,7 +21,7 @@ void NoFall::onSendPacket(C_Packet* packet) { if (localPlayer == nullptr) return; - if (localPlayer->fallDistance > 2.f) { + if (localPlayer->fallDistance > 2.f && mode.selected == 1) { if (packet->isInstanceOf()) { C_MovePlayerPacket* movePacket = reinterpret_cast(packet); movePacket->onGround = true; @@ -37,7 +37,7 @@ void NoFall::onTick(C_GameMode* gm) { /* case 0:{ C_PlayerActionPacket actionPacket; - actionPacket.action = 7; //重生 + actionPacket.action = 7; //Respawn actionPacket.entityRuntimeId = localPlayer->entityRuntimeId; g_Data.getClientInstance()->loopbackPacketSender->sendToServer(&actionPacket); } @@ -50,7 +50,7 @@ void NoFall::onTick(C_GameMode* gm) { break; case 3:{ C_PlayerActionPacket actionPacket; - actionPacket.action = 15; //启动鞘翅 + actionPacket.action = 15; //Open Elytra actionPacket.entityRuntimeId = localPlayer->entityRuntimeId; g_Data.getClientInstance()->loopbackPacketSender->sendToServer(&actionPacket); } diff --git a/Horion/Module/Modules/NoFall.h b/Horion/Module/Modules/NoFall.h index 82cc59b..41dcded 100644 --- a/Horion/Module/Modules/NoFall.h +++ b/Horion/Module/Modules/NoFall.h @@ -6,11 +6,12 @@ class NoFall : public IModule { public: SettingEnum mode; - + NoFall(); ~NoFall(); // Inherited via IModule virtual const char* getModuleName() override; virtual void onSendPacket(C_Packet* packet) override; -}; + virtual void onTick(C_GameMode* gm) override; +}; \ No newline at end of file