Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
FreezeEngine committed Jul 21, 2024
1 parent 46a20b2 commit 711b372
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 20 deletions.
18 changes: 16 additions & 2 deletions src/Client/Module/Modules/Nick/NickListener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,25 @@ class NickListener : public Listener {
public:
static inline std::string backupOri;

void onRaknetTick(RaknetTickEvent &event) override {
if (module->isEnabled()) {
std::string serverIP = SDK::getServerIP();
if(serverIP.find("cubecraft") != std::string::npos) {
if(!module->restricted) {
FlarialGUI::Notify("Can't use Nick on " + serverIP); // TODO: move restrictions to API
module->restricted = true;
}
} else {
module->restricted = false;
}
}
}

void onDrawText(DrawTextEvent &event) override {
if (SDK::clientInstance != nullptr) {
if (SDK::clientInstance->getLocalPlayer() != nullptr) {
if (original.empty()) original = SDK::clientInstance->getLocalPlayer()->playerName;
if (module->isEnabled()) {
if (module->isEnabled() && !module->restricted) {
std::string localPlayerName = original;
size_t pos = event.getText()->find(localPlayerName);
if (pos != std::string::npos) {
Expand Down Expand Up @@ -48,7 +62,7 @@ class NickListener : public Listener {
if (!enabled) original2 = *SDK::clientInstance->getLocalPlayer()->getNametag();
}

if (enabled) {
if (enabled && !module->restricted) {

std::string val = module->settings.getSettingByName<std::string>("nick")->value;
SDK::clientInstance->getLocalPlayer()->setNametag(&val);
Expand Down
21 changes: 3 additions & 18 deletions src/Client/Module/Modules/NoHurtCam/NoHurtCam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,23 @@

#include "../Module.hpp"
#include "../../../Events/EventHandler.hpp"
#include "NoHurtCamListener.hpp"


class NoHurtCam : public Module {
public:
// 76 1C 66 0F 6E 00 | 40 F2 0F 11 03 8B 44 24 48 89 43 08 C6 43 0C 01
// 8B 44 24 48 89 43 08 C6 patch to 8B 44 24 48 90 90 90 C6

// TODO: restrict on hive

static inline uintptr_t sigOffset;
static inline std::vector<uint8_t> originalCameraAngle;
static inline uint8_t newCameraAngle[3] = {0x90, 0x90, 0x90};

NoHurtCam() : Module("No Hurt Cam", "Disables hurt camera animation", IDR_REACH_PNG, "") {

originalCameraAngle.resize(3);

sigOffset = Memory::findSig(GET_SIG("CameraAssignAngle")) + 4;

memcpy(originalCameraAngle.data(), (LPVOID) sigOffset, 3);

Module::setup();

};

void onEnable() override {
Memory::patchBytes((LPVOID) sigOffset, newCameraAngle, 3);
EventHandler::registerListener(new NoHurtCamListener("NoHurtCam", this));
Module::onEnable();
}

void onDisable() override {
Memory::patchBytes((LPVOID) sigOffset, originalCameraAngle.data(), 3);
EventHandler::unregisterListener("NoHurtCam");
Module::onDisable();
}
};
69 changes: 69 additions & 0 deletions src/Client/Module/Modules/NoHurtCam/NoHurtCamListener.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#pragma once

#include <format>
#include "../../../Events/Listener.hpp"
#include "../../../Events/Input/KeyEvent.hpp"
#include "../../../../Utils/Logger/Logger.hpp"
#include "../Module.hpp"
#include "../../../../SDK/SDK.hpp"
#include <Windows.h>

class NoHurtCamListener : public Listener {
Module* module;

// 76 1C 66 0F 6E 00 | 40 F2 0F 11 03 8B 44 24 48 89 43 08 C6 43 0C 01
// 8B 44 24 48 89 43 08 C6 patch to 8B 44 24 48 90 90 90 C6

static inline bool patched = false;

static inline uintptr_t sigOffset;
static inline std::vector<uint8_t> originalCameraAngle;
static inline uint8_t newCameraAngle[3] = {0x90, 0x90, 0x90};

public:

static void patch() {
if(patched) return;
patched = true;
Memory::patchBytes((LPVOID) sigOffset, newCameraAngle, 3);
}

static void unpatch() {
if(!patched) return;
patched = false;
Memory::patchBytes((LPVOID) sigOffset, originalCameraAngle.data(), 3);
}

void onRaknetTick(RaknetTickEvent &event) override {
if (module->isEnabled()) {
std::string serverIP = SDK::getServerIP();
if (serverIP.find("hive") != std::string::npos) {
if (!module->restricted) {
FlarialGUI::Notify("Can't use No Hurt Cam on " + serverIP); // TODO: move restrictions to API
module->restricted = true;
}
} else {
module->restricted = false;
}
}
}

void onTick(TickEvent &event) override {
if (module->isEnabled() && !module->restricted) {
patch();
} else {
unpatch();
}
}

NoHurtCamListener(const char string[5], Module *module) {
this->name = string;
this->module = module;

originalCameraAngle.resize(3);

sigOffset = Memory::findSig(GET_SIG("CameraAssignAngle")) + 4;

memcpy(originalCameraAngle.data(), (LPVOID) sigOffset, 3);
}
};

0 comments on commit 711b372

Please sign in to comment.