2023-01-22 21:57:32 +00:00
|
|
|
#include "core/scr_globals.hpp"
|
2023-03-01 21:27:15 +00:00
|
|
|
#include "gta/net_array.hpp"
|
2023-01-22 21:57:32 +00:00
|
|
|
#include "gta/script_handler.hpp"
|
2023-03-01 21:27:15 +00:00
|
|
|
#include "gta_util.hpp"
|
|
|
|
#include "hooking.hpp"
|
|
|
|
#include "script_local.hpp"
|
2023-07-05 07:30:06 +00:00
|
|
|
#include "services/players/player_service.hpp"
|
|
|
|
#include "util/misc.hpp"
|
2023-03-01 21:27:15 +00:00
|
|
|
#include "util/notify.hpp"
|
2023-01-22 21:57:32 +00:00
|
|
|
|
|
|
|
#include <script/globals/GlobalPlayerBD.hpp>
|
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
|
|
|
bool hooks::received_array_update(rage::netArrayHandlerBase* array, CNetGamePlayer* sender, rage::datBitBuffer* buffer, int size, std::int16_t cycle)
|
|
|
|
{
|
|
|
|
int old_beast_index = -1;
|
2023-03-01 21:27:15 +00:00
|
|
|
int participant_id = 0;
|
|
|
|
auto beast = gta_util::find_script_thread(RAGE_JOAAT("am_hunt_the_beast"));
|
2023-01-22 21:57:32 +00:00
|
|
|
|
|
|
|
if (beast)
|
|
|
|
{
|
|
|
|
old_beast_index = *script_local(beast->m_stack, scr_locals::am_hunt_the_beast::broadcast_idx).at(1).at(6).as<int*>();
|
|
|
|
if (beast->m_net_component)
|
2023-07-16 12:24:40 -04:00
|
|
|
participant_id = ((CGameScriptHandlerNetComponent*)beast->m_net_component)->m_local_participant_index;
|
2023-01-22 21:57:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool result = g_hooking->get_original<hooks::received_array_update>()(array, sender, buffer, size, cycle);
|
|
|
|
|
2023-03-01 21:27:15 +00:00
|
|
|
if (beast && array->m_array == script_local(beast->m_stack, scr_locals::am_hunt_the_beast::broadcast_idx).as<void*>()
|
|
|
|
&& old_beast_index
|
|
|
|
!= *script_local(beast->m_stack, scr_locals::am_hunt_the_beast::broadcast_idx).at(1).at(6).as<int*>()
|
|
|
|
&& *script_local(beast->m_stack, scr_locals::am_hunt_the_beast::broadcast_idx).at(1).at(6).as<int*>() == participant_id
|
|
|
|
&& !misc::has_bit_set(script_local(beast->m_stack, scr_locals::am_hunt_the_beast::player_broadcast_idx)
|
|
|
|
.at(participant_id, 4)
|
|
|
|
.at(3)
|
|
|
|
.as<int*>(),
|
|
|
|
1))
|
2023-01-22 21:57:32 +00:00
|
|
|
{
|
2023-03-01 21:27:15 +00:00
|
|
|
*script_local(beast->m_stack, scr_locals::am_hunt_the_beast::broadcast_idx).at(1).at(6).as<int*>() = -1;
|
2023-01-22 21:57:32 +00:00
|
|
|
*script_local(beast->m_stack, scr_locals::am_hunt_the_beast::broadcast_idx).at(1).at(7).as<Player*>() = -1;
|
|
|
|
|
|
|
|
if (auto plyr = g_player_service->get_by_id(sender->m_player_id))
|
|
|
|
g.reactions.turn_into_beast.process(plyr);
|
|
|
|
}
|
|
|
|
|
2023-03-01 21:27:15 +00:00
|
|
|
if ((array->m_array >= scr_globals::globalplayer_bd.as<uint8_t*>()
|
|
|
|
&& array->m_array <= scr_globals::globalplayer_bd.at(31, sizeof(GlobalPlayerBDEntry) / 8).as<uint8_t*>())
|
|
|
|
&& scr_globals::globalplayer_bd.as<GlobalPlayerBD*>()->Entries[sender->m_player_id].RemoteWantedLevelPlayer != -1)
|
2023-01-22 21:57:32 +00:00
|
|
|
{
|
|
|
|
if (auto plyr = g_player_service->get_by_id(sender->m_player_id))
|
|
|
|
{
|
|
|
|
if (scr_globals::globalplayer_bd.as<GlobalPlayerBD*>()->Entries[sender->m_player_id].RemoteWantedLevelPlayer == self::id)
|
|
|
|
{
|
|
|
|
g.reactions.remote_wanted_level.process(plyr);
|
|
|
|
}
|
2023-03-01 21:27:15 +00:00
|
|
|
else if (auto victim = g_player_service->get_by_id(
|
|
|
|
scr_globals::globalplayer_bd.as<GlobalPlayerBD*>()->Entries[sender->m_player_id].RemoteWantedLevelPlayer))
|
2023-01-22 21:57:32 +00:00
|
|
|
{
|
|
|
|
g.reactions.remote_wanted_level_others.process(plyr, victim);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 07:30:06 +00:00
|
|
|
scr_globals::globalplayer_bd.as<GlobalPlayerBD*>()->Entries[sender->m_player_id].RemoteWantedLevelPlayer = -1; // reset locally
|
2023-01-22 21:57:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (array->m_array == scr_globals::gsbd.as<void*>() && *scr_globals::gsbd.as<eFreemodeState*>() == eFreemodeState::CLOSING)
|
|
|
|
{
|
|
|
|
*scr_globals::gsbd.as<eFreemodeState*>() = eFreemodeState::RUNNING;
|
|
|
|
|
|
|
|
if (auto plyr = g_player_service->get_by_id(sender->m_player_id))
|
|
|
|
g.reactions.end_session_kick.process(plyr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|