2021-09-21 01:44:24 +02:00
|
|
|
#include "backend/looped/looped.hpp"
|
2022-05-23 06:38:45 +08:00
|
|
|
#include "gta/enums.hpp"
|
2021-09-21 01:44:24 +02:00
|
|
|
#include "natives.hpp"
|
|
|
|
#include "util/math.hpp"
|
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
|
|
|
static bool bLastFreeCam = false;
|
|
|
|
|
|
|
|
static float speed = 0.5f;
|
|
|
|
static float mult = 0.f;
|
|
|
|
|
|
|
|
static Cam cCam = -1;
|
|
|
|
static Vector3 vecPosition;
|
|
|
|
static Vector3 vecRot;
|
|
|
|
|
2022-06-25 21:17:35 +02:00
|
|
|
static const ControllerInputs controls[] =
|
|
|
|
{
|
|
|
|
ControllerInputs::INPUT_LOOK_LR,
|
|
|
|
ControllerInputs::INPUT_LOOK_UD,
|
|
|
|
ControllerInputs::INPUT_LOOK_UP_ONLY,
|
|
|
|
ControllerInputs::INPUT_LOOK_DOWN_ONLY,
|
|
|
|
ControllerInputs::INPUT_LOOK_LEFT_ONLY,
|
|
|
|
ControllerInputs::INPUT_LOOK_RIGHT_ONLY,
|
|
|
|
ControllerInputs::INPUT_LOOK_LEFT,
|
|
|
|
ControllerInputs::INPUT_LOOK_RIGHT,
|
|
|
|
ControllerInputs::INPUT_LOOK_UP,
|
|
|
|
ControllerInputs::INPUT_LOOK_DOWN
|
|
|
|
};
|
|
|
|
|
|
|
|
void looped::self_free_cam_disable_control_action()
|
|
|
|
{
|
|
|
|
if (g_local_player == nullptr) return;
|
|
|
|
|
|
|
|
if (g->self.free_cam && !bLastFreeCam)
|
|
|
|
{
|
|
|
|
PAD::DISABLE_ALL_CONTROL_ACTIONS(0);
|
|
|
|
|
|
|
|
for (const auto& control : controls)
|
|
|
|
PAD::DISABLE_CONTROL_ACTION(0, static_cast<int>(control), true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-21 01:44:24 +02:00
|
|
|
void looped::self_free_cam()
|
|
|
|
{
|
|
|
|
if (g_local_player == nullptr) return;
|
|
|
|
|
2022-05-23 06:38:45 +08:00
|
|
|
Vehicle vehicle = self::veh;
|
|
|
|
Ped ped = self::ped;
|
2022-02-22 01:18:49 +01:00
|
|
|
if (!g->self.free_cam && !bLastFreeCam) return;
|
2021-09-21 01:44:24 +02:00
|
|
|
|
2022-02-22 01:18:49 +01:00
|
|
|
if (g->self.free_cam && !bLastFreeCam)
|
2021-09-21 01:44:24 +02:00
|
|
|
{
|
|
|
|
cCam = CAM::CREATE_CAM("DEFAULT_SCRIPTED_CAMERA", 0);
|
|
|
|
|
|
|
|
vecPosition = CAM::GET_GAMEPLAY_CAM_COORD();
|
|
|
|
vecRot = CAM::GET_GAMEPLAY_CAM_ROT(2);
|
|
|
|
|
2022-05-23 06:38:45 +08:00
|
|
|
ENTITY::FREEZE_ENTITY_POSITION(vehicle, true);
|
2021-09-21 01:44:24 +02:00
|
|
|
CAM::SET_CAM_COORD(cCam, vecPosition.x, vecPosition.y, vecPosition.z);
|
|
|
|
CAM::SET_CAM_ROT(cCam, vecRot.x, vecRot.y, vecRot.z, 2);
|
|
|
|
CAM::SET_CAM_ACTIVE(cCam, true);
|
|
|
|
CAM::RENDER_SCRIPT_CAMS(true, true, 500, true, true, 0);
|
|
|
|
|
|
|
|
bLastFreeCam = true;
|
|
|
|
}
|
2022-02-22 01:18:49 +01:00
|
|
|
else if (!g->self.free_cam && bLastFreeCam)
|
2021-09-21 01:44:24 +02:00
|
|
|
{
|
2022-05-23 06:38:45 +08:00
|
|
|
ENTITY::FREEZE_ENTITY_POSITION(vehicle, false);
|
2021-09-21 01:44:24 +02:00
|
|
|
CAM::SET_CAM_ACTIVE(cCam, false);
|
|
|
|
CAM::RENDER_SCRIPT_CAMS(false, true, 500, true, true, 0);
|
|
|
|
CAM::DESTROY_CAM(cCam, false);
|
2022-05-23 06:38:45 +08:00
|
|
|
STREAMING::SET_FOCUS_ENTITY(ped);
|
2021-09-21 01:44:24 +02:00
|
|
|
|
|
|
|
bLastFreeCam = false;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector3 vecChange = { 0.f, 0.f, 0.f };
|
|
|
|
|
|
|
|
// Left Shift
|
2022-05-23 06:38:45 +08:00
|
|
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_SPRINT))
|
2021-09-21 01:44:24 +02:00
|
|
|
vecChange.z += speed / 2;
|
|
|
|
// Left Control
|
2022-05-23 06:38:45 +08:00
|
|
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_DUCK))
|
2021-09-21 01:44:24 +02:00
|
|
|
vecChange.z -= speed / 2;
|
|
|
|
// Forward
|
2022-05-23 06:38:45 +08:00
|
|
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_UP_ONLY))
|
2021-09-21 01:44:24 +02:00
|
|
|
vecChange.y += speed;
|
|
|
|
// Backward
|
2022-05-23 06:38:45 +08:00
|
|
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_DOWN_ONLY))
|
2021-09-21 01:44:24 +02:00
|
|
|
vecChange.y -= speed;
|
|
|
|
// Left
|
2022-05-23 06:38:45 +08:00
|
|
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_LEFT_ONLY))
|
2021-09-21 01:44:24 +02:00
|
|
|
vecChange.x -= speed;
|
|
|
|
// Right
|
2022-05-23 06:38:45 +08:00
|
|
|
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_RIGHT_ONLY))
|
2021-09-21 01:44:24 +02:00
|
|
|
vecChange.x += speed;
|
|
|
|
|
|
|
|
if (vecChange.x == 0.f && vecChange.y == 0.f && vecChange.z == 0.f)
|
|
|
|
mult = 0.f;
|
|
|
|
else if (mult < 10)
|
|
|
|
mult += 0.15f;
|
|
|
|
|
|
|
|
Vector3 rot = CAM::GET_CAM_ROT(cCam, 2);
|
|
|
|
//float pitch = math::deg_to_rad(rot.x); // vertical
|
|
|
|
//float roll = rot.y;
|
|
|
|
float yaw = math::deg_to_rad(rot.z); // horizontal
|
|
|
|
|
|
|
|
vecPosition.x += (vecChange.x * cos(yaw) - vecChange.y * sin(yaw)) * mult;
|
|
|
|
vecPosition.y += (vecChange.x * sin(yaw) + vecChange.y * cos(yaw)) * mult;
|
|
|
|
vecPosition.z += vecChange.z * mult;
|
|
|
|
|
|
|
|
CAM::SET_CAM_COORD(cCam, vecPosition.x, vecPosition.y, vecPosition.z);
|
2022-03-08 01:06:12 +01:00
|
|
|
STREAMING::SET_FOCUS_POS_AND_VEL(vecPosition.x, vecPosition.y, vecPosition.z, 0.f, 0.f, 0.f);
|
2021-09-21 01:44:24 +02:00
|
|
|
|
|
|
|
vecRot = CAM::GET_GAMEPLAY_CAM_ROT(2);
|
|
|
|
CAM::SET_CAM_ROT(cCam, vecRot.x, vecRot.y, vecRot.z, 2);
|
|
|
|
}
|
2022-05-08 00:13:53 +03:00
|
|
|
}
|