diff --git a/src/hacks/Walkbot.cpp b/src/hacks/Walkbot.cpp index 5f4311c9..fefeeb00 100644 --- a/src/hacks/Walkbot.cpp +++ b/src/hacks/Walkbot.cpp @@ -180,8 +180,23 @@ using state::nodes; using state::node_good; bool HasLowAmmo() { - // Yes, I know m_iAmmo is a table, not an int. - return CE_INT(LOCAL_E, netvar.m_iAmmo); + // 0x13D = CBaseCombatWeapon::HasPrimaryAmmo() + // 190 = IsBaseCombatWeapon + // 1C1 = C_TFWeaponBase::UsesPrimaryAmmo() + int *weapon_list = (int*)((unsigned)(RAW_ENT(LOCAL_E)) + netvar.hMyWeapons); + for (int i = 0; weapon_list[i]; i++) { + int handle = weapon_list[i]; + int eid = handle & 0xFFF; + if (eid >= 32 && eid <= HIGHEST_ENTITY) { + IClientEntity* weapon = g_IEntityList->GetClientEntity(eid); + if (weapon and vfunc(weapon, 190, 0)(weapon) and + vfunc(weapon, 0x1C1, 0)(weapon) and + not vfunc(weapon, 0x13D, 0)(weapon)) { + return true; + } + } + } + return false; } bool HasLowHealth() { diff --git a/src/helpers.cpp b/src/helpers.cpp index 2c0ca978..6d427130 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -75,6 +75,7 @@ ConVar* CreateConVar(std::string name, std::string value, std::string help) { // Function for when you want to goto a vector void WalkTo(const Vector& vector) { + if (CE_BAD(LOCAL_E)) return; // Calculate how to get to a vector auto result = ComputeMove(LOCAL_E->m_vecOrigin, vector); // Push our move to usercmd