Anti holidaypunch and some optimizations

This commit is contained in:
LightCat 2018-11-10 19:32:49 +01:00
parent b012a07401
commit 6c86ae7524
3 changed files with 70 additions and 63 deletions

View File

@ -67,17 +67,20 @@ CachedEntity *ClosestSpy()
if (CE_BYTE(ent, netvar.iLifeState))
continue;
bool ispyro = false;
bool isheavy = false;
if (CE_INT(ent, netvar.iClass) != tf_class::tf_spy)
{
if (CE_INT(ent, netvar.iClass) != tf_class::tf_pyro)
if (CE_INT(ent, netvar.iClass) != tf_class::tf_pyro && CE_INT(ent, netvar.iClass) != tf_class::tf_heavy)
continue;
int idx = CE_INT(ent, netvar.hActiveWeapon) & 0xFFF;
if (IDX_BAD(idx))
continue;
CachedEntity *pyro_weapon = ENTITY(idx);
int widx = CE_INT(pyro_weapon, netvar.iItemDefinitionIndex);
if (widx != 40 && widx != 1146)
if (widx != 40 && widx != 1146 && widx != 656)
continue;
if (widx == 656)
isheavy = true;
ispyro = true;
}
if (CE_INT(ent, netvar.iTeamNum) == g_pLocalPlayer->team)
@ -85,13 +88,13 @@ CachedEntity *ClosestSpy()
if (IsPlayerInvisible(ent))
continue;
dist = ent->m_flDistance();
if (fabs(GetAngle(ent)) > (float) angle)
if (fabs(GetAngle(ent)) > (float) angle || (ispyro && !isheavy && fabs(GetAngle(ent)) > 90.0f) || (isheavy && fabs(GetAngle(ent)) > 132.0f))
{
break;
// logging::Info("Backstab???");
}
if ((((!ispyro && dist < (float) distance)) ||
(ispyro && dist < 314.0f)) &&
(ispyro && !isheavy && dist < 314.0f) || (isheavy && dist < 120.0f)) &&
(dist < closest_dist || !closest_dist))
{
closest_dist = dist;
@ -117,8 +120,8 @@ void CreateMove()
const Vector &A = LOCAL_E->m_vecOrigin();
const Vector &B = spy->m_vecOrigin();
diff = (A - B);
if (diff.y < 0)
current_user_cmd->viewangles.x = 160.0f;
if (diff.y < 0 || CE_INT(spy, netvar.iClass) == tf_class::tf_heavy)
current_user_cmd->viewangles.x = 180.0f;
if (silent)
g_pLocalPlayer->bUseSilentAngles = true;
if (sayno)

View File

@ -891,62 +891,7 @@ bool IsProjectileCrit(CachedEntity *ent)
weaponmode GetWeaponMode()
{
int weapon_handle, slot;
CachedEntity *weapon;
if (CE_BAD(LOCAL_E) | CE_BAD(LOCAL_W))
return weapon_invalid;
weapon_handle = CE_INT(LOCAL_E, netvar.hActiveWeapon);
if (IDX_BAD((weapon_handle & 0xFFF)))
{
// logging::Info("IDX_BAD: %i", weapon_handle & 0xFFF);
return weaponmode::weapon_invalid;
}
weapon = (ENTITY(weapon_handle & 0xFFF));
if (CE_BAD(weapon))
return weaponmode::weapon_invalid;
int classid = weapon->m_iClassID();
slot = re::C_BaseCombatWeapon::GetSlot(RAW_ENT(weapon));
if (slot == 2)
return weaponmode::weapon_melee;
if (slot > 2)
{
return weaponmode::weapon_pda;
}
else if (classid == CL_CLASS(CTFLunchBox) ||
classid == CL_CLASS(CTFLunchBox_Drink) ||
classid == CL_CLASS(CTFBuffItem))
{
return weaponmode::weapon_consumable;
}
else if (classid == CL_CLASS(CTFRocketLauncher_DirectHit) ||
classid == CL_CLASS(CTFRocketLauncher) ||
classid == CL_CLASS(CTFGrenadeLauncher) ||
classid == CL_CLASS(CTFPipebombLauncher) ||
classid == CL_CLASS(CTFCompoundBow) ||
classid == CL_CLASS(CTFBat_Wood) ||
classid == CL_CLASS(CTFBat_Giftwrap) ||
classid == CL_CLASS(CTFFlareGun) ||
classid == CL_CLASS(CTFFlareGun_Revenge) ||
classid == CL_CLASS(CTFSyringeGun) ||
classid == CL_CLASS(CTFCrossbow) ||
classid == CL_CLASS(CTFShotgunBuildingRescue) ||
classid == CL_CLASS(CTFDRGPomson) ||
classid == CL_CLASS(CTFWeaponFlameBall) ||
classid == CL_CLASS(CTFRaygun) ||
classid == CL_CLASS(CTFGrapplingHook))
{
return weaponmode::weapon_projectile;
}
else if (classid == CL_CLASS(CTFJar) || classid == CL_CLASS(CTFJarMilk))
{
return weaponmode::weapon_throwable;
}
else if (classid == CL_CLASS(CWeaponMedigun))
{
return weaponmode::weapon_medigun;
}
return weaponmode::weapon_hitscan;
return g_pLocalPlayer->weapon_mode;
}
bool LineIntersectsBox(Vector &bmin, Vector &bmax, Vector &lmin, Vector &lmax)

View File

@ -12,6 +12,65 @@ CatCommand printfov("fov_print", "Dump achievements to file (development)",
if (CE_GOOD(LOCAL_E))
logging::Info("%d", CE_INT(LOCAL_E, netvar.iFOV));
});
weaponmode GetWeaponModeloc()
{
int weapon_handle, slot;
CachedEntity *weapon;
if (CE_BAD(LOCAL_E) | CE_BAD(LOCAL_W))
return weapon_invalid;
weapon_handle = CE_INT(LOCAL_E, netvar.hActiveWeapon);
if (IDX_BAD((weapon_handle & 0xFFF)))
{
// logging::Info("IDX_BAD: %i", weapon_handle & 0xFFF);
return weaponmode::weapon_invalid;
}
weapon = (ENTITY(weapon_handle & 0xFFF));
if (CE_BAD(weapon))
return weaponmode::weapon_invalid;
int classid = weapon->m_iClassID();
slot = re::C_BaseCombatWeapon::GetSlot(RAW_ENT(weapon));
if (slot == 2)
return weaponmode::weapon_melee;
if (slot > 2)
{
return weaponmode::weapon_pda;
}
else if (classid == CL_CLASS(CTFLunchBox) ||
classid == CL_CLASS(CTFLunchBox_Drink) ||
classid == CL_CLASS(CTFBuffItem))
{
return weaponmode::weapon_consumable;
}
else if (classid == CL_CLASS(CTFRocketLauncher_DirectHit) ||
classid == CL_CLASS(CTFRocketLauncher) ||
classid == CL_CLASS(CTFGrenadeLauncher) ||
classid == CL_CLASS(CTFPipebombLauncher) ||
classid == CL_CLASS(CTFCompoundBow) ||
classid == CL_CLASS(CTFBat_Wood) ||
classid == CL_CLASS(CTFBat_Giftwrap) ||
classid == CL_CLASS(CTFFlareGun) ||
classid == CL_CLASS(CTFFlareGun_Revenge) ||
classid == CL_CLASS(CTFSyringeGun) ||
classid == CL_CLASS(CTFCrossbow) ||
classid == CL_CLASS(CTFShotgunBuildingRescue) ||
classid == CL_CLASS(CTFDRGPomson) ||
classid == CL_CLASS(CTFWeaponFlameBall) ||
classid == CL_CLASS(CTFRaygun) ||
classid == CL_CLASS(CTFGrapplingHook))
{
return weaponmode::weapon_projectile;
}
else if (classid == CL_CLASS(CTFJar) || classid == CL_CLASS(CTFJarMilk))
{
return weaponmode::weapon_throwable;
}
else if (classid == CL_CLASS(CWeaponMedigun))
{
return weaponmode::weapon_medigun;
}
return weaponmode::weapon_hitscan;
}
void LocalPlayer::Update()
{
CachedEntity *wep;
@ -28,7 +87,7 @@ void LocalPlayer::Update()
wep = weapon();
if (CE_GOOD(wep))
{
weapon_mode = GetWeaponMode();
weapon_mode = GetWeaponModeloc();
if (wep->m_iClassID() == CL_CLASS(CTFSniperRifle) ||
wep->m_iClassID() == CL_CLASS(CTFSniperRifleDecap))
holding_sniper_rifle = true;