2022-12-22 21:23:32 +00:00
|
|
|
#include "gta/enums.hpp"
|
|
|
|
#include "natives.hpp"
|
|
|
|
#include "backend/looped_command.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;
|
|
|
|
float og_recoil_value = 0.0f;
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
if (p_modified_weapon != weapon_mgr->m_weapon_info && weapon_mgr->m_weapon_info)
|
|
|
|
{
|
|
|
|
if (p_modified_weapon)
|
|
|
|
p_modified_weapon->m_explosion_shake_amplitude = og_recoil_value;
|
2022-03-02 08:48:53 -05:00
|
|
|
|
2022-12-22 21:23:32 +00:00
|
|
|
og_recoil_value = weapon_mgr->m_weapon_info->m_explosion_shake_amplitude;
|
|
|
|
p_modified_weapon = weapon_mgr->m_weapon_info;
|
|
|
|
weapon_mgr->m_weapon_info->m_explosion_shake_amplitude = 0.0f;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
{
|
2022-12-22 21:23:32 +00:00
|
|
|
p_modified_weapon->m_explosion_shake_amplitude = og_recoil_value;
|
|
|
|
p_modified_weapon = nullptr;
|
2022-03-02 08:48:53 -05:00
|
|
|
}
|
|
|
|
}
|
2022-12-22 21:23:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
no_recoil g_no_recoil("norecoil", "No Recoil", "Removes weapon recoil when shooting", g.weapons.no_recoil);
|
|
|
|
}
|