MOre fixes and NavBot improves
This commit is contained in:
parent
5eccd108d5
commit
6e22ffa94b
@ -257,8 +257,9 @@ void smart_crouch()
|
||||
}
|
||||
|
||||
CatCommand print_ammo("debug_print_ammo", "debug", []() {
|
||||
if (CE_BAD(LOCAL_E) || !LOCAL_E->m_bAlivePlayer())
|
||||
if (CE_BAD(LOCAL_E) || !LOCAL_E->m_bAlivePlayer() || CE_BAD(LOCAL_W))
|
||||
return;
|
||||
logging::Info("Current slot: %d", re::C_BaseCombatWeapon::GetSlot(RAW_ENT(LOCAL_W)));
|
||||
for (int i = 0; i < 10; i++)
|
||||
logging::Info("Ammo Table %d: %d", i, CE_INT(LOCAL_E, netvar.m_iAmmo + i * 4));
|
||||
});
|
||||
@ -267,6 +268,7 @@ static Timer report_timer{};
|
||||
static std::string health = "Health: 0/0";
|
||||
static std::string ammo = "Ammo: 0/0";
|
||||
static int max_ammo;
|
||||
static CachedEntity *local_w;
|
||||
// TODO: add more stuffs
|
||||
static HookedFunction cm(HF_CreateMove, "catbot", 5, []() {
|
||||
if (!*catbotmode)
|
||||
@ -274,10 +276,15 @@ static HookedFunction cm(HF_CreateMove, "catbot", 5, []() {
|
||||
|
||||
if (CE_GOOD(LOCAL_E))
|
||||
{
|
||||
if (LOCAL_W != local_w)
|
||||
{
|
||||
local_w = LOCAL_W;
|
||||
max_ammo = 0;
|
||||
}
|
||||
float max_hp = g_pPlayerResource->GetMaxHealth(LOCAL_E);
|
||||
float curr_hp = CE_INT(LOCAL_E, netvar.iHealth);
|
||||
int ammo0 = CE_INT(LOCAL_E, netvar.m_iAmmo + 4);
|
||||
int ammo2 = CE_INT(LOCAL_E, netvar.m_iAmmo + 8);
|
||||
int ammo0 = CE_INT(LOCAL_E, netvar.m_iClip2);
|
||||
int ammo2 = CE_INT(LOCAL_E, netvar.m_iClip1);
|
||||
if (ammo0 + ammo2 > max_ammo)
|
||||
max_ammo = ammo0 + ammo2;
|
||||
health = format("Health: ", curr_hp, "/", max_hp);
|
||||
|
@ -390,6 +390,39 @@ static void autoJump()
|
||||
current_user_cmd->buttons |= IN_JUMP;
|
||||
}
|
||||
|
||||
enum slots
|
||||
{
|
||||
primary = 1,
|
||||
secondary = 2,
|
||||
melee = 3
|
||||
};
|
||||
static int GetBestSlot()
|
||||
{
|
||||
|
||||
switch (g_pLocalPlayer->clazz)
|
||||
{
|
||||
case tf_scout:
|
||||
{
|
||||
float nearest_dist = getNearestPlayerDistance().second;
|
||||
if (nearest_dist < 700)
|
||||
return primary;
|
||||
else
|
||||
return secondary;
|
||||
}
|
||||
case tf_heavy:
|
||||
return primary;
|
||||
default:
|
||||
{
|
||||
float nearest_dist = getNearestPlayerDistance().second;
|
||||
if (nearest_dist > 500)
|
||||
return primary;
|
||||
else
|
||||
return secondary;
|
||||
}
|
||||
}
|
||||
return primary;
|
||||
}
|
||||
|
||||
static void updateSlot()
|
||||
{
|
||||
static Timer slot_timer{};
|
||||
@ -402,7 +435,7 @@ static void updateSlot()
|
||||
if (re::C_BaseCombatWeapon::IsBaseCombatWeapon(weapon))
|
||||
{
|
||||
int slot = re::C_BaseCombatWeapon::GetSlot(weapon);
|
||||
int newslot = 1;
|
||||
int newslot = GetBestSlot();
|
||||
if (slot != newslot - 1)
|
||||
g_IEngine->ClientCmd_Unrestricted(format("slot", newslot).c_str());
|
||||
}
|
||||
|
@ -32,26 +32,38 @@ weaponmode GetWeaponModeloc()
|
||||
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))
|
||||
switch (classid)
|
||||
{
|
||||
case CL_CLASS(CTFLunchBox):
|
||||
case CL_CLASS(CTFLunchBox_Drink):
|
||||
case 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))
|
||||
{
|
||||
case CL_CLASS(CTFRocketLauncher_DirectHit):
|
||||
case CL_CLASS(CTFRocketLauncher):
|
||||
case CL_CLASS(CTFGrenadeLauncher):
|
||||
case CL_CLASS(CTFPipebombLauncher):
|
||||
case CL_CLASS(CTFCompoundBow):
|
||||
case CL_CLASS(CTFBat_Wood):
|
||||
case CL_CLASS(CTFBat_Giftwrap):
|
||||
case CL_CLASS(CTFFlareGun):
|
||||
case CL_CLASS(CTFFlareGun_Revenge):
|
||||
case CL_CLASS(CTFSyringeGun):
|
||||
case CL_CLASS(CTFCrossbow):
|
||||
case CL_CLASS(CTFShotgunBuildingRescue):
|
||||
case CL_CLASS(CTFDRGPomson):
|
||||
case CL_CLASS(CTFWeaponFlameBall):
|
||||
case CL_CLASS(CTFRaygun):
|
||||
case CL_CLASS(CTFGrapplingHook):
|
||||
return weaponmode::weapon_projectile;
|
||||
}
|
||||
else if (classid == CL_CLASS(CTFJar) || classid == CL_CLASS(CTFJarMilk))
|
||||
{
|
||||
case CL_CLASS(CTFJar):
|
||||
case CL_CLASS(CTFJarMilk):
|
||||
return weaponmode::weapon_throwable;
|
||||
}
|
||||
else if (classid == CL_CLASS(CWeaponMedigun))
|
||||
{
|
||||
case CL_CLASS(CWeaponMedigun):
|
||||
return weaponmode::weapon_medigun;
|
||||
default:
|
||||
return weaponmode::weapon_hitscan;
|
||||
}
|
||||
return weaponmode::weapon_hitscan;
|
||||
}
|
||||
void LocalPlayer::Update()
|
||||
{
|
||||
|
Reference in New Issue
Block a user