Fixes Idle Kick to replace the globals that freemode.c4 uses to determine idle time. (#1979)
This commit is contained in:
parent
6c1e821d60
commit
81e43b51d7
@ -1,5 +1,6 @@
|
|||||||
#include "backend/looped_command.hpp"
|
#include "backend/looped_command.hpp"
|
||||||
#include "services/tunables/tunables_service.hpp"
|
#include "services/tunables/tunables_service.hpp"
|
||||||
|
#include "core/scr_globals.hpp"
|
||||||
|
|
||||||
namespace big
|
namespace big
|
||||||
{
|
{
|
||||||
@ -7,49 +8,20 @@ namespace big
|
|||||||
{
|
{
|
||||||
using looped_command::looped_command;
|
using looped_command::looped_command;
|
||||||
|
|
||||||
std::array<int*, 8> m_tunables = { nullptr };
|
|
||||||
std::array<int, 8> m_restore;
|
|
||||||
bool m_ready_to_use;
|
|
||||||
|
|
||||||
virtual void on_tick() override
|
virtual void on_tick() override
|
||||||
{
|
{
|
||||||
if (!m_ready_to_use)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
m_tunables[0] = g_tunables_service->get_tunable<int*>(RAGE_JOAAT("IDLEKICK_WARNING1"));
|
*scr_globals::tuneables.at(87).at(i).as<PINT>() = INT_MAX;
|
||||||
m_tunables[1] = g_tunables_service->get_tunable<int*>(RAGE_JOAAT("IDLEKICK_WARNING2"));
|
|
||||||
m_tunables[2] = g_tunables_service->get_tunable<int*>(RAGE_JOAAT("IDLEKICK_WARNING3"));
|
|
||||||
m_tunables[3] = g_tunables_service->get_tunable<int*>(RAGE_JOAAT("IDLEKICK_KICK"));
|
|
||||||
m_tunables[4] = g_tunables_service->get_tunable<int*>(RAGE_JOAAT("ConstrainedKick_Warning1"));
|
|
||||||
m_tunables[5] = g_tunables_service->get_tunable<int*>(RAGE_JOAAT("ConstrainedKick_Warning2"));
|
|
||||||
m_tunables[6] = g_tunables_service->get_tunable<int*>(RAGE_JOAAT("ConstrainedKick_Warning3"));
|
|
||||||
m_tunables[7] = g_tunables_service->get_tunable<int*>(RAGE_JOAAT("ConstrainedKick_Kick"));
|
|
||||||
|
|
||||||
// create backup of tunables
|
|
||||||
m_ready_to_use = true;
|
|
||||||
for (int i = 0; i < m_restore.size(); ++i)
|
|
||||||
{
|
|
||||||
if (m_ready_to_use = m_tunables[i]; !m_ready_to_use)
|
|
||||||
break;
|
|
||||||
m_restore[i] = *m_tunables[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (const auto& tunable : m_tunables)
|
|
||||||
{
|
|
||||||
if (tunable)
|
|
||||||
*tunable = INT_MAX;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void on_disable() override
|
virtual void on_disable() override
|
||||||
{
|
{
|
||||||
for (int i = 0; m_ready_to_use && i < m_restore.size(); ++i)
|
*scr_globals::tuneables.at(87).as<PINT>() = *g_tunables_service->get_tunable<int*>(RAGE_JOAAT("IDLEKICK_WARNING1"));
|
||||||
{
|
*scr_globals::tuneables.at(87).at(1).as<PINT>() = *g_tunables_service->get_tunable<int*>(RAGE_JOAAT("IDLEKICK_WARNING2"));
|
||||||
if (m_tunables[i])
|
*scr_globals::tuneables.at(87).at(2).as<PINT>() = *g_tunables_service->get_tunable<int*>(RAGE_JOAAT("IDLEKICK_WARNING3"));
|
||||||
*m_tunables[i] = m_restore[i];
|
*scr_globals::tuneables.at(87).at(3).as<PINT>() = *g_tunables_service->get_tunable<int*>(RAGE_JOAAT("IDLEKICK_KICK"));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,6 +37,8 @@ namespace big::scr_globals
|
|||||||
static inline const script_global spawn_global(2694613);
|
static inline const script_global spawn_global(2694613);
|
||||||
|
|
||||||
static inline const script_global offradar_time(2672524);
|
static inline const script_global offradar_time(2672524);
|
||||||
|
|
||||||
|
static inline const script_global tuneables(262145);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace big::scr_locals
|
namespace big::scr_locals
|
||||||
|
Reference in New Issue
Block a user