From 00048bb277eae0ac6670ab03b7b9c72afac3d867 Mon Sep 17 00:00:00 2001 From: Yimura Date: Thu, 20 May 2021 21:04:03 +0200 Subject: [PATCH] feat(CustomWeapons): Added vehicle gun --- BigBaseV2/src/backend/backend.cpp | 1 + BigBaseV2/src/backend/looped/looped.hpp | 3 +- .../backend/looped/weapons/vehicle_gun.cpp | 55 +++++++++++++++++++ BigBaseV2/src/core/data/custom_weapons.hpp | 3 +- BigBaseV2/src/core/enums.hpp | 3 +- 5 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 BigBaseV2/src/backend/looped/weapons/vehicle_gun.cpp diff --git a/BigBaseV2/src/backend/backend.cpp b/BigBaseV2/src/backend/backend.cpp index f0b0cf8e..4a5d806f 100644 --- a/BigBaseV2/src/backend/backend.cpp +++ b/BigBaseV2/src/backend/backend.cpp @@ -25,6 +25,7 @@ namespace big looped::weapons_delete_gun(); looped::weapons_gravity_gun(); looped::weapons_repair_gun(); + looped::weapons_vehicle_gun(); }QUEUE_JOB_END_CLAUSE QUEUE_JOB_BEGIN_CLAUSE() diff --git a/BigBaseV2/src/backend/looped/looped.hpp b/BigBaseV2/src/backend/looped/looped.hpp index 3261a127..63b3fa0e 100644 --- a/BigBaseV2/src/backend/looped/looped.hpp +++ b/BigBaseV2/src/backend/looped/looped.hpp @@ -9,10 +9,11 @@ namespace big static void self_noclip(); static void weapons_cage_gun(); + static void weapons_delete_gun(); static void weapons_gravity_gun(); static void weapons_repair_gun(); + static void weapons_vehicle_gun(); static void vehicle_speedo_meter(); - static void weapons_delete_gun(); }; } \ No newline at end of file diff --git a/BigBaseV2/src/backend/looped/weapons/vehicle_gun.cpp b/BigBaseV2/src/backend/looped/weapons/vehicle_gun.cpp new file mode 100644 index 00000000..42545890 --- /dev/null +++ b/BigBaseV2/src/backend/looped/weapons/vehicle_gun.cpp @@ -0,0 +1,55 @@ +#include "backend/looped/looped.hpp" +#include "core/enums.hpp" +#include "util/math.hpp" +#include "util/vehicle.hpp" + +namespace big +{ + static const int controls[] = { 14, 15, 24 }; + + void looped::weapons_vehicle_gun() + { + bool bVehicleGun = g.weapons.custom_weapon == CustomWeapon::VEHICLE_GUN; + + if (bVehicleGun) + { + Ped player = PLAYER::PLAYER_PED_ID(); + + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, 25)) + { + PLAYER::DISABLE_PLAYER_FIRING(PLAYER::PLAYER_ID(), true); + for (int control : controls) + PAD::DISABLE_CONTROL_ACTION(0, control, true); + + if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, 24)) + { + Vector3 location = ENTITY::GET_ENTITY_COORDS(player, 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 + + 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( + "bus", + location, + ENTITY::GET_ENTITY_HEADING(player) + ); + + Vector3 velocity; + dist = 150.f; + velocity.x = dist * cos(pitch) * cos(yaw); + velocity.y = dist * sin(yaw) * cos(pitch); + velocity.z = dist * sin(pitch); + + ENTITY::SET_ENTITY_ROTATION(veh, rot.x, rot.y, rot.z, 2, 1); + ENTITY::SET_ENTITY_VELOCITY(veh, velocity.x, velocity.y, velocity.z); + } + } + } + } +} \ No newline at end of file diff --git a/BigBaseV2/src/core/data/custom_weapons.hpp b/BigBaseV2/src/core/data/custom_weapons.hpp index 9b8bc749..eea02370 100644 --- a/BigBaseV2/src/core/data/custom_weapons.hpp +++ b/BigBaseV2/src/core/data/custom_weapons.hpp @@ -11,5 +11,6 @@ const custom_weapon custom_weapons[] = { { big::CustomWeapon::CAGE_GUN, "Cage Gun" }, { big::CustomWeapon::DELETE_GUN, "Delete Gun" }, { big::CustomWeapon::GRAVITY_GUN, "Gravity Gun" }, - { big::CustomWeapon::REPAIR_GUN, "Repair Gun" } + { big::CustomWeapon::REPAIR_GUN, "Repair Gun" }, + { big::CustomWeapon::VEHICLE_GUN, "Vehicle Gun" } }; \ No newline at end of file diff --git a/BigBaseV2/src/core/enums.hpp b/BigBaseV2/src/core/enums.hpp index e3b8ccce..13ba32f0 100644 --- a/BigBaseV2/src/core/enums.hpp +++ b/BigBaseV2/src/core/enums.hpp @@ -8,7 +8,8 @@ namespace big CAGE_GUN, DELETE_GUN, GRAVITY_GUN, - REPAIR_GUN + REPAIR_GUN, + VEHICLE_GUN }; enum class SpeedoMeter