Fix crashes caused by tf2 update and fix punch angle

This commit is contained in:
BenCat07 2021-11-17 16:00:52 +01:00
parent 59a0e4b8a4
commit 2e5a2ae82f
5 changed files with 43 additions and 25 deletions

View File

@ -42,19 +42,19 @@ public:
}
void Load(IClientEntity *weapon)
{
crit_bucket = *(float *) ((uintptr_t) weapon + 0xa38);
weapon_seed = *(unsigned int *) ((uintptr_t) weapon + 0xb3c);
unknown1 = *(unsigned int *) ((uintptr_t) weapon + 0xb30);
unknown2 = *(unsigned int *) ((uintptr_t) weapon + 0xb34);
unknown3 = *(bool *) ((uintptr_t) weapon + 0xb17);
m_flCritTime = *(float *) ((uintptr_t) weapon + 0xb40);
crit_attempts = *(int *) ((uintptr_t) weapon + 0xa3c);
crit_count = *(int *) ((uintptr_t) weapon + 0xa40);
observed_crit_chance = *(float *) ((uintptr_t) weapon + 0xbfc);
unknown7 = *(bool *) ((uintptr_t) weapon + 0xb18);
crit_bucket = *(float *) ((uintptr_t) weapon + 0xa3c);
weapon_seed = *(unsigned int *) ((uintptr_t) weapon + 0xb40);
unknown1 = *(unsigned int *) ((uintptr_t) weapon + 0xb34);
unknown2 = *(unsigned int *) ((uintptr_t) weapon + 0xb38);
unknown3 = *(bool *) ((uintptr_t) weapon + 0xb1b);
m_flCritTime = *(float *) ((uintptr_t) weapon + 0xb44);
crit_attempts = *(int *) ((uintptr_t) weapon + 0xa40);
crit_count = *(int *) ((uintptr_t) weapon + 0xa44);
observed_crit_chance = *(float *) ((uintptr_t) weapon + 0xc00);
unknown7 = *(bool *) ((uintptr_t) weapon + 0xb1c);
// No need to restore
weapon_mode = *(int *) ((uintptr_t) weapon + 0xb04);
weapon_data = *(int *) ((uintptr_t) weapon + 0xb10);
weapon_mode = *(int *) ((uintptr_t) weapon + 0xb08);
weapon_data = *(int *) ((uintptr_t) weapon + 0xb14);
}
weapon_info(IClientEntity *weapon)
{
@ -62,16 +62,16 @@ public:
}
void restore_data(IClientEntity *weapon)
{
*(float *) ((uintptr_t) weapon + 0xa38) = crit_bucket;
*(unsigned int *) ((uintptr_t) weapon + 0xb3c) = weapon_seed;
*(unsigned int *) ((uintptr_t) weapon + 0xb30) = unknown1;
*(unsigned int *) ((uintptr_t) weapon + 0xb34) = unknown2;
*(bool *) ((uintptr_t) weapon + 0xb17) = unknown3;
*(float *) ((uintptr_t) weapon + 0xb40) = m_flCritTime;
*(int *) ((uintptr_t) weapon + 0xa3c) = crit_attempts;
*(int *) ((uintptr_t) weapon + 0xa40) = crit_count;
*(float *) ((uintptr_t) weapon + 0xbfc) = observed_crit_chance;
*(bool *) ((uintptr_t) weapon + 0xb18) = unknown7;
*(float *) ((uintptr_t) weapon + 0xa3c) = crit_bucket;
*(unsigned int *) ((uintptr_t) weapon + 0xb40) = weapon_seed;
*(unsigned int *) ((uintptr_t) weapon + 0xb34) = unknown1;
*(unsigned int *) ((uintptr_t) weapon + 0xb38) = unknown2;
*(bool *) ((uintptr_t) weapon + 0xb1b) = unknown3;
*(float *) ((uintptr_t) weapon + 0xb44) = m_flCritTime;
*(int *) ((uintptr_t) weapon + 0xa40) = crit_attempts;
*(int *) ((uintptr_t) weapon + 0xa44) = crit_count;
*(float *) ((uintptr_t) weapon + 0xc00) = observed_crit_chance;
*(bool *) ((uintptr_t) weapon + 0xb1c) = unknown7;
}
bool operator==(const weapon_info &B) const
{

View File

@ -1157,6 +1157,24 @@ static CatCommand debug_print_crit_info("debug_print_crit_info", "Print a bunch
}
});
static CatCommand debug_data("debug_data", "debug",
[]()
{
IClientEntity *wep = RAW_ENT(LOCAL_W);
weapon_info info(wep);
logging::Info("%f", info.crit_bucket);
logging::Info("%d", info.weapon_seed);
logging::Info("%d", info.unknown1);
logging::Info("%d", info.unknown2);
logging::Info("%d", info.unknown3);
logging::Info("%f", info.m_flCritTime);
logging::Info("%d", info.crit_attempts);
logging::Info("%d", info.crit_count);
logging::Info("%f", info.observed_crit_chance);
logging::Info("%d", info.unknown7);
logging::Info("%d", info.weapon_mode);
logging::Info("%d", info.weapon_data);
});
static InitRoutine init(
[]()
{

View File

@ -1118,7 +1118,7 @@ void Aim(CachedEntity *entity)
return;
// Get angles from eye to target
Vector angles = GetAimAtAngles(g_pLocalPlayer->v_Eye, PredictEntity(entity, false));
Vector angles = GetAimAtAngles(g_pLocalPlayer->v_Eye, PredictEntity(entity, false), LOCAL_E);
// Slow aim
if (slow_aim)

View File

@ -1104,7 +1104,7 @@ static InitRoutine init(
static BytePatch stealth_kill{ gSignatures.GetClientSignature, "84 C0 75 28 A1", 2, { 0x90, 0x90 } }; // stealth kill patch
stealth_kill.Patch();
static BytePatch cyoa_patch{ gSignatures.GetClientSignature, "74 20 A1 ? ? ? ? 8B 10 C7 44 24 ? ? ? ? ? 89 04 24", 0, { 0xEB } };
static BytePatch cyoa_patch{ gSignatures.GetClientSignature, "75 ? 80 BB ? ? ? ? 00 74 ? A1 ? ? ? ? 8B 10 C7 44 24", 0, { 0xEB } };
cyoa_patch.Patch();
EC::Register(
EC::Shutdown,

View File

@ -1515,7 +1515,7 @@ Vector GetForwardVector(Vector origin, Vector viewangles, float distance, Cached
QAngle angle = VectorToQAngle(viewangles);
// Compensate for punch angle
if (punch_entity && should_correct_punch)
angle += VectorToQAngle(CE_VECTOR(punch_entity, netvar.vecPunchAngle));
angle -= VectorToQAngle(CE_VECTOR(punch_entity, netvar.vecPunchAngle));
sy = sinf(DEG2RAD(angle[1]));
cy = cosf(DEG2RAD(angle[1]));