AFK check
This commit is contained in:
parent
1ad0582caf
commit
d6a9132003
@ -50,10 +50,12 @@ static CatVar always_medigun(CV_SWITCH, "fb_always_medigun", "0",
|
|||||||
"Always Medigun", "Always use medigun");
|
"Always Medigun", "Always use medigun");
|
||||||
static CatVar sync_taunt(CV_SWITCH, "fb_sync_taunt", "0", "Synced taunt",
|
static CatVar sync_taunt(CV_SWITCH, "fb_sync_taunt", "0", "Synced taunt",
|
||||||
"Taunt when follow target does");
|
"Taunt when follow target does");
|
||||||
static CatVar change(CV_SWITCH, "fb_switch", "1", "Change followbot target",
|
static CatVar change(CV_SWITCH, "fb_switch", "0", "Change followbot target",
|
||||||
"Always change roaming target when possible");
|
"Always change roaming target when possible");
|
||||||
static CatVar autojump(CV_SWITCH, "fb_autojump", "1", "Autojump",
|
static CatVar autojump(CV_SWITCH, "fb_autojump", "1", "Autojump",
|
||||||
"Automatically jump if stuck");
|
"Automatically jump if stuck");
|
||||||
|
static CatVar afk(CV_SWITCH, "fb_afk", "1", "Switch target if AFK",
|
||||||
|
"Automatically switch target if the target is afk");
|
||||||
|
|
||||||
// Something to store breadcrumbs created by followed players
|
// Something to store breadcrumbs created by followed players
|
||||||
static std::vector<Vector> breadcrumbs;
|
static std::vector<Vector> breadcrumbs;
|
||||||
@ -61,7 +63,10 @@ static const int crumb_limit = 64; // limit
|
|||||||
|
|
||||||
// Followed entity, externed for highlight color
|
// Followed entity, externed for highlight color
|
||||||
int follow_target = 0;
|
int follow_target = 0;
|
||||||
long int lasttaunt;
|
|
||||||
|
long int lasttaunt; //time since epoch when "taunt" was last executed
|
||||||
|
int lasttarget; //target we should not follow again
|
||||||
|
int tickswasted; //how many createmove ticks we have wasted because a target is afk
|
||||||
|
|
||||||
void WorldTick()
|
void WorldTick()
|
||||||
{
|
{
|
||||||
@ -133,6 +138,8 @@ void WorldTick()
|
|||||||
continue;
|
continue;
|
||||||
if (entity->m_bEnemy())
|
if (entity->m_bEnemy())
|
||||||
continue;
|
continue;
|
||||||
|
if (i == lasttarget) //don't follow target that was determined afk
|
||||||
|
continue;
|
||||||
if (IsPlayerDisguised(entity) || IsPlayerInvisible(entity))
|
if (IsPlayerDisguised(entity) || IsPlayerInvisible(entity))
|
||||||
continue;
|
continue;
|
||||||
if (!entity->m_bAlivePlayer()) // Dont follow dead players
|
if (!entity->m_bAlivePlayer()) // Dont follow dead players
|
||||||
@ -162,6 +169,7 @@ void WorldTick()
|
|||||||
continue;
|
continue;
|
||||||
// ooooo, a target
|
// ooooo, a target
|
||||||
follow_target = entity->m_IDX;
|
follow_target = entity->m_IDX;
|
||||||
|
tickswasted = 0; //set afk ticks to 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// last check for entity before we continue
|
// last check for entity before we continue
|
||||||
@ -173,11 +181,31 @@ void WorldTick()
|
|||||||
if (CE_BAD(followtar))
|
if (CE_BAD(followtar))
|
||||||
return;
|
return;
|
||||||
// Check if we are following a disguised/spy
|
// Check if we are following a disguised/spy
|
||||||
if (IsPlayerDisguised(entity) || IsPlayerInvisible(entity))
|
if (IsPlayerDisguised(followtar) || IsPlayerInvisible(followtar))
|
||||||
{
|
{
|
||||||
follow_target = 0;
|
follow_target = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//check if player is afk
|
||||||
|
if (afk)
|
||||||
|
{
|
||||||
|
if (CE_VECTOR(followtar, netvar.vVelocity).IsZero(1.0f))
|
||||||
|
{
|
||||||
|
tickswasted = tickswasted + 1;
|
||||||
|
if (tickswasted >= 990)
|
||||||
|
{
|
||||||
|
lasttarget = follow_target;
|
||||||
|
follow_target = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tickswasted = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Update timer on new target
|
// Update timer on new target
|
||||||
static Timer idle_time{};
|
static Timer idle_time{};
|
||||||
if (breadcrumbs.empty())
|
if (breadcrumbs.empty())
|
||||||
@ -233,8 +261,7 @@ void WorldTick()
|
|||||||
if (dist_to_target > (float) follow_distance)
|
if (dist_to_target > (float) follow_distance)
|
||||||
{
|
{
|
||||||
// Check for idle
|
// Check for idle
|
||||||
if (autojump && (idle_time.check(3000) ||
|
if (autojump && idle_time.check(3000))
|
||||||
(breadcrumbs.size() > 1 && LOCAL_E->m_vecVelocity.IsZero(5.0f))))
|
|
||||||
g_pUserCmd->buttons |= IN_JUMP;
|
g_pUserCmd->buttons |= IN_JUMP;
|
||||||
if (idle_time.test_and_set(5000))
|
if (idle_time.test_and_set(5000))
|
||||||
{
|
{
|
||||||
|
@ -222,11 +222,11 @@ rgba_t EffectChams::ChamsColor(IClientEntity *entity)
|
|||||||
|
|
||||||
bool EffectChams::ShouldRenderChams(IClientEntity *entity)
|
bool EffectChams::ShouldRenderChams(IClientEntity *entity)
|
||||||
{
|
{
|
||||||
|
if (!enable)
|
||||||
|
return false;
|
||||||
if (entity->entindex() < 0)
|
if (entity->entindex() < 0)
|
||||||
return false;
|
return false;
|
||||||
CachedEntity *ent = ENTITY(entity->entindex());
|
CachedEntity *ent = ENTITY(entity->entindex());
|
||||||
if (CE_BAD(ent))
|
|
||||||
return false;
|
|
||||||
if (ent->m_IDX == LOCAL_E->m_IDX && !chamsself)
|
if (ent->m_IDX == LOCAL_E->m_IDX && !chamsself)
|
||||||
return false;
|
return false;
|
||||||
switch (ent->m_Type())
|
switch (ent->m_Type())
|
||||||
@ -317,13 +317,9 @@ void EffectChams::RenderChamsRecursive(IClientEntity *entity)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectChams::RenderChams(int idx)
|
|
||||||
void EffectChams::RenderChams(IClientEntity *entity)
|
void EffectChams::RenderChams(IClientEntity *entity)
|
||||||
{
|
{
|
||||||
CMatRenderContextPtr ptr(GET_RENDER_CONTEXT);
|
CMatRenderContextPtr ptr(GET_RENDER_CONTEXT);
|
||||||
IClientEntity *entity = g_IEntityList->GetClientEntity(idx);
|
|
||||||
if (entity && !entity->IsDormant())
|
|
||||||
{
|
|
||||||
if (ShouldRenderChams(entity))
|
if (ShouldRenderChams(entity))
|
||||||
{
|
{
|
||||||
rgba_t color = ChamsColor(entity);
|
rgba_t color = ChamsColor(entity);
|
||||||
@ -347,7 +343,6 @@ void EffectChams::RenderChams(IClientEntity *entity)
|
|||||||
g_IVModelRender->ForcedMaterialOverride(flat ? mat_unlit
|
g_IVModelRender->ForcedMaterialOverride(flat ? mat_unlit
|
||||||
: mat_lit);
|
: mat_lit);
|
||||||
RenderChamsRecursive(entity);
|
RenderChamsRecursive(entity);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -365,7 +360,9 @@ void EffectChams::Render(int x, int y, int w, int h)
|
|||||||
BeginRenderChams();
|
BeginRenderChams();
|
||||||
for (int i = 1; i < HIGHEST_ENTITY; i++)
|
for (int i = 1; i < HIGHEST_ENTITY; i++)
|
||||||
{
|
{
|
||||||
RenderChams(i);
|
IClientEntity *entity = g_IEntityList->GetClientEntity(i);
|
||||||
|
if (!entity || entity->IsDormant() || CE_BAD(ENTITY(i)))
|
||||||
|
return;
|
||||||
RenderChams(entity);
|
RenderChams(entity);
|
||||||
}
|
}
|
||||||
EndRenderChams();
|
EndRenderChams();
|
||||||
|
Reference in New Issue
Block a user