WORKING health and ammo connections. close #229

This commit is contained in:
nullifiedcat 2017-07-27 23:32:23 +03:00
parent 8974006bf1
commit 8a72b2abd8
2 changed files with 18 additions and 2 deletions

View File

@ -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<bool(*)(IClientEntity*)>(weapon, 190, 0)(weapon) and
vfunc<bool(*)(IClientEntity*)>(weapon, 0x1C1, 0)(weapon) and
not vfunc<bool(*)(IClientEntity*)>(weapon, 0x13D, 0)(weapon)) {
return true;
}
}
}
return false;
}
bool HasLowHealth() {

View File

@ -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