mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-01-08 18:33:37 +08:00
Feat vehicle gun improv (#291)
This commit is contained in:
parent
e2696ef4d5
commit
ba19c7b2b3
@ -2,47 +2,61 @@
|
||||
#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()
|
||||
{
|
||||
bool bVehicleGun = g->weapons.custom_weapon == CustomWeapon::VEHICLE_GUN;
|
||||
const bool is_vehicle_gun_selected = g->weapons.custom_weapon == CustomWeapon::VEHICLE_GUN;
|
||||
|
||||
if (bVehicleGun)
|
||||
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))
|
||||
{
|
||||
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM))
|
||||
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(
|
||||
(const char*)g->weapons.vehicle_gun_model,
|
||||
location,
|
||||
ENTITY::GET_ENTITY_HEADING(self::ped)
|
||||
);
|
||||
|
||||
dist = 150.f;
|
||||
Vector3 velocity
|
||||
{
|
||||
if (PAD::IS_DISABLED_CONTROL_JUST_RELEASED(0, (int)ControllerInputs::INPUT_ATTACK))
|
||||
{
|
||||
Vector3 location = self::pos;
|
||||
dist * cos(pitch) * cos(yaw),
|
||||
dist * sin(yaw) * cos(pitch),
|
||||
dist * sin(pitch)
|
||||
};
|
||||
|
||||
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
|
||||
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);
|
||||
|
||||
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(
|
||||
(const char*)g->weapons.vehicle_gun_model,
|
||||
location,
|
||||
ENTITY::GET_ENTITY_HEADING(self::ped)
|
||||
);
|
||||
// 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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
last_time = time_now;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,10 +89,12 @@ namespace big
|
||||
switch (selected)
|
||||
{
|
||||
case CustomWeapon::VEHICLE_GUN:
|
||||
ImGui::Text("Shooting Model:");
|
||||
ImGui::InputText("##vehicle_gun_model", g->weapons.vehicle_gun_model, 12);
|
||||
components::input_text_with_hint(
|
||||
"Shooting Model",
|
||||
"Name of the vehicle model",
|
||||
g->weapons.vehicle_gun_model, sizeof(g->weapons.vehicle_gun_model));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user