From 0f09234130995d1606f365b212ffc9cb062ba2bf Mon Sep 17 00:00:00 2001 From: karifeld <96363819+karifeld@users.noreply.github.com> Date: Mon, 23 May 2022 06:38:45 +0800 Subject: [PATCH] refactor: Modernized/optimized general code, bug fixing and more (#226) * refactor: Use self globals * refactor: Use gui::components * fix(Vehicle Preview): Addresses #119 Previewed vehicle set to unclimbable Only preview when hovered on vehicle * fix(Infinite Clip): Disabling it now works * fix(No Ragdoll): Disabling it now works Removed unnecessary calls to natives (0xB128377056A54E2A should be enough) * fix(Spawn): Wrong footer placement * fix self globals file name typo * refactor(Mobile): Clear ped tasks when set conditions are met Only clear ped tasks if pv_teleport_into bool is true and ped is in a vehicle * feat(Weapons): Remove current weapon * refactor: Added missing variable in calls to self globals * refactor: Utilize usage of ControllerInputs * fix(Vehicle Fly): uninitialized local variable 'ped' used * refactor(No Ragdoll, Infinite Clip): Only run on boolean change. * refactor(Infinite Ammo): Simplified code * refactor: Utilize ControllerInputs in other areas of code * refactor: Utilize ControllerInputs in other areas of code --- .../src/backend/looped/player/spectate.cpp | 11 ++-- .../src/backend/looped/self/clean_player.cpp | 2 +- .../src/backend/looped/self/free_cam.cpp | 37 +++++++---- BigBaseV2/src/backend/looped/self/godmode.cpp | 2 +- .../src/backend/looped/self/invisibility.cpp | 8 ++- .../src/backend/looped/self/no_ragdoll.cpp | 14 ++-- BigBaseV2/src/backend/looped/self/noclip.cpp | 32 +++++---- .../src/backend/looped/self/super_run.cpp | 21 +++--- .../{self_gloabls.cpp => self_globals.cpp} | 0 .../src/backend/looped/vehicle/auto_drive.cpp | 34 +++++----- .../backend/looped/vehicle/drive_on_water.cpp | 30 +++++---- BigBaseV2/src/backend/looped/vehicle/fly.cpp | 66 ++++++++++--------- .../src/backend/looped/vehicle/horn_boost.cpp | 10 +-- .../backend/looped/vehicle/instant_brake.cpp | 8 ++- .../src/backend/looped/vehicle/ls_customs.cpp | 2 +- .../src/backend/looped/vehicle/rgb_paint.cpp | 8 ++- .../src/backend/looped/weapons/cage_gun.cpp | 13 ++-- .../src/backend/looped/weapons/delete_gun.cpp | 13 ++-- .../backend/looped/weapons/gravity_gun.cpp | 19 ++++-- .../looped/weapons/increase_damage.cpp | 4 +- .../backend/looped/weapons/infinite_ammo.cpp | 16 ++--- .../backend/looped/weapons/infinite_mag.cpp | 11 +++- .../src/backend/looped/weapons/repair_gun.cpp | 12 ++-- .../looped/weapons/steal_vehicle_gun.cpp | 17 +++-- .../backend/looped/weapons/vehicle_gun.cpp | 12 ++-- .../gui/handling/handling_current_profile.cpp | 6 +- .../src/gui/handling/handling_my_profiles.cpp | 2 +- .../gui/handling/handling_saved_profiles.cpp | 2 +- .../src/gui/handling/handling_search.cpp | 14 ++-- .../src/gui/handling/modals/save_handling.cpp | 11 ++-- .../gui/handling/modals/update_handling.cpp | 11 ++-- .../src/services/vehicle_preview_service.cpp | 4 +- BigBaseV2/src/util/entity.hpp | 10 +-- BigBaseV2/src/util/mobile.hpp | 3 +- BigBaseV2/src/util/ped.hpp | 24 ++++--- BigBaseV2/src/util/teleport.hpp | 15 +++-- BigBaseV2/src/util/toxic.hpp | 2 +- BigBaseV2/src/util/vehicle.hpp | 8 ++- BigBaseV2/src/views/network/view_session.cpp | 12 ++-- BigBaseV2/src/views/players/view_player.cpp | 2 +- BigBaseV2/src/views/self/view_self.cpp | 16 ++--- BigBaseV2/src/views/self/view_weapons.cpp | 25 +++---- BigBaseV2/src/views/settings/view_debug.cpp | 16 ++--- BigBaseV2/src/views/vehicle/view_spawn.cpp | 8 ++- BigBaseV2/src/views/vehicle/view_vehicle.cpp | 29 +++----- 45 files changed, 353 insertions(+), 269 deletions(-) rename BigBaseV2/src/backend/looped/system/{self_gloabls.cpp => self_globals.cpp} (100%) diff --git a/BigBaseV2/src/backend/looped/player/spectate.cpp b/BigBaseV2/src/backend/looped/player/spectate.cpp index e3b9ac1e..8f30f270 100644 --- a/BigBaseV2/src/backend/looped/player/spectate.cpp +++ b/BigBaseV2/src/backend/looped/player/spectate.cpp @@ -8,6 +8,9 @@ namespace big void looped::player_spectate() { + Vehicle vehicle = self::veh; + Ped ped = self::ped; + if (!g_player_service->get_selected()->is_valid() || !g->player.spectating) { if (g->player.spectating) g->player.spectating = false; @@ -18,8 +21,8 @@ namespace big NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(false, -1); HUD::SET_MINIMAP_IN_SPECTATOR_MODE(false, -1); - ENTITY::FREEZE_ENTITY_POSITION(PLAYER::PLAYER_PED_ID(), false); - ENTITY::FREEZE_ENTITY_POSITION(PED::GET_VEHICLE_PED_IS_USING(PLAYER::PLAYER_PED_ID()), false); + ENTITY::FREEZE_ENTITY_POSITION(ped, false); + ENTITY::FREEZE_ENTITY_POSITION(vehicle, false); } return; @@ -29,8 +32,8 @@ namespace big NETWORK::NETWORK_SET_IN_SPECTATOR_MODE(true, target); HUD::SET_MINIMAP_IN_SPECTATOR_MODE(true, target); - ENTITY::FREEZE_ENTITY_POSITION(PLAYER::PLAYER_PED_ID(), true); - ENTITY::FREEZE_ENTITY_POSITION(PED::GET_VEHICLE_PED_IS_USING(PLAYER::PLAYER_PED_ID()), true); + ENTITY::FREEZE_ENTITY_POSITION(ped, true); + ENTITY::FREEZE_ENTITY_POSITION(vehicle, true); bReset = false; } diff --git a/BigBaseV2/src/backend/looped/self/clean_player.cpp b/BigBaseV2/src/backend/looped/self/clean_player.cpp index b84d732c..95940fd1 100644 --- a/BigBaseV2/src/backend/looped/self/clean_player.cpp +++ b/BigBaseV2/src/backend/looped/self/clean_player.cpp @@ -7,7 +7,7 @@ namespace big void looped::self_clean_player() { if (g->self.clean_player) { - entity::clean_ped(PLAYER::PLAYER_PED_ID()); + entity::clean_ped(self::ped); } } } \ No newline at end of file diff --git a/BigBaseV2/src/backend/looped/self/free_cam.cpp b/BigBaseV2/src/backend/looped/self/free_cam.cpp index 5cfa5f3f..7d6d3ded 100644 --- a/BigBaseV2/src/backend/looped/self/free_cam.cpp +++ b/BigBaseV2/src/backend/looped/self/free_cam.cpp @@ -1,4 +1,5 @@ #include "backend/looped/looped.hpp" +#include "gta/enums.hpp" #include "natives.hpp" #include "util/math.hpp" @@ -17,7 +18,8 @@ namespace big { if (g_local_player == nullptr) return; - Entity ent = PLAYER::PLAYER_PED_ID(); + Vehicle vehicle = self::veh; + Ped ped = self::ped; if (!g->self.free_cam && !bLastFreeCam) return; if (g->self.free_cam && !bLastFreeCam) @@ -27,7 +29,7 @@ namespace big vecPosition = CAM::GET_GAMEPLAY_CAM_COORD(); vecRot = CAM::GET_GAMEPLAY_CAM_ROT(2); - ENTITY::FREEZE_ENTITY_POSITION(PED::GET_VEHICLE_PED_IS_USING(PLAYER::PLAYER_PED_ID()), 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); @@ -37,11 +39,11 @@ namespace big } else if (!g->self.free_cam && bLastFreeCam) { - ENTITY::FREEZE_ENTITY_POSITION(PED::GET_VEHICLE_PED_IS_USING(PLAYER::PLAYER_PED_ID()), false); + ENTITY::FREEZE_ENTITY_POSITION(vehicle, false); 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(PLAYER::PLAYER_PED_ID()); + STREAMING::SET_FOCUS_ENTITY(ped); bLastFreeCam = false; @@ -49,29 +51,42 @@ namespace big } PAD::DISABLE_ALL_CONTROL_ACTIONS(0); - const int controls[] = { 1, 2, 3, 4, 5, 6, 270, 271, 272, 273 }; + + const int controls[] = { + (int)ControllerInputs::INPUT_LOOK_LR, + (int)ControllerInputs::INPUT_LOOK_UD, + (int)ControllerInputs::INPUT_LOOK_UP_ONLY, + (int)ControllerInputs::INPUT_LOOK_DOWN_ONLY, + (int)ControllerInputs::INPUT_LOOK_LEFT_ONLY, + (int)ControllerInputs::INPUT_LOOK_RIGHT_ONLY, + (int)ControllerInputs::INPUT_LOOK_LEFT, + (int)ControllerInputs::INPUT_LOOK_RIGHT, + (int)ControllerInputs::INPUT_LOOK_UP, + (int)ControllerInputs::INPUT_LOOK_DOWN + }; + for (int control : controls) PAD::ENABLE_CONTROL_ACTION(2, control, true); Vector3 vecChange = { 0.f, 0.f, 0.f }; // Left Shift - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 21)) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_SPRINT)) vecChange.z += speed / 2; // Left Control - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 36)) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_DUCK)) vecChange.z -= speed / 2; // Forward - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 32)) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_UP_ONLY)) vecChange.y += speed; // Backward - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 33)) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_DOWN_ONLY)) vecChange.y -= speed; // Left - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 34)) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_LEFT_ONLY)) vecChange.x -= speed; // Right - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 35)) + 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) diff --git a/BigBaseV2/src/backend/looped/self/godmode.cpp b/BigBaseV2/src/backend/looped/self/godmode.cpp index aecdabaf..41311e2f 100644 --- a/BigBaseV2/src/backend/looped/self/godmode.cpp +++ b/BigBaseV2/src/backend/looped/self/godmode.cpp @@ -11,7 +11,7 @@ namespace big if (bGodMode || (!bGodMode && bGodMode != bLastGodMode)) { - ENTITY::SET_ENTITY_INVINCIBLE(PLAYER::PLAYER_PED_ID(), g->self.godmode); + ENTITY::SET_ENTITY_INVINCIBLE(self::ped, g->self.godmode); bLastGodMode = g->self.godmode; } diff --git a/BigBaseV2/src/backend/looped/self/invisibility.cpp b/BigBaseV2/src/backend/looped/self/invisibility.cpp index be014d9e..529e84e7 100644 --- a/BigBaseV2/src/backend/looped/self/invisibility.cpp +++ b/BigBaseV2/src/backend/looped/self/invisibility.cpp @@ -7,11 +7,13 @@ namespace big void looped::self_invisibility() { + Ped ped = self::ped; + bool bInvisibility = g->self.invisibility; if (bInvisibility || (!bInvisibility && bInvisibility != bLastInvisibility)) { - ENTITY::SET_ENTITY_VISIBLE(PLAYER::PLAYER_PED_ID(), !g->self.invisibility, 0); + ENTITY::SET_ENTITY_VISIBLE(ped, !g->self.invisibility, 0); bLastInvisibility = g->self.invisibility; } @@ -20,14 +22,14 @@ namespace big { if (g->self.invisibility && g->self.local_visibility) { - NETWORK::SET_ENTITY_LOCALLY_VISIBLE(PLAYER::PLAYER_PED_ID()); + NETWORK::SET_ENTITY_LOCALLY_VISIBLE(ped); } } else { if (g->self.local_visibility) { - ENTITY::SET_ENTITY_VISIBLE(PLAYER::PLAYER_PED_ID(), true, 0); + ENTITY::SET_ENTITY_VISIBLE(ped, true, 0); } } } diff --git a/BigBaseV2/src/backend/looped/self/no_ragdoll.cpp b/BigBaseV2/src/backend/looped/self/no_ragdoll.cpp index 24b1fd2a..a4e94af1 100644 --- a/BigBaseV2/src/backend/looped/self/no_ragdoll.cpp +++ b/BigBaseV2/src/backend/looped/self/no_ragdoll.cpp @@ -3,15 +3,17 @@ namespace big { + static bool bLastNoRagdoll = false; + void looped::self_no_ragdoll() { - Ped player = PLAYER::PLAYER_PED_ID(); + bool bNoRagdoll = g->self.no_ragdoll; - if (g->self.no_ragdoll) { - PED::SET_PED_CAN_RAGDOLL(player, !g->self.no_ragdoll); - PED::SET_PED_CAN_RAGDOLL_FROM_PLAYER_IMPACT(player, !g->self.no_ragdoll); - PED::SET_PED_RAGDOLL_ON_COLLISION(player, !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; } - } } diff --git a/BigBaseV2/src/backend/looped/self/noclip.cpp b/BigBaseV2/src/backend/looped/self/noclip.cpp index dbf5d4cd..24e711c2 100644 --- a/BigBaseV2/src/backend/looped/self/noclip.cpp +++ b/BigBaseV2/src/backend/looped/self/noclip.cpp @@ -1,12 +1,21 @@ #include "backend/looped/looped.hpp" #include "fiber_pool.hpp" +#include "gta/enums.hpp" #include "natives.hpp" #include "script.hpp" #include "util/entity.hpp" namespace big { - static const int controls[] = { 21, 32, 33, 34, 35, 36 }; + static const int controls[] = { + (int)ControllerInputs::INPUT_SPRINT, + (int)ControllerInputs::INPUT_MOVE_UP_ONLY, + (int)ControllerInputs::INPUT_MOVE_DOWN_ONLY, + (int)ControllerInputs::INPUT_MOVE_LEFT_ONLY, + (int)ControllerInputs::INPUT_MOVE_RIGHT_ONLY, + (int)ControllerInputs::INPUT_DUCK + }; + static float speed = 20.f; static float mult = 0.f; @@ -18,9 +27,8 @@ namespace big void looped::self_noclip() { bool bNoclip = g->self.noclip; - Entity ent = PLAYER::PLAYER_PED_ID(); - bool bInVehicle = PED::IS_PED_IN_ANY_VEHICLE(ent, true); - if (bInVehicle) ent = PED::GET_VEHICLE_PED_IS_IN(ent, false); + Vector3 location = self::pos; + Entity ent = self::veh != NULL ? self::veh : self::ped; // cleanup when changing entities if (prev != ent) @@ -40,22 +48,22 @@ namespace big float heading = 0.f; // Left Shift - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 21)) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_SPRINT)) vel.z += speed / 2; // Left Control - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 36)) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_DUCK)) vel.z -= speed / 2; // Forward - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 32)) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_UP_ONLY)) vel.y += speed; // Backward - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 33)) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_DOWN_ONLY)) vel.y -= speed; // Left - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 34)) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_LEFT_ONLY)) vel.x -= speed; // Right - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 35)) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_MOVE_RIGHT_ONLY)) vel.x += speed; rot = CAM::GET_GAMEPLAY_CAM_ROT(2); @@ -76,8 +84,8 @@ namespace big ENTITY::FREEZE_ENTITY_POSITION(ent, false); Vector3 offset = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(ent, vel.x, vel.y, 0.f); - vel.x = offset.x - self::pos.x; - vel.y = offset.y - self::pos.y; + 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); } diff --git a/BigBaseV2/src/backend/looped/self/super_run.cpp b/BigBaseV2/src/backend/looped/self/super_run.cpp index 5c66be11..a7fbb118 100644 --- a/BigBaseV2/src/backend/looped/self/super_run.cpp +++ b/BigBaseV2/src/backend/looped/self/super_run.cpp @@ -1,4 +1,5 @@ #include "backend/looped/looped.hpp" +#include "gta/enums.hpp" #include "natives.hpp" #include "util/math.hpp" @@ -10,28 +11,30 @@ namespace big void looped::self_super_run() { - if (g->self.super_run && PAD::IS_CONTROL_PRESSED(0, 21)) + 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(self::ped, 2); + Vector3 rot = ENTITY::GET_ENTITY_ROTATION(ped, 2); float yaw = math::deg_to_rad(rot.z + 90); Vector3 offset; - offset.x = self::pos.x + (run_speed * cos(yaw)); - offset.y = self::pos.y + (run_speed * sin(yaw)); - offset.z = self::pos.z + .2f; + 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 < self::pos.z) + if (groundZ < location.z) offset.z = groundZ; - Vector3 vel = offset - self::pos; + Vector3 vel = offset - location; - ENTITY::SET_ENTITY_VELOCITY(self::ped, vel.x, vel.y, vel.z); + ENTITY::SET_ENTITY_VELOCITY(ped, vel.x, vel.y, vel.z); g_local_player->m_player_info->m_run_speed = .7f; } @@ -39,7 +42,7 @@ namespace big { g_local_player->m_player_info->m_run_speed = 1.f; } - else if (PAD::IS_CONTROL_JUST_RELEASED(0, 21)) + 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; diff --git a/BigBaseV2/src/backend/looped/system/self_gloabls.cpp b/BigBaseV2/src/backend/looped/system/self_globals.cpp similarity index 100% rename from BigBaseV2/src/backend/looped/system/self_gloabls.cpp rename to BigBaseV2/src/backend/looped/system/self_globals.cpp diff --git a/BigBaseV2/src/backend/looped/vehicle/auto_drive.cpp b/BigBaseV2/src/backend/looped/vehicle/auto_drive.cpp index 8ace0dbd..b48d3e83 100644 --- a/BigBaseV2/src/backend/looped/vehicle/auto_drive.cpp +++ b/BigBaseV2/src/backend/looped/vehicle/auto_drive.cpp @@ -8,6 +8,8 @@ namespace big { void looped::vehicle_auto_drive() { + Vehicle vehicle = self::veh; + Ped ped = self::ped; static Vector3 location; static bool running = true; static bool wandering = true; @@ -23,7 +25,7 @@ namespace big g_notification_service->push_warning("Warning", "No Waypoint found please set one first."); g->vehicle.auto_drive_to_waypoint = false; } - else if (!self::veh) + else if (!vehicle) { g_notification_service->push_warning("Warning", "Please be in a car first then try again."); } @@ -35,10 +37,10 @@ namespace big g_notification_service->push_warning("Auto Drive", "Start driving or leave car to take back control."); - TASK::CLEAR_VEHICLE_TASKS_(self::veh); + TASK::CLEAR_VEHICLE_TASKS_(vehicle); - TASK::TASK_VEHICLE_DRIVE_TO_COORD(self::ped, self::veh, location.x, location.y, location.z, - static_cast(g->vehicle.auto_drive_speed), 5, ENTITY::GET_ENTITY_MODEL(self::veh), g->vehicle.driving_style_flags, 20, true); + TASK::TASK_VEHICLE_DRIVE_TO_COORD(ped, vehicle, location.x, location.y, location.z, + static_cast(g->vehicle.auto_drive_speed), 5, ENTITY::GET_ENTITY_MODEL(vehicle), g->vehicle.driving_style_flags, 20, true); g->vehicle.auto_drive_to_waypoint = false; @@ -51,23 +53,23 @@ namespace big ran_once = true; wandering = false; - if (!self::veh) + if (!vehicle) { g_notification_service->push_warning("Warning", "Please be in a car first then try again."); g->vehicle.auto_drive_wander = false; - TASK::CLEAR_VEHICLE_TASKS_(self::veh); + TASK::CLEAR_VEHICLE_TASKS_(vehicle); } else { g->vehicle.auto_drive_wander = false; - TASK::CLEAR_VEHICLE_TASKS_(self::veh); + TASK::CLEAR_VEHICLE_TASKS_(vehicle); - TASK::CLEAR_PED_TASKS(self::ped); + TASK::CLEAR_PED_TASKS(ped); - TASK::TASK_VEHICLE_DRIVE_WANDER(self::ped, self::veh, static_cast(g->vehicle.auto_drive_speed), g->vehicle.driving_style_flags); + TASK::TASK_VEHICLE_DRIVE_WANDER(ped, vehicle, static_cast(g->vehicle.auto_drive_speed), g->vehicle.driving_style_flags); wandering = true; @@ -77,10 +79,10 @@ namespace big if (wandering && ran_once) { - if (PAD::IS_CONTROL_PRESSED(0, 63) || PAD::IS_CONTROL_PRESSED(0, 64) || PAD::IS_CONTROL_PRESSED(0, 71) || PAD::IS_CONTROL_PRESSED(0, 72) || PAD::IS_CONTROL_PRESSED(0, 75) || PAD::IS_CONTROL_PRESSED(0, 76)) + if (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)) { - TASK::CLEAR_VEHICLE_TASKS_(self::veh); - TASK::CLEAR_PED_TASKS(self::ped); + TASK::CLEAR_VEHICLE_TASKS_(vehicle); + TASK::CLEAR_PED_TASKS(ped); g_notification_service->push_warning("Warning", "Wandering Stopped"); g->vehicle.auto_drive_wander = false; wandering = false; @@ -89,11 +91,11 @@ namespace big if (running) { - if (!blip::get_blip_location(location, (int)BlipIcons::Waypoint) || PAD::IS_CONTROL_PRESSED(0, 75) || PAD::IS_CONTROL_PRESSED(0, 63) || PAD::IS_CONTROL_PRESSED(0, 64)) + if (!blip::get_blip_location(location, (int)BlipIcons::Waypoint) || 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 (!blip::get_blip_location(location, (int)BlipIcons::Waypoint)) { - VEHICLE::SET_VEHICLE_FORWARD_SPEED(self::veh, 8); + VEHICLE::SET_VEHICLE_FORWARD_SPEED(vehicle, 8); } g->vehicle.auto_drive_to_waypoint = false; @@ -103,8 +105,8 @@ namespace big g_notification_service->push_warning("Warning", "Autodrive Stopped"); } - TASK::CLEAR_VEHICLE_TASKS_(self::veh); - TASK::CLEAR_PED_TASKS(self::ped); + TASK::CLEAR_VEHICLE_TASKS_(vehicle); + TASK::CLEAR_PED_TASKS(ped); running = false; } diff --git a/BigBaseV2/src/backend/looped/vehicle/drive_on_water.cpp b/BigBaseV2/src/backend/looped/vehicle/drive_on_water.cpp index 1d354da0..2091cf45 100644 --- a/BigBaseV2/src/backend/looped/vehicle/drive_on_water.cpp +++ b/BigBaseV2/src/backend/looped/vehicle/drive_on_water.cpp @@ -9,30 +9,32 @@ namespace big { if (g->vehicle.drive_on_water) { - Player player = PLAYER::PLAYER_ID(); - Ped playerPed = PLAYER::PLAYER_PED_ID(); - DWORD model = ENTITY::GET_ENTITY_MODEL(self::veh); + Vector3 location = self::pos; + Vehicle vehicle = self::veh; + Player player = self::id; + Ped playerPed = self::ped; + DWORD model = ENTITY::GET_ENTITY_MODEL(vehicle); Hash hash = MISC::GET_HASH_KEY("prop_container_ld2"); float height = 0; WATER::SET_DEEP_OCEAN_SCALER(height); - if ((!(VEHICLE::IS_THIS_MODEL_A_PLANE(ENTITY::GET_ENTITY_MODEL(self::veh)))) && WATER::GET_WATER_HEIGHT_NO_WAVES(self::pos.x, self::pos.y, self::pos.z, &height)) { - Object container = OBJECT::GET_CLOSEST_OBJECT_OF_TYPE(self::pos.x, self::pos.y, self::pos.z, 4.0, hash, 0, 0, 1); + if ((!(VEHICLE::IS_THIS_MODEL_A_PLANE(model))) && WATER::GET_WATER_HEIGHT_NO_WAVES(location.x, location.y, location.z, &height)) { + Object container = OBJECT::GET_CLOSEST_OBJECT_OF_TYPE(location.x, location.y, location.z, 4.0, hash, 0, 0, 1); if (ENTITY::DOES_ENTITY_EXIST(container) && height > -50.0f) { Vector3 pRot = ENTITY::GET_ENTITY_ROTATION(playerPed, 0); - if (PED::IS_PED_IN_ANY_VEHICLE(playerPed, 1)) pRot = ENTITY::GET_ENTITY_ROTATION(self::veh, 0); + if (PED::IS_PED_IN_ANY_VEHICLE(playerPed, 1)) pRot = ENTITY::GET_ENTITY_ROTATION(vehicle, 0); entity::take_control_of(container); - ENTITY::SET_ENTITY_COORDS(container, self::pos.x, self::pos.y, height - 2.5f, 0, 0, 0, 1); + ENTITY::SET_ENTITY_COORDS(container, location.x, location.y, height - 2.5f, 0, 0, 0, 1); ENTITY::SET_ENTITY_ROTATION(container, 0, 0, pRot.z, 0, 1); Vector3 containerCoords = ENTITY::GET_ENTITY_COORDS(container, 1); - if (self::pos.z < containerCoords.z) { + if (location.z < containerCoords.z) { if (!PED::IS_PED_IN_ANY_VEHICLE(playerPed, 0)) { - ENTITY::SET_ENTITY_COORDS(playerPed, self::pos.x, self::pos.y, containerCoords.z + 2.0f, 0, 0, 0, 1); + ENTITY::SET_ENTITY_COORDS(playerPed, location.x, location.y, containerCoords.z + 2.0f, 0, 0, 0, 1); } else { - entity::take_control_of(self::veh); - Vector3 vehc = ENTITY::GET_ENTITY_COORDS(self::veh, 1); - ENTITY::SET_ENTITY_COORDS(self::veh, vehc.x, vehc.y, containerCoords.z + 2.0f, 0, 0, 0, 1); + entity::take_control_of(vehicle); + Vector3 vehc = ENTITY::GET_ENTITY_COORDS(vehicle, 1); + ENTITY::SET_ENTITY_COORDS(vehicle, vehc.x, vehc.y, containerCoords.z + 2.0f, 0, 0, 0, 1); } } } @@ -40,7 +42,7 @@ namespace big Hash model = hash; STREAMING::REQUEST_MODEL(model); while (!STREAMING::HAS_MODEL_LOADED(model)) script::get_current()->yield(0ms); - container = OBJECT::CREATE_OBJECT(model, self::pos.x, self::pos.y, self::pos.z, 1, 1, 0); + container = OBJECT::CREATE_OBJECT(model, location.x, location.y, location.z, 1, 1, 0); entity::take_control_of(container); ENTITY::FREEZE_ENTITY_POSITION(container, 1); ENTITY::SET_ENTITY_ALPHA(container, 0, 1); @@ -48,7 +50,7 @@ namespace big } } else { - Object container = OBJECT::GET_CLOSEST_OBJECT_OF_TYPE(self::pos.x, self::pos.y, self::pos.z, 4.0, hash, 0, 0, 1); + Object container = OBJECT::GET_CLOSEST_OBJECT_OF_TYPE(location.x, location.y, location.z, 4.0, hash, 0, 0, 1); if (ENTITY::DOES_ENTITY_EXIST(container)) { entity::take_control_of(container); ENTITY::SET_ENTITY_COORDS(container, 0, 0, -1000.0f, 0, 0, 0, 1); diff --git a/BigBaseV2/src/backend/looped/vehicle/fly.cpp b/BigBaseV2/src/backend/looped/vehicle/fly.cpp index 41bed528..95e1f61e 100644 --- a/BigBaseV2/src/backend/looped/vehicle/fly.cpp +++ b/BigBaseV2/src/backend/looped/vehicle/fly.cpp @@ -1,4 +1,5 @@ #include "backend/looped/looped.hpp" +#include "gta/enums.hpp" #include "natives.hpp" #include "util/entity.hpp" @@ -9,108 +10,111 @@ namespace big void do_vehicle_fly() { + Vehicle vehicle = self::veh; + Vector3 cam_pos = CAM::GET_GAMEPLAY_CAM_ROT(0); - ENTITY::SET_ENTITY_ROTATION(self::veh, cam_pos.x, cam_pos.y, cam_pos.z, 1, true); - ENTITY::SET_ENTITY_COLLISION(self::veh, !g->vehicle.fly.no_collision, true); + 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 * 10); float locspeed2 = g->vehicle.fly.speed; - if (PAD::IS_CONTROL_PRESSED(0, 61)) + if (PAD::IS_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_VEH_MOVE_UP_ONLY)) { - locspeed = (locspeed * 2); - locspeed2 = (locspeed2 * 2); + locspeed *= 2; + locspeed2 *= 2; } - if (PAD::IS_CONTROL_PRESSED(2, 71)) + if (PAD::IS_CONTROL_PRESSED(2, (int)ControllerInputs::INPUT_VEH_ACCELERATE)) { if (g->vehicle.fly.dont_stop) { - ENTITY::APPLY_FORCE_TO_ENTITY(self::veh, 1, 0.0, g->vehicle.fly.speed, 0.0, 0.0, 0.0, 0.0, 0, 1, 1, 1, 0, 1); + 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(self::veh, locspeed); + VEHICLE::SET_VEHICLE_FORWARD_SPEED(vehicle, locspeed); } } - if (PAD::IS_CONTROL_PRESSED(2, 72)) + if (PAD::IS_CONTROL_PRESSED(2, (int)ControllerInputs::INPUT_VEH_BRAKE)) { float lsp = g->vehicle.fly.speed; - if (!PAD::IS_CONTROL_PRESSED(0, 61)) + 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(self::veh, 1, 0.0, 0 - (lsp), 0.0, 0.0, 0.0, 0.0, 0, 1, 1, 1, 0, 1); + 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(self::veh, (0 - locspeed)); + VEHICLE::SET_VEHICLE_FORWARD_SPEED(vehicle, (0 - locspeed)); } } - if (PAD::IS_CONTROL_PRESSED(2, 63)) + 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, 61)) + 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(self::veh, 1, (lsp), 0.0, 0.0, 0.0, 0.0, 0.0, 0, 1, 1, 1, 0, 1); + 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(self::veh, 1, (0 - (locspeed)), 0.0, 0.0, 0.0, 0.0, 0.0, 0, 1, 1, 1, 0, 1); + 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, 64)) + 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, 61)) + 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(self::veh, 1, lsp, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 1, 1, 1, 0, 1); + 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(self::veh, 1, locspeed, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 1, 1, 1, 0, 1); + 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, 71) && !PAD::IS_CONTROL_PRESSED(2, 72)) + 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(self::veh, 0.0); + 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(self::veh, true); - ENTITY::SET_ENTITY_COLLISION(self::veh, true, true); + 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(self::veh, 0.0); + 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 (!self::veh) + if (!vehicle) { g_notification_service->push_warning("Warning", "Please be in a vehicle before enabling vehicle fly."); g->vehicle.fly.enabled = false; @@ -118,16 +122,16 @@ namespace big } else { - if (NETWORK::NETWORK_HAS_CONTROL_OF_ENTITY(self::veh)) + if (NETWORK::NETWORK_HAS_CONTROL_OF_ENTITY(vehicle)) { do_vehicle_fly(); - VEHICLE::SET_VEHICLE_GRAVITY(self::veh, false); + VEHICLE::SET_VEHICLE_GRAVITY(vehicle, false); } else { for (int i = 0; i < 5; i++) { - entity::take_control_of(self::veh); + entity::take_control_of(vehicle); g_notification_service->push_warning("Warning", "Failed to take control of the vehicle."); } @@ -138,8 +142,8 @@ namespace big { if (last_fly_tick) { - ENTITY::SET_ENTITY_COLLISION(self::veh, true, true); - VEHICLE::SET_VEHICLE_GRAVITY(self::veh, true); + ENTITY::SET_ENTITY_COLLISION(vehicle, true, true); + VEHICLE::SET_VEHICLE_GRAVITY(vehicle, true); last_fly_tick = false; } } diff --git a/BigBaseV2/src/backend/looped/vehicle/horn_boost.cpp b/BigBaseV2/src/backend/looped/vehicle/horn_boost.cpp index 21a611f3..84c3ab64 100644 --- a/BigBaseV2/src/backend/looped/vehicle/horn_boost.cpp +++ b/BigBaseV2/src/backend/looped/vehicle/horn_boost.cpp @@ -12,7 +12,9 @@ namespace big { if (!g->vehicle.horn_boost) return; - if (self::veh == 0) + Vehicle vehicle = self::veh; + + if (vehicle == 0) { hornBoostSpeed = hornBoostSpeedDefault; @@ -20,15 +22,15 @@ namespace big } if (PAD::IS_CONTROL_JUST_PRESSED(0, (int)ControllerInputs::INPUT_VEH_HORN)) - hornBoostSpeed = ENTITY::GET_ENTITY_SPEED(self::veh); + 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(self::veh, 0.f, hornBoostSpeed, 0.f) - ENTITY::GET_ENTITY_COORDS(self::veh, true); - ENTITY::SET_ENTITY_VELOCITY(self::veh, velocity.x, velocity.y, velocity.z); + 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; diff --git a/BigBaseV2/src/backend/looped/vehicle/instant_brake.cpp b/BigBaseV2/src/backend/looped/vehicle/instant_brake.cpp index 6667645e..5fcbb445 100644 --- a/BigBaseV2/src/backend/looped/vehicle/instant_brake.cpp +++ b/BigBaseV2/src/backend/looped/vehicle/instant_brake.cpp @@ -9,12 +9,14 @@ namespace big { if (!g->vehicle.instant_brake) return; - if (self::veh == 0 || ENTITY::GET_ENTITY_SPEED_VECTOR(self::veh, true).y < 1.f) + 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, 33)) - VEHICLE::SET_VEHICLE_FORWARD_SPEED(self::veh, 0); + 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); } } diff --git a/BigBaseV2/src/backend/looped/vehicle/ls_customs.cpp b/BigBaseV2/src/backend/looped/vehicle/ls_customs.cpp index fc27dabe..554dc027 100644 --- a/BigBaseV2/src/backend/looped/vehicle/ls_customs.cpp +++ b/BigBaseV2/src/backend/looped/vehicle/ls_customs.cpp @@ -31,7 +31,7 @@ namespace big if (g->vehicle.ls_customs && g->vehicle.ls_customs != state) { - Vehicle veh = PED::GET_VEHICLE_PED_IS_USING(PLAYER::PLAYER_PED_ID()); + Vehicle veh = self::veh; if (!ENTITY::DOES_ENTITY_EXIST(veh) || ENTITY::IS_ENTITY_DEAD(veh, false)) { busy = false; diff --git a/BigBaseV2/src/backend/looped/vehicle/rgb_paint.cpp b/BigBaseV2/src/backend/looped/vehicle/rgb_paint.cpp index b27cc290..0358108e 100644 --- a/BigBaseV2/src/backend/looped/vehicle/rgb_paint.cpp +++ b/BigBaseV2/src/backend/looped/vehicle/rgb_paint.cpp @@ -6,8 +6,10 @@ namespace big void looped::vehicle_rainbow_paint() { - if (self::veh && g->vehicle.rainbow_paint) + if (g->vehicle.rainbow_paint) { + Vehicle vehicle = self::veh; + if (g->vehicle.rainbow_paint == 1) { g->rgb.fade = true; @@ -19,8 +21,8 @@ namespace big g->rgb.fade = false; } - VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(self::veh, g->rgb.r, g->rgb.g, g->rgb.b); - VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(self::veh, g->rgb.r, g->rgb.g, g->rgb.b); + VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(vehicle, g->rgb.r, g->rgb.g, g->rgb.b); + VEHICLE::SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(vehicle, g->rgb.r, g->rgb.g, g->rgb.b); } } } \ No newline at end of file diff --git a/BigBaseV2/src/backend/looped/weapons/cage_gun.cpp b/BigBaseV2/src/backend/looped/weapons/cage_gun.cpp index 13287539..85b3ce9b 100644 --- a/BigBaseV2/src/backend/looped/weapons/cage_gun.cpp +++ b/BigBaseV2/src/backend/looped/weapons/cage_gun.cpp @@ -1,10 +1,15 @@ #include "backend/looped/looped.hpp" #include "core/enums.hpp" +#include "gta/enums.hpp" #include "util/entity.hpp" namespace big { - static const int controls[] = { 14, 15, 24 }; + static const int controls[] = { + (int)ControllerInputs::INPUT_WEAPON_WHEEL_NEXT, + (int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV, + (int)ControllerInputs::INPUT_ATTACK + }; void looped::weapons_cage_gun() { @@ -12,13 +17,13 @@ namespace big if (bCageGun) { - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 25)) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) { - PLAYER::DISABLE_PLAYER_FIRING(PLAYER::GET_PLAYER_INDEX(), true); + PLAYER::DISABLE_PLAYER_FIRING(self::id, true); for (int control : controls) PAD::DISABLE_CONTROL_ACTION(0, control, true); - if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, 24)) + if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_ATTACK)) { Entity entity; diff --git a/BigBaseV2/src/backend/looped/weapons/delete_gun.cpp b/BigBaseV2/src/backend/looped/weapons/delete_gun.cpp index 8c9f7827..2411ecc2 100644 --- a/BigBaseV2/src/backend/looped/weapons/delete_gun.cpp +++ b/BigBaseV2/src/backend/looped/weapons/delete_gun.cpp @@ -1,11 +1,16 @@ #include "backend/looped/looped.hpp" #include "core/enums.hpp" +#include "gta/enums.hpp" #include "util/entity.hpp" #include "util/math.hpp" namespace big { - static const int controls[] = { 14, 15, 24 }; + static const int controls[] = { + (int)ControllerInputs::INPUT_WEAPON_WHEEL_NEXT, + (int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV, + (int)ControllerInputs::INPUT_ATTACK + }; void looped::weapons_delete_gun() { @@ -13,13 +18,13 @@ namespace big if (bCageGun) { - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 25)) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) { - PLAYER::DISABLE_PLAYER_FIRING(PLAYER::GET_PLAYER_INDEX(), true); + PLAYER::DISABLE_PLAYER_FIRING(self::id, true); for (int control : controls) PAD::DISABLE_CONTROL_ACTION(0, control, true); - if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, 24)) + if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_ATTACK)) { Entity entity; diff --git a/BigBaseV2/src/backend/looped/weapons/gravity_gun.cpp b/BigBaseV2/src/backend/looped/weapons/gravity_gun.cpp index 02ce0a49..83bb1f73 100644 --- a/BigBaseV2/src/backend/looped/weapons/gravity_gun.cpp +++ b/BigBaseV2/src/backend/looped/weapons/gravity_gun.cpp @@ -1,5 +1,6 @@ #include "backend/looped/looped.hpp" #include "core/enums.hpp" +#include "gta/enums.hpp" #include "util/entity.hpp" #include "util/math.hpp" @@ -11,7 +12,11 @@ namespace big static float dist; static const int scroll = 0; - static const int controls[] = { 14, 15, 24 }; + static const int controls[] = { + (int)ControllerInputs::INPUT_WEAPON_WHEEL_NEXT, + (int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV, + (int)ControllerInputs::INPUT_ATTACK + }; void looped::weapons_gravity_gun() { @@ -19,16 +24,16 @@ namespace big double multiplier = 3.0; // ZOOMED IN - if (bGravityGun && PAD::IS_DISABLED_CONTROL_PRESSED(0, 25)) + if (bGravityGun && PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) { - PLAYER::DISABLE_PLAYER_FIRING(PLAYER::GET_PLAYER_INDEX(), true); + PLAYER::DISABLE_PLAYER_FIRING(self::id, true); for (int control : controls) PAD::DISABLE_CONTROL_ACTION(0, control, true); - location = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), true); + location = self::pos; // Attack RELEASED - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 24) && ent == 0) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_ATTACK) && ent == 0) { if (entity::raycast(&ent)) { @@ -70,9 +75,9 @@ namespace big if (ENTITY::DOES_ENTITY_EXIST(ent)) { - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 14)) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_NEXT)) dist -= 5; - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 15)) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV)) dist += 5; if (!entity::take_control_of(ent)) diff --git a/BigBaseV2/src/backend/looped/weapons/increase_damage.cpp b/BigBaseV2/src/backend/looped/weapons/increase_damage.cpp index b9b28ea7..f4231fc0 100644 --- a/BigBaseV2/src/backend/looped/weapons/increase_damage.cpp +++ b/BigBaseV2/src/backend/looped/weapons/increase_damage.cpp @@ -5,11 +5,9 @@ namespace big { void looped::weapons_increased_damage() { - auto const player_ped = PLAYER::PLAYER_PED_ID(); - if (g->weapons.increased_damage != 1) { Hash weapon{}; - WEAPON::GET_CURRENT_PED_WEAPON(player_ped, &weapon, 0); + WEAPON::GET_CURRENT_PED_WEAPON(self::ped, &weapon, 0); WEAPON::SET_WEAPON_DAMAGE_MODIFIER_THIS_FRAME_(weapon, g->weapons.increased_damage); } } diff --git a/BigBaseV2/src/backend/looped/weapons/infinite_ammo.cpp b/BigBaseV2/src/backend/looped/weapons/infinite_ammo.cpp index 4c2e9c52..1c92af5e 100644 --- a/BigBaseV2/src/backend/looped/weapons/infinite_ammo.cpp +++ b/BigBaseV2/src/backend/looped/weapons/infinite_ammo.cpp @@ -1,19 +1,19 @@ #include "backend/looped/looped.hpp" -#include "gta/joaat.hpp" #include "natives.hpp" namespace big { + static bool bLastInfiniteAmmo = false; + void looped::weapons_infinite_ammo() { - if (g->weapons.infinite_ammo) { - Hash weaponHash; - auto const ped = PLAYER::PLAYER_PED_ID(); + bool bInfiniteAmmo = g->weapons.infinite_ammo; - WEAPON::GET_CURRENT_PED_WEAPON(ped, &weaponHash, 1); - if (weaponHash != RAGE_JOAAT("WEAPON_UNARMED")) { - WEAPON::GIVE_WEAPON_TO_PED(ped, weaponHash, 9999, false, false); - } + if (bInfiniteAmmo || (!bInfiniteAmmo && bInfiniteAmmo != bLastInfiniteAmmo)) + { + WEAPON::SET_PED_INFINITE_AMMO(self::ped, g->weapons.infinite_ammo, NULL); + + bLastInfiniteAmmo = g->weapons.infinite_ammo; } } } \ No newline at end of file diff --git a/BigBaseV2/src/backend/looped/weapons/infinite_mag.cpp b/BigBaseV2/src/backend/looped/weapons/infinite_mag.cpp index 5c2675b2..0d41e76d 100644 --- a/BigBaseV2/src/backend/looped/weapons/infinite_mag.cpp +++ b/BigBaseV2/src/backend/looped/weapons/infinite_mag.cpp @@ -3,10 +3,17 @@ namespace big { + static bool bLastInfiniteMag = false; + void looped::weapons_infinite_mag() { - if (g->weapons.infinite_mag) { - WEAPON::SET_PED_INFINITE_AMMO_CLIP(PLAYER::PLAYER_PED_ID(), g->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; } } } \ No newline at end of file diff --git a/BigBaseV2/src/backend/looped/weapons/repair_gun.cpp b/BigBaseV2/src/backend/looped/weapons/repair_gun.cpp index e98758a1..53ac6c1c 100644 --- a/BigBaseV2/src/backend/looped/weapons/repair_gun.cpp +++ b/BigBaseV2/src/backend/looped/weapons/repair_gun.cpp @@ -5,7 +5,11 @@ namespace big { - static const int controls[] = { 14, 15, 24 }; + static const int controls[] = { + (int)ControllerInputs::INPUT_WEAPON_WHEEL_NEXT, + (int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV, + (int)ControllerInputs::INPUT_ATTACK + }; void looped::weapons_repair_gun() { @@ -13,13 +17,13 @@ namespace big if (bRepairGun) { - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 25)) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) { - PLAYER::DISABLE_PLAYER_FIRING(PLAYER::GET_PLAYER_INDEX(), true); + PLAYER::DISABLE_PLAYER_FIRING(self::id, true); for (int control : controls) PAD::DISABLE_CONTROL_ACTION(0, control, true); - if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, 24)) + if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_ATTACK)) { Entity entity; diff --git a/BigBaseV2/src/backend/looped/weapons/steal_vehicle_gun.cpp b/BigBaseV2/src/backend/looped/weapons/steal_vehicle_gun.cpp index e31f49f5..1a465f79 100644 --- a/BigBaseV2/src/backend/looped/weapons/steal_vehicle_gun.cpp +++ b/BigBaseV2/src/backend/looped/weapons/steal_vehicle_gun.cpp @@ -1,25 +1,28 @@ #include "backend/looped/looped.hpp" #include "core/enums.hpp" +#include "gta/enums.hpp" #include "util/entity.hpp" namespace big { - static const int controls[] = { 14, 15, 24 }; + static const int controls[] = { + (int)ControllerInputs::INPUT_WEAPON_WHEEL_NEXT, + (int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV, + (int)ControllerInputs::INPUT_ATTACK + }; static Entity ent; void looped::weapons_steal_vehicle_gun() { if (const bool bStealVehicleGun = g->weapons.custom_weapon == CustomWeapon::STEAL_VEHICLE_GUN; bStealVehicleGun) { - Ped player = PLAYER::PLAYER_PED_ID(); - - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 25)) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) { - PLAYER::DISABLE_PLAYER_FIRING(PLAYER::GET_PLAYER_INDEX(), true); + PLAYER::DISABLE_PLAYER_FIRING(self::id, true); for (const int control : controls) PAD::DISABLE_CONTROL_ACTION(0, control, true); - if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, 24)) + if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_ATTACK)) { if (entity::raycast(&ent)) { @@ -33,7 +36,7 @@ namespace big script::get_current()->yield(100ms); } - PED::SET_PED_INTO_VEHICLE(PLAYER::PLAYER_PED_ID(), ent, -1); + PED::SET_PED_INTO_VEHICLE(self::ped, ent, -1); } else g_notification_service->push_warning("Weapons", "Entity is not a vehicle."); } diff --git a/BigBaseV2/src/backend/looped/weapons/vehicle_gun.cpp b/BigBaseV2/src/backend/looped/weapons/vehicle_gun.cpp index 507113e1..53bb963a 100644 --- a/BigBaseV2/src/backend/looped/weapons/vehicle_gun.cpp +++ b/BigBaseV2/src/backend/looped/weapons/vehicle_gun.cpp @@ -5,7 +5,11 @@ namespace big { - static const int controls[] = { 14, 15, 24 }; + static const int controls[] = { + (int)ControllerInputs::INPUT_WEAPON_WHEEL_NEXT, + (int)ControllerInputs::INPUT_WEAPON_WHEEL_PREV, + (int)ControllerInputs::INPUT_ATTACK + }; void looped::weapons_vehicle_gun() { @@ -14,13 +18,13 @@ namespace big if (bVehicleGun) { - if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 25)) + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) { - PLAYER::DISABLE_PLAYER_FIRING(PLAYER::GET_PLAYER_INDEX(), true); + PLAYER::DISABLE_PLAYER_FIRING(self::id, true); for (int control : controls) PAD::DISABLE_CONTROL_ACTION(0, control, true); - if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, 24)) + if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_ATTACK)) { Vector3 location = self::pos; diff --git a/BigBaseV2/src/gui/handling/handling_current_profile.cpp b/BigBaseV2/src/gui/handling/handling_current_profile.cpp index 5dd443b0..8936bbf6 100644 --- a/BigBaseV2/src/gui/handling/handling_current_profile.cpp +++ b/BigBaseV2/src/gui/handling/handling_current_profile.cpp @@ -14,14 +14,14 @@ namespace big if (g_vehicle_service->get_active_profile(g_local_player->m_vehicle->m_handling->m_model_hash).empty()) { - if (ImGui::Button("Save Profile")) + if (components::button("Save Profile")) { ImGui::OpenPopup("Save Handling"); } } else { - if (ImGui::Button("Update Profile")) + if (components::button("Update Profile")) { ImGui::OpenPopup("Update Handling"); } @@ -30,7 +30,7 @@ namespace big modal_handling::modal_save_handling(); modal_handling::modal_update_handling(); ImGui::SameLine(); - if (ImGui::Button("Restore Handling")) + if (components::button("Restore Handling")) g_vehicle_service->restore_vehicle(); ImGui::Separator(); diff --git a/BigBaseV2/src/gui/handling/handling_my_profiles.cpp b/BigBaseV2/src/gui/handling/handling_my_profiles.cpp index f6150ce5..db5e71a9 100644 --- a/BigBaseV2/src/gui/handling/handling_my_profiles.cpp +++ b/BigBaseV2/src/gui/handling/handling_my_profiles.cpp @@ -44,7 +44,7 @@ namespace big ImGui::TableNextColumn(); ImGui::TextWrapped(profile.description.c_str()); ImGui::TableNextColumn(); - if (ImGui::Button("Load Profile")) + if (components::button("Load Profile")) g_vehicle_service->set_handling_profile(profile); ImGui::EndTable(); diff --git a/BigBaseV2/src/gui/handling/handling_saved_profiles.cpp b/BigBaseV2/src/gui/handling/handling_saved_profiles.cpp index 31a008fe..281c9bf0 100644 --- a/BigBaseV2/src/gui/handling/handling_saved_profiles.cpp +++ b/BigBaseV2/src/gui/handling/handling_saved_profiles.cpp @@ -44,7 +44,7 @@ namespace big ImGui::TableNextColumn(); ImGui::TextWrapped(profile.description.c_str()); ImGui::TableNextColumn(); - if (ImGui::Button("Load Profile")) + if (components::button("Load Profile")) g_vehicle_service->set_handling_profile(profile); ImGui::EndTable(); diff --git a/BigBaseV2/src/gui/handling/handling_search.cpp b/BigBaseV2/src/gui/handling/handling_search.cpp index 35c745f5..fb28c56b 100644 --- a/BigBaseV2/src/gui/handling/handling_search.cpp +++ b/BigBaseV2/src/gui/handling/handling_search.cpp @@ -22,7 +22,7 @@ namespace big g_thread_pool->push([&] { g_vehicle_service->get_by_share_code(search); }); }); ImGui::SameLine(); - if (ImGui::Button("Search")) + if (components::button("Search")) g_thread_pool->push([&] { g_vehicle_service->get_by_share_code(search); }); switch (g_vehicle_service->m_search_status) @@ -65,17 +65,17 @@ namespace big ImGui::TableNextColumn(); ImGui::TextWrapped(profile.description.c_str()); ImGui::TableNextColumn(); - if (ImGui::Button("Load Profile")) + if (components::button("Load Profile")) g_vehicle_service->set_handling_profile(profile); ImGui::SameLine(); - if (ImGui::Button("Save Profile")) + if (components::button("Save Profile")) { g_thread_pool->push([&] - { - api::vehicle::handling::save_profile(profile.share_code); + { + api::vehicle::handling::save_profile(profile.share_code); - g_vehicle_service->load_saved_profiles(true); - }); + g_vehicle_service->load_saved_profiles(true); + }); } ImGui::EndTable(); diff --git a/BigBaseV2/src/gui/handling/modals/save_handling.cpp b/BigBaseV2/src/gui/handling/modals/save_handling.cpp index 40857a39..20e69df2 100644 --- a/BigBaseV2/src/gui/handling/modals/save_handling.cpp +++ b/BigBaseV2/src/gui/handling/modals/save_handling.cpp @@ -4,6 +4,7 @@ #include "natives.hpp" #include "script.hpp" #include "services/vehicle_service.hpp" +#include "views/view.hpp" namespace big { @@ -55,7 +56,7 @@ namespace big ImGui::EndGroup(); - if (ImGui::Button("Cancel")) + if (components::button("Cancel")) { strcpy(name, ""); strcpy(description, "No description."); @@ -63,12 +64,12 @@ namespace big ImGui::CloseCurrentPopup(); } ImGui::SameLine(); - if (ImGui::Button("Save")) + if (components::button("Save")) { g_thread_pool->push([&] - { - g_vehicle_service->publish_profile(name, description); - }); + { + g_vehicle_service->publish_profile(name, description); + }); } ImGui::EndPopup(); diff --git a/BigBaseV2/src/gui/handling/modals/update_handling.cpp b/BigBaseV2/src/gui/handling/modals/update_handling.cpp index b4222119..62fb3925 100644 --- a/BigBaseV2/src/gui/handling/modals/update_handling.cpp +++ b/BigBaseV2/src/gui/handling/modals/update_handling.cpp @@ -4,6 +4,7 @@ #include "natives.hpp" #include "script.hpp" #include "services/vehicle_service.hpp" +#include "views/view.hpp" namespace big { @@ -70,7 +71,7 @@ namespace big ImGui::EndGroup(); - if (ImGui::Button("Cancel")) + if (components::button("Cancel")) { strcpy(name, ""); strcpy(description, "No description."); @@ -78,12 +79,12 @@ namespace big ImGui::CloseCurrentPopup(); } ImGui::SameLine(); - if (ImGui::Button("Update")) + if (components::button("Update")) { g_thread_pool->push([&] - { - g_vehicle_service->publish_profile(name, description, profile.share_code); - }); + { + g_vehicle_service->publish_profile(name, description, profile.share_code); + }); } ImGui::EndPopup(); diff --git a/BigBaseV2/src/services/vehicle_preview_service.cpp b/BigBaseV2/src/services/vehicle_preview_service.cpp index aa77ae08..2e8656a8 100644 --- a/BigBaseV2/src/services/vehicle_preview_service.cpp +++ b/BigBaseV2/src/services/vehicle_preview_service.cpp @@ -48,7 +48,7 @@ namespace big { while (g_running && m_running && g->spawn.preview_vehicle && g_gui.m_opened) { - auto location = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(PLAYER::PLAYER_PED_ID(), 2.5f, 2.5f, .5f); + auto location = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(self::ped, 2.5f, 2.5f, .5f); if (m_current_veh == -1) { m_new_model = false; @@ -57,6 +57,8 @@ namespace big ENTITY::FREEZE_ENTITY_POSITION(m_current_veh, true); ENTITY::SET_ENTITY_ALPHA(m_current_veh, 0, 0); ENTITY::SET_ENTITY_COLLISION(m_current_veh, false, false); + ENTITY::SET_CAN_CLIMB_ON_ENTITY(m_current_veh, false); + OBJECT::SET_OBJECT_ALLOW_LOW_LOD_BUOYANCY(m_current_veh, false); } else if (m_new_model) { diff --git a/BigBaseV2/src/util/entity.hpp b/BigBaseV2/src/util/entity.hpp index 9b9a4bed..da5cb95f 100644 --- a/BigBaseV2/src/util/entity.hpp +++ b/BigBaseV2/src/util/entity.hpp @@ -16,10 +16,12 @@ namespace big::entity inline void clean_ped(Ped ped) { - PED::CLEAR_PED_BLOOD_DAMAGE(PLAYER::PLAYER_PED_ID()); - PED::CLEAR_PED_WETNESS(PLAYER::PLAYER_PED_ID()); - PED::CLEAR_PED_ENV_DIRT(PLAYER::PLAYER_PED_ID()); - PED::RESET_PED_VISIBLE_DAMAGE(PLAYER::PLAYER_PED_ID()); + Ped player_ped = self::ped; + + PED::CLEAR_PED_BLOOD_DAMAGE(player_ped); + PED::CLEAR_PED_WETNESS(player_ped); + PED::CLEAR_PED_ENV_DIRT(player_ped); + PED::RESET_PED_VISIBLE_DAMAGE(player_ped); } inline void delete_entity(Entity ent) diff --git a/BigBaseV2/src/util/mobile.hpp b/BigBaseV2/src/util/mobile.hpp index 57aab3d3..49f93912 100644 --- a/BigBaseV2/src/util/mobile.hpp +++ b/BigBaseV2/src/util/mobile.hpp @@ -89,7 +89,8 @@ namespace big::mobile if (*mechanic_global.at(958).as() != -1) return g_notification_service->push_warning("Vehicle", "Mechanic is not ready to deliver a vehicle right now."); - TASK::CLEAR_PED_TASKS_IMMEDIATELY(PLAYER::PLAYER_PED_ID()); + if (g->vehicle.pv_teleport_into && self::veh) + TASK::CLEAR_PED_TASKS_IMMEDIATELY(PLAYER::PLAYER_PED_ID()); // despawn current veh util::despawn_current_personal_vehicle(); diff --git a/BigBaseV2/src/util/ped.hpp b/BigBaseV2/src/util/ped.hpp index 36fbe837..8e534525 100644 --- a/BigBaseV2/src/util/ped.hpp +++ b/BigBaseV2/src/util/ped.hpp @@ -5,14 +5,16 @@ namespace big::ped { inline void steal_outfit(const Ped target) { - if (ENTITY::GET_ENTITY_MODEL(PLAYER::PLAYER_PED_ID()) != ENTITY::GET_ENTITY_MODEL(target)) { + Ped ped = self::ped; + + if (ENTITY::GET_ENTITY_MODEL(ped) != ENTITY::GET_ENTITY_MODEL(target)) { g_notification_service->push("Error", "Model mismatch, use steal identity instead."); return; } for (int i = 0; i < 12; i++) { PED::SET_PED_COMPONENT_VARIATION ( - PLAYER::PLAYER_PED_ID(), + ped, i, PED::GET_PED_DRAWABLE_VARIATION(target, i), PED::GET_PED_TEXTURE_VARIATION(target, i), @@ -23,14 +25,16 @@ namespace big::ped inline void steal_identity(const Ped target) { - const int max_health = ENTITY::GET_ENTITY_MAX_HEALTH(PLAYER::PLAYER_PED_ID()); - const int current_health = ENTITY::GET_ENTITY_HEALTH(PLAYER::PLAYER_PED_ID()); - const int current_armor = PED::GET_PED_ARMOUR(PLAYER::PLAYER_PED_ID()); + Ped ped = self::ped; - PLAYER::SET_PLAYER_MODEL(PLAYER::PLAYER_ID(), ENTITY::GET_ENTITY_MODEL(target)); - PED::CLONE_PED_TO_TARGET(target, PLAYER::PLAYER_PED_ID()); - ENTITY::SET_ENTITY_MAX_HEALTH(PLAYER::PLAYER_PED_ID(), max_health); - ENTITY::SET_ENTITY_HEALTH(PLAYER::PLAYER_PED_ID(), current_health, 0); - PED::SET_PED_ARMOUR(PLAYER::PLAYER_PED_ID(), current_armor); + const int max_health = ENTITY::GET_ENTITY_MAX_HEALTH(ped); + const int current_health = ENTITY::GET_ENTITY_HEALTH(ped); + const int current_armor = PED::GET_PED_ARMOUR(ped); + + PLAYER::SET_PLAYER_MODEL(self::id , ENTITY::GET_ENTITY_MODEL(target)); + PED::CLONE_PED_TO_TARGET(target, ped); + ENTITY::SET_ENTITY_MAX_HEALTH(ped, max_health); + ENTITY::SET_ENTITY_HEALTH(ped, current_health, 0); + PED::SET_PED_ARMOUR(ped, current_armor); } } \ No newline at end of file diff --git a/BigBaseV2/src/util/teleport.hpp b/BigBaseV2/src/util/teleport.hpp index 03ceed01..77ccc149 100644 --- a/BigBaseV2/src/util/teleport.hpp +++ b/BigBaseV2/src/util/teleport.hpp @@ -24,9 +24,10 @@ namespace big::teleport } ent = PED::GET_VEHICLE_PED_IS_IN(ent, false); + Vector3 location = self::pos; if (entity::take_control_of(ent)) - ENTITY::SET_ENTITY_COORDS(ent, self::pos.x, self::pos.y, self::pos.z, 0, 0, 0, 0); + ENTITY::SET_ENTITY_COORDS(ent, location.x, location.y, location.z, 0, 0, 0, 0); else g_notification_service->push_warning("Teleport", "Failed to take control of player vehicle."); @@ -88,18 +89,20 @@ namespace big::teleport Vector3 location = ENTITY::GET_ENTITY_COORDS(veh, true); load_ground_at_3dcoord(location); - ENTITY::SET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), location.x, location.y, location.z, 0, 0, 0, 0); + Ped ped = self::ped; + + ENTITY::SET_ENTITY_COORDS(ped, location.x, location.y, location.z, 0, 0, 0, 0); script::get_current()->yield(); - PED::SET_PED_INTO_VEHICLE(PLAYER::PLAYER_PED_ID(), veh, seat_index); + PED::SET_PED_INTO_VEHICLE(ped, veh, seat_index); return true; } inline void to_coords(Vector3 location) { - PED::SET_PED_COORDS_KEEP_VEHICLE(PLAYER::PLAYER_PED_ID(), location.x, location.y, location.z + 1.f); + PED::SET_PED_COORDS_KEEP_VEHICLE(self::ped, location.x, location.y, location.z + 1.f); } inline bool to_blip(int sprite, int color = -1) @@ -111,7 +114,7 @@ namespace big::teleport load_ground_at_3dcoord(location); - PED::SET_PED_COORDS_KEEP_VEHICLE(PLAYER::PLAYER_PED_ID(), location.x, location.y, location.z); + PED::SET_PED_COORDS_KEEP_VEHICLE(self::ped, location.x, location.y, location.z); return true; } @@ -120,7 +123,7 @@ namespace big::teleport { Vector3 location = ENTITY::GET_ENTITY_COORDS(ent, true); - PED::SET_PED_COORDS_KEEP_VEHICLE(PLAYER::PLAYER_PED_ID(), location.x, location.y, location.z); + PED::SET_PED_COORDS_KEEP_VEHICLE(self::ped, location.x, location.y, location.z); return true; } diff --git a/BigBaseV2/src/util/toxic.hpp b/BigBaseV2/src/util/toxic.hpp index 7c4538f9..d88ec54c 100644 --- a/BigBaseV2/src/util/toxic.hpp +++ b/BigBaseV2/src/util/toxic.hpp @@ -56,7 +56,7 @@ namespace big::toxic const Vector3 destination = PED::GET_PED_BONE_COORDS(target, (int)PedBones::SKEL_ROOT, 0.0f, 0.0f, 0.0f); const Vector3 origin = PED::GET_PED_BONE_COORDS(target, (int)PedBones::SKEL_R_Hand, 0.0f, 0.0f, 0.2f); - MISC::SHOOT_SINGLE_BULLET_BETWEEN_COORDS(origin.x, origin.y, origin.z, destination.x, destination.y, destination.z, 1, 0, RAGE_JOAAT("WEAPON_STUNGUN"), PLAYER::PLAYER_PED_ID(), false, true, 1); + MISC::SHOOT_SINGLE_BULLET_BETWEEN_COORDS(origin.x, origin.y, origin.z, destination.x, destination.y, destination.z, 1, 0, RAGE_JOAAT("WEAPON_STUNGUN"), self::ped, false, true, 1); } } diff --git a/BigBaseV2/src/util/vehicle.hpp b/BigBaseV2/src/util/vehicle.hpp index 2725d39d..ca778cf1 100644 --- a/BigBaseV2/src/util/vehicle.hpp +++ b/BigBaseV2/src/util/vehicle.hpp @@ -22,15 +22,17 @@ namespace big::vehicle if (!entity::take_control_of(veh)) return g_notification_service->push_warning("Vehicle", "Failed to take control of remote vehicle."); + Ped ped = self::ped; + ENTITY::SET_ENTITY_COORDS(veh, location.x, location.y, location.z + 1.f, 0, 0, 0, 0); - ENTITY::SET_ENTITY_HEADING(veh, ENTITY::GET_ENTITY_HEADING(PLAYER::PLAYER_PED_ID())); + ENTITY::SET_ENTITY_HEADING(veh, ENTITY::GET_ENTITY_HEADING(ped)); if (put_in) { for (size_t i = 0; i < 100 && math::distance_between_vectors(location, ENTITY::GET_ENTITY_COORDS(veh, true)) > 10; i++) script::get_current()->yield(); - PED::SET_PED_INTO_VEHICLE(PLAYER::PLAYER_PED_ID(), veh, -1); + PED::SET_PED_INTO_VEHICLE(ped, veh, -1); } } @@ -93,7 +95,7 @@ namespace big::vehicle inline void telport_into_veh(Vehicle veh) { - PED::SET_PED_INTO_VEHICLE(PLAYER::PLAYER_PED_ID(), veh, -1); + PED::SET_PED_INTO_VEHICLE(self::ped, veh, -1); } inline void max_vehicle(Vehicle veh) diff --git a/BigBaseV2/src/views/network/view_session.cpp b/BigBaseV2/src/views/network/view_session.cpp index c4dd2677..8791dea3 100644 --- a/BigBaseV2/src/views/network/view_session.cpp +++ b/BigBaseV2/src/views/network/view_session.cpp @@ -10,7 +10,7 @@ namespace big { components::button(session_type.name, [session_type] { session::join_type(session_type); - }); + }); } if (ImGui::TreeNode("Local Time")) { @@ -27,13 +27,9 @@ namespace big } if (ImGui::TreeNode("Local Weather")) { - if (ImGui::Button("Clear Override")) - { - g_fiber_pool->queue_job([] - { - MISC::CLEAR_OVERRIDE_WEATHER(); - }); - } + components::button("Clear Override", [] { + MISC::CLEAR_OVERRIDE_WEATHER(); + }); if(ImGui::ListBox("", &g->session.local_weather, session::weathers, 15)) { diff --git a/BigBaseV2/src/views/players/view_player.cpp b/BigBaseV2/src/views/players/view_player.cpp index 5205d2f6..c07cd16a 100644 --- a/BigBaseV2/src/views/players/view_player.cpp +++ b/BigBaseV2/src/views/players/view_player.cpp @@ -17,7 +17,7 @@ namespace big if (g_player_service->get_selected()->is_valid()) { - // if (ImGui::Button("Desync")) { gta_util::get_network_player_mgr()->RemovePlayer(g_player_service->get_selected()->get_net_game_player()); } + //components::button("Desync", [] { gta_util::get_network_player_mgr()->RemovePlayer(g_player_service->get_selected()->get_net_game_player()); }); if (ImGui::TreeNode("Misc")) { components::button("Steal Outfit", [] { diff --git a/BigBaseV2/src/views/self/view_self.cpp b/BigBaseV2/src/views/self/view_self.cpp index 787ea88f..9c9837a3 100644 --- a/BigBaseV2/src/views/self/view_self.cpp +++ b/BigBaseV2/src/views/self/view_self.cpp @@ -6,7 +6,7 @@ namespace big { void view::self() { components::button("Suicide", [] { - ENTITY::SET_ENTITY_HEALTH(PLAYER::PLAYER_PED_ID(), 0, 0); + ENTITY::SET_ENTITY_HEALTH(self::ped, 0, 0); }); ImGui::SameLine(); @@ -35,7 +35,7 @@ namespace big } PLAYER::SET_PLAYER_MODEL(PLAYER::GET_PLAYER_INDEX(), hash); - PED::SET_PED_DEFAULT_COMPONENT_VARIATION(PLAYER::PLAYER_PED_ID()); + PED::SET_PED_DEFAULT_COMPONENT_VARIATION(self::ped); script::get_current()->yield(); STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(hash); }); @@ -72,14 +72,10 @@ namespace big } ImGui::Checkbox("Keep Player Clean", &g->self.clean_player); - if (ImGui::Button("Clean Player")) - { - QUEUE_JOB_BEGIN_CLAUSE() - { - entity::clean_ped(PLAYER::PLAYER_PED_ID()); - } - QUEUE_JOB_END_CLAUSE - } + + components::button("Clean Player", [] { + entity::clean_ped(self::ped); + }); ImGui::EndGroup(); diff --git a/BigBaseV2/src/views/self/view_weapons.cpp b/BigBaseV2/src/views/self/view_weapons.cpp index 7c3d22e7..a3fd1d40 100644 --- a/BigBaseV2/src/views/self/view_weapons.cpp +++ b/BigBaseV2/src/views/self/view_weapons.cpp @@ -19,7 +19,7 @@ namespace big eAmmoSpecialType selected_ammo = g->weapons.ammo_special.type; - if (ImGui::BeginCombo("Ammo Special", SPECIAL_AMMOS[(int)selected_ammo].name)) + if (ImGui::BeginCombo("Special Ammo", SPECIAL_AMMOS[(int)selected_ammo].name)) { for (const auto& special_ammo : SPECIAL_AMMOS) { @@ -47,17 +47,20 @@ namespace big ImGui::Checkbox("No Spread", &g->weapons.no_spread); - if (ImGui::Button("Get All Weapons")) - { - QUEUE_JOB_BEGIN_CLAUSE() - { - for (auto const& weapon : weapon_list) { - WEAPON::GIVE_DELAYED_WEAPON_TO_PED(PLAYER::PLAYER_PED_ID(), weapon, 9999, false); - } - WEAPON::GIVE_DELAYED_WEAPON_TO_PED(PLAYER::PLAYER_PED_ID(), -72657034, 0, true); + components::button("Get All Weapons", [] { + for (auto const& weapon : weapon_list) { + WEAPON::GIVE_DELAYED_WEAPON_TO_PED(self::ped, weapon, 9999, false); } - QUEUE_JOB_END_CLAUSE - } + WEAPON::GIVE_DELAYED_WEAPON_TO_PED(self::ped, -72657034, 0, true); + }); + ImGui::SameLine(); + components::button("Remove Current Weapon", [] { + Hash weaponHash; + WEAPON::GET_CURRENT_PED_WEAPON(self::ped, &weaponHash, 1); + if (weaponHash != RAGE_JOAAT("WEAPON_UNARMED")) { + WEAPON::REMOVE_WEAPON_FROM_PED(self::ped, weaponHash); + } + }); ImGui::SliderFloat("Damage Multiplier", &g->weapons.increased_damage, 1.f, 10.f, "%.1f"); diff --git a/BigBaseV2/src/views/settings/view_debug.cpp b/BigBaseV2/src/views/settings/view_debug.cpp index 321fedac..91fb9a43 100644 --- a/BigBaseV2/src/views/settings/view_debug.cpp +++ b/BigBaseV2/src/views/settings/view_debug.cpp @@ -15,10 +15,10 @@ namespace big if (ImGui::Checkbox("Enable Freezing", &g_globals_service->m_running) && g_globals_service->m_running) g_thread_pool->push([&]() { g_globals_service->loop(); }); - if (ImGui::Button("Load")) + if (components::button("Load")) g_globals_service->load(); ImGui::SameLine(); - if (ImGui::Button("Save")) + if (components::button("Save")) g_globals_service->save(); components::button("Network Bail", [] @@ -27,7 +27,7 @@ namespace big }); ImGui::SameLine(); - if (ImGui::Button("Add Global")) + if (components::button("Add Global")) { ImGui::OpenPopup("New Global"); } @@ -87,7 +87,7 @@ namespace big } ImGui::PopItemWidth(); - if (ImGui::Button("Cancel")) + if (components::button("Cancel")) { strcpy(name, ""); freeze = false; @@ -99,7 +99,7 @@ namespace big ImGui::CloseCurrentPopup(); } ImGui::SameLine(); - if (ImGui::Button("Save")) + if (components::button("Save")) { auto new_global = global(name, base_address, freeze, offsets, offset_count); new_global.build_cache(); @@ -152,7 +152,7 @@ namespace big ImGui::BeginGroup(); sprintf(label, "Delete##%d", global.get_id()); - if (ImGui::Button(label)) + if (components::button(label)) { for (int i = 0; i < g_globals_service->m_globals.size(); i++) if (auto& it = g_globals_service->m_globals.at(i); it.get_id() == global.get_id()) @@ -162,7 +162,7 @@ namespace big } sprintf(label, "Write###%d", global.get_id()); - if (ImGui::Button(label)) + if (components::button(label)) global.write(); ImGui::EndGroup(); @@ -224,7 +224,7 @@ namespace big ImGui::Checkbox("Script Event Logging", &g->debug.script_event_logging); - if (ImGui::Button("Dump entrypoints")) + if (components::button("Dump entrypoints")) { system::dump_entry_points(); } diff --git a/BigBaseV2/src/views/vehicle/view_spawn.cpp b/BigBaseV2/src/views/vehicle/view_spawn.cpp index 636a6cfb..c7fe5508 100644 --- a/BigBaseV2/src/views/vehicle/view_spawn.cpp +++ b/BigBaseV2/src/views/vehicle/view_spawn.cpp @@ -26,7 +26,9 @@ namespace big components::input_text_with_hint("Model Name", "Search", model, sizeof(model), ImGuiInputTextFlags_EnterReturnsTrue, [] { - const auto location = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(PLAYER::PLAYER_PED_ID(), 2.f, 2.f, 0.f); + Ped ped = self::ped; + + const auto location = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(ped, 2.f, 2.f, 0.f); const Vehicle veh = vehicle::spawn(model, location, g_local_player->m_player_info->m_ped->m_navigation->m_heading + 90.f); if (g->spawn.spawn_inside) @@ -82,11 +84,13 @@ namespace big if (g->spawn.preview_vehicle && ImGui::IsItemHovered()) g_vehicle_preview_service->set_preview_vehicle(item); + else if (g->spawn.preview_vehicle && !ImGui::IsAnyItemHovered()) + g_vehicle_preview_service->stop_preview(); } } - ImGui::ListBoxFooter(); } else ImGui::Text("No vehicles in registry."); + ImGui::ListBoxFooter(); } } } \ No newline at end of file diff --git a/BigBaseV2/src/views/vehicle/view_vehicle.cpp b/BigBaseV2/src/views/vehicle/view_vehicle.cpp index 01931fb7..6807550d 100644 --- a/BigBaseV2/src/views/vehicle/view_vehicle.cpp +++ b/BigBaseV2/src/views/vehicle/view_vehicle.cpp @@ -23,16 +23,14 @@ namespace big ImGui::Checkbox("Seatbelt", &g->vehicle.seatbelt); components::button("Repair", [] { - vehicle::repair(self::veh); - }); + }); components::button("Instant in personal vehicle", [] { if (!*g_pointers->m_is_session_started) return g_notification_service->push_warning("WARNING", "Go into GTA V Online to use this option"); vehicle::go_into_personal_vehicle(); - - }); + }); if (ImGui::TreeNode("Paint")) { @@ -53,29 +51,22 @@ namespace big components::small_text("Auto Drive"); components::button("Drive To Waypoint", [] { - g->vehicle.auto_drive_to_waypoint = true; - }); + }); components::button("Wander", [] { - g->vehicle.auto_drive_wander = true; - }); + }); ImGui::SliderInt("Top Speed", &g->vehicle.auto_drive_speed, 1, 200); components::button("E-Stop", [] { - - QUEUE_JOB_BEGIN_CLAUSE() - { - g->vehicle.auto_drive_to_waypoint = false; - g->vehicle.auto_drive_wander = false; - VEHICLE::SET_VEHICLE_FORWARD_SPEED(self::veh, 0); - TASK::CLEAR_VEHICLE_TASKS_(self::veh); - TASK::CLEAR_PED_TASKS(self::ped); - } - QUEUE_JOB_END_CLAUSE - }); + g->vehicle.auto_drive_to_waypoint = false; + g->vehicle.auto_drive_wander = false; + VEHICLE::SET_VEHICLE_FORWARD_SPEED(self::veh, 0); + TASK::CLEAR_VEHICLE_TASKS_(self::veh); + TASK::CLEAR_PED_TASKS(self::ped); + }); if (ImGui::ListBox("Driving Style", &g->vehicle.driving_style_id, vehicle::driving_style_names, 3)) {