feat(Features): Run loop in backend
This commit is contained in:
parent
1b32950020
commit
a73040a03a
16
BigBaseV2/src/backend/backend.cpp
Normal file
16
BigBaseV2/src/backend/backend.cpp
Normal file
@ -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
|
||||
}
|
||||
}
|
10
BigBaseV2/src/backend/backend.hpp
Normal file
10
BigBaseV2/src/backend/backend.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include "common.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
class backend {
|
||||
public:
|
||||
static void loop();
|
||||
};
|
||||
}
|
10
BigBaseV2/src/backend/looped/looped.hpp
Normal file
10
BigBaseV2/src/backend/looped/looped.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include "common.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
class looped {
|
||||
public:
|
||||
static void self_noclip();
|
||||
};
|
||||
}
|
91
BigBaseV2/src/backend/looped/self/noclip.cpp
Normal file
91
BigBaseV2/src/backend/looped/self/noclip.cpp
Normal file
@ -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;
|
||||
}
|
||||
}
|
@ -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()
|
||||
|
Reference in New Issue
Block a user