This repository has been archived by the owner on Feb 4, 2024. It is now read-only.
Is there a better way to get player states? #472
Answered
by
Xsintashi
MesuDevastator
asked this question in
Q&A
-
This is how I do it. AntiAim::moving_flag AntiAim::get_moving_flag(const UserCmd* cmd) noexcept
{
if (!localPlayer->getAnimstate()->onGround && cmd->buttons & UserCmd::IN_DUCK)
return latest_moving_flag = duck_jumping;
if (cmd->buttons & UserCmd::IN_DUCK)
return latest_moving_flag = ducking;
if (!localPlayer->getAnimstate()->onGround)
return latest_moving_flag = jumping;
if (localPlayer->velocity().x > 0 || localPlayer->velocity().y > 0 || localPlayer->velocity().z > 0 || localPlayer->velocity().x < 0 || localPlayer->velocity().y < 0 || localPlayer->velocity().z < 0)
{
if (config->misc.slowwalkKey.isActive())
return latest_moving_flag = slow_walking;
return latest_moving_flag = moving;
}
if (config->misc.fakeduckKey.isActive())
return latest_moving_flag = fake_ducking;
return latest_moving_flag = freestanding;
} Dumb but working still. Is there a better way to do it? |
Beta Was this translation helpful? Give feedback.
Answered by
Xsintashi
Jan 12, 2023
Replies: 2 comments 1 reply
-
for for |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
MesuDevastator
-
This is my improved version AntiAim::moving_flag AntiAim::get_moving_flag(const UserCmd* cmd) noexcept
{
if ((EnginePrediction::getFlags() & 3) == 2)
return latest_moving_flag = duck_jumping;
if (EnginePrediction::getFlags() & 2)
return latest_moving_flag = ducking;
if (!localPlayer->getAnimstate()->onGround)
return latest_moving_flag = jumping;
if (localPlayer->velocity().length2D() > 0.f)
{
if (config->misc.slowwalkKey.isActive())
return latest_moving_flag = slow_walking;
return latest_moving_flag = moving;
}
if (config->misc.fakeduckKey.isActive())
return latest_moving_flag = fake_ducking;
return latest_moving_flag = freestanding;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for
is on ground
i recommendif (EnginePrediction::getFlags() & 1)
for
is ducking
i recommendif (EnginePrediction::getFlags() & 2)
for
is not on ground
i recommendif (!EnginePrediction::getFlags() & 1)
for
checking velocity
i recommendif (localPlayer->velocity().length2D() > 0.0f)