Address some PR issues and improve engineer navbot
Also fixes an issue with ipc + party
This commit is contained in:
parent
896cd82bd1
commit
ed8a626766
@ -114,7 +114,7 @@ void fClampAngle(Vector &qaAng);
|
||||
bool GetProjectileData(CachedEntity *weapon, float &speed, float &gravity);
|
||||
bool IsVectorVisible(Vector a, Vector b, bool enviroment_only = false, CachedEntity *self = LOCAL_E, unsigned int mask = MASK_SHOT_HULL);
|
||||
// A Special function for navparser to check if a Vector is visible.
|
||||
bool IsVectorVisibleNavigation(Vector a, Vector b, CachedEntity *self = LOCAL_E, unsigned int mask = MASK_SHOT_HULL);
|
||||
bool IsVectorVisibleNavigation(Vector a, Vector b, unsigned int mask = MASK_SHOT_HULL);
|
||||
Vector GetForwardVector(Vector origin, Vector viewangles, float distance);
|
||||
Vector GetForwardVector(float distance);
|
||||
CachedEntity *getClosestEntity(Vector vec);
|
||||
|
@ -43,14 +43,11 @@ public:
|
||||
};
|
||||
class FilterNavigation : public ITraceFilter
|
||||
{
|
||||
public:
|
||||
IClientEntity *m_pSelf;
|
||||
|
||||
public:
|
||||
virtual ~FilterNavigation();
|
||||
FilterNavigation();
|
||||
virtual bool ShouldHitEntity(IHandleEntity *entity, int mask);
|
||||
void SetSelf(IClientEntity *self);
|
||||
virtual TraceType_t GetTraceType() const;
|
||||
};
|
||||
|
||||
|
@ -102,7 +102,7 @@ constexpr bot_class_config DIST_SNIPER{ 1000.0f, 1500.0f, 3000.0f };
|
||||
constexpr bot_class_config DIST_ENGINEER{ 600.0f, 1000.0f, 2500.0f };
|
||||
|
||||
// Gunslinger Engineers really don't care at all
|
||||
constexpr bot_class_config DIST_GUNSLINGER_ENGINEER{ 100.0f, 300.0f, 500.0f };
|
||||
constexpr bot_class_config DIST_GUNSLINGER_ENGINEER{ 50.0f, 200.0f, 900.0f };
|
||||
|
||||
inline bool HasGunslinger(CachedEntity *ent)
|
||||
{
|
||||
@ -122,7 +122,7 @@ static void CreateMove()
|
||||
else
|
||||
current_task = task::none;
|
||||
// Check if we should path at all
|
||||
if (!blocking)
|
||||
if (!blocking || task::current_task == task::engineer)
|
||||
{
|
||||
round_states round_state = g_pTeamRoundTimer->GetRoundState();
|
||||
// Still in setuptime, if on fitting team, then do not path yet
|
||||
@ -481,7 +481,7 @@ static success_build buildBuilding()
|
||||
build_attempts++;
|
||||
// Put building in hand if not already
|
||||
if (hacks::shared::misc::getCarriedBuilding() == -1 && build_command_timer.test_and_set(50))
|
||||
g_IEngine->ClientCmd_Unrestricted(format("build ", building).c_str());
|
||||
g_IEngine->ClientCmd_Unrestricted(("build " + std::to_string(building)).c_str());
|
||||
}
|
||||
else if (rotation_timer.check(200))
|
||||
{
|
||||
@ -555,9 +555,47 @@ static bool engineerLogic()
|
||||
return true;
|
||||
}
|
||||
|
||||
// Let's terrify some people (gunslinger engineer)
|
||||
// Gunslinger engineer should run at people, given their building isn't too far away
|
||||
if (HasGunslinger(LOCAL_E))
|
||||
{
|
||||
// Deconstruct too far away buildings
|
||||
for (auto &building : local_buildings)
|
||||
{
|
||||
// Too far away, destroy it
|
||||
if (building->m_vecOrigin().DistTo(LOCAL_E->m_vecOrigin()) >= 1800.0f)
|
||||
{
|
||||
Building building_type = None;
|
||||
switch (building->m_iClassID())
|
||||
{
|
||||
case CL_CLASS(CObjectDispenser):
|
||||
{
|
||||
building_type = Dispenser;
|
||||
break;
|
||||
}
|
||||
case CL_CLASS(CObjectTeleporter):
|
||||
{
|
||||
// We cannot reliably detect entrance and exit, so just destruct both but mark as "Entrance"
|
||||
building_type = TP_Entrace;
|
||||
break;
|
||||
}
|
||||
case CL_CLASS(CObjectSentrygun):
|
||||
{
|
||||
building_type = Sentry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// If we have a valid building
|
||||
if (building_type != None)
|
||||
{
|
||||
// Destroy exit too because we have no idea what is what
|
||||
if (building_type == TP_Entrace)
|
||||
g_IEngine->ClientCmd_Unrestricted("destroy 3");
|
||||
g_IEngine->ClientCmd_Unrestricted(("destroy " + std::to_string(building_type)).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
stayNearEngineer();
|
||||
}
|
||||
|
||||
else if (selectBuilding() != None)
|
||||
{
|
||||
@ -657,11 +695,8 @@ static bool engineerLogic()
|
||||
else if (engineer_recheck.test_and_set(15000))
|
||||
{
|
||||
if (navToBuildingSpot())
|
||||
{
|
||||
engineer_recheck.update();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Build building
|
||||
@ -918,10 +953,8 @@ static bool stayNearEngineer()
|
||||
}
|
||||
|
||||
static Timer wait_until_stay_near{};
|
||||
if (current_task == task::engineer_task::staynear_engineer)
|
||||
{
|
||||
if (current_engineer_task == task::engineer_task::staynear_engineer)
|
||||
return true;
|
||||
}
|
||||
else if (wait_until_stay_near.test_and_set(4000))
|
||||
{
|
||||
// We're doing nothing? Do something!
|
||||
|
@ -1362,12 +1362,11 @@ bool IsVectorVisible(Vector origin, Vector target, bool enviroment_only, CachedE
|
||||
}
|
||||
}
|
||||
|
||||
bool IsVectorVisibleNavigation(Vector origin, Vector target, CachedEntity *self, unsigned int mask)
|
||||
bool IsVectorVisibleNavigation(Vector origin, Vector target, unsigned int mask)
|
||||
{
|
||||
trace_t trace_visible;
|
||||
Ray_t ray;
|
||||
|
||||
trace::filter_no_entity.SetSelf(RAW_ENT(self));
|
||||
ray.Init(origin, target);
|
||||
PROF_SECTION(IEVV_TraceRay);
|
||||
g_ITrace->TraceRay(ray, mask, &trace::filter_navigation, &trace_visible);
|
||||
|
@ -104,7 +104,7 @@ static ignore_status vischeck(CNavArea *begin, CNavArea *end)
|
||||
first.z += 70;
|
||||
second.z += 70;
|
||||
// Is world blocking it?
|
||||
if (IsVectorVisibleNavigation(first, second, LOCAL_E, MASK_PLAYERSOLID))
|
||||
if (IsVectorVisibleNavigation(first, second, MASK_PLAYERSOLID))
|
||||
{
|
||||
// Is something else blocking it?
|
||||
if (!IsVectorVisible(first, second, true, LOCAL_E, MASK_PLAYERSOLID))
|
||||
@ -418,11 +418,7 @@ struct Graph : public micropather::Graph
|
||||
continue;
|
||||
float distance = center->m_center.DistTo(i.area->m_center);
|
||||
if (isIgnored == 1)
|
||||
{
|
||||
if (*vischeckBlock)
|
||||
continue;
|
||||
distance += 50000;
|
||||
}
|
||||
distance += 1000;
|
||||
adjacent->emplace_back(micropather::StateCost{ reinterpret_cast<void *>(neighbour), distance });
|
||||
}
|
||||
}
|
||||
@ -528,7 +524,7 @@ CNavArea *findClosestNavSquare(const Vector &vec)
|
||||
bestSquare = &i;
|
||||
}
|
||||
// Check if we are within x and y bounds of an area
|
||||
if (ovBestDist >= dist || !i.IsOverlapping(vec) || !IsVectorVisibleNavigation(vec, i.m_center, LOCAL_E, MASK_PLAYERSOLID))
|
||||
if (ovBestDist >= dist || !i.IsOverlapping(vec) || !IsVectorVisibleNavigation(vec, i.m_center, MASK_PLAYERSOLID))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -708,7 +704,7 @@ static void cm()
|
||||
|
||||
// Update jump timer now
|
||||
if (flip_action)
|
||||
last_jump.test_and_set(200);
|
||||
last_jump.update();
|
||||
flip_action = !flip_action;
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ bool ChangeState(unsigned int steamid, k_EState state, bool force)
|
||||
else
|
||||
return false;
|
||||
case k_EState::PARTY:
|
||||
if (state == k_EState::TEXTMODE || state == k_EState::FRIEND)
|
||||
if (state == k_EState::FRIEND)
|
||||
{
|
||||
ChangeState(steamid, state, true);
|
||||
return true;
|
||||
|
@ -111,23 +111,10 @@ TraceType_t trace::FilterNoPlayer::GetTraceType() const
|
||||
|
||||
/* Navigation filter */
|
||||
|
||||
trace::FilterNavigation::FilterNavigation()
|
||||
{
|
||||
m_pSelf = nullptr;
|
||||
}
|
||||
trace::FilterNavigation::FilterNavigation(){};
|
||||
|
||||
trace::FilterNavigation::~FilterNavigation(){};
|
||||
|
||||
void trace::FilterNavigation::SetSelf(IClientEntity *self)
|
||||
{
|
||||
if (self == nullptr)
|
||||
{
|
||||
logging::Info("nullptr in FilterNavigation::SetSelf");
|
||||
return;
|
||||
}
|
||||
m_pSelf = self;
|
||||
}
|
||||
|
||||
#define MOVEMENT_COLLISION_GROUP 8
|
||||
#define RED_CONTENTS_MASK 0x800
|
||||
#define BLU_CONTENTS_MASK 0x1000
|
||||
|
Reference in New Issue
Block a user