feat(CustomWeapons): Added vehicle gun

This commit is contained in:
Yimura 2021-05-20 21:04:03 +02:00
parent d0cff3b4a8
commit 00048bb277
No known key found for this signature in database
GPG Key ID: 3D8FF4397E768682
5 changed files with 62 additions and 3 deletions

View File

@ -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()

View File

@ -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();
};
}

View File

@ -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);
}
}
}
}
}

View File

@ -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" }
};

View File

@ -8,7 +8,8 @@ namespace big
CAGE_GUN,
DELETE_GUN,
GRAVITY_GUN,
REPAIR_GUN
REPAIR_GUN,
VEHICLE_GUN
};
enum class SpeedoMeter