From fd5951d0183c8256604f7999a819ce4ef0d19932 Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Sun, 30 Oct 2016 22:24:29 +0300 Subject: [PATCH] asdddd --- uran/src/hacks/HPyroBot.cpp | 43 +++++++++++++++++++++++-------------- uran/src/hacks/HPyroBot.h | 2 +- uran/src/helpers.cpp | 1 + 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/uran/src/hacks/HPyroBot.cpp b/uran/src/hacks/HPyroBot.cpp index f6207fc5..3ee962f3 100644 --- a/uran/src/hacks/HPyroBot.cpp +++ b/uran/src/hacks/HPyroBot.cpp @@ -111,22 +111,33 @@ void AimAt(IClientEntity* entity, CUserCmd* cmd) { interfaces::engineClient->SetViewAngles(a); } -bool HPyroBot::ShouldTarget(IClientEntity* ent) { - if (!ent || ent->IsDormant()) return false; - if (ent->GetClientClass()->m_ClassID != 241) return false; - if (GetEntityValue(ent, eoffsets.iLifeState)) return false; +/* + * pick target + * if can't pick target: + * forward + * follow + * if can't follow: + * goto pick target + * if at shooting distance: + * shoot + */ + +int HPyroBot::ShouldTarget(IClientEntity* ent) { + if (!ent || ent->IsDormant()) return 1; + if (ent->GetClientClass()->m_ClassID != 241) return 2; + if (GetEntityValue(ent, eoffsets.iLifeState)) return 3; bool enemy = GetEntityValue(ent, eoffsets.iTeamNum) != g_pLocalPlayer->team; if (enemy) { - if (IsPlayerInvulnerable(ent)) return false; + if (IsPlayerInvulnerable(ent)) return 4; } - if (DistToSqr(ent) > (v_iMaxDistance->GetInt() * v_iMaxDistance->GetInt())) return false; + if (DistToSqr(ent) > (v_iMaxDistance->GetInt() * v_iMaxDistance->GetInt())) return 5; bool a = false; for (int i = 0; i < 17; i++) { if (IsEntityVisible(ent, i)) a = true; } - if (!a) return false; - if (abs(ent->GetAbsOrigin().z - g_pLocalPlayer->v_Origin.z) > v_iMaxDeltaY->GetInt()) return false; - return true; + if (!a) return 6; + if (abs(ent->GetAbsOrigin().z - g_pLocalPlayer->v_Origin.z) > v_iMaxDeltaY->GetInt()) return 7; + return 0; } void HPyroBot::Tick(CUserCmd* cmd) { @@ -136,15 +147,15 @@ void HPyroBot::Tick(CUserCmd* cmd) { IClientEntity* target = GetTarget(); IClientEntity* target_old = target; - bool target_lost = (!target || !ShouldTarget(target) || g_bState == bot_state_t::PILOT_SEARCH); + bool target_lost = (!target || ShouldTarget(target) || (g_bState != bot_state_t::FOLLOWING_ENEMY && g_bState != bot_state_t::FOLLOWING_TEAMMATE)); - if (target_lost) logging::Info("Target lost! Target: %i, State: %i, ShouldTarget: %i", target, g_bState, ShouldTarget(target)); + if (target_lost && g_bState != bot_state_t::PILOT_SEARCH) logging::Info("Target lost! Target: %i, State: %i, ShouldTarget: %i", target, g_bState, ShouldTarget(target)); if (target_lost && g_bState == bot_state_t::FOLLOWING_ENEMY) { g_bState = bot_state_t::PILOT_SEARCH; nPilotSearch++; - SetTarget(0); - target = 0; + //SetTarget(0); + //target = 0; } if (target_lost && (g_bState == bot_state_t::FOLLOWING_TEAMMATE || g_bState == bot_state_t::PILOT_SEARCH)) { g_bState = bot_state_t::PILOT_SEARCH; @@ -165,14 +176,14 @@ void HPyroBot::Tick(CUserCmd* cmd) { if ((g_nTick % 400 == 0) || target_lost) { for (int i = 0; i < 64 && i < interfaces::entityList->GetMaxEntities(); i++) { IClientEntity* ent = interfaces::entityList->GetClientEntity(i); - if (!ShouldTarget(ent)) continue; + if (ShouldTarget(ent)) continue; bool enemy = GetEntityValue(ent, eoffsets.iTeamNum) != g_pLocalPlayer->team; ProcessEntity(ent, enemy); } } target = GetTarget(); - target_lost = (!target || !ShouldTarget(target) || g_bState == bot_state_t::IDLE || g_bState == bot_state_t::PILOT_SEARCH || g_bState == bot_state_t::TARGET_LOST); + target_lost = (!target || ShouldTarget(target) || g_bState == bot_state_t::IDLE || g_bState == bot_state_t::PILOT_SEARCH || g_bState == bot_state_t::TARGET_LOST); if (target_lost) { if (target_old != 0) { @@ -185,7 +196,7 @@ void HPyroBot::Tick(CUserCmd* cmd) { //logging::Info("Target lost! State: %i, %i", !!target, !!ShouldTarget(target)); } } - return; + if (ShouldTarget(target) != 6 && (nPilotSearch < 100)) return; } if (target != target_old) { diff --git a/uran/src/hacks/HPyroBot.h b/uran/src/hacks/HPyroBot.h index af0a4c65..9bfe7c84 100644 --- a/uran/src/hacks/HPyroBot.h +++ b/uran/src/hacks/HPyroBot.h @@ -22,7 +22,7 @@ public: void PaintTraverse(void*, unsigned int, bool, bool); void ProcessEntity(IClientEntity* entity, bool enemy); void Tick(CUserCmd*); - bool ShouldTarget(IClientEntity* ent); + int ShouldTarget(IClientEntity* ent); ConCommand* cmd_Status; ConVar* v_bEnabled; ConVar* v_iForceFollow; diff --git a/uran/src/helpers.cpp b/uran/src/helpers.cpp index 3ee8e873..66ea34d4 100644 --- a/uran/src/helpers.cpp +++ b/uran/src/helpers.cpp @@ -281,6 +281,7 @@ bool IsEntityVisible(IClientEntity* entity, int hb) { Vector hit; int ret = GetHitboxPosition(entity, hb, hit); if (ret) { + logging::Info("Couldn't get hitbox position: %i", hb); return false; } ray.Init(local->GetAbsOrigin() + GetEntityValue(local, eoffsets.vViewOffset), hit);