asdddd
This commit is contained in:
parent
9776c4c8ab
commit
fd5951d018
@ -111,22 +111,33 @@ void AimAt(IClientEntity* entity, CUserCmd* cmd) {
|
|||||||
interfaces::engineClient->SetViewAngles(a);
|
interfaces::engineClient->SetViewAngles(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HPyroBot::ShouldTarget(IClientEntity* ent) {
|
/*
|
||||||
if (!ent || ent->IsDormant()) return false;
|
* pick target
|
||||||
if (ent->GetClientClass()->m_ClassID != 241) return false;
|
* if can't pick target:
|
||||||
if (GetEntityValue<char>(ent, eoffsets.iLifeState)) return false;
|
* 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<char>(ent, eoffsets.iLifeState)) return 3;
|
||||||
bool enemy = GetEntityValue<int>(ent, eoffsets.iTeamNum) != g_pLocalPlayer->team;
|
bool enemy = GetEntityValue<int>(ent, eoffsets.iTeamNum) != g_pLocalPlayer->team;
|
||||||
if (enemy) {
|
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;
|
bool a = false;
|
||||||
for (int i = 0; i < 17; i++) {
|
for (int i = 0; i < 17; i++) {
|
||||||
if (IsEntityVisible(ent, i)) a = true;
|
if (IsEntityVisible(ent, i)) a = true;
|
||||||
}
|
}
|
||||||
if (!a) return false;
|
if (!a) return 6;
|
||||||
if (abs(ent->GetAbsOrigin().z - g_pLocalPlayer->v_Origin.z) > v_iMaxDeltaY->GetInt()) return false;
|
if (abs(ent->GetAbsOrigin().z - g_pLocalPlayer->v_Origin.z) > v_iMaxDeltaY->GetInt()) return 7;
|
||||||
return true;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HPyroBot::Tick(CUserCmd* cmd) {
|
void HPyroBot::Tick(CUserCmd* cmd) {
|
||||||
@ -136,15 +147,15 @@ void HPyroBot::Tick(CUserCmd* cmd) {
|
|||||||
IClientEntity* target = GetTarget();
|
IClientEntity* target = GetTarget();
|
||||||
IClientEntity* target_old = target;
|
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) {
|
if (target_lost && g_bState == bot_state_t::FOLLOWING_ENEMY) {
|
||||||
g_bState = bot_state_t::PILOT_SEARCH;
|
g_bState = bot_state_t::PILOT_SEARCH;
|
||||||
nPilotSearch++;
|
nPilotSearch++;
|
||||||
SetTarget(0);
|
//SetTarget(0);
|
||||||
target = 0;
|
//target = 0;
|
||||||
}
|
}
|
||||||
if (target_lost && (g_bState == bot_state_t::FOLLOWING_TEAMMATE || g_bState == bot_state_t::PILOT_SEARCH)) {
|
if (target_lost && (g_bState == bot_state_t::FOLLOWING_TEAMMATE || g_bState == bot_state_t::PILOT_SEARCH)) {
|
||||||
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) {
|
if ((g_nTick % 400 == 0) || target_lost) {
|
||||||
for (int i = 0; i < 64 && i < interfaces::entityList->GetMaxEntities(); i++) {
|
for (int i = 0; i < 64 && i < interfaces::entityList->GetMaxEntities(); i++) {
|
||||||
IClientEntity* ent = interfaces::entityList->GetClientEntity(i);
|
IClientEntity* ent = interfaces::entityList->GetClientEntity(i);
|
||||||
if (!ShouldTarget(ent)) continue;
|
if (ShouldTarget(ent)) continue;
|
||||||
bool enemy = GetEntityValue<int>(ent, eoffsets.iTeamNum) != g_pLocalPlayer->team;
|
bool enemy = GetEntityValue<int>(ent, eoffsets.iTeamNum) != g_pLocalPlayer->team;
|
||||||
ProcessEntity(ent, enemy);
|
ProcessEntity(ent, enemy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
target = GetTarget();
|
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_lost) {
|
||||||
if (target_old != 0) {
|
if (target_old != 0) {
|
||||||
@ -185,7 +196,7 @@ void HPyroBot::Tick(CUserCmd* cmd) {
|
|||||||
//logging::Info("Target lost! State: %i, %i", !!target, !!ShouldTarget(target));
|
//logging::Info("Target lost! State: %i, %i", !!target, !!ShouldTarget(target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
if (ShouldTarget(target) != 6 && (nPilotSearch < 100)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target != target_old) {
|
if (target != target_old) {
|
||||||
|
@ -22,7 +22,7 @@ public:
|
|||||||
void PaintTraverse(void*, unsigned int, bool, bool);
|
void PaintTraverse(void*, unsigned int, bool, bool);
|
||||||
void ProcessEntity(IClientEntity* entity, bool enemy);
|
void ProcessEntity(IClientEntity* entity, bool enemy);
|
||||||
void Tick(CUserCmd*);
|
void Tick(CUserCmd*);
|
||||||
bool ShouldTarget(IClientEntity* ent);
|
int ShouldTarget(IClientEntity* ent);
|
||||||
ConCommand* cmd_Status;
|
ConCommand* cmd_Status;
|
||||||
ConVar* v_bEnabled;
|
ConVar* v_bEnabled;
|
||||||
ConVar* v_iForceFollow;
|
ConVar* v_iForceFollow;
|
||||||
|
@ -281,6 +281,7 @@ bool IsEntityVisible(IClientEntity* entity, int hb) {
|
|||||||
Vector hit;
|
Vector hit;
|
||||||
int ret = GetHitboxPosition(entity, hb, hit);
|
int ret = GetHitboxPosition(entity, hb, hit);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
logging::Info("Couldn't get hitbox position: %i", hb);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ray.Init(local->GetAbsOrigin() + GetEntityValue<Vector>(local, eoffsets.vViewOffset), hit);
|
ray.Init(local->GetAbsOrigin() + GetEntityValue<Vector>(local, eoffsets.vViewOffset), hit);
|
||||||
|
Reference in New Issue
Block a user