2022-03-18 03:14:07 +01:00
|
|
|
//=============================================================================//
|
|
|
|
//
|
|
|
|
// Purpose: AI system utility
|
|
|
|
//
|
|
|
|
//=============================================================================//
|
|
|
|
|
|
|
|
#include "core/stdafx.h"
|
2022-04-09 16:16:40 +02:00
|
|
|
#include "tier1/cvar.h"
|
2022-03-18 03:14:07 +01:00
|
|
|
#include "game/server/detour_impl.h"
|
2022-07-20 12:33:39 +02:00
|
|
|
#include "game/server/ai_networkmanager.h"
|
2022-03-18 03:14:07 +01:00
|
|
|
|
2022-07-20 12:33:39 +02:00
|
|
|
inline uint32_t g_pHullMasks[10] = // Hull mask table [r5apex_ds.exe + 131a2f8].
|
2022-03-18 03:14:07 +01:00
|
|
|
{
|
2022-07-20 12:33:39 +02:00
|
|
|
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
|
|
0xfffffffb, 0xfffffffa, 0xfffffff9, 0xfffffff8, 0x00040200
|
|
|
|
};
|
2022-03-18 03:14:07 +01:00
|
|
|
|
2022-07-13 11:42:07 +02:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: gets the navmesh by hull from global array [small, med_short, medium, large, extra_large]
|
|
|
|
// input : hull -
|
|
|
|
// Output : pointer to navmesh
|
|
|
|
//-----------------------------------------------------------------------------
|
2022-07-20 12:33:39 +02:00
|
|
|
dtNavMesh* GetNavMeshForHull(int hullSize)
|
|
|
|
{
|
|
|
|
assert(hullSize >= 0 && hullSize <= 4); // Programmer error.
|
|
|
|
return g_pNavMesh[hullSize];
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: gets hull mask by id
|
|
|
|
// input : hullId -
|
|
|
|
// Output : hull mask
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
uint32_t GetHullMaskById(int hullId)
|
|
|
|
{
|
|
|
|
assert(hullId >= 0 && hullId <= 9); // Programmer error.
|
|
|
|
return (hullId + g_pHullMasks[hullId]);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: determines whether goal poly is reachable from agent poly
|
|
|
|
// input : *nav -
|
|
|
|
// fromRef -
|
|
|
|
// goalRef -
|
|
|
|
// hull_type -
|
|
|
|
// Output : value if reachable, false otherwise
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
uint8_t IsGoalPolyReachable(dtNavMesh* nav, dtPolyRef fromRef, dtPolyRef goalRef, int hullId)
|
2022-07-13 11:42:07 +02:00
|
|
|
{
|
2022-07-20 12:33:39 +02:00
|
|
|
if (navmesh_always_reachable->GetBool())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return v_dtNavMesh__isPolyReachable(nav, fromRef, goalRef, hullId);
|
2022-07-13 11:42:07 +02:00
|
|
|
}
|
|
|
|
|
2022-03-18 03:14:07 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
void CAI_Utility_Attach()
|
|
|
|
{
|
2022-07-20 12:33:39 +02:00
|
|
|
DetourAttach((LPVOID*)&v_dtNavMesh__isPolyReachable, &IsGoalPolyReachable);
|
2022-03-18 03:14:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CAI_Utility_Detach()
|
|
|
|
{
|
2022-07-20 12:33:39 +02:00
|
|
|
DetourDetach((LPVOID*)&v_dtNavMesh__isPolyReachable, &IsGoalPolyReachable);
|
2022-03-18 03:14:07 +01:00
|
|
|
}
|