feat(NoClip): Added velocity based noclipping

This commit is contained in:
Yimura 2021-01-13 15:33:52 +01:00
parent d0c3063148
commit f9c3e718ae
No known key found for this signature in database
GPG Key ID: 3D8FF4397E768682
5 changed files with 88 additions and 2 deletions

View File

@ -16,8 +16,9 @@ namespace big
disable_phone();
god_mode();
join_message();
gravity_gun();
never_wanted();
noclip();
no_bike_fall();
no_idle_kick();
no_ragdoll();

View File

@ -32,8 +32,9 @@ namespace big
void disable_phone();
void god_mode();
void join_message();
void gravity_gun();
void never_wanted();
void noclip();
void no_bike_fall();
void no_idle_kick();
void no_ragdoll();

View File

@ -0,0 +1,63 @@
#include "features.hpp"
namespace big
{
static const int controls[] = { 21, 32, 33, 34, 35, 36 };
static const float speed = 20.f;
static const float headingSpeed = 3.f;
void features::noclip()
{
bool bNoclip = g_settings.options["noclip"]["enabled"];
float fHorizontal = g_settings.options["noclip"]["horizontal"];
float fVertical = g_settings.options["noclip"]["vertical"];
Entity ent = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_playerId);
bool inVehicle = PED::IS_PED_IN_ANY_VEHICLE(ent, true);
if (inVehicle) ent = PED::GET_VEHICLE_PED_IS_IN(ent, false);
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.07f };
float heading = 0.f;
// Left Shift
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 21))
vel.z += speed;
// Left Control
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 36))
vel.z -= speed;
// 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))
{
if (inVehicle) heading += headingSpeed;
vel.x -= speed;
}
// Right
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 35))
{
if (inVehicle) heading -= headingSpeed;
vel.x += speed;
}
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_ROTATION(ent, 0.f, 0.f, ENTITY::GET_ENTITY_HEADING(ent) + heading, 0, true);
ENTITY::SET_ENTITY_VELOCITY(ent, vel.x * fHorizontal, vel.y * fHorizontal, vel.z * fVertical);
}
ENTITY::SET_ENTITY_COLLISION(ent, !bNoclip, !bNoclip);
}
}

View File

@ -27,6 +27,21 @@ namespace big
ImGui::Separator();
if (ImGui::TreeNode("No Clip"))
{
if (ImGui::Checkbox("No Clip", g_settings.options["noclip"]["enabled"].get<bool*>()))
g_settings.save();
const double min = 0.0, max = 10.0;
if (ImGui::SliderScalar("Horizontal Multiplier", ImGuiDataType_Double, g_settings.options["noclip"]["horizontal"].get<double*>(), &min, &max))
g_settings.save();
if (ImGui::SliderScalar("Vertical Multiplier", ImGuiDataType_Double, g_settings.options["noclip"]["vertical"].get<double*>(), &min, &max))
g_settings.save();
ImGui::TreePop();
}
ImGui::Separator();
if (ImGui::Checkbox("God Mode", g_settings.options["god_mode"].get<bool*>()) || ImGui::Checkbox("No Ragdoll", g_settings.options["ragdoll"].get<bool*>()))
g_settings.save();

View File

@ -16,8 +16,14 @@ namespace big
"disable_phone": false,
"disable_chat_censoring": false,
"god_mode": false,
"gravity_gun": true,
"join_message": false,
"never_wanted": false,
"noclip": {
"enabled": false,
"horizontal": 5.0,
"vertical": 1.0
},
"no_bike_fall": false,
"no_idle_kick": false,
"off_radar": false,