TmpMenu/BigBaseV2/src/views/self/view_weapons.cpp
karifeld 0f09234130 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
2022-05-22 18:38:45 -04:00

98 lines
2.4 KiB
C++

#include "core/data/custom_weapons.hpp"
#include "fiber_pool.hpp"
#include "gta/Weapons.h"
#include "script.hpp"
#include "core/data/special_ammo_types.hpp"
#include "views/view.hpp"
namespace big
{
void view::weapons() {
components::small_text("Ammo");
ImGui::Checkbox("Infinite Ammo", &g->weapons.infinite_ammo);
ImGui::SameLine();
ImGui::Checkbox("Infinite Clip", &g->weapons.infinite_mag);
ImGui::Checkbox("Enable Special Ammo", &g->weapons.ammo_special.toggle);
eAmmoSpecialType selected_ammo = g->weapons.ammo_special.type;
if (ImGui::BeginCombo("Special Ammo", SPECIAL_AMMOS[(int)selected_ammo].name))
{
for (const auto& special_ammo : SPECIAL_AMMOS)
{
if (ImGui::Selectable(special_ammo.name, special_ammo.type == selected_ammo))
g->weapons.ammo_special.type = special_ammo.type;
if (special_ammo.type == selected_ammo)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::Separator();
components::small_text("Misc");
ImGui::Checkbox("Force Crosshairs", &g->weapons.force_crosshairs);
ImGui::SameLine();
ImGui::Checkbox("No Recoil", &g->weapons.no_recoil);
ImGui::SameLine();
ImGui::Checkbox("No Spread", &g->weapons.no_spread);
components::button("Get All Weapons", [] {
for (auto const& weapon : weapon_list) {
WEAPON::GIVE_DELAYED_WEAPON_TO_PED(self::ped, weapon, 9999, false);
}
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");
ImGui::Separator();
components::small_text("Custom Weapons");
CustomWeapon selected = g->weapons.custom_weapon;
if (ImGui::BeginCombo("Weapon", custom_weapons[(int)selected].name))
{
for (const custom_weapon& weapon : custom_weapons)
{
if (ImGui::Selectable(weapon.name, weapon.id == selected))
{
g->weapons.custom_weapon = weapon.id;
}
if (weapon.id == selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
switch (selected)
{
case CustomWeapon::VEHICLE_GUN:
ImGui::Text("Shooting Model:");
ImGui::InputText("##vehicle_gun_model", g->weapons.vehicle_gun_model, 12);
break;
}
}
}