2023-03-01 21:27:15 +00:00
|
|
|
#include "backend/looped_command.hpp"
|
2022-12-22 21:23:32 +00:00
|
|
|
#include "gta/enums.hpp"
|
|
|
|
#include "natives.hpp"
|
2022-03-02 08:48:53 -05:00
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
2022-12-22 21:23:32 +00:00
|
|
|
class no_recoil : looped_command
|
2022-03-02 08:48:53 -05:00
|
|
|
{
|
2022-12-22 21:23:32 +00:00
|
|
|
using looped_command::looped_command;
|
2022-03-02 08:48:53 -05:00
|
|
|
|
2022-12-22 21:23:32 +00:00
|
|
|
CWeaponInfo* p_modified_weapon = nullptr;
|
2023-09-22 02:06:06 +08:00
|
|
|
uint32_t og_recoil_hash = 0;
|
|
|
|
uint32_t og_recoil_hash_fp = 0;
|
2022-12-22 21:23:32 +00:00
|
|
|
|
|
|
|
virtual void on_tick() override
|
|
|
|
{
|
|
|
|
if (!g_local_player)
|
2022-03-02 08:48:53 -05:00
|
|
|
{
|
2022-12-22 21:23:32 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-03-02 08:48:53 -05:00
|
|
|
|
2022-12-22 21:23:32 +00:00
|
|
|
auto* const weapon_mgr = g_local_player->m_weapon_manager;
|
|
|
|
if (weapon_mgr)
|
|
|
|
{
|
2023-06-06 07:40:40 +00:00
|
|
|
if (p_modified_weapon != weapon_mgr->m_weapon_info)
|
2022-12-22 21:23:32 +00:00
|
|
|
{
|
|
|
|
if (p_modified_weapon)
|
2023-09-22 02:06:06 +08:00
|
|
|
{
|
|
|
|
p_modified_weapon->m_recoil_shake_hash = og_recoil_hash;
|
|
|
|
p_modified_weapon->m_recoil_shake_hash_first_person = og_recoil_hash_fp;
|
|
|
|
}
|
2022-03-02 08:48:53 -05:00
|
|
|
|
2022-12-22 21:23:32 +00:00
|
|
|
p_modified_weapon = weapon_mgr->m_weapon_info;
|
2023-06-06 07:40:40 +00:00
|
|
|
|
|
|
|
if (weapon_mgr->m_weapon_info)
|
|
|
|
{
|
2023-09-22 02:06:06 +08:00
|
|
|
og_recoil_hash = weapon_mgr->m_weapon_info->m_recoil_shake_hash;
|
|
|
|
og_recoil_hash_fp = weapon_mgr->m_weapon_info->m_recoil_shake_hash_first_person;
|
|
|
|
weapon_mgr->m_weapon_info->m_recoil_shake_hash = 0;
|
|
|
|
weapon_mgr->m_weapon_info->m_recoil_shake_hash_first_person = 0;
|
2023-06-06 07:40:40 +00:00
|
|
|
}
|
2022-12-22 21:23:32 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-02 08:48:53 -05:00
|
|
|
}
|
|
|
|
|
2022-12-22 21:23:32 +00:00
|
|
|
virtual void on_disable() override
|
2022-03-02 08:48:53 -05:00
|
|
|
{
|
2022-12-22 21:23:32 +00:00
|
|
|
if (g_local_player && p_modified_weapon)
|
2022-03-02 08:48:53 -05:00
|
|
|
{
|
2023-09-22 02:06:06 +08:00
|
|
|
p_modified_weapon->m_recoil_shake_hash = og_recoil_hash;
|
|
|
|
p_modified_weapon->m_recoil_shake_hash_first_person = og_recoil_hash_fp;
|
|
|
|
p_modified_weapon = nullptr;
|
2022-03-02 08:48:53 -05:00
|
|
|
}
|
|
|
|
}
|
2022-12-22 21:23:32 +00:00
|
|
|
};
|
|
|
|
|
2023-10-20 12:24:44 -04:00
|
|
|
no_recoil g_no_recoil("norecoil", "BACKEND_LOOPED_WEAPONS_NO_RECOIL", "BACKEND_LOOPED_WEAPONS_NO_RECOIL_DESC", g.weapons.no_recoil);
|
2022-12-22 21:23:32 +00:00
|
|
|
}
|