mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 20:17:24 +08:00
Basic hostile ped disarm (#1437)
This commit is contained in:
parent
e5581a6f03
commit
4b74f411a2
42
src/backend/looped/world/nearby/auto_disarm.cpp
Normal file
42
src/backend/looped/world/nearby/auto_disarm.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
#include "backend/looped_command.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "util/entity.hpp"
|
||||
#include "util/pools.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
class auto_disarm : looped_command
|
||||
{
|
||||
using looped_command::looped_command;
|
||||
|
||||
virtual void on_enable() override
|
||||
{
|
||||
g_notification_service->push("Auto disarm", "Nearby hostile peds will be disarmed");
|
||||
}
|
||||
|
||||
virtual void on_tick() override
|
||||
{
|
||||
for (auto ped : pools::get_all_peds())
|
||||
{
|
||||
if (!ped)
|
||||
continue;
|
||||
|
||||
auto handle = g_pointers->m_gta.m_ptr_to_handle(ped);
|
||||
|
||||
if (!PED::IS_PED_A_PLAYER(handle) && ENTITY::DOES_ENTITY_EXIST(PED::GET_PED_TARGET_FROM_COMBAT_PED(handle, false)))
|
||||
{
|
||||
if (entity::take_control_of(handle))
|
||||
{
|
||||
if (WEAPON::IS_PED_ARMED(handle, 1 | 2 | 4))
|
||||
WEAPON::REMOVE_ALL_PED_WEAPONS(handle, false);
|
||||
|
||||
if (g.world.nearby.auto_disarm.neutralize)
|
||||
TASK::TASK_STAND_STILL(handle, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
auto_disarm g_auto_disarm("autodisarm", "Auto Disarm", "Disarm nearby pedestrians", g.world.nearby.auto_disarm.enable);
|
||||
}
|
@ -513,7 +513,14 @@ namespace big
|
||||
bool ped_rush = false;
|
||||
bool combative = false;
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(nearby, ignore, ped_rain, veh_rain, high_alert, ped_rush, combative)
|
||||
struct auto_disarm
|
||||
{
|
||||
bool enable = false;
|
||||
bool neutralize = false;
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(auto_disarm, enable, neutralize)
|
||||
} auto_disarm{};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(nearby, ignore, ped_rain, veh_rain, high_alert, ped_rush, combative, auto_disarm)
|
||||
} nearby{};
|
||||
|
||||
struct model_swapper
|
||||
|
@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
#include "gta/pools.hpp"
|
||||
|
||||
namespace big::pools
|
||||
|
@ -42,6 +42,10 @@ namespace big
|
||||
components::command_checkbox<"highalert">();
|
||||
ImGui::SameLine(140.f);
|
||||
components::command_checkbox<"pedrush">();
|
||||
components::command_checkbox<"autodisarm">();
|
||||
components::options_modal("Auto Disarm", []{
|
||||
ImGui::Checkbox("Neutralize", &g.world.nearby.auto_disarm.neutralize);
|
||||
});
|
||||
|
||||
ImGui::Separator();
|
||||
components::sub_title("Vehicles");
|
||||
@ -72,4 +76,4 @@ namespace big
|
||||
|
||||
components::command_checkbox<"vehiclerain">();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user