feat(debug): log explosion event

This commit is contained in:
dynamoNg 2024-07-31 12:55:00 +05:30
parent 80af2d7c6a
commit dbefb72201
3 changed files with 26 additions and 2 deletions

View File

@ -123,6 +123,7 @@ namespace big
{ {
int metric_logs{}; int metric_logs{};
int packet_logs{}; int packet_logs{};
bool explosion_event = false;
bool script_hook_logs{}; bool script_hook_logs{};

View File

@ -7,6 +7,7 @@
#include "util/mobile.hpp" #include "util/mobile.hpp"
#include "util/notify.hpp" #include "util/notify.hpp"
#include "util/toxic.hpp" #include "util/toxic.hpp"
#include "core/data/bullet_impact_types.hpp"
#include <base/CObject.hpp> #include <base/CObject.hpp>
#include <network/CNetGamePlayer.hpp> #include <network/CNetGamePlayer.hpp>
@ -259,7 +260,7 @@ namespace big
return false; return false;
} }
void scan_explosion_event(CNetGamePlayer* player, rage::datBitBuffer* buffer) void scan_explosion_event(player_ptr plyr, CNetGamePlayer* player, rage::datBitBuffer* buffer)
{ {
uint16_t f186; uint16_t f186;
uint16_t targetEntity; uint16_t targetEntity;
@ -386,6 +387,19 @@ namespace big
return; return;
} }
// logs all type of explosion including owned one, fire, water hydrant etc, one without damage but camerashake, npcs shooting explosive ammo from planes from source client etc
if (g.debug.logs.explosion_event && plyr)
{
auto exp_type_itr = BULLET_IMPACTS.find(explosionType);
LOGF(
WARNING,
"Explosion Event: {} (Dist- {} {})",
player->get_name(),
math::distance_between_vectors(*plyr->get_ped()->get_position(), {posX, posY, posZ}),
exp_type_itr != BULLET_IMPACTS.end() ? exp_type_itr->second : "?"
);
}
if (g.session.explosion_karma && g_local_player if (g.session.explosion_karma && g_local_player
&& math::distance_between_vectors({posX, posY, posZ}, *g_local_player->m_navigation->get_position()) < 3.0f) && math::distance_between_vectors({posX, posY, posZ}, *g_local_player->m_navigation->get_position()) < 3.0f)
{ {
@ -867,7 +881,15 @@ namespace big
return; return;
} }
scan_explosion_event(source_player, buffer); scan_explosion_event(plyr, source_player, buffer);
// dont accept event in died state
if (g_local_player->m_player_info->m_game_state == eGameState::Died)
{
g_pointers->m_gta.m_send_event_ack(event_manager, source_player, target_player, event_index, event_handled_bitset);
return;
}
break; break;
} }
case eNetworkEvents::WEAPON_DAMAGE_EVENT: case eNetworkEvents::WEAPON_DAMAGE_EVENT:

View File

@ -12,6 +12,7 @@ namespace big
ImGui::Combo("DEBUG_LOG_METRICS"_T.data(), (int*)&g.debug.logs.metric_logs, options, IM_ARRAYSIZE(options)); ImGui::Combo("DEBUG_LOG_METRICS"_T.data(), (int*)&g.debug.logs.metric_logs, options, IM_ARRAYSIZE(options));
ImGui::Combo("VIEW_DEBUG_LOGS_LOG_PACKETS"_T.data(), (int*)&g.debug.logs.packet_logs, options, IM_ARRAYSIZE(options)); ImGui::Combo("VIEW_DEBUG_LOGS_LOG_PACKETS"_T.data(), (int*)&g.debug.logs.packet_logs, options, IM_ARRAYSIZE(options));
ImGui::Checkbox("DEBUG_LOG_NATIVE_SCRIPT_HOOKS"_T.data(), &g.debug.logs.script_hook_logs); ImGui::Checkbox("DEBUG_LOG_NATIVE_SCRIPT_HOOKS"_T.data(), &g.debug.logs.script_hook_logs);
ImGui::Checkbox("DEBUG_LOG_EXPLOSION_EVENT"_T.data(), &g.debug.logs.explosion_event);
if (ImGui::TreeNode("DEBUG_LOG_TREE_SCRIPT_EVENT"_T.data())) if (ImGui::TreeNode("DEBUG_LOG_TREE_SCRIPT_EVENT"_T.data()))
{ {