mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-07-15 23:07:59 +08:00
refactor!: Replace premake5 with CMake. (#551)
Co-authored-by: tupoy-ya <tupoy-ya@users.noreply.github.com>
This commit is contained in:
121
src/backend/looped/hud/hud_transition_state.cpp
Normal file
121
src/backend/looped/hud/hud_transition_state.cpp
Normal file
@ -0,0 +1,121 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "script_global.hpp"
|
||||
|
||||
// Credits: QuickNET
|
||||
namespace big
|
||||
{
|
||||
constexpr char transition_states[][48] = {
|
||||
"TRANSITION_STATE_EMPTY",
|
||||
"Singleplayer Swoop Up",
|
||||
"Multiplayer Swoop Up",
|
||||
"Creator Swoop Up",
|
||||
"Pre-HUD Checks",
|
||||
"Wait HUD Exit",
|
||||
"Wait For Summon",
|
||||
"Singleplayer Swoop Down",
|
||||
"Multiplayer Swoop Down",
|
||||
"Cancel Joining",
|
||||
"Retry Loading",
|
||||
"Retry Loading Slot 1",
|
||||
"Retry Loading Slot 2",
|
||||
"Retry Loading Slot 3",
|
||||
"Retry Loading Slot 4",
|
||||
"Wait On Invite",
|
||||
"Prejoining Freemode Session Checks",
|
||||
"Look For Fresh Join Freemode",
|
||||
"Look To Join Another Session Freemode",
|
||||
"Confirm Freemode Session Joining",
|
||||
"Wait Join Freemode Session",
|
||||
"Creation Enter Session",
|
||||
"Pre-Freemode Launch Script",
|
||||
"Freemode Teamfull Check",
|
||||
"Start Freemode Launch Script",
|
||||
"Freemode Transition Create Player",
|
||||
"Is Freemode And Transition Ready",
|
||||
"Freemode Swoop Down",
|
||||
"Post Bink Video Warp",
|
||||
"Freemode Final Setup Player",
|
||||
"Move Freemode To Running State",
|
||||
"Freemode How To Terminate",
|
||||
"Start Creator Pre-Launch Script Check",
|
||||
"Start Creator Launch Script",
|
||||
"Creator Transition Create Player",
|
||||
"Is Creator And Transition Ready",
|
||||
"Creator Swoop Down",
|
||||
"Creator Final Setup Player",
|
||||
"Move Creator To Running State",
|
||||
"Prejoining Testbed Session Checks",
|
||||
"Look For Fresh Join Testbed",
|
||||
"Look For Fresh Host Testbed",
|
||||
"Look To Join Another Session Testbed",
|
||||
"Look To Host Session Testbed",
|
||||
"Confirm Testbed Session Joining",
|
||||
"Wait Join Testbed Session",
|
||||
"Start Testbed Launch Script",
|
||||
"Testbed Transition Create Player",
|
||||
"Is Testbed And Transition Ready",
|
||||
"Testbed Swoop Down",
|
||||
"Testbed Final Setup Player",
|
||||
"Move Testbed To Running State",
|
||||
"Testbed How To Terminate",
|
||||
"Quit Current Session Prompt",
|
||||
"Wait For Transition Session To Setup",
|
||||
"Terminate Singleplayer",
|
||||
"Wait Terminate Singleplayer",
|
||||
"Kick Terminate Session",
|
||||
"Terminate Session",
|
||||
"Wait Terminate Session",
|
||||
"Terminate Session And Hold",
|
||||
"Terminate Session And Move Into Holding State",
|
||||
"Team Swapping Checks",
|
||||
"Return To Singleplayer",
|
||||
"Wait For Singleplayer To Start",
|
||||
"Waiting For External Termination Call",
|
||||
"Terminate Maintransition",
|
||||
"Wait For Dirty Load Confirm",
|
||||
"DLC Intro Bink",
|
||||
};
|
||||
|
||||
auto transition_state = script_global(1574991);
|
||||
eTransitionState last_state = eTransitionState::TRANSITION_STATE_EMPTY;
|
||||
void looped::hud_transition_state()
|
||||
{
|
||||
const auto state = *transition_state.as<eTransitionState*>();
|
||||
|
||||
// When freemode script loaded remove loading screen.
|
||||
if (state == eTransitionState::TRANSITION_STATE_WAIT_JOIN_FM_SESSION
|
||||
&& DLC::GET_IS_LOADING_SCREEN_ACTIVE())
|
||||
{
|
||||
SCRIPT::SHUTDOWN_LOADING_SCREEN();
|
||||
}
|
||||
|
||||
if (last_state == state
|
||||
|| state == eTransitionState::TRANSITION_STATE_EMPTY
|
||||
|| state > eTransitionState::TRANSITION_STATE_DLC_INTRO_BINK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (HUD::BUSYSPINNER_IS_ON())
|
||||
{
|
||||
HUD::BUSYSPINNER_OFF();
|
||||
}
|
||||
|
||||
// sometimes when going into a single player mission or transition this one remains on screen permanently
|
||||
if (state == eTransitionState::TRANSITION_STATE_TERMINATE_MAINTRANSITION)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((int)state > 0 && (int)std::size(transition_states))
|
||||
{
|
||||
HUD::BEGIN_TEXT_COMMAND_BUSYSPINNER_ON("STRING");
|
||||
auto const spinner_text = std::format("{} | {}", transition_states[(int)state], static_cast<int>(state));
|
||||
HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(spinner_text.c_str());
|
||||
HUD::END_TEXT_COMMAND_BUSYSPINNER_ON(5);
|
||||
}
|
||||
|
||||
last_state = state;
|
||||
}
|
||||
}
|
79
src/backend/looped/looped.hpp
Normal file
79
src/backend/looped/looped.hpp
Normal file
@ -0,0 +1,79 @@
|
||||
#pragma once
|
||||
|
||||
#include "common.hpp"
|
||||
|
||||
#include "services/players/player_service.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
class looped {
|
||||
public:
|
||||
static void api_login_session();
|
||||
|
||||
static void context_menu();
|
||||
static void hud_transition_state();
|
||||
|
||||
static void tunables_disable_phone();
|
||||
static void tunables_no_idle_kick();
|
||||
|
||||
static void player_never_wanted(const player_ptr &player);
|
||||
static void player_spectate();
|
||||
|
||||
static void protections_replay_interface();
|
||||
|
||||
static void self_clean_player();
|
||||
static void self_free_cam_disable_control_action();
|
||||
static void self_free_cam();
|
||||
static void self_godmode();
|
||||
static void self_invisibility();
|
||||
static void self_noclip_disable_control_action();
|
||||
static void self_noclip();
|
||||
static void self_no_ragdoll();
|
||||
static void self_off_radar();
|
||||
static void self_police();
|
||||
static void self_super_run();
|
||||
static void self_no_collision();
|
||||
static void self_hud();
|
||||
static void self_unlimited_oxygen();
|
||||
static void self_no_water_collision();
|
||||
|
||||
static void session_local_time();
|
||||
|
||||
static void system_self_globals();
|
||||
static void system_update_pointers();
|
||||
static void system_desync_kick_protection();
|
||||
|
||||
static void vehicle_auto_drive();
|
||||
static void vehicle_boost_behavior();
|
||||
static void vehicle_despawn_bypass();
|
||||
static void vehicle_drive_on_water();
|
||||
static void vehicle_fly();
|
||||
static void vehicle_god_mode();
|
||||
static void vehicle_horn_boost();
|
||||
static void vehicle_jump();
|
||||
static void vehicle_instant_brake();
|
||||
static void vehicle_is_targetable();
|
||||
static void vehicle_ls_customs();
|
||||
static void vehicle_rainbow_paint();
|
||||
static void vehicle_seatbelt();
|
||||
static void vehicle_speedo_meter();
|
||||
static void vehicle_turn_signals();
|
||||
static void vehicle_keep_vehicle_repaired();
|
||||
static void vehicle_no_water_collision();
|
||||
|
||||
static void weapons_ammo_special_type();
|
||||
static void weapons_cage_gun();
|
||||
static void custom_gun_disable_control_action();
|
||||
static void weapons_delete_gun();
|
||||
static void weapons_force_crosshairs();
|
||||
static void weapons_gravity_gun();
|
||||
static void weapons_increased_damage();
|
||||
static void weapons_infinite_ammo();
|
||||
static void weapons_infinite_mag();
|
||||
static void weapons_no_recoil();
|
||||
static void weapons_no_spread();
|
||||
static void weapons_repair_gun();
|
||||
static void weapons_steal_vehicle_gun();
|
||||
static void weapons_vehicle_gun();
|
||||
};
|
||||
}
|
14
src/backend/looped/player/player_never_wanted.cpp
Normal file
14
src/backend/looped/player/player_never_wanted.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "services/players/player_service.hpp"
|
||||
#include "util/globals.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::player_never_wanted(const player_ptr &player)
|
||||
{
|
||||
if (player->never_wanted)
|
||||
{
|
||||
globals::clear_wanted_player(player->id());
|
||||
}
|
||||
}
|
||||
}
|
51
src/backend/looped/player/spectate.cpp
Normal file
51
src/backend/looped/player/spectate.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "services/players/player_service.hpp"
|
||||
#include "util/globals.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static bool bReset = true;
|
||||
|
||||
void looped::player_spectate()
|
||||
{
|
||||
const auto vehicle = self::veh;
|
||||
const auto ped = self::ped;
|
||||
|
||||
if (!g_player_service->get_selected()->is_valid() || !g->player.spectating)
|
||||
{
|
||||
if (g->player.spectating) g->player.spectating = false;
|
||||
|
||||
if (!bReset)
|
||||
{
|
||||
bReset = true;
|
||||
|
||||
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(false, -1);
|
||||
HUD::SET_MINIMAP_IN_SPECTATOR_MODE(false, -1);
|
||||
|
||||
ENTITY::FREEZE_ENTITY_POSITION(ped, false);
|
||||
ENTITY::FREEZE_ENTITY_POSITION(vehicle, false);
|
||||
|
||||
STREAMING::SET_FOCUS_ENTITY(ped);
|
||||
|
||||
globals::disable_kill_trigger(false);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const auto target = PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_player_service->get_selected()->id());
|
||||
|
||||
globals::disable_kill_trigger(true);
|
||||
|
||||
NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(true, target);
|
||||
HUD::SET_MINIMAP_IN_SPECTATOR_MODE(true, target);
|
||||
|
||||
ENTITY::FREEZE_ENTITY_POSITION(ped, true);
|
||||
ENTITY::FREEZE_ENTITY_POSITION(vehicle, true);
|
||||
|
||||
STREAMING::SET_FOCUS_ENTITY(target);
|
||||
|
||||
bReset = false;
|
||||
}
|
||||
}
|
13
src/backend/looped/self/clean_player.cpp
Normal file
13
src/backend/looped/self/clean_player.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "util/entity.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::self_clean_player()
|
||||
{
|
||||
if (g->self.clean_player) {
|
||||
entity::clean_ped(self::ped);
|
||||
}
|
||||
}
|
||||
}
|
126
src/backend/looped/self/free_cam.cpp
Normal file
126
src/backend/looped/self/free_cam.cpp
Normal file
@ -0,0 +1,126 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "util/globals.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;
|
||||
|
||||
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)
|
||||
{
|
||||
PAD::DISABLE_ALL_CONTROL_ACTIONS(0);
|
||||
|
||||
for (const auto& control : controls)
|
||||
PAD::ENABLE_CONTROL_ACTION(0, static_cast<int>(control), true);
|
||||
}
|
||||
}
|
||||
|
||||
void looped::self_free_cam()
|
||||
{
|
||||
if (g_local_player == nullptr) return;
|
||||
|
||||
const auto vehicle = self::veh;
|
||||
const auto ped = self::ped;
|
||||
if (!g->self.free_cam && !bLastFreeCam) return;
|
||||
|
||||
if (g->self.free_cam && !bLastFreeCam)
|
||||
{
|
||||
cCam = CAM::CREATE_CAM("DEFAULT_SCRIPTED_CAMERA", 0);
|
||||
|
||||
vecPosition = CAM::GET_GAMEPLAY_CAM_COORD();
|
||||
vecRot = CAM::GET_GAMEPLAY_CAM_ROT(2);
|
||||
|
||||
globals::disable_kill_trigger(true);
|
||||
ENTITY::FREEZE_ENTITY_POSITION(vehicle, true);
|
||||
|
||||
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;
|
||||
}
|
||||
else if (!g->self.free_cam && bLastFreeCam)
|
||||
{
|
||||
CAM::SET_CAM_ACTIVE(cCam, false);
|
||||
CAM::RENDER_SCRIPT_CAMS(false, true, 500, true, true, 0);
|
||||
CAM::DESTROY_CAM(cCam, false);
|
||||
STREAMING::SET_FOCUS_ENTITY(ped);
|
||||
|
||||
ENTITY::FREEZE_ENTITY_POSITION(vehicle, false);
|
||||
globals::disable_kill_trigger(false);
|
||||
|
||||
bLastFreeCam = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 vecChange = { 0.f, 0.f, 0.f };
|
||||
|
||||
// Left Shift
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_SPRINT))
|
||||
vecChange.z += speed / 2;
|
||||
// Left Control
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_DUCK))
|
||||
vecChange.z -= speed / 2;
|
||||
// Forward
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_UP_ONLY))
|
||||
vecChange.y += speed;
|
||||
// Backward
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_DOWN_ONLY))
|
||||
vecChange.y -= speed;
|
||||
// Left
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_LEFT_ONLY))
|
||||
vecChange.x -= speed;
|
||||
// Right
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_RIGHT_ONLY))
|
||||
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);
|
||||
STREAMING::SET_FOCUS_POS_AND_VEL(vecPosition.x, vecPosition.y, vecPosition.z, 0.f, 0.f, 0.f);
|
||||
|
||||
vecRot = CAM::GET_GAMEPLAY_CAM_ROT(2);
|
||||
CAM::SET_CAM_ROT(cCam, vecRot.x, vecRot.y, vecRot.z, 2);
|
||||
}
|
||||
}
|
53
src/backend/looped/self/godmode.cpp
Normal file
53
src/backend/looped/self/godmode.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "util/water.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static uint32_t last_bits = 0;
|
||||
static float last_water_collistion_strength = 0;
|
||||
|
||||
void looped::self_godmode()
|
||||
{
|
||||
if (g_local_player == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float* water_collision_ptr = nullptr;
|
||||
if (g_local_player->m_navigation != nullptr)
|
||||
{
|
||||
water_collision_ptr = water::get_water_collision_ptr(g_local_player->m_navigation);
|
||||
}
|
||||
|
||||
uint32_t bits = g->self.proof_mask;
|
||||
uint32_t changed_bits = bits ^ last_bits;
|
||||
uint32_t changed_or_enabled_bits = bits | changed_bits;
|
||||
|
||||
if (changed_or_enabled_bits)
|
||||
{
|
||||
uint32_t unchanged_bits = g_local_player->m_damage_bits & ~changed_or_enabled_bits;
|
||||
g_local_player->m_damage_bits = unchanged_bits | bits;
|
||||
last_bits = bits;
|
||||
|
||||
|
||||
if (changed_or_enabled_bits & (uint32_t)eEntityProofs::WATER)
|
||||
{
|
||||
water::reset_ped_oxygen_time(g_local_player);
|
||||
|
||||
if (water_collision_ptr != nullptr && *water_collision_ptr != 0.f)
|
||||
{
|
||||
last_water_collistion_strength = *water_collision_ptr;
|
||||
*water_collision_ptr = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (last_water_collistion_strength != 0 && water_collision_ptr != nullptr)
|
||||
{
|
||||
*water_collision_ptr = last_water_collistion_strength;
|
||||
last_water_collistion_strength = 0;
|
||||
}
|
||||
}
|
||||
}
|
50
src/backend/looped/self/hud.cpp
Normal file
50
src/backend/looped/self/hud.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "core/data/hud_component_names.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
namespace big
|
||||
{
|
||||
static bool bLastHideRadar = false;
|
||||
|
||||
void looped::self_hud()
|
||||
{
|
||||
const bool bHideRadar = g->self.hide_radar;
|
||||
const bool bHideAmmo = g->self.hide_ammo;
|
||||
auto& bHudComponents = g->self.hud_components_states;
|
||||
|
||||
if (bHideRadar)
|
||||
{
|
||||
HUD::DISPLAY_RADAR(false);
|
||||
}
|
||||
else if (bHideRadar != bLastHideRadar)
|
||||
{
|
||||
HUD::DISPLAY_RADAR(true);
|
||||
}
|
||||
bLastHideRadar = bHideRadar;
|
||||
|
||||
if (bHideAmmo)
|
||||
{
|
||||
HUD::DISPLAY_AMMO_THIS_FRAME(false);
|
||||
}
|
||||
|
||||
if (
|
||||
std::all_of(
|
||||
std::begin(bHudComponents),
|
||||
std::end(bHudComponents),
|
||||
[](bool i) { return i; }
|
||||
)
|
||||
) {
|
||||
HUD::DISPLAY_HUD(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
HUD::DISPLAY_HUD(true);
|
||||
for (int i = 0; i < (int)HudComponents::HUD_WEAPONS; i++)
|
||||
{
|
||||
if (bHudComponents[i])
|
||||
HUD::HIDE_HUD_COMPONENT_THIS_FRAME(i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
36
src/backend/looped/self/invisibility.cpp
Normal file
36
src/backend/looped/self/invisibility.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static bool bLastInvisibility = false;
|
||||
|
||||
void looped::self_invisibility()
|
||||
{
|
||||
Ped ped = self::ped;
|
||||
|
||||
bool bInvisibility = g->self.invisibility;
|
||||
|
||||
if (bInvisibility || (!bInvisibility && bInvisibility != bLastInvisibility))
|
||||
{
|
||||
ENTITY::SET_ENTITY_VISIBLE(ped, !g->self.invisibility, 0);
|
||||
|
||||
bLastInvisibility = g->self.invisibility;
|
||||
}
|
||||
|
||||
if (NETWORK::NETWORK_IS_SESSION_STARTED())
|
||||
{
|
||||
if (g->self.invisibility && g->self.local_visibility)
|
||||
{
|
||||
NETWORK::SET_ENTITY_LOCALLY_VISIBLE(ped);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g->self.local_visibility)
|
||||
{
|
||||
ENTITY::SET_ENTITY_VISIBLE(ped, true, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
24
src/backend/looped/self/no_collision.cpp
Normal file
24
src/backend/looped/self/no_collision.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static bool bLastNoCollsion = false;
|
||||
|
||||
void looped::self_no_collision()
|
||||
{
|
||||
if (g_local_player == nullptr) return;
|
||||
|
||||
bool bNoCollsion = g->self.no_collision;
|
||||
|
||||
if (bNoCollsion)
|
||||
{
|
||||
g_local_player->m_navigation->m_damp->m_bound_composite->m_bound_capsule_list->m_bound_capsule->m_collision = -1;
|
||||
bLastNoCollsion = bNoCollsion;
|
||||
}
|
||||
else if (bNoCollsion != bLastNoCollsion)
|
||||
{
|
||||
g_local_player->m_navigation->m_damp->m_bound_composite->m_bound_capsule_list->m_bound_capsule->m_collision = 0.25;
|
||||
bLastNoCollsion = bNoCollsion;
|
||||
}
|
||||
}
|
||||
}
|
19
src/backend/looped/self/no_ragdoll.cpp
Normal file
19
src/backend/looped/self/no_ragdoll.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static bool bLastNoRagdoll = false;
|
||||
|
||||
void looped::self_no_ragdoll()
|
||||
{
|
||||
bool bNoRagdoll = g->self.no_ragdoll;
|
||||
|
||||
if (bNoRagdoll || (!bNoRagdoll && bNoRagdoll != bLastNoRagdoll))
|
||||
{
|
||||
PED::SET_PED_CAN_RAGDOLL(self::ped, !g->self.no_ragdoll);
|
||||
|
||||
bLastNoRagdoll = g->self.no_ragdoll;
|
||||
}
|
||||
}
|
||||
}
|
24
src/backend/looped/self/no_water_collision.cpp
Normal file
24
src/backend/looped/self/no_water_collision.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static bool bLastSelfNoWaterCollsion = false;
|
||||
|
||||
void looped::self_no_water_collision()
|
||||
{
|
||||
if (g_local_player == nullptr) return;
|
||||
|
||||
bool bNoWaterCollsion = g->self.no_water_collision;
|
||||
|
||||
if (bNoWaterCollsion)
|
||||
{
|
||||
g_local_player->m_navigation->m_damp->m_water_collision = 0;
|
||||
bLastSelfNoWaterCollsion = bNoWaterCollsion;
|
||||
}
|
||||
else if (bNoWaterCollsion != bLastSelfNoWaterCollsion)
|
||||
{
|
||||
g_local_player->m_navigation->m_damp->m_water_collision = 1;
|
||||
bLastSelfNoWaterCollsion = bNoWaterCollsion;
|
||||
}
|
||||
}
|
||||
}
|
110
src/backend/looped/self/noclip.cpp
Normal file
110
src/backend/looped/self/noclip.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "fiber_pool.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "util/entity.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static const ControllerInputs controls[] =
|
||||
{
|
||||
ControllerInputs::INPUT_SPRINT,
|
||||
ControllerInputs::INPUT_MOVE_UP_ONLY,
|
||||
ControllerInputs::INPUT_MOVE_DOWN_ONLY,
|
||||
ControllerInputs::INPUT_MOVE_LEFT_ONLY,
|
||||
ControllerInputs::INPUT_MOVE_RIGHT_ONLY,
|
||||
ControllerInputs::INPUT_DUCK
|
||||
};
|
||||
|
||||
static float speed = 20.f;
|
||||
static float mult = 0.f;
|
||||
|
||||
static bool bLastNoclip = false;
|
||||
|
||||
static Entity prev = -1;
|
||||
static Vector3 rot{};
|
||||
|
||||
void looped::self_noclip_disable_control_action()
|
||||
{
|
||||
if (g->self.noclip)
|
||||
{
|
||||
for (const auto& control : controls)
|
||||
PAD::DISABLE_CONTROL_ACTION(0, static_cast<int>(control), true);
|
||||
}
|
||||
}
|
||||
|
||||
void looped::self_noclip()
|
||||
{
|
||||
const auto bNoclip = g->self.noclip;
|
||||
|
||||
const auto location = self::pos;
|
||||
const Entity ent = (self::veh != 0 && g_local_player->m_ped_task_flag & (int)ePedTask::TASK_DRIVING) ? self::veh : self::ped;
|
||||
|
||||
// cleanup when changing entities
|
||||
if (prev != ent)
|
||||
{
|
||||
ENTITY::FREEZE_ENTITY_POSITION(prev, false);
|
||||
ENTITY::SET_ENTITY_COLLISION(prev, true, true);
|
||||
|
||||
prev = ent;
|
||||
}
|
||||
|
||||
if (bNoclip)
|
||||
{
|
||||
Vector3 vel = { 0.f, 0.f, 0.f };
|
||||
|
||||
// Left Shift
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_SPRINT))
|
||||
vel.z += speed / 2;
|
||||
// Left Control
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_DUCK))
|
||||
vel.z -= speed / 2;
|
||||
// Forward
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_UP_ONLY))
|
||||
vel.y += speed;
|
||||
// Backward
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_DOWN_ONLY))
|
||||
vel.y -= speed;
|
||||
// Left
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_LEFT_ONLY))
|
||||
vel.x -= speed;
|
||||
// Right
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_RIGHT_ONLY))
|
||||
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);
|
||||
|
||||
mult = 0.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mult < 20.f)
|
||||
mult += 0.15f;
|
||||
|
||||
ENTITY::FREEZE_ENTITY_POSITION(ent, false);
|
||||
|
||||
const auto offset = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(ent, vel.x, vel.y, 0.f);
|
||||
vel.x = offset.x - location.x;
|
||||
vel.y = offset.y - location.y;
|
||||
|
||||
ENTITY::SET_ENTITY_VELOCITY(ent, vel.x * mult, vel.y * mult, vel.z * mult);
|
||||
}
|
||||
}
|
||||
else if (bNoclip != bLastNoclip)
|
||||
{
|
||||
if (entity::take_control_of(ent))
|
||||
{
|
||||
ENTITY::FREEZE_ENTITY_POSITION(ent, false);
|
||||
ENTITY::SET_ENTITY_COLLISION(ent, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
bLastNoclip = bNoclip;
|
||||
}
|
||||
}
|
11
src/backend/looped/self/off_radar.cpp
Normal file
11
src/backend/looped/self/off_radar.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "util/mobile.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::self_off_radar()
|
||||
{
|
||||
if (g->self.off_radar)
|
||||
mobile::lester::off_radar(g->self.off_radar);
|
||||
}
|
||||
}
|
31
src/backend/looped/self/police.cpp
Normal file
31
src/backend/looped/self/police.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "pointers.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::self_police()
|
||||
{
|
||||
if (g_local_player == nullptr || g_local_player->m_player_info == nullptr) return;
|
||||
|
||||
static bool bLast = false;
|
||||
|
||||
bool b = g->self.never_wanted;
|
||||
|
||||
if (b)
|
||||
{
|
||||
g_local_player->m_player_info->m_wanted_level = 0;
|
||||
g_pointers->m_max_wanted_level->apply();
|
||||
g_pointers->m_max_wanted_level_2->apply();
|
||||
bLast = b;
|
||||
}
|
||||
else if (b != bLast)
|
||||
{
|
||||
g_pointers->m_max_wanted_level->restore();
|
||||
g_pointers->m_max_wanted_level_2->restore();
|
||||
bLast = b;
|
||||
}
|
||||
|
||||
if(g->self.force_wanted_level && !b)
|
||||
g_local_player->m_player_info->m_wanted_level = g->self.wanted_level;
|
||||
}
|
||||
}
|
53
src/backend/looped/self/super_run.cpp
Normal file
53
src/backend/looped/self/super_run.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "util/math.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static float run_speed = 10.f;
|
||||
static float run_cap = 100.f;
|
||||
static bool super_run_state = false;
|
||||
|
||||
void looped::self_super_run()
|
||||
{
|
||||
if (g->self.super_run && PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_SPRINT))
|
||||
{
|
||||
if (run_speed < run_cap) run_speed += .5f;
|
||||
|
||||
Vector3 location = self::pos;
|
||||
Ped ped = self::ped;
|
||||
|
||||
//Vector3 rot = CAM::GET_GAMEPLAY_CAM_ROT(2);
|
||||
Vector3 rot = ENTITY::GET_ENTITY_ROTATION(ped, 2);
|
||||
float yaw = math::deg_to_rad(rot.z + 90);
|
||||
|
||||
Vector3 offset;
|
||||
offset.x = location.x + (run_speed * cos(yaw));
|
||||
offset.y = location.y + (run_speed * sin(yaw));
|
||||
offset.z = location.z + .2f;
|
||||
|
||||
float groundZ;
|
||||
MISC::GET_GROUND_Z_FOR_3D_COORD(offset.x, offset.y, 1000.f, &groundZ, false, false);
|
||||
if (groundZ < location.z)
|
||||
offset.z = groundZ;
|
||||
|
||||
Vector3 vel = offset - location;
|
||||
|
||||
ENTITY::SET_ENTITY_VELOCITY(ped, vel.x, vel.y, vel.z);
|
||||
|
||||
g_local_player->m_player_info->m_run_speed = .7f;
|
||||
}
|
||||
else if (!g->self.super_run && g->self.super_run != super_run_state)
|
||||
{
|
||||
g_local_player->m_player_info->m_run_speed = 1.f;
|
||||
}
|
||||
else if (PAD::IS_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_SPRINT))
|
||||
{
|
||||
run_speed = 10.f;
|
||||
g_local_player->m_player_info->m_run_speed = 1.f;
|
||||
}
|
||||
|
||||
super_run_state = g->self.super_run;
|
||||
}
|
||||
}
|
12
src/backend/looped/self/unlimited_oxygen.cpp
Normal file
12
src/backend/looped/self/unlimited_oxygen.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::self_unlimited_oxygen()
|
||||
{
|
||||
if (g_local_player == nullptr) return;
|
||||
|
||||
if (g->self.unlimited_oxygen)
|
||||
g_local_player->m_oxygen_info->m_oxygen_time = 0;
|
||||
}
|
||||
}
|
26
src/backend/looped/session/local_time.cpp
Normal file
26
src/backend/looped/session/local_time.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static bool toggled = true;
|
||||
|
||||
void looped::session_local_time()
|
||||
{
|
||||
if (g->session.override_time)
|
||||
{
|
||||
if (toggled)
|
||||
{
|
||||
NETWORK::NETWORK_GET_GLOBAL_MULTIPLAYER_CLOCK(&g->session.custom_time.hour, &g->session.custom_time.minute, &g->session.custom_time.second);
|
||||
toggled = false;
|
||||
}
|
||||
|
||||
NETWORK::NETWORK_OVERRIDE_CLOCK_TIME(g->session.custom_time.hour, g->session.custom_time.minute, g->session.custom_time.second);
|
||||
}
|
||||
else
|
||||
{
|
||||
NETWORK::NETWORK_CLEAR_CLOCK_TIME_OVERRIDE();
|
||||
toggled = true;
|
||||
}
|
||||
}
|
||||
}
|
37
src/backend/looped/system/desync_kick_protection.cpp
Normal file
37
src/backend/looped/system/desync_kick_protection.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "fiber_pool.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "script.hpp"
|
||||
#include "services/players/player_service.hpp"
|
||||
#include "gta_util.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::system_desync_kick_protection()
|
||||
{
|
||||
memset(>a_util::get_network()->m_game_complaint_mgr.m_host_tokens_complained, 0, 64 * sizeof(std::uint64_t));
|
||||
gta_util::get_network()->m_game_complaint_mgr.m_num_tokens_complained = 0;
|
||||
|
||||
auto old = gta_util::get_network()->m_game_complaint_mgr.m_host_token;
|
||||
|
||||
if (gta_util::get_network()->m_game_session_state > 3 && gta_util::get_network()->m_game_session_state < 6)
|
||||
{
|
||||
for (auto& [_, plyr] : g_player_service->players())
|
||||
{
|
||||
if (plyr->get_net_data())
|
||||
{
|
||||
gta_util::get_network()->m_game_complaint_mgr.m_host_token = plyr->get_net_data()->m_host_token;
|
||||
g_pointers->m_reset_network_complaints(>a_util::get_network()->m_game_complaint_mgr);
|
||||
}
|
||||
}
|
||||
|
||||
if (g_player_service->get_self() && g_player_service->get_self()->get_net_data())
|
||||
{
|
||||
gta_util::get_network()->m_game_complaint_mgr.m_host_token = g_player_service->get_self()->get_net_data()->m_host_token;
|
||||
g_pointers->m_reset_network_complaints(>a_util::get_network()->m_game_complaint_mgr);
|
||||
}
|
||||
}
|
||||
|
||||
gta_util::get_network()->m_game_complaint_mgr.m_host_token = old;
|
||||
}
|
||||
}
|
23
src/backend/looped/system/self_globals.cpp
Normal file
23
src/backend/looped/system/self_globals.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::system_self_globals()
|
||||
{
|
||||
self::id = PLAYER::PLAYER_ID();
|
||||
|
||||
self::ped = PLAYER::PLAYER_PED_ID();
|
||||
|
||||
self::pos = ENTITY::GET_ENTITY_COORDS(self::ped, false /*Unused*/);
|
||||
|
||||
if (PED::IS_PED_IN_ANY_VEHICLE(self::ped, 0))
|
||||
{
|
||||
self::veh = PED::GET_VEHICLE_PED_IS_IN(self::ped, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
self::veh = 0;
|
||||
}
|
||||
}
|
||||
}
|
10
src/backend/looped/system/update_pointers.cpp
Normal file
10
src/backend/looped/system/update_pointers.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "gta_util.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::system_update_pointers()
|
||||
{
|
||||
g_local_player = gta_util::get_local_ped();
|
||||
}
|
||||
}
|
10
src/backend/looped/tunables/disable_phone.cpp
Normal file
10
src/backend/looped/tunables/disable_phone.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "script_global.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::tunables_disable_phone()
|
||||
{
|
||||
*script_global(20249).as<bool*>() = g->tunables.disable_phone;
|
||||
}
|
||||
}
|
28
src/backend/looped/tunables/no_idle_kick.cpp
Normal file
28
src/backend/looped/tunables/no_idle_kick.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "script_global.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
auto idle_kick_a = script_global(1648034);
|
||||
auto idle_kick_b = script_global(262145);
|
||||
|
||||
// ref: https://www.unknowncheats.me/forum/3487508-post22.html#post3487508
|
||||
void looped::tunables_no_idle_kick()
|
||||
{
|
||||
if (g->tunables.no_idle_kick)
|
||||
{
|
||||
*idle_kick_a.at(1156).as<int*>() = 0; // idle time
|
||||
*idle_kick_a.at(1172).as<int*>() = 0;
|
||||
|
||||
*idle_kick_b.at(87).as<int*>() = INT32_MAX; // IDLEKICK_WARNING1
|
||||
*idle_kick_b.at(88).as<int*>() = INT32_MAX; // IDLEKICK_WARNING2
|
||||
*idle_kick_b.at(89).as<int*>() = INT32_MAX; // IDLEKICK_WARNING3
|
||||
*idle_kick_b.at(90).as<int*>() = INT32_MAX; // IDLEKICK_KICK
|
||||
|
||||
*idle_kick_b.at(8248).as<int*>() = INT32_MAX; // ConstrainedKick_Warning1
|
||||
*idle_kick_b.at(8249).as<int*>() = INT32_MAX; // ConstrainedKick_Warning2
|
||||
*idle_kick_b.at(8250).as<int*>() = INT32_MAX; // ConstrainedKick_Warning3
|
||||
*idle_kick_b.at(8251).as<int*>() = INT32_MAX; // ConstrainedKick_Kick
|
||||
}
|
||||
}
|
||||
}
|
133
src/backend/looped/vehicle/auto_drive.cpp
Normal file
133
src/backend/looped/vehicle/auto_drive.cpp
Normal file
@ -0,0 +1,133 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "util/blip.hpp"
|
||||
#include "util/entity.hpp"
|
||||
#include "util/vehicle.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::vehicle_auto_drive()
|
||||
{
|
||||
static std::map<AutoDriveStyle, int> driving_style_flags = {
|
||||
{AutoDriveStyle::LAW_ABIDING, 443},
|
||||
{AutoDriveStyle::THE_ROAD_IS_YOURS, 787004}
|
||||
};
|
||||
|
||||
static int changing_driving_styles = false;
|
||||
static AutoDriveDestination current_destination = AutoDriveDestination::STOPPED;
|
||||
static int current_driving_flag = driving_style_flags[AutoDriveStyle::LAW_ABIDING];
|
||||
static float current_speed = 8;
|
||||
static bool started = false;
|
||||
static Vector3 waypoint;
|
||||
|
||||
if (g->vehicle.auto_drive_destination != AutoDriveDestination::STOPPED)
|
||||
{
|
||||
current_destination = g->vehicle.auto_drive_destination;
|
||||
g->vehicle.auto_drive_destination = AutoDriveDestination::STOPPED;
|
||||
changing_driving_styles = true;
|
||||
}
|
||||
|
||||
if (!self::veh && current_destination != AutoDriveDestination::STOPPED)
|
||||
{
|
||||
current_destination = AutoDriveDestination::STOPPED;
|
||||
changing_driving_styles = false;
|
||||
g_notification_service->push_warning("Warning", "Please be in a car first then try again.");
|
||||
}
|
||||
else if (
|
||||
current_driving_flag != driving_style_flags[g->vehicle.auto_drive_style] ||
|
||||
current_speed != g->vehicle.auto_drive_speed
|
||||
) {
|
||||
current_driving_flag = driving_style_flags[g->vehicle.auto_drive_style];
|
||||
current_speed = g->vehicle.auto_drive_speed;
|
||||
changing_driving_styles = true;
|
||||
}
|
||||
|
||||
if (current_destination != AutoDriveDestination::STOPPED)
|
||||
{
|
||||
Vector3 last_waypoint = waypoint;
|
||||
bool does_waypoint_exist = false;
|
||||
bool to_waypoint = false;
|
||||
|
||||
if (current_destination == AutoDriveDestination::OBJECTITVE)
|
||||
{
|
||||
to_waypoint = true;
|
||||
does_waypoint_exist = blip::get_objective_location(waypoint);
|
||||
}
|
||||
else if (current_destination == AutoDriveDestination::WAYPOINT)
|
||||
{
|
||||
to_waypoint = true;
|
||||
does_waypoint_exist = blip::get_blip_location(waypoint, (int)BlipIcons::Waypoint);
|
||||
}
|
||||
|
||||
if (
|
||||
does_waypoint_exist &&
|
||||
(
|
||||
last_waypoint.x != waypoint.x ||
|
||||
last_waypoint.y != waypoint.y ||
|
||||
last_waypoint.z != waypoint.z
|
||||
)
|
||||
) {
|
||||
changing_driving_styles = true;
|
||||
}
|
||||
|
||||
bool interupted = (
|
||||
PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_MOVE_LEFT_ONLY) ||
|
||||
PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_MOVE_RIGHT_ONLY) ||
|
||||
PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_ACCELERATE) ||
|
||||
PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_BRAKE) ||
|
||||
PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_EXIT) ||
|
||||
PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_HANDBRAKE)
|
||||
);
|
||||
|
||||
if (
|
||||
current_destination == AutoDriveDestination::EMERGENCY_STOP ||
|
||||
(to_waypoint && !does_waypoint_exist) ||
|
||||
interupted
|
||||
) {
|
||||
TASK::CLEAR_PRIMARY_VEHICLE_TASK(self::veh);
|
||||
TASK::CLEAR_PED_TASKS(self::ped);
|
||||
|
||||
if (!interupted && started)
|
||||
{
|
||||
VEHICLE::SET_VEHICLE_FORWARD_SPEED(self::veh, 0);
|
||||
}
|
||||
|
||||
current_destination = AutoDriveDestination::STOPPED;
|
||||
|
||||
if (to_waypoint && !does_waypoint_exist)
|
||||
{
|
||||
g_notification_service->push_warning("Warning", "No Waypoint found please set one first.");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_notification_service->push_warning("Warning", "Auto Drive Stopped");
|
||||
}
|
||||
|
||||
started = false;
|
||||
}
|
||||
else if (changing_driving_styles)
|
||||
{
|
||||
changing_driving_styles = false;
|
||||
|
||||
TASK::CLEAR_PRIMARY_VEHICLE_TASK(self::veh);
|
||||
TASK::CLEAR_PED_TASKS(self::ped);
|
||||
|
||||
if (to_waypoint)
|
||||
{
|
||||
TASK::TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE(
|
||||
self::ped, self::veh,
|
||||
waypoint.x, waypoint.y, waypoint.z, current_speed,
|
||||
current_driving_flag, 20
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
TASK::TASK_VEHICLE_DRIVE_WANDER(self::ped, self::veh, current_speed, current_driving_flag);
|
||||
}
|
||||
|
||||
started = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
25
src/backend/looped/vehicle/boost_behavior.cpp
Normal file
25
src/backend/looped/vehicle/boost_behavior.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "core/enums.hpp"
|
||||
#include "natives.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::vehicle_boost_behavior()
|
||||
{
|
||||
auto* const vehicle = g_local_player->m_vehicle;
|
||||
|
||||
if (vehicle && VEHICLE::GET_HAS_ROCKET_BOOST(self::veh))
|
||||
{
|
||||
if (g->vehicle.boost_behavior == eBoostBehaviors::INSTANT_REFIL && (vehicle->m_boost == 0.f || !vehicle->m_boost_state)) // Instant Refill
|
||||
{
|
||||
vehicle->m_boost_allow_recharge = true;
|
||||
vehicle->m_boost = 3.f;
|
||||
}
|
||||
else if (g->vehicle.boost_behavior == eBoostBehaviors::INFINITE_BOOST) // Infinite Boost
|
||||
{
|
||||
vehicle->m_boost_allow_recharge = true;
|
||||
vehicle->m_boost = 3.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
src/backend/looped/vehicle/despawn_bypass.cpp
Normal file
11
src/backend/looped/vehicle/despawn_bypass.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "script_global.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
// allows for spawning unreleased vehicles in online and online vehicles in single player
|
||||
void looped::vehicle_despawn_bypass()
|
||||
{
|
||||
*script_global(4539659).as<bool*>() = true;
|
||||
}
|
||||
}
|
93
src/backend/looped/vehicle/drive_on_water.cpp
Normal file
93
src/backend/looped/vehicle/drive_on_water.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "script.hpp"
|
||||
#include "util/entity.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
constexpr auto drive_on_water_surface_hash = RAGE_JOAAT("stt_prop_stunt_bblock_xl3");
|
||||
static Vector3 drive_on_water_last_loc;
|
||||
|
||||
void drive_on_water_hide_surface()
|
||||
{
|
||||
Object surface = OBJECT::GET_CLOSEST_OBJECT_OF_TYPE(
|
||||
drive_on_water_last_loc.x, drive_on_water_last_loc.y, drive_on_water_last_loc.z,
|
||||
4.0, drive_on_water_surface_hash, 0, 0, 1
|
||||
);
|
||||
|
||||
if (surface)
|
||||
{
|
||||
entity::take_control_of(surface);
|
||||
ENTITY::SET_ENTITY_COORDS(surface, 0, 0, -1000.0f, 0, 0, 0, 1);
|
||||
script::get_current()->yield(10ms);
|
||||
ENTITY::SET_ENTITY_AS_NO_LONGER_NEEDED(&surface);
|
||||
ENTITY::DELETE_ENTITY(&surface);
|
||||
WATER::RESET_DEEP_OCEAN_SCALER();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void looped::vehicle_drive_on_water()
|
||||
{
|
||||
if (!g->vehicle.drive_on_water || self::veh == 0) {
|
||||
drive_on_water_hide_surface();
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 location = ENTITY::GET_ENTITY_COORDS(self::veh, 1);
|
||||
float height = 0;
|
||||
|
||||
WATER::SET_DEEP_OCEAN_SCALER(0);
|
||||
if (location.z - height < 10 && WATER::GET_WATER_HEIGHT_NO_WAVES(location.x, location.y, location.z, &height))
|
||||
{
|
||||
Object surface = OBJECT::GET_CLOSEST_OBJECT_OF_TYPE(
|
||||
drive_on_water_last_loc.x, drive_on_water_last_loc.y, drive_on_water_last_loc.z,
|
||||
4.0, drive_on_water_surface_hash, 0, 0, 1
|
||||
);
|
||||
|
||||
if (ENTITY::DOES_ENTITY_EXIST(surface) && height > -50.0f)
|
||||
{
|
||||
entity::take_control_of(surface);
|
||||
|
||||
drive_on_water_last_loc = location;
|
||||
drive_on_water_last_loc.z = height - 0.5f;
|
||||
ENTITY::SET_ENTITY_COORDS(
|
||||
surface,
|
||||
drive_on_water_last_loc.x, drive_on_water_last_loc.y, drive_on_water_last_loc.z,
|
||||
0, 0, 0, 0
|
||||
);
|
||||
|
||||
if (location.z < height - 2.f)
|
||||
{
|
||||
entity::take_control_of(self::veh);
|
||||
ENTITY::SET_ENTITY_COORDS(self::veh, location.x, location.y, height, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
STREAMING::REQUEST_MODEL(drive_on_water_surface_hash);
|
||||
while (!STREAMING::HAS_MODEL_LOADED(drive_on_water_surface_hash))
|
||||
{
|
||||
script::get_current()->yield();
|
||||
}
|
||||
|
||||
drive_on_water_last_loc = location;
|
||||
drive_on_water_last_loc.z = height - 0.5f;
|
||||
surface = OBJECT::CREATE_OBJECT(
|
||||
drive_on_water_surface_hash,
|
||||
drive_on_water_last_loc.x, drive_on_water_last_loc.y, drive_on_water_last_loc.z,
|
||||
1, 1, 0
|
||||
);
|
||||
|
||||
entity::take_control_of(surface);
|
||||
ENTITY::FREEZE_ENTITY_POSITION(surface, 1);
|
||||
ENTITY::SET_ENTITY_ALPHA(surface, 0, 1);
|
||||
ENTITY::SET_ENTITY_VISIBLE(surface, false, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
drive_on_water_hide_surface();
|
||||
}
|
||||
}
|
||||
}
|
149
src/backend/looped/vehicle/fly.cpp
Normal file
149
src/backend/looped/vehicle/fly.cpp
Normal file
@ -0,0 +1,149 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "util/entity.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
|
||||
static bool last_fly_tick = false;
|
||||
|
||||
void do_vehicle_fly()
|
||||
{
|
||||
Vehicle vehicle = self::veh;
|
||||
|
||||
Vector3 cam_pos = CAM::GET_GAMEPLAY_CAM_ROT(0);
|
||||
ENTITY::SET_ENTITY_ROTATION(vehicle, cam_pos.x, cam_pos.y, cam_pos.z, 1, true);
|
||||
ENTITY::SET_ENTITY_COLLISION(vehicle, !g->vehicle.fly.no_collision, true);
|
||||
|
||||
float locspeed = g->vehicle.fly.speed;
|
||||
|
||||
if (PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_MOVE_UP_ONLY))
|
||||
{
|
||||
locspeed *= 2;
|
||||
}
|
||||
|
||||
|
||||
if (PAD::IS_CONTROL_PRESSED(2, (int)ControllerInputs::INPUT_VEH_ACCELERATE))
|
||||
{
|
||||
if (g->vehicle.fly.dont_stop)
|
||||
{
|
||||
ENTITY::APPLY_FORCE_TO_ENTITY(vehicle, 1, 0.0, g->vehicle.fly.speed, 0.0, 0.0, 0.0, 0.0, 0, 1, 1, 1, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
VEHICLE::SET_VEHICLE_FORWARD_SPEED(vehicle, locspeed);
|
||||
}
|
||||
}
|
||||
|
||||
if (PAD::IS_CONTROL_PRESSED(2, (int)ControllerInputs::INPUT_VEH_BRAKE))
|
||||
{
|
||||
float lsp = g->vehicle.fly.speed;
|
||||
if (!PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_MOVE_UP_ONLY))
|
||||
{
|
||||
lsp = (g->vehicle.fly.speed * 2);
|
||||
}
|
||||
if (g->vehicle.fly.dont_stop)
|
||||
{
|
||||
ENTITY::APPLY_FORCE_TO_ENTITY(vehicle, 1, 0.0, 0 - (lsp), 0.0, 0.0, 0.0, 0.0, 0, 1, 1, 1, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
VEHICLE::SET_VEHICLE_FORWARD_SPEED(vehicle, (0 - locspeed));
|
||||
}
|
||||
}
|
||||
|
||||
if (PAD::IS_CONTROL_PRESSED(2, (int)ControllerInputs::INPUT_VEH_MOVE_LEFT_ONLY))
|
||||
{
|
||||
float lsp = ((0 - g->vehicle.fly.speed) * 2);
|
||||
if (!PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_MOVE_UP_ONLY))
|
||||
{
|
||||
lsp = (0 - g->vehicle.fly.speed);
|
||||
}
|
||||
if (g->vehicle.fly.dont_stop)
|
||||
{
|
||||
ENTITY::APPLY_FORCE_TO_ENTITY(vehicle, 1, (lsp), 0.0, 0.0, 0.0, 0.0, 0.0, 0, 1, 1, 1, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ENTITY::APPLY_FORCE_TO_ENTITY(vehicle, 1, (0 - (locspeed)), 0.0, 0.0, 0.0, 0.0, 0.0, 0, 1, 1, 1, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (PAD::IS_CONTROL_PRESSED(2, (int)ControllerInputs::INPUT_VEH_MOVE_RIGHT_ONLY))
|
||||
{
|
||||
float lsp = g->vehicle.fly.speed;
|
||||
if (!PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_MOVE_UP_ONLY))
|
||||
{
|
||||
lsp = (g->vehicle.fly.speed * 2);
|
||||
}
|
||||
if (g->vehicle.fly.dont_stop)
|
||||
{
|
||||
ENTITY::APPLY_FORCE_TO_ENTITY(vehicle, 1, lsp, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 1, 1, 1, 0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ENTITY::APPLY_FORCE_TO_ENTITY(vehicle, 1, locspeed, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 1, 1, 1, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!g->vehicle.fly.dont_stop && !PAD::IS_CONTROL_PRESSED(2, (int)ControllerInputs::INPUT_VEH_ACCELERATE) && !PAD::IS_CONTROL_PRESSED(2, (int)ControllerInputs::INPUT_VEH_BRAKE))
|
||||
{
|
||||
VEHICLE::SET_VEHICLE_FORWARD_SPEED(vehicle, 0.0);
|
||||
}
|
||||
|
||||
if (TASK::GET_IS_TASK_ACTIVE(self::ped, 2))
|
||||
{
|
||||
g->vehicle.fly.enabled = false;
|
||||
VEHICLE::SET_VEHICLE_GRAVITY(vehicle, true);
|
||||
ENTITY::SET_ENTITY_COLLISION(vehicle, true, true);
|
||||
if (g->vehicle.fly.stop_on_exit)
|
||||
{
|
||||
VEHICLE::SET_VEHICLE_FORWARD_SPEED(vehicle, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void looped::vehicle_fly()
|
||||
{
|
||||
Vehicle vehicle = self::veh;
|
||||
if (g->vehicle.fly.enabled)
|
||||
{
|
||||
|
||||
last_fly_tick = true;
|
||||
|
||||
if (!vehicle)
|
||||
{
|
||||
g_notification_service->push_warning("Warning", "Please be in a vehicle before enabling vehicle fly.");
|
||||
g->vehicle.fly.enabled = false;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (NETWORK::NETWORK_HAS_CONTROL_OF_ENTITY(vehicle))
|
||||
{
|
||||
do_vehicle_fly();
|
||||
VEHICLE::SET_VEHICLE_GRAVITY(vehicle, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
entity::take_control_of(vehicle);
|
||||
g_notification_service->push_warning("Warning", "Failed to take control of the vehicle.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (last_fly_tick)
|
||||
{
|
||||
ENTITY::SET_ENTITY_COLLISION(vehicle, true, true);
|
||||
VEHICLE::SET_VEHICLE_GRAVITY(vehicle, true);
|
||||
last_fly_tick = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
38
src/backend/looped/vehicle/horn_boost.cpp
Normal file
38
src/backend/looped/vehicle/horn_boost.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "natives.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static constexpr float hornBoostSpeedDefault = 10.f;
|
||||
static float hornBoostSpeed = hornBoostSpeedDefault;
|
||||
static constexpr float hostBoostSpeedMax = 200.f;
|
||||
|
||||
void looped::vehicle_horn_boost()
|
||||
{
|
||||
if (!g->vehicle.horn_boost) return;
|
||||
|
||||
Vehicle vehicle = self::veh;
|
||||
|
||||
if (vehicle == 0)
|
||||
{
|
||||
hornBoostSpeed = hornBoostSpeedDefault;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (PAD::IS_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_VEH_HORN))
|
||||
hornBoostSpeed = ENTITY::GET_ENTITY_SPEED(vehicle);
|
||||
|
||||
if (PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_HORN))
|
||||
{
|
||||
if (hornBoostSpeed < hostBoostSpeedMax) hornBoostSpeed++;
|
||||
|
||||
const auto velocity =
|
||||
ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(vehicle, 0.f, hornBoostSpeed, 0.f) - ENTITY::GET_ENTITY_COORDS(vehicle, true);
|
||||
ENTITY::SET_ENTITY_VELOCITY(vehicle, velocity.x, velocity.y, velocity.z);
|
||||
}
|
||||
else if (PAD::IS_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_VEH_HORN))
|
||||
hornBoostSpeed = hornBoostSpeedDefault;
|
||||
}
|
||||
}
|
22
src/backend/looped/vehicle/instant_brake.cpp
Normal file
22
src/backend/looped/vehicle/instant_brake.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "natives.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
|
||||
void looped::vehicle_instant_brake()
|
||||
{
|
||||
if (!g->vehicle.instant_brake) return;
|
||||
|
||||
Vehicle vehicle = self::veh;
|
||||
|
||||
if (vehicle == 0 || ENTITY::GET_ENTITY_SPEED_VECTOR(vehicle, true).y < 1.f || !VEHICLE::IS_VEHICLE_ON_ALL_WHEELS(vehicle))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_BRAKE) || PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_HANDBRAKE))
|
||||
VEHICLE::SET_VEHICLE_FORWARD_SPEED(vehicle, 0);
|
||||
}
|
||||
}
|
10
src/backend/looped/vehicle/is_targetable.cpp
Normal file
10
src/backend/looped/vehicle/is_targetable.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::vehicle_is_targetable()
|
||||
{
|
||||
if (g_local_player && g_local_player->m_vehicle)
|
||||
g_local_player->m_vehicle->m_is_targetable = g->vehicle.is_targetable;
|
||||
}
|
||||
}
|
12
src/backend/looped/vehicle/keep_vehicle_repaired.cpp
Normal file
12
src/backend/looped/vehicle/keep_vehicle_repaired.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "util/vehicle.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::vehicle_keep_vehicle_repaired()
|
||||
{
|
||||
if (g->vehicle.keep_vehicle_repaired && VEHICLE::GET_DOES_VEHICLE_HAVE_DAMAGE_DECALS(self::veh)) {
|
||||
vehicle::repair(self::veh);
|
||||
}
|
||||
}
|
||||
}
|
69
src/backend/looped/vehicle/ls_customs.cpp
Normal file
69
src/backend/looped/vehicle/ls_customs.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "gta_util.hpp"
|
||||
#include "script_local.hpp"
|
||||
#include "util/math.hpp"
|
||||
#include "util/scripts.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static bool state = false;
|
||||
static bool busy = false;
|
||||
|
||||
void looped::vehicle_ls_customs()
|
||||
{
|
||||
if (busy) return;
|
||||
busy = true;
|
||||
|
||||
constexpr int hash = RAGE_JOAAT("carmod_shop");
|
||||
if (g->vehicle.ls_customs && g->vehicle.ls_customs == state)
|
||||
{
|
||||
if (
|
||||
auto carmod_shop_thread = gta_util::find_script_thread(hash);
|
||||
carmod_shop_thread &&
|
||||
*script_local(carmod_shop_thread, 728).at(11).as<int*>() != 4
|
||||
)
|
||||
{
|
||||
g->vehicle.ls_customs = false;
|
||||
|
||||
*script_local(carmod_shop_thread, 728).as<int*>() = 1; // cleanup
|
||||
}
|
||||
}
|
||||
|
||||
if (g->vehicle.ls_customs && g->vehicle.ls_customs != state)
|
||||
{
|
||||
Vehicle veh = self::veh;
|
||||
if (!ENTITY::DOES_ENTITY_EXIST(veh) || ENTITY::IS_ENTITY_DEAD(veh, false))
|
||||
{
|
||||
busy = false;
|
||||
g->vehicle.ls_customs = false;
|
||||
|
||||
g_notification_service->push_warning("LS Customs", "You aren't in a vehicle.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
scripts::request_script(hash);
|
||||
if (scripts::wait_till_loaded(hash))
|
||||
{
|
||||
int args[] = { 45, 0, 9 };
|
||||
scripts::start_script_with_args(hash, args, 3, 3600);
|
||||
|
||||
scripts::wait_till_running(hash);
|
||||
}
|
||||
|
||||
if (scripts::is_running(hash))
|
||||
{
|
||||
if (auto carmod_shop_thread = gta_util::find_script_thread(hash); carmod_shop_thread)
|
||||
{
|
||||
*script_local(carmod_shop_thread, 728).at(406).as<int*>() = veh;
|
||||
*script_local(carmod_shop_thread, 2149).as<bool*>() = false; // skips cutscene that's invisible
|
||||
|
||||
*script_local(carmod_shop_thread, 728).at(11).as<int*>() = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
busy = false;
|
||||
state = g->vehicle.ls_customs;
|
||||
}
|
||||
}
|
24
src/backend/looped/vehicle/no_water_collision.cpp
Normal file
24
src/backend/looped/vehicle/no_water_collision.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static bool bLastVehicleNoWaterCollsion = false;
|
||||
|
||||
void looped::vehicle_no_water_collision()
|
||||
{
|
||||
if (g_local_player == nullptr || g_local_player->m_vehicle == nullptr) return;
|
||||
|
||||
bool bNoWaterCollsion = g->vehicle.no_water_collision;
|
||||
|
||||
if (bNoWaterCollsion)
|
||||
{
|
||||
g_local_player->m_vehicle->m_navigation->m_damp->m_water_collision = 0;
|
||||
bLastVehicleNoWaterCollsion = bNoWaterCollsion;
|
||||
}
|
||||
else if (bNoWaterCollsion != bLastVehicleNoWaterCollsion)
|
||||
{
|
||||
g_local_player->m_vehicle->m_navigation->m_damp->m_water_collision = 1;
|
||||
bLastVehicleNoWaterCollsion = bNoWaterCollsion;
|
||||
}
|
||||
}
|
||||
}
|
124
src/backend/looped/vehicle/rgb_paint.cpp
Normal file
124
src/backend/looped/vehicle/rgb_paint.cpp
Normal file
@ -0,0 +1,124 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "script.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
enum rgb_controller_t
|
||||
{
|
||||
rgb_controller_green_up,
|
||||
rgb_controller_red_down,
|
||||
rgb_controller_blue_up,
|
||||
rgb_controller_green_down,
|
||||
rgb_controller_red_up,
|
||||
rgb_controller_blue_down,
|
||||
};
|
||||
|
||||
void looped::vehicle_rainbow_paint()
|
||||
{
|
||||
static int rgb_controller_v = rgb_controller_green_up;
|
||||
|
||||
static int red = 255;
|
||||
static int green = 0;
|
||||
static int blue = 0;
|
||||
|
||||
if (self::veh && g->vehicle.rainbow_paint.type != RainbowPaintType::Off)
|
||||
{
|
||||
int delay_step = 100;
|
||||
|
||||
if (g->vehicle.rainbow_paint.type == RainbowPaintType::Spasm)
|
||||
{
|
||||
red = rand() % 256;
|
||||
green = rand() % 256;
|
||||
blue = rand() % 256;
|
||||
}
|
||||
else if (g->vehicle.rainbow_paint.type == RainbowPaintType::Fade)
|
||||
{
|
||||
delay_step = 10;
|
||||
|
||||
switch (rgb_controller_v)
|
||||
{
|
||||
case rgb_controller_green_up:
|
||||
green += 5;
|
||||
if (green >= 255)
|
||||
{
|
||||
green = 255;
|
||||
rgb_controller_v = rgb_controller_red_down;
|
||||
}
|
||||
break;
|
||||
|
||||
case rgb_controller_red_down:
|
||||
red -= 5;
|
||||
if (red < 0)
|
||||
{
|
||||
red = 0;
|
||||
rgb_controller_v = rgb_controller_blue_up;
|
||||
}
|
||||
break;
|
||||
|
||||
case rgb_controller_blue_up:
|
||||
blue += 5;
|
||||
if (blue >= 255)
|
||||
{
|
||||
blue = 255;
|
||||
rgb_controller_v = rgb_controller_green_down;
|
||||
}
|
||||
break;
|
||||
|
||||
case rgb_controller_green_down:
|
||||
green -= 5;
|
||||
if (green < 0)
|
||||
{
|
||||
green = 0;
|
||||
rgb_controller_v = rgb_controller_red_up;
|
||||
}
|
||||
break;
|
||||
|
||||
case rgb_controller_red_up:
|
||||
red += 5;
|
||||
if (red >= 255)
|
||||
{
|
||||
red = 255;
|
||||
rgb_controller_v = rgb_controller_blue_down;
|
||||
}
|
||||
break;
|
||||
|
||||
case rgb_controller_blue_down:
|
||||
blue -= 5;
|
||||
if (blue < 0)
|
||||
{
|
||||
blue = 0;
|
||||
rgb_controller_v = rgb_controller_green_up;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vehicle vehicle = self::veh;
|
||||
|
||||
if (g->vehicle.rainbow_paint.primary) {
|
||||
VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(vehicle, red, green, blue);
|
||||
}
|
||||
if (g->vehicle.rainbow_paint.secondary) {
|
||||
VEHICLE::SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(vehicle, red, green, blue);
|
||||
}
|
||||
if (g->vehicle.rainbow_paint.neon) {
|
||||
VEHICLE::SET_VEHICLE_NEON_ENABLED(vehicle, 0, 1);
|
||||
VEHICLE::SET_VEHICLE_NEON_ENABLED(vehicle, 1, 1);
|
||||
VEHICLE::SET_VEHICLE_NEON_ENABLED(vehicle, 2, 1);
|
||||
VEHICLE::SET_VEHICLE_NEON_ENABLED(vehicle, 3, 1);
|
||||
VEHICLE::SET_VEHICLE_NEON_COLOUR(vehicle, red, green, blue);
|
||||
}
|
||||
if (g->vehicle.rainbow_paint.smoke) {
|
||||
VEHICLE::SET_VEHICLE_TYRE_SMOKE_COLOR(vehicle, red, green, blue);
|
||||
}
|
||||
|
||||
auto delay = std::chrono::milliseconds(((delay_step * 10) + 10) - (g->vehicle.rainbow_paint.speed * delay_step));
|
||||
script::get_current()->yield(delay);
|
||||
}
|
||||
}
|
||||
}
|
21
src/backend/looped/vehicle/seatbelt.cpp
Normal file
21
src/backend/looped/vehicle/seatbelt.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static bool b_last_seatbelt = false;
|
||||
|
||||
void looped::vehicle_seatbelt()
|
||||
{
|
||||
bool b_seatbelt = g->vehicle.seatbelt;
|
||||
|
||||
if (b_seatbelt || (!b_seatbelt && b_seatbelt != b_last_seatbelt))
|
||||
{
|
||||
PED::SET_PED_CONFIG_FLAG(self::ped, 32, g->vehicle.seatbelt);
|
||||
|
||||
PED::SET_PED_CAN_BE_KNOCKED_OFF_VEHICLE(self::ped, g->vehicle.seatbelt);
|
||||
|
||||
b_last_seatbelt = g->vehicle.seatbelt;
|
||||
}
|
||||
}
|
||||
}
|
61
src/backend/looped/vehicle/speedo_meter.cpp
Normal file
61
src/backend/looped/vehicle/speedo_meter.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "util/vehicle.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::vehicle_speedo_meter()
|
||||
{
|
||||
if (
|
||||
!g->vehicle.speedo_meter.enabled ||
|
||||
self::veh == 0 ||
|
||||
HUD::IS_PAUSE_MENU_ACTIVE() ||
|
||||
HUD::IS_WARNING_MESSAGE_ACTIVE() ||
|
||||
CAM::IS_SCREEN_FADED_OUT() ||
|
||||
CAM::IS_SCREEN_FADING_OUT() ||
|
||||
CAM::IS_SCREEN_FADING_IN()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
char speed_type[16], speed[16];
|
||||
int char_width = 3;
|
||||
|
||||
float veh_speed = vehicle::mps_to_speed(
|
||||
ENTITY::GET_ENTITY_SPEED(self::veh),
|
||||
g->vehicle.speed_unit
|
||||
);
|
||||
|
||||
switch (g->vehicle.speed_unit)
|
||||
{
|
||||
case SpeedUnit::KMPH:
|
||||
strcpy(speed_type, "kmph");
|
||||
char_width = 4;
|
||||
break;
|
||||
case SpeedUnit::MIPH:
|
||||
strcpy(speed_type, "mph");
|
||||
break;
|
||||
case SpeedUnit::MPS:
|
||||
strcpy(speed_type, "mps");
|
||||
break;
|
||||
}
|
||||
|
||||
sprintf(speed, "%*d", g->vehicle.speedo_meter.left_side ? 0 : char_width, (int)veh_speed);
|
||||
|
||||
HUD::SET_TEXT_FONT(2);
|
||||
HUD::SET_TEXT_SCALE(.9f, .9f);
|
||||
HUD::SET_TEXT_OUTLINE();
|
||||
HUD::BEGIN_TEXT_COMMAND_DISPLAY_TEXT("STRING");
|
||||
HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(speed_type);
|
||||
HUD::END_TEXT_COMMAND_DISPLAY_TEXT(g->vehicle.speedo_meter.x, g->vehicle.speedo_meter.y, 1);
|
||||
|
||||
HUD::SET_TEXT_FONT(2);
|
||||
HUD::SET_TEXT_SCALE(.9f, .9f);
|
||||
HUD::SET_TEXT_OUTLINE();
|
||||
HUD::BEGIN_TEXT_COMMAND_DISPLAY_TEXT("STRING");
|
||||
HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(speed);
|
||||
HUD::END_TEXT_COMMAND_DISPLAY_TEXT(g->vehicle.speedo_meter.x + (g->vehicle.speedo_meter.left_side ? 0 : .003f), g->vehicle.speedo_meter.y + .04f, 1);
|
||||
|
||||
}
|
||||
}
|
176
src/backend/looped/vehicle/turn_signals.cpp
Normal file
176
src/backend/looped/vehicle/turn_signals.cpp
Normal file
@ -0,0 +1,176 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "fiber_pool.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "script.hpp"
|
||||
#include "windows.h"
|
||||
|
||||
struct key_state
|
||||
{
|
||||
key_state(int v_key) : v_key(v_key) {}
|
||||
|
||||
enum
|
||||
{
|
||||
up,
|
||||
down,
|
||||
just_pressed,
|
||||
just_released,
|
||||
};
|
||||
|
||||
uint8_t state = up;
|
||||
int v_key;
|
||||
};
|
||||
|
||||
inline key_state right_signal_key{ 'L' };
|
||||
inline key_state left_signal_key{ 'J' };
|
||||
inline key_state hazzards_key{ 'K' };
|
||||
|
||||
bool is_key_pressed(int const v_key)
|
||||
{
|
||||
return GetAsyncKeyState(v_key) & 0x8000;
|
||||
}
|
||||
|
||||
void update_key_state(key_state& key_last_tick)
|
||||
{
|
||||
if (is_key_pressed(key_last_tick.v_key))
|
||||
{
|
||||
switch (key_last_tick.state)
|
||||
{
|
||||
case key_state::up:
|
||||
key_last_tick.state = key_state::just_pressed;
|
||||
break;
|
||||
|
||||
case key_state::just_pressed:
|
||||
key_last_tick.state = key_state::down;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (key_last_tick.state)
|
||||
{
|
||||
case key_state::down:
|
||||
key_last_tick.state = key_state::just_released;
|
||||
break;
|
||||
|
||||
case key_state::just_released:
|
||||
key_last_tick.state = key_state::up;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void update_key_states()
|
||||
{
|
||||
update_key_state(left_signal_key);
|
||||
update_key_state(hazzards_key);
|
||||
update_key_state(right_signal_key);
|
||||
}
|
||||
|
||||
struct signal_state {
|
||||
enum
|
||||
{
|
||||
right,
|
||||
left,
|
||||
hazzards
|
||||
};
|
||||
};
|
||||
|
||||
inline void set_turn_signals(int signal_state, bool on)
|
||||
{
|
||||
static constexpr int off = 0;
|
||||
|
||||
if (self::veh && big::g->vehicle.turn_signals)
|
||||
{
|
||||
switch (signal_state)
|
||||
{
|
||||
case signal_state::hazzards:
|
||||
VEHICLE::SET_VEHICLE_INDICATOR_LIGHTS(self::veh, signal_state::left, on);
|
||||
VEHICLE::SET_VEHICLE_INDICATOR_LIGHTS(self::veh, signal_state::right, on);
|
||||
break;
|
||||
|
||||
case signal_state::right:
|
||||
VEHICLE::SET_VEHICLE_INDICATOR_LIGHTS(self::veh, signal_state::left, off);
|
||||
VEHICLE::SET_VEHICLE_INDICATOR_LIGHTS(self::veh, signal_state::right, on);
|
||||
break;
|
||||
|
||||
case signal_state::left:
|
||||
VEHICLE::SET_VEHICLE_INDICATOR_LIGHTS(self::veh, signal_state::left, on);
|
||||
VEHICLE::SET_VEHICLE_INDICATOR_LIGHTS(self::veh, signal_state::right, off);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace big
|
||||
{
|
||||
static bool b_last_turn_signals = false;
|
||||
|
||||
void looped::vehicle_turn_signals()
|
||||
{
|
||||
static bool hazzards = false;
|
||||
bool b_turn_signals = g->vehicle.turn_signals;
|
||||
|
||||
if (!b_turn_signals && b_turn_signals != b_last_turn_signals)
|
||||
{
|
||||
VEHICLE::SET_VEHICLE_INDICATOR_LIGHTS(PED::GET_VEHICLE_PED_IS_IN(PLAYER::PLAYER_PED_ID(), false), 0, 0);
|
||||
VEHICLE::SET_VEHICLE_INDICATOR_LIGHTS(PED::GET_VEHICLE_PED_IS_IN(PLAYER::PLAYER_PED_ID(), false), 1, 0);
|
||||
}
|
||||
|
||||
if (g->vehicle.turn_signals)
|
||||
{
|
||||
static bool ran_once = []
|
||||
{
|
||||
g_notification_service->push("Instructions", "Manual: J = Left, L = Right, K = Toggle Hazzards");
|
||||
return true;
|
||||
}();
|
||||
}
|
||||
|
||||
|
||||
update_key_states();
|
||||
|
||||
if (left_signal_key.state == key_state::just_pressed || g->vehicle.auto_turn_signals && PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_MOVE_LEFT_ONLY))
|
||||
{
|
||||
set_turn_signals(signal_state::left, true);
|
||||
}
|
||||
|
||||
if (right_signal_key.state == key_state::just_pressed || g->vehicle.auto_turn_signals && PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_MOVE_RIGHT_ONLY))
|
||||
{
|
||||
set_turn_signals(signal_state::right, true);
|
||||
}
|
||||
|
||||
if (hazzards_key.state == key_state::just_pressed && !hazzards)
|
||||
{
|
||||
set_turn_signals(signal_state::hazzards, true);
|
||||
hazzards = true;
|
||||
}
|
||||
else if (hazzards_key.state == key_state::just_pressed && hazzards || !g->vehicle.turn_signals)
|
||||
{
|
||||
set_turn_signals(signal_state::hazzards, false);
|
||||
hazzards = false;
|
||||
}
|
||||
|
||||
|
||||
if (PAD::IS_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_VEH_MOVE_LEFT_ONLY))
|
||||
{
|
||||
if (g->vehicle.turn_signals)
|
||||
{
|
||||
script::get_current()->yield(1500ms);
|
||||
}
|
||||
set_turn_signals(signal_state::left, false);
|
||||
}
|
||||
|
||||
if (PAD::IS_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_VEH_MOVE_RIGHT_ONLY))
|
||||
{
|
||||
if (g->vehicle.turn_signals)
|
||||
{
|
||||
script::get_current()->yield(1500ms);
|
||||
}
|
||||
set_turn_signals(signal_state::right, false);
|
||||
}
|
||||
|
||||
b_last_turn_signals = g->vehicle.turn_signals;
|
||||
|
||||
}
|
||||
}
|
64
src/backend/looped/vehicle/vehicle_god.cpp
Normal file
64
src/backend/looped/vehicle/vehicle_god.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "util/misc.hpp"
|
||||
#include "util/water.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static uint32_t last_bits = 0;
|
||||
static float last_water_collistion_strength = 0;
|
||||
|
||||
void looped::vehicle_god_mode()
|
||||
{
|
||||
if (g_local_player == nullptr || g_local_player->m_vehicle == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
(g->vehicle.god_mode || g->vehicle.proof_collision) &&
|
||||
g_local_player->m_ped_task_flag & (int)ePedTask::TASK_DRIVING
|
||||
) {
|
||||
g_local_player->m_vehicle->m_deform_god = 0x8C;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_local_player->m_vehicle->m_deform_god = 0x9C;
|
||||
}
|
||||
|
||||
float* water_collision_ptr = nullptr;
|
||||
if (g_local_player->m_vehicle->m_navigation != nullptr)
|
||||
{
|
||||
water_collision_ptr = water::get_water_collision_ptr(g_local_player->m_vehicle->m_navigation);
|
||||
}
|
||||
|
||||
uint32_t bits = g->vehicle.proof_mask;
|
||||
uint32_t changed_bits = bits ^ last_bits;
|
||||
uint32_t changed_or_enabled_bits = bits | changed_bits;
|
||||
|
||||
if (changed_or_enabled_bits)
|
||||
{
|
||||
uint32_t unchanged_bits = g_local_player->m_vehicle->m_damage_bits & ~changed_or_enabled_bits;
|
||||
g_local_player->m_vehicle->m_damage_bits = unchanged_bits | bits;
|
||||
last_bits = bits;
|
||||
|
||||
if (changed_or_enabled_bits & (uint32_t)eEntityProofs::WATER)
|
||||
{
|
||||
water::reset_ped_oxygen_time(g_local_player);
|
||||
|
||||
if (water_collision_ptr != nullptr && *water_collision_ptr != 0.f)
|
||||
{
|
||||
last_water_collistion_strength = *water_collision_ptr;
|
||||
*water_collision_ptr = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (last_water_collistion_strength != 0 && water_collision_ptr != nullptr)
|
||||
{
|
||||
*water_collision_ptr = last_water_collistion_strength;
|
||||
last_water_collistion_strength = 0;
|
||||
}
|
||||
}
|
||||
}
|
23
src/backend/looped/vehicle/vehicle_jump.cpp
Normal file
23
src/backend/looped/vehicle/vehicle_jump.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "natives.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::vehicle_jump()
|
||||
{
|
||||
if (!g->vehicle.vehicle_jump) return;
|
||||
|
||||
const auto vehicle = self::veh;
|
||||
|
||||
if (!vehicle || !ENTITY::IS_ENTITY_A_VEHICLE(vehicle))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (PAD::IS_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_VEH_HANDBRAKE))
|
||||
{
|
||||
ENTITY::APPLY_FORCE_TO_ENTITY(vehicle, 1, 0.0, 0.0, 20, 0.0, 0.0, 0.0, 0, 0, 1, 1, 0, 1);
|
||||
}
|
||||
}
|
||||
}
|
76
src/backend/looped/weapons/ammo_special_type.cpp
Normal file
76
src/backend/looped/weapons/ammo_special_type.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static CWeaponInfo* p_modified_weapon = nullptr;
|
||||
static eDamageType modified_weapon_damage_type = eDamageType::None;
|
||||
static CWeaponInfo::sExplosion modified_weapon_explosion{};
|
||||
static eAmmoSpecialType modified_weapon_ammo_type = eAmmoSpecialType::None;
|
||||
|
||||
void looped::weapons_ammo_special_type()
|
||||
{
|
||||
if (
|
||||
g_local_player == nullptr ||
|
||||
g_local_player->m_weapon_manager == nullptr ||
|
||||
g_local_player->m_weapon_manager->m_weapon_info == nullptr ||
|
||||
g_local_player->m_weapon_manager->m_weapon_info->m_ammo_info == nullptr
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (g->weapons.ammo_special.toggle) {
|
||||
CWeaponInfo* weapon_info = g_local_player->m_weapon_manager->m_weapon_info;
|
||||
|
||||
// check if the player changed their weapon
|
||||
if (p_modified_weapon != weapon_info) {
|
||||
// apply the original bullet and impact type to the old weapon
|
||||
if (p_modified_weapon != nullptr) {
|
||||
p_modified_weapon->m_damage_type = modified_weapon_damage_type;
|
||||
p_modified_weapon->m_explosion = modified_weapon_explosion;
|
||||
p_modified_weapon->m_ammo_info->m_ammo_special_type = modified_weapon_ammo_type;
|
||||
}
|
||||
|
||||
// backup the bullet and impact type of the new weapon
|
||||
p_modified_weapon = weapon_info;
|
||||
modified_weapon_damage_type = weapon_info->m_damage_type;
|
||||
modified_weapon_explosion = weapon_info->m_explosion;
|
||||
modified_weapon_ammo_type = weapon_info->m_ammo_info->m_ammo_special_type;
|
||||
}
|
||||
|
||||
// apply ammo type changes to the current weapon
|
||||
eDamageType damage_type = eDamageType::None;
|
||||
eExplosionTag explosion_tag = g->weapons.ammo_special.explosion_tag;
|
||||
eAmmoSpecialType ammo_type = eAmmoSpecialType::None;
|
||||
|
||||
if (explosion_tag == eExplosionTag::DONTCARE) {
|
||||
damage_type = modified_weapon_damage_type;
|
||||
ammo_type = g->weapons.ammo_special.type;
|
||||
}
|
||||
else {
|
||||
damage_type = eDamageType::Explosive;
|
||||
ammo_type = modified_weapon_ammo_type;
|
||||
}
|
||||
|
||||
weapon_info->m_damage_type = damage_type;
|
||||
|
||||
CWeaponInfo::sExplosion explosion;
|
||||
explosion.m_default = explosion_tag;
|
||||
explosion.m_hit_bike = explosion_tag;
|
||||
explosion.m_hit_boat = explosion_tag;
|
||||
explosion.m_hit_car = explosion_tag;
|
||||
explosion.m_hit_plane = explosion_tag;
|
||||
explosion.m_hit_truck = explosion_tag;
|
||||
weapon_info->m_explosion = explosion;
|
||||
|
||||
weapon_info->m_ammo_info->m_ammo_special_type = ammo_type;
|
||||
}
|
||||
else if (p_modified_weapon != nullptr) {
|
||||
// apply the original bullet and impact type to the weapon
|
||||
// when the ammo type feature is off
|
||||
p_modified_weapon->m_damage_type = modified_weapon_damage_type;
|
||||
p_modified_weapon->m_explosion = modified_weapon_explosion;
|
||||
p_modified_weapon->m_ammo_info->m_ammo_special_type = modified_weapon_ammo_type;
|
||||
p_modified_weapon = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
32
src/backend/looped/weapons/cage_gun.cpp
Normal file
32
src/backend/looped/weapons/cage_gun.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "core/enums.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "util/entity.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::weapons_cage_gun()
|
||||
{
|
||||
bool bCageGun = g->weapons.custom_weapon == CustomWeapon::CAGE_GUN;
|
||||
|
||||
if (bCageGun)
|
||||
{
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM))
|
||||
{
|
||||
if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_ATTACK))
|
||||
{
|
||||
Entity entity;
|
||||
|
||||
if (entity::raycast(&entity))
|
||||
{
|
||||
if (ENTITY::IS_ENTITY_A_PED(entity))
|
||||
{
|
||||
entity::cage_ped(entity);
|
||||
}
|
||||
}
|
||||
else g_notification_service->push_error("Weapons", "No entity found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
#include <gta/enums.hpp>
|
||||
|
||||
namespace big
|
||||
{
|
||||
static const ControllerInputs attack_controls[] =
|
||||
{
|
||||
ControllerInputs::INPUT_WEAPON_WHEEL_NEXT,
|
||||
ControllerInputs::INPUT_WEAPON_WHEEL_PREV,
|
||||
ControllerInputs::INPUT_ATTACK,
|
||||
ControllerInputs::INPUT_ATTACK2,
|
||||
ControllerInputs::INPUT_VEH_ATTACK,
|
||||
ControllerInputs::INPUT_VEH_ATTACK2,
|
||||
ControllerInputs::INPUT_VEH_PASSENGER_ATTACK,
|
||||
ControllerInputs::INPUT_VEH_FLY_ATTACK,
|
||||
ControllerInputs::INPUT_VEH_FLY_ATTACK2,
|
||||
};
|
||||
|
||||
void looped::custom_gun_disable_control_action()
|
||||
{
|
||||
bool is_custom_gun_selected = g->weapons.custom_weapon != CustomWeapon::NONE;
|
||||
if (is_custom_gun_selected)
|
||||
{
|
||||
for (const auto& control : attack_controls)
|
||||
PAD::DISABLE_CONTROL_ACTION(0, static_cast<int>(control), true);
|
||||
}
|
||||
}
|
||||
}
|
51
src/backend/looped/weapons/delete_gun.cpp
Normal file
51
src/backend/looped/weapons/delete_gun.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "core/enums.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "util/entity.hpp"
|
||||
#include "util/math.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::weapons_delete_gun()
|
||||
{
|
||||
bool bCageGun = g->weapons.custom_weapon == CustomWeapon::DELETE_GUN;
|
||||
|
||||
if (bCageGun)
|
||||
{
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM))
|
||||
{
|
||||
if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_ATTACK))
|
||||
{
|
||||
Entity entity;
|
||||
|
||||
if (entity::raycast(&entity))
|
||||
{
|
||||
if (ENTITY::IS_ENTITY_A_PED(entity) && PED::IS_PED_A_PLAYER(entity))
|
||||
{
|
||||
g_notification_service->push_error("Weapons", "You can't delete player entities!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 entLoc = ENTITY::GET_ENTITY_COORDS(entity, true);
|
||||
double dist = math::distance_between_vectors(self::pos, entLoc);
|
||||
|
||||
if (dist > 500)
|
||||
{
|
||||
g_notification_service->push_error("Weapons", "Entity is too far.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entity::take_control_of(entity))
|
||||
{
|
||||
entity::delete_entity(entity);
|
||||
}
|
||||
else g_notification_service->push_error("Weapons", "Failed to take control of entity.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else g_notification_service->push_error("Weapons", "No entity found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
12
src/backend/looped/weapons/force_crosshairs.cpp
Normal file
12
src/backend/looped/weapons/force_crosshairs.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::weapons_force_crosshairs()
|
||||
{
|
||||
if (g->weapons.force_crosshairs) {
|
||||
HUD::SHOW_HUD_COMPONENT_THIS_FRAME(14 /*RETICLE*/);
|
||||
}
|
||||
}
|
||||
}
|
110
src/backend/looped/weapons/gravity_gun.cpp
Normal file
110
src/backend/looped/weapons/gravity_gun.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "core/enums.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "util/entity.hpp"
|
||||
#include "util/math.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static Entity ent = 0;
|
||||
static Vector3 location;
|
||||
static Vector3 other;
|
||||
static float dist;
|
||||
|
||||
static const int scroll = 0;
|
||||
|
||||
void looped::weapons_gravity_gun()
|
||||
{
|
||||
bool is_gravity_gun_selected = g->weapons.custom_weapon == CustomWeapon::GRAVITY_GUN;
|
||||
constexpr double multiplier = 3.0;
|
||||
|
||||
auto is_zoomed_in = is_gravity_gun_selected && PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM);
|
||||
if (is_zoomed_in)
|
||||
{
|
||||
location = self::pos;
|
||||
|
||||
auto is_attack_released = PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_ATTACK) && ent == 0;
|
||||
if (is_attack_released)
|
||||
{
|
||||
if (entity::raycast(&ent))
|
||||
{
|
||||
if (ENTITY::IS_ENTITY_A_PED(ent) && PED::IS_PED_A_PLAYER(ent))
|
||||
{
|
||||
ent = 0;
|
||||
|
||||
g_notification_service->push_warning("Weapons", "You can't move player entities!");
|
||||
}
|
||||
else
|
||||
{
|
||||
other = ENTITY::GET_ENTITY_COORDS(ent, true);
|
||||
dist = (float)math::distance_between_vectors(location, other);
|
||||
|
||||
if (dist > 500)
|
||||
{
|
||||
ent = 0;
|
||||
|
||||
g_notification_service->push_warning("Weapons", "Entity is too far.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entity::take_control_of(ent) && ENTITY::IS_ENTITY_A_PED(ent) && !PED::IS_PED_RAGDOLL(ent))
|
||||
{
|
||||
TASK::SET_HIGH_FALL_TASK(ent, 0, 0, 0);
|
||||
|
||||
g_notification_service->push_warning("Weapons", "Selected entity at crosshair.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ent = 0;
|
||||
|
||||
g_notification_service->push_warning("Weapons", "No entity found.");
|
||||
}
|
||||
}
|
||||
|
||||
if (ENTITY::DOES_ENTITY_EXIST(ent))
|
||||
{
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_NEXT))
|
||||
dist -= 5;
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV))
|
||||
dist += 5;
|
||||
|
||||
if (!entity::take_control_of(ent))
|
||||
{
|
||||
ent = 0;
|
||||
|
||||
return g_notification_service->push_warning("Weapons", "Failed to take control of entity.");
|
||||
}
|
||||
|
||||
ENTITY::SET_ENTITY_COLLISION(ent, false, false);
|
||||
|
||||
other = ENTITY::GET_ENTITY_COORDS(ent, true);
|
||||
|
||||
Vector3 rot = CAM::GET_GAMEPLAY_CAM_ROT(2);
|
||||
float pitch = math::deg_to_rad(rot.x); // vertical
|
||||
// float roll = rot.y;
|
||||
float yaw = math::deg_to_rad(rot.z + 90); // horizontal
|
||||
|
||||
Vector3 velocity;
|
||||
|
||||
velocity.x = location.x + (dist * cos(pitch) * cos(yaw)) - other.x;
|
||||
velocity.y = location.y + (dist * sin(yaw) * cos(pitch)) - other.y;
|
||||
velocity.z = location.z + (dist * sin(pitch)) - other.z;
|
||||
|
||||
ENTITY::SET_ENTITY_VELOCITY(ent, velocity.x * (float)multiplier, velocity.y * (float)multiplier, velocity.z * (float)multiplier);
|
||||
ENTITY::SET_ENTITY_ALPHA(ent, 105, 0);
|
||||
}
|
||||
}
|
||||
else if (ent != 0 && entity::take_control_of(ent))
|
||||
{
|
||||
ENTITY::SET_ENTITY_COLLISION(ent, true, true);
|
||||
ENTITY::RESET_ENTITY_ALPHA(ent);
|
||||
|
||||
ent = 0;
|
||||
|
||||
g_notification_service->push("Weapons", "Released entity.");
|
||||
}
|
||||
}
|
||||
}
|
14
src/backend/looped/weapons/increase_damage.cpp
Normal file
14
src/backend/looped/weapons/increase_damage.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::weapons_increased_damage()
|
||||
{
|
||||
if (g->weapons.increased_damage != 1) {
|
||||
Hash weapon{};
|
||||
WEAPON::GET_CURRENT_PED_WEAPON(self::ped, &weapon, 0);
|
||||
WEAPON::SET_WEAPON_DAMAGE_MODIFIER(weapon, g->weapons.increased_damage);
|
||||
}
|
||||
}
|
||||
}
|
19
src/backend/looped/weapons/infinite_ammo.cpp
Normal file
19
src/backend/looped/weapons/infinite_ammo.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static bool bLastInfiniteAmmo = false;
|
||||
|
||||
void looped::weapons_infinite_ammo()
|
||||
{
|
||||
bool bInfiniteAmmo = g->weapons.infinite_ammo;
|
||||
|
||||
if (bInfiniteAmmo || (!bInfiniteAmmo && bInfiniteAmmo != bLastInfiniteAmmo))
|
||||
{
|
||||
WEAPON::SET_PED_INFINITE_AMMO(self::ped, g->weapons.infinite_ammo, NULL);
|
||||
|
||||
bLastInfiniteAmmo = g->weapons.infinite_ammo;
|
||||
}
|
||||
}
|
||||
}
|
19
src/backend/looped/weapons/infinite_mag.cpp
Normal file
19
src/backend/looped/weapons/infinite_mag.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static bool bLastInfiniteMag = false;
|
||||
|
||||
void looped::weapons_infinite_mag()
|
||||
{
|
||||
bool bInfiniteMag = g->weapons.infinite_mag;
|
||||
|
||||
if (bInfiniteMag || (!bInfiniteMag && bInfiniteMag != bLastInfiniteMag))
|
||||
{
|
||||
WEAPON::SET_PED_INFINITE_AMMO_CLIP(self::ped, g->weapons.infinite_mag);
|
||||
|
||||
bLastInfiniteMag = g->weapons.infinite_mag;
|
||||
}
|
||||
}
|
||||
}
|
54
src/backend/looped/weapons/no_recoil.cpp
Normal file
54
src/backend/looped/weapons/no_recoil.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "pointers.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static std::vector<std::pair<uint32_t, float>> og_recoil_values{};
|
||||
static uint32_t prev_weapon_hash{};
|
||||
|
||||
bool is_recoil_value_cached(uint32_t hash)
|
||||
{
|
||||
return std::find_if(og_recoil_values.begin(), og_recoil_values.end(), [hash](auto const entry)
|
||||
{
|
||||
return hash == entry.first;
|
||||
}) != og_recoil_values.end();
|
||||
}
|
||||
|
||||
float get_og_recoil_value(uint32_t hash)
|
||||
{
|
||||
return std::find_if(og_recoil_values.begin(), og_recoil_values.end(), [hash](auto const entry)
|
||||
{
|
||||
return hash == entry.first;
|
||||
})->second;
|
||||
}
|
||||
|
||||
float get_recoil_value(uint32_t hash)
|
||||
{
|
||||
return g->weapons.no_recoil
|
||||
? 0.f
|
||||
: get_og_recoil_value(hash);
|
||||
}
|
||||
|
||||
void looped::weapons_no_recoil()
|
||||
{
|
||||
if (!g_local_player)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto* const weapon_mgr = g_local_player->m_weapon_manager;
|
||||
if (weapon_mgr)
|
||||
{
|
||||
auto const cur_weapon_hash = weapon_mgr->m_selected_weapon_hash;
|
||||
if (prev_weapon_hash != cur_weapon_hash)
|
||||
{
|
||||
if (!is_recoil_value_cached(cur_weapon_hash))
|
||||
{
|
||||
og_recoil_values.push_back({ cur_weapon_hash, weapon_mgr->m_weapon_info->m_explosion_shake_amplitude });
|
||||
}
|
||||
|
||||
weapon_mgr->m_weapon_info->m_explosion_shake_amplitude = get_recoil_value(cur_weapon_hash); // m_explosion_shake_amplitude is the right offset in https://github.com/Yimura/GTAV-Classes
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
54
src/backend/looped/weapons/no_spread.cpp
Normal file
54
src/backend/looped/weapons/no_spread.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "pointers.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static std::vector<std::pair<uint32_t, float>> og_spread_values{};
|
||||
static uint32_t prev_weapon_hash{};
|
||||
|
||||
bool is_spread_value_cached(uint32_t hash)
|
||||
{
|
||||
return std::find_if(og_spread_values.begin(), og_spread_values.end(), [hash](auto const entry)
|
||||
{
|
||||
return hash == entry.first;
|
||||
}) != og_spread_values.end();
|
||||
}
|
||||
|
||||
float get_og_spread_value(uint32_t hash)
|
||||
{
|
||||
return std::find_if(og_spread_values.begin(), og_spread_values.end(), [hash](auto const entry)
|
||||
{
|
||||
return hash == entry.first;
|
||||
})->second;
|
||||
}
|
||||
|
||||
float get_spread_value(uint32_t hash)
|
||||
{
|
||||
return g->weapons.no_spread
|
||||
? 0.f
|
||||
: get_og_spread_value(hash);
|
||||
}
|
||||
|
||||
void looped::weapons_no_spread()
|
||||
{
|
||||
if (!g_local_player)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto* const weapon_mgr = g_local_player->m_weapon_manager;
|
||||
if (weapon_mgr)
|
||||
{
|
||||
auto const cur_weapon_hash = weapon_mgr->m_selected_weapon_hash;
|
||||
if (prev_weapon_hash != cur_weapon_hash)
|
||||
{
|
||||
if (!is_spread_value_cached(cur_weapon_hash))
|
||||
{
|
||||
og_spread_values.push_back({ cur_weapon_hash, weapon_mgr->m_weapon_info->m_accuracy_spread });
|
||||
}
|
||||
|
||||
weapon_mgr->m_weapon_info->m_accuracy_spread = get_spread_value(cur_weapon_hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
36
src/backend/looped/weapons/repair_gun.cpp
Normal file
36
src/backend/looped/weapons/repair_gun.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "core/enums.hpp"
|
||||
#include "util/entity.hpp"
|
||||
#include "util/vehicle.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::weapons_repair_gun()
|
||||
{
|
||||
bool bRepairGun = g->weapons.custom_weapon == CustomWeapon::REPAIR_GUN;
|
||||
|
||||
if (bRepairGun)
|
||||
{
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM))
|
||||
{
|
||||
if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_ATTACK))
|
||||
{
|
||||
Entity entity;
|
||||
|
||||
if (entity::raycast(&entity))
|
||||
{
|
||||
if (ENTITY::IS_ENTITY_A_VEHICLE(entity))
|
||||
{
|
||||
vehicle::repair(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_notification_service->push_warning("Weapons", "Entity is not a vehicle.");
|
||||
}
|
||||
}
|
||||
else g_notification_service->push_warning("Weapons", "No entity found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
39
src/backend/looped/weapons/steal_vehicle_gun.cpp
Normal file
39
src/backend/looped/weapons/steal_vehicle_gun.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "core/enums.hpp"
|
||||
#include "gta/enums.hpp"
|
||||
#include "util/entity.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static Entity ent;
|
||||
|
||||
void looped::weapons_steal_vehicle_gun()
|
||||
{
|
||||
if (const bool bStealVehicleGun = g->weapons.custom_weapon == CustomWeapon::STEAL_VEHICLE_GUN; bStealVehicleGun)
|
||||
{
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM))
|
||||
{
|
||||
if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_ATTACK))
|
||||
{
|
||||
if (entity::raycast(&ent))
|
||||
{
|
||||
if (ENTITY::IS_ENTITY_A_VEHICLE(ent))
|
||||
{
|
||||
for (size_t i = 0; i < 8 && !VEHICLE::IS_VEHICLE_SEAT_FREE(ent, -1, 0); i++)
|
||||
{
|
||||
const auto ped = VEHICLE::GET_PED_IN_VEHICLE_SEAT(ent, -1, 0);
|
||||
TASK::CLEAR_PED_TASKS_IMMEDIATELY(ped);
|
||||
|
||||
script::get_current()->yield(100ms);
|
||||
}
|
||||
|
||||
PED::SET_PED_INTO_VEHICLE(self::ped, ent, -1);
|
||||
}
|
||||
else g_notification_service->push_warning("Weapons", "Entity is not a vehicle.");
|
||||
}
|
||||
else g_notification_service->push_warning("Weapons", "No entity found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
62
src/backend/looped/weapons/vehicle_gun.cpp
Normal file
62
src/backend/looped/weapons/vehicle_gun.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "core/enums.hpp"
|
||||
#include "util/math.hpp"
|
||||
#include "util/vehicle.hpp"
|
||||
#include "gui.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static auto last_time = std::chrono::steady_clock::now();
|
||||
|
||||
void looped::weapons_vehicle_gun()
|
||||
{
|
||||
const bool is_vehicle_gun_selected = g->weapons.custom_weapon == CustomWeapon::VEHICLE_GUN;
|
||||
|
||||
const auto time_now = std::chrono::steady_clock::now();
|
||||
|
||||
const auto elapsed_time_in_ms = std::chrono::duration_cast<std::chrono::milliseconds>(time_now - last_time).count();
|
||||
|
||||
if (is_vehicle_gun_selected &&
|
||||
!g_gui.m_opened &&
|
||||
elapsed_time_in_ms >= 100 &&
|
||||
PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_ATTACK))
|
||||
{
|
||||
Vector3 location = self::pos;
|
||||
|
||||
constexpr int rotation_order = 2;
|
||||
|
||||
Vector3 rot = CAM::GET_GAMEPLAY_CAM_ROT(rotation_order);
|
||||
float pitch = math::deg_to_rad(rot.x); // vertical
|
||||
//float roll = rot.y;
|
||||
float yaw = math::deg_to_rad(rot.z + 90); // horizontal
|
||||
|
||||
float dist = 10.f;
|
||||
location.x += dist * cos(pitch) * cos(yaw);
|
||||
location.y += dist * sin(yaw) * cos(pitch);
|
||||
location.z += dist * sin(pitch);
|
||||
Vehicle veh = vehicle::spawn(
|
||||
rage::joaat((const char*)g->weapons.vehicle_gun_model),
|
||||
location,
|
||||
ENTITY::GET_ENTITY_HEADING(self::ped)
|
||||
);
|
||||
|
||||
dist = 150.f;
|
||||
Vector3 velocity
|
||||
{
|
||||
dist * cos(pitch) * cos(yaw),
|
||||
dist * sin(yaw) * cos(pitch),
|
||||
dist * sin(pitch)
|
||||
};
|
||||
|
||||
ENTITY::SET_ENTITY_ROTATION(veh, rot.x, rot.y, rot.z, rotation_order, 1);
|
||||
ENTITY::SET_ENTITY_VELOCITY(veh, velocity.x, velocity.y, velocity.z);
|
||||
|
||||
// flagging the veh as no longer needed so that the game can remove it
|
||||
// when reaching the maximum vehicle limit,
|
||||
// allowing the vehicle gun to keep working
|
||||
ENTITY::SET_VEHICLE_AS_NO_LONGER_NEEDED(&veh);
|
||||
|
||||
last_time = time_now;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user