Upgrade CanShoot!

This commit is contained in:
LightCat 2018-10-20 14:50:43 +02:00
parent 59e58925bf
commit f2fee90358
4 changed files with 33 additions and 5 deletions

View File

@ -27,4 +27,7 @@ extern settings::Bool clean_screenshots;
extern settings::Bool crypt_chat;
extern settings::Bool nolerp;
extern settings::Bool no_zoom;
extern settings::Bool disable_visuals;
extern settings::Bool disable_visuals;
void SetCanshootStatus();
extern bool CanShootException;

15
src/MiscTemporary.cpp Executable file → Normal file
View File

@ -16,6 +16,21 @@ int prevflowticks = 0;
bool *bSendPackets{ nullptr };
bool CanShootException = false;
void SetCanshootStatus()
{
static int lastammo = -1;
static int prevweaponclass = -1;
if (LOCAL_W->m_iClassID() != prevweaponclass)
lastammo = -1;
if (lastammo == 0 && CE_INT(g_pLocalPlayer->weapon(), netvar.m_iClip1))
CanShootException = true;
else
CanShootException = false;
lastammo = CE_INT(g_pLocalPlayer->weapon(), netvar.m_iClip1);
prevweaponclass = LOCAL_W->m_iClassID();
}
settings::Bool crypt_chat{ "chat.crypto", "true" };
settings::Bool clean_screenshots{ "visual.clean-screenshots", "false" };
settings::Bool nolerp{ "misc.no-lerp", "false" };

View File

@ -6,6 +6,7 @@
*/
#include "common.hpp"
#include "MiscTemporary.hpp"
#include <sys/mman.h>
#include <settings/Bool.hpp>
@ -1251,12 +1252,19 @@ bool CanHeadshot()
bool CanShoot()
{
static float servertime, lastfire, nextattack;
float servertime, nextattack;
float currfire = CE_FLOAT(g_pLocalPlayer->weapon(), netvar.flLastFireTime);
servertime = (float) (CE_INT(g_pLocalPlayer->entity, netvar.nTickBase)) *
g_GlobalVars->interval_per_tick;
nextattack = CE_FLOAT(g_pLocalPlayer->weapon(), netvar.flNextPrimaryAttack);
if (lastfire != currfire)
{
lastfire = currfire;
nextattack = CE_FLOAT(g_pLocalPlayer->weapon(), netvar.flNextPrimaryAttack);
}
servertime = (float) (CE_INT(g_pLocalPlayer->entity, netvar.nTickBase)) * g_GlobalVars->interval_per_tick;
if (CanShootException)
return true;
return nextattack <= servertime;
}

View File

@ -257,6 +257,8 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time,
PROF_SECTION(CM_LocalPlayer);
g_pLocalPlayer->Update();
}
if (CE_GOOD(LOCAL_E) && !g_pLocalPlayer->life_state && CE_GOOD(LOCAL_W))
SetCanshootStatus();
if (firstcm)
{
DelayTimer.update();