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
This commit is contained in:
karifeld
2022-05-23 06:38:45 +08:00
committed by GitHub
parent ce1d22a238
commit 04142b2d98
45 changed files with 353 additions and 269 deletions

View File

@ -10,7 +10,7 @@ namespace big
{
components::button(session_type.name, [session_type] {
session::join_type(session_type);
});
});
}
if (ImGui::TreeNode("Local Time"))
{
@ -27,13 +27,9 @@ namespace big
}
if (ImGui::TreeNode("Local Weather"))
{
if (ImGui::Button("Clear Override"))
{
g_fiber_pool->queue_job([]
{
MISC::CLEAR_OVERRIDE_WEATHER();
});
}
components::button("Clear Override", [] {
MISC::CLEAR_OVERRIDE_WEATHER();
});
if(ImGui::ListBox("", &g->session.local_weather, session::weathers, 15))
{

View File

@ -17,7 +17,7 @@ namespace big
if (g_player_service->get_selected()->is_valid())
{
// if (ImGui::Button("Desync")) { gta_util::get_network_player_mgr()->RemovePlayer(g_player_service->get_selected()->get_net_game_player()); }
//components::button("Desync", [] { gta_util::get_network_player_mgr()->RemovePlayer(g_player_service->get_selected()->get_net_game_player()); });
if (ImGui::TreeNode("Misc")) {
components::button("Steal Outfit", [] {

View File

@ -6,7 +6,7 @@ namespace big
{
void view::self() {
components::button("Suicide", [] {
ENTITY::SET_ENTITY_HEALTH(PLAYER::PLAYER_PED_ID(), 0, 0);
ENTITY::SET_ENTITY_HEALTH(self::ped, 0, 0);
});
ImGui::SameLine();
@ -35,7 +35,7 @@ namespace big
}
PLAYER::SET_PLAYER_MODEL(PLAYER::GET_PLAYER_INDEX(), hash);
PED::SET_PED_DEFAULT_COMPONENT_VARIATION(PLAYER::PLAYER_PED_ID());
PED::SET_PED_DEFAULT_COMPONENT_VARIATION(self::ped);
script::get_current()->yield();
STREAMING::SET_MODEL_AS_NO_LONGER_NEEDED(hash);
});
@ -72,14 +72,10 @@ namespace big
}
ImGui::Checkbox("Keep Player Clean", &g->self.clean_player);
if (ImGui::Button("Clean Player"))
{
QUEUE_JOB_BEGIN_CLAUSE()
{
entity::clean_ped(PLAYER::PLAYER_PED_ID());
}
QUEUE_JOB_END_CLAUSE
}
components::button("Clean Player", [] {
entity::clean_ped(self::ped);
});
ImGui::EndGroup();

View File

@ -19,7 +19,7 @@ namespace big
eAmmoSpecialType selected_ammo = g->weapons.ammo_special.type;
if (ImGui::BeginCombo("Ammo Special", SPECIAL_AMMOS[(int)selected_ammo].name))
if (ImGui::BeginCombo("Special Ammo", SPECIAL_AMMOS[(int)selected_ammo].name))
{
for (const auto& special_ammo : SPECIAL_AMMOS)
{
@ -47,17 +47,20 @@ namespace big
ImGui::Checkbox("No Spread", &g->weapons.no_spread);
if (ImGui::Button("Get All Weapons"))
{
QUEUE_JOB_BEGIN_CLAUSE()
{
for (auto const& weapon : weapon_list) {
WEAPON::GIVE_DELAYED_WEAPON_TO_PED(PLAYER::PLAYER_PED_ID(), weapon, 9999, false);
}
WEAPON::GIVE_DELAYED_WEAPON_TO_PED(PLAYER::PLAYER_PED_ID(), -72657034, 0, true);
components::button("Get All Weapons", [] {
for (auto const& weapon : weapon_list) {
WEAPON::GIVE_DELAYED_WEAPON_TO_PED(self::ped, weapon, 9999, false);
}
QUEUE_JOB_END_CLAUSE
}
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");

View File

@ -15,10 +15,10 @@ namespace big
if (ImGui::Checkbox("Enable Freezing", &g_globals_service->m_running) && g_globals_service->m_running)
g_thread_pool->push([&]() { g_globals_service->loop(); });
if (ImGui::Button("Load"))
if (components::button("Load"))
g_globals_service->load();
ImGui::SameLine();
if (ImGui::Button("Save"))
if (components::button("Save"))
g_globals_service->save();
components::button("Network Bail", []
@ -27,7 +27,7 @@ namespace big
});
ImGui::SameLine();
if (ImGui::Button("Add Global"))
if (components::button("Add Global"))
{
ImGui::OpenPopup("New Global");
}
@ -87,7 +87,7 @@ namespace big
}
ImGui::PopItemWidth();
if (ImGui::Button("Cancel"))
if (components::button("Cancel"))
{
strcpy(name, "");
freeze = false;
@ -99,7 +99,7 @@ namespace big
ImGui::CloseCurrentPopup();
}
ImGui::SameLine();
if (ImGui::Button("Save"))
if (components::button("Save"))
{
auto new_global = global(name, base_address, freeze, offsets, offset_count);
new_global.build_cache();
@ -152,7 +152,7 @@ namespace big
ImGui::BeginGroup();
sprintf(label, "Delete##%d", global.get_id());
if (ImGui::Button(label))
if (components::button(label))
{
for (int i = 0; i < g_globals_service->m_globals.size(); i++)
if (auto& it = g_globals_service->m_globals.at(i); it.get_id() == global.get_id())
@ -162,7 +162,7 @@ namespace big
}
sprintf(label, "Write###%d", global.get_id());
if (ImGui::Button(label))
if (components::button(label))
global.write();
ImGui::EndGroup();
@ -224,7 +224,7 @@ namespace big
ImGui::Checkbox("Script Event Logging", &g->debug.script_event_logging);
if (ImGui::Button("Dump entrypoints"))
if (components::button("Dump entrypoints"))
{
system::dump_entry_points();
}

View File

@ -26,7 +26,9 @@ namespace big
components::input_text_with_hint("Model Name", "Search", model, sizeof(model), ImGuiInputTextFlags_EnterReturnsTrue, []
{
const auto location = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(PLAYER::PLAYER_PED_ID(), 2.f, 2.f, 0.f);
Ped ped = self::ped;
const auto location = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(ped, 2.f, 2.f, 0.f);
const Vehicle veh = vehicle::spawn(model, location, g_local_player->m_player_info->m_ped->m_navigation->m_heading + 90.f);
if (g->spawn.spawn_inside)
@ -82,11 +84,13 @@ namespace big
if (g->spawn.preview_vehicle && ImGui::IsItemHovered())
g_vehicle_preview_service->set_preview_vehicle(item);
else if (g->spawn.preview_vehicle && !ImGui::IsAnyItemHovered())
g_vehicle_preview_service->stop_preview();
}
}
ImGui::ListBoxFooter();
}
else ImGui::Text("No vehicles in registry.");
ImGui::ListBoxFooter();
}
}
}

View File

@ -23,16 +23,14 @@ namespace big
ImGui::Checkbox("Seatbelt", &g->vehicle.seatbelt);
components::button("Repair", [] {
vehicle::repair(self::veh);
});
});
components::button("Instant in personal vehicle", [] {
if (!*g_pointers->m_is_session_started) return g_notification_service->push_warning("WARNING", "Go into GTA V Online to use this option");
vehicle::go_into_personal_vehicle();
});
});
if (ImGui::TreeNode("Paint"))
{
@ -53,29 +51,22 @@ namespace big
components::small_text("Auto Drive");
components::button("Drive To Waypoint", [] {
g->vehicle.auto_drive_to_waypoint = true;
});
});
components::button("Wander", [] {
g->vehicle.auto_drive_wander = true;
});
});
ImGui::SliderInt("Top Speed", &g->vehicle.auto_drive_speed, 1, 200);
components::button("E-Stop", [] {
QUEUE_JOB_BEGIN_CLAUSE()
{
g->vehicle.auto_drive_to_waypoint = false;
g->vehicle.auto_drive_wander = false;
VEHICLE::SET_VEHICLE_FORWARD_SPEED(self::veh, 0);
TASK::CLEAR_VEHICLE_TASKS_(self::veh);
TASK::CLEAR_PED_TASKS(self::ped);
}
QUEUE_JOB_END_CLAUSE
});
g->vehicle.auto_drive_to_waypoint = false;
g->vehicle.auto_drive_wander = false;
VEHICLE::SET_VEHICLE_FORWARD_SPEED(self::veh, 0);
TASK::CLEAR_VEHICLE_TASKS_(self::veh);
TASK::CLEAR_PED_TASKS(self::ped);
});
if (ImGui::ListBox("Driving Style", &g->vehicle.driving_style_id, vehicle::driving_style_names, 3))
{