add votelogger.restart_on_kick to make catbots restart on kick and quit party
This commit is contained in:
parent
3a903863df
commit
0b9893a5cb
@ -13,4 +13,5 @@ namespace votelogger
|
|||||||
{
|
{
|
||||||
|
|
||||||
void dispatchUserMessage(bf_read &buffer, int type);
|
void dispatchUserMessage(bf_read &buffer, int type);
|
||||||
}
|
void onShutdown(std::string message);
|
||||||
|
} // namespace votelogger
|
||||||
|
@ -80,15 +80,18 @@ static void updateAntiAfk()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (anti_afk_timer.check(60000))
|
static auto afk_timer = g_ICvar->FindVar("mp_idlemaxtime");
|
||||||
|
if (!afk_timer)
|
||||||
|
afk_timer = g_ICvar->FindVar("mp_idlemaxtime");
|
||||||
|
// Trigger 10 seconds before kick
|
||||||
|
else if (afk_timer->m_nValue != 0 && anti_afk_timer.check(afk_timer->m_nValue*60*1000-10000))
|
||||||
{
|
{
|
||||||
// Send random commands
|
// Just duck tf
|
||||||
current_user_cmd->sidemove = RandFloatRange(-450.0, 450.0);
|
if (current_user_cmd->buttons & IN_DUCK)
|
||||||
current_user_cmd->forwardmove = RandFloatRange(-450.0, 450.0);
|
current_user_cmd->buttons &= ~IN_DUCK;
|
||||||
current_user_cmd->buttons = rand();
|
else
|
||||||
// Prevent attack command
|
current_user_cmd->buttons = IN_DUCK;
|
||||||
current_user_cmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
|
if (anti_afk_timer.check(afk_timer->m_nValue*60*1000+1000))
|
||||||
if (anti_afk_timer.check(61000))
|
|
||||||
{
|
{
|
||||||
anti_afk_timer.update();
|
anti_afk_timer.update();
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,8 @@ DEFINE_HOOKED_METHOD(Shutdown, void, INetChannel *this_, const char *reason)
|
|||||||
if (autoabandon)
|
if (autoabandon)
|
||||||
tfmm::disconnectAndAbandon();
|
tfmm::disconnectAndAbandon();
|
||||||
hacks::shared::autojoin::onShutdown();
|
hacks::shared::autojoin::onShutdown();
|
||||||
|
std::string message = reason;
|
||||||
|
votelogger::onShutdown(message);
|
||||||
if (*random_name)
|
if (*random_name)
|
||||||
{
|
{
|
||||||
static TextFile file;
|
static TextFile file;
|
||||||
|
@ -13,11 +13,13 @@ static settings::Bool vote_kicky{ "votelogger.autovote.yes", "false" };
|
|||||||
static settings::Bool vote_kickn{ "votelogger.autovote.no", "false" };
|
static settings::Bool vote_kickn{ "votelogger.autovote.no", "false" };
|
||||||
static settings::Bool vote_rage_vote{ "votelogger.autovote.no.rage", "false" };
|
static settings::Bool vote_rage_vote{ "votelogger.autovote.no.rage", "false" };
|
||||||
static settings::Bool party_say{ "votelogger.partysay", "true" };
|
static settings::Bool party_say{ "votelogger.partysay", "true" };
|
||||||
|
static settings::Bool abandon_and_crash_on_kick{ "votelogger.restart-on-kick", "false" };
|
||||||
|
|
||||||
namespace votelogger
|
namespace votelogger
|
||||||
{
|
{
|
||||||
|
|
||||||
static bool was_local_player{ false };
|
static bool was_local_player{ false };
|
||||||
|
static Timer local_kick_timer{};
|
||||||
|
|
||||||
static void vote_rage_back()
|
static void vote_rage_back()
|
||||||
{
|
{
|
||||||
@ -79,7 +81,10 @@ void dispatchUserMessage(bf_read &buffer, int type)
|
|||||||
|
|
||||||
logging::Info("Vote called to kick %s [U:1:%u] for %s by %s [U:1:%u]", info.name, info.friendsID, reason, info2.name, info2.friendsID);
|
logging::Info("Vote called to kick %s [U:1:%u] for %s by %s [U:1:%u]", info.name, info.friendsID, reason, info2.name, info2.friendsID);
|
||||||
if (eid == LOCAL_E->m_IDX)
|
if (eid == LOCAL_E->m_IDX)
|
||||||
|
{
|
||||||
was_local_player = true;
|
was_local_player = true;
|
||||||
|
local_kick_timer.update();
|
||||||
|
}
|
||||||
|
|
||||||
if (*vote_kickn || *vote_kicky)
|
if (*vote_kickn || *vote_kicky)
|
||||||
{
|
{
|
||||||
@ -108,10 +113,12 @@ void dispatchUserMessage(bf_read &buffer, int type)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 47:
|
case 47:
|
||||||
|
{
|
||||||
logging::Info("Vote passed");
|
logging::Info("Vote passed");
|
||||||
// if (was_local_player && requeue)
|
// if (was_local_player && requeue)
|
||||||
// tfmm::startQueue();
|
// tfmm::startQueue();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 48:
|
case 48:
|
||||||
logging::Info("Vote failed");
|
logging::Info("Vote failed");
|
||||||
break;
|
break;
|
||||||
@ -122,6 +129,43 @@ void dispatchUserMessage(bf_read &buffer, int type)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static bool found_message = false;
|
||||||
|
void onShutdown(std::string message)
|
||||||
|
{
|
||||||
|
if (message.find("Generic_Kicked") == message.npos)
|
||||||
|
{
|
||||||
|
found_message = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (local_kick_timer.check(60000) || !was_local_player)
|
||||||
|
{
|
||||||
|
found_message = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (abandon_and_crash_on_kick)
|
||||||
|
{
|
||||||
|
found_message = true;
|
||||||
|
g_IEngine->ClientCmd_Unrestricted("tf_party_leave");
|
||||||
|
local_kick_timer.update();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
found_message = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setup_paint_abandon()
|
||||||
|
{
|
||||||
|
EC::Register(
|
||||||
|
EC::Paint,
|
||||||
|
[]() {
|
||||||
|
if (!found_message)
|
||||||
|
return;
|
||||||
|
if (local_kick_timer.check(60000) || !local_kick_timer.test_and_set(10000) || !was_local_player)
|
||||||
|
return;
|
||||||
|
if (abandon_and_crash_on_kick)
|
||||||
|
*(int *) 0 = 0;
|
||||||
|
},
|
||||||
|
"vote_abandon_restart");
|
||||||
|
}
|
||||||
|
|
||||||
static void setup_vote_rage()
|
static void setup_vote_rage()
|
||||||
{
|
{
|
||||||
@ -136,6 +180,7 @@ static void reset_vote_rage()
|
|||||||
static InitRoutine init([]() {
|
static InitRoutine init([]() {
|
||||||
if (*vote_rage_vote)
|
if (*vote_rage_vote)
|
||||||
setup_vote_rage();
|
setup_vote_rage();
|
||||||
|
setup_paint_abandon();
|
||||||
|
|
||||||
vote_rage_vote.installChangeCallback([](settings::VariableBase<bool> &var, bool new_val) {
|
vote_rage_vote.installChangeCallback([](settings::VariableBase<bool> &var, bool new_val) {
|
||||||
if (new_val)
|
if (new_val)
|
||||||
|
Reference in New Issue
Block a user