diff --git a/BigBaseV2/src/backend/backend.cpp b/BigBaseV2/src/backend/backend.cpp new file mode 100644 index 00000000..4de80019 --- /dev/null +++ b/BigBaseV2/src/backend/backend.cpp @@ -0,0 +1,16 @@ +#include "backend.hpp" +#include "fiber_pool.hpp" +#include "script.hpp" +#include "looped/looped.hpp" +#include "core/globals.hpp" + +namespace big +{ + void backend::loop() + { + QUEUE_JOB_BEGIN_CLAUSE() + { + looped::self_noclip(); + }QUEUE_JOB_END_CLAUSE + } +} \ No newline at end of file diff --git a/BigBaseV2/src/backend/backend.hpp b/BigBaseV2/src/backend/backend.hpp new file mode 100644 index 00000000..3a41540e --- /dev/null +++ b/BigBaseV2/src/backend/backend.hpp @@ -0,0 +1,10 @@ +#pragma once +#include "common.hpp" + +namespace big +{ + class backend { + public: + static void loop(); + }; +} \ No newline at end of file diff --git a/BigBaseV2/src/backend/looped/looped.hpp b/BigBaseV2/src/backend/looped/looped.hpp new file mode 100644 index 00000000..3610fed1 --- /dev/null +++ b/BigBaseV2/src/backend/looped/looped.hpp @@ -0,0 +1,10 @@ +#pragma once +#include "common.hpp" + +namespace big +{ + class looped { + public: + static void self_noclip(); + }; +} \ No newline at end of file diff --git a/BigBaseV2/src/backend/looped/self/noclip.cpp b/BigBaseV2/src/backend/looped/self/noclip.cpp new file mode 100644 index 00000000..12b26883 --- /dev/null +++ b/BigBaseV2/src/backend/looped/self/noclip.cpp @@ -0,0 +1,91 @@ +#include "backend/looped/looped.hpp" +#include "fiber_pool.hpp" +#include "natives.hpp" +#include "script.hpp" +#include "core/globals.hpp" +#include "util/entity.hpp" + +namespace big +{ + static const int controls[] = { 21, 32, 33, 34, 35, 36 }; + static const float speed = 20.f; + + static bool bLastNoclip = false; + + static Entity prev = -1; + static Vector3 rot{}; + + void looped::self_noclip() { + bool bNoclip = g.self.noclip; + + Entity ent = PLAYER::PLAYER_PED_ID(); + bool bInVehicle = PED::IS_PED_IN_ANY_VEHICLE(ent, true); + if (bInVehicle) ent = PED::GET_VEHICLE_PED_IS_IN(ent, false); + + // cleanup when changing entities + if (prev != ent) + { + ENTITY::FREEZE_ENTITY_POSITION(ent, false); + ENTITY::SET_ENTITY_COLLISION(prev, true, true); + + prev = ent; + } + + if (bNoclip) + { + for (int control : controls) + PAD::DISABLE_CONTROL_ACTION(0, control, true); + + Vector3 cur_pos = ENTITY::GET_ENTITY_COORDS(ent, true); + Vector3 vel = { 0.f, 0.f, 0.f }; + float heading = 0.f; + + // Left Shift + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 21)) + vel.z += speed / 2; + // Left Control + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 36)) + vel.z -= speed / 2; + // Forward + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 32)) + vel.y += speed; + // Backward + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 33)) + vel.y -= speed; + // Left + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 34)) + vel.x -= speed; + // Right + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 35)) + vel.x += speed; + + rot = CAM::GET_GAMEPLAY_CAM_ROT(2); + ENTITY::SET_ENTITY_ROTATION(ent, 0.f, rot.y, rot.z, 2, 0); + ENTITY::SET_ENTITY_COLLISION(ent, false, false); + if (vel.x == 0.f && vel.y == 0.f && vel.z == 0.f) + { + // freeze entity to prevent drifting when standing still + ENTITY::FREEZE_ENTITY_POSITION(ent, true); + } + else + { + ENTITY::FREEZE_ENTITY_POSITION(ent, false); + + Vector3 offset = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(ent, vel.x, vel.y, 0.f); + vel.x = offset.x - cur_pos.x; + vel.y = offset.y - cur_pos.y; + + ENTITY::SET_ENTITY_VELOCITY(ent, vel.x * speed, vel.y * speed, vel.z * speed); + } + } + else if (bNoclip != bLastNoclip) + { + entity::take_control_of(ent); + + ENTITY::FREEZE_ENTITY_POSITION(ent, false); + ENTITY::SET_ENTITY_COLLISION(ent, true, false); + } + + bLastNoclip = bNoclip; + } +} \ No newline at end of file diff --git a/BigBaseV2/src/features.cpp b/BigBaseV2/src/features.cpp index 978f3a65..c18b35c5 100644 --- a/BigBaseV2/src/features.cpp +++ b/BigBaseV2/src/features.cpp @@ -1,13 +1,15 @@ #include "common.hpp" #include "features.hpp" #include "logger.hpp" -#include "natives.hpp" #include "script.hpp" +#include "backend/backend.hpp" + namespace big { void features::run_tick() { + backend::loop(); } void features::script_func()