feat(CustomWeapons): deactivate when weapon is holstered (#1231)

This commit is contained in:
Rxann 2023-04-15 17:17:43 -04:00 committed by GitHub
parent 8a9c6a22c0
commit 60e1c2e3c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 21 additions and 13 deletions

View File

@ -7,7 +7,7 @@ namespace big
{ {
void looped::weapons_cage_gun() void looped::weapons_cage_gun()
{ {
if (const bool bCageGun = g.weapons.custom_weapon == CustomWeapon::CAGE_GUN; bCageGun) if (const bool bCageGun = g.weapons.custom_weapon == CustomWeapon::CAGE_GUN; bCageGun && (!g.self.custom_weapon_stop || WEAPON::IS_PED_ARMED(self::ped, 4 | 2)))
{ {
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM))
{ {
@ -28,4 +28,5 @@ namespace big
} }
} }
} }
} }

View File

@ -8,7 +8,7 @@ namespace big
{ {
void looped::weapons_delete_gun() void looped::weapons_delete_gun()
{ {
if (const bool bDeleteGun = g.weapons.custom_weapon == CustomWeapon::DELETE_GUN; bDeleteGun) if (const bool bDeleteGun = g.weapons.custom_weapon == CustomWeapon::DELETE_GUN; bDeleteGun && (!g.self.custom_weapon_stop || WEAPON::IS_PED_ARMED(self::ped, 4 | 2)))
{ {
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM))
{ {

View File

@ -51,7 +51,7 @@ namespace big
bool is_gravity_gun_selected = g.weapons.custom_weapon == CustomWeapon::GRAVITY_GUN; bool is_gravity_gun_selected = g.weapons.custom_weapon == CustomWeapon::GRAVITY_GUN;
auto is_zoomed_in = is_gravity_gun_selected && PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM); auto is_zoomed_in = is_gravity_gun_selected && PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM);
if (is_zoomed_in) if (is_zoomed_in && (!g.self.custom_weapon_stop || WEAPON::IS_PED_ARMED(self::ped, 4 | 2)))
{ {
location = self::pos; location = self::pos;

View File

@ -8,7 +8,7 @@ namespace big
{ {
void looped::weapons_repair_gun() void looped::weapons_repair_gun()
{ {
if (const bool bRepairGun = g.weapons.custom_weapon == CustomWeapon::REPAIR_GUN; bRepairGun) if (const bool bRepairGun = g.weapons.custom_weapon == CustomWeapon::REPAIR_GUN; bRepairGun && (!g.self.custom_weapon_stop || WEAPON::IS_PED_ARMED(self::ped, 4 | 2)))
{ {
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM))
{ {

View File

@ -9,7 +9,8 @@ namespace big
void looped::weapons_steal_vehicle_gun() void looped::weapons_steal_vehicle_gun()
{ {
if (const bool bStealVehicleGun = g.weapons.custom_weapon == CustomWeapon::STEAL_VEHICLE_GUN; bStealVehicleGun) if (const bool bStealVehicleGun = g.weapons.custom_weapon == CustomWeapon::STEAL_VEHICLE_GUN;
bStealVehicleGun && (!g.self.custom_weapon_stop || WEAPON::IS_PED_ARMED(self::ped, 4 | 2)))
{ {
if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM))
{ {
@ -38,4 +39,6 @@ namespace big
} }
} }
} }
} }

View File

@ -17,7 +17,8 @@ namespace big
const auto elapsed_time_in_ms = std::chrono::duration_cast<std::chrono::milliseconds>(time_now - last_time).count(); 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->is_open() && elapsed_time_in_ms >= 100 && PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_ATTACK)) if (is_vehicle_gun_selected && !g_gui->is_open() && elapsed_time_in_ms >= 100 && PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_ATTACK)
&& (!g.self.custom_weapon_stop || WEAPON::IS_PED_ARMED(self::ped, 4 | 2)))
{ {
Vector3 location = self::pos; Vector3 location = self::pos;
@ -48,4 +49,5 @@ namespace big
last_time = time_now; last_time = time_now;
} }
} }
} }

View File

@ -286,6 +286,7 @@ namespace big
bool healthregen = false; bool healthregen = false;
float healthregenrate = 1.0f; float healthregenrate = 1.0f;
bool superman = false; bool superman = false;
bool custom_weapon_stop = true;
struct hud struct hud
{ {
bool hudcolor = false; bool hudcolor = false;
@ -307,7 +308,7 @@ namespace big
// do not save below entries // do not save below entries
bool dance_mode = false; bool dance_mode = false;
NLOHMANN_DEFINE_TYPE_INTRUSIVE(self, ptfx_effects, clean_player, force_wanted_level, free_cam, invisibility, local_visibility, never_wanted, no_ragdoll, noclip, off_radar, super_run, no_collision, unlimited_oxygen, no_water_collision, wanted_level, god_mode, part_water, proof_bullet, proof_fire, proof_collision, proof_melee, proof_explosion, proof_steam, proof_drown, proof_water, proof_mask, mobile_radio, fast_respawn, auto_tp, super_jump, beast_jump, healthregen, healthregenrate, hud, superman) NLOHMANN_DEFINE_TYPE_INTRUSIVE(self, ptfx_effects, clean_player, force_wanted_level, free_cam, invisibility, local_visibility, never_wanted, no_ragdoll, noclip, off_radar, super_run, no_collision, unlimited_oxygen, no_water_collision, wanted_level, god_mode, part_water, proof_bullet, proof_fire, proof_collision, proof_melee, proof_explosion, proof_steam, proof_drown, proof_water, proof_mask, mobile_radio, fast_respawn, auto_tp, super_jump, beast_jump, healthregen, healthregenrate, hud, superman, custom_weapon_stop)
} self{}; } self{};
struct session struct session

View File

@ -111,6 +111,7 @@ namespace big
components::sub_title("CUSTOM_WEAPONS"_T); components::sub_title("CUSTOM_WEAPONS"_T);
ImGui::Checkbox("Custom Gun only fires when weapon is out", &g.self.custom_weapon_stop);
CustomWeapon selected = g.weapons.custom_weapon; CustomWeapon selected = g.weapons.custom_weapon;
if (ImGui::BeginCombo("WEAPON"_T.data(), custom_weapons[(int)selected].name)) if (ImGui::BeginCombo("WEAPON"_T.data(), custom_weapons[(int)selected].name))