Move pathfinding related code to ai.cpp.

Add a gsc.hpp header to allow creating methods and functions for GSC outside of the gsc component. Add experimental path generating code to ai.cpp.
This commit is contained in:
JezuzLizard
2023-03-29 20:15:05 -07:00
parent 4135e7653a
commit 6461aa85d3
7 changed files with 452 additions and 111 deletions

View File

@ -441,6 +441,55 @@ namespace game
return answer;
}
pathnode_t* Path_NearestNodeNotCrossPlanes(float maxDistSq, float maxHeightSq, float* vOrigin, pathsort_t* nodes, float a5, int a6, int a7, int a8, int* returnCount, int a10)
{
static const auto call_addr = SELECT(0x0, 0x55C210);
pathnode_t* answer;
__asm
{
push a10;
push returnCount;
push a8;
push a7;
push a6;
push a5;
push nodes;
push vOrigin;
movss xmm0, maxHeightSq;
movss xmm1, maxDistSq;
call call_addr;
add esp, 0x20;
mov answer, eax;
}
return answer;
}
int Path_FindPathFromTo(float* startPos, pathnode_t* pNodeTo, path_t* pPath, team_t eTeam, pathnode_t* pNodeFrom, float* vGoalPos, int bAllowNegotiationLinks, int bIgnoreBadplaces)
{
static const auto call_addr = SELECT(0x0, 0x4CF3F0);
int answer;
__asm
{
push bIgnoreBadplaces;
push bAllowNegotiationLinks;
push vGoalPos;
push pNodeFrom;
push eTeam;
push pPath;
mov edx, pNodeTo;
mov eax, startPos;
call call_addr;
mov answer, eax;
}
return answer;
}
namespace plutonium
{
}

View File

@ -57,6 +57,8 @@ namespace game
const char* SL_ConvertToString(scriptInstance_t inst, int id);
int Path_FindPath(path_t* pPath, team_t eTeam, float* vStartPos, float* vGoalPos, int bAllowNegotiationLinks);
pathnode_t* Path_NearestNodeNotCrossPlanes(float maxDistSq, float maxHeightSq, float* vOrigin, pathsort_t* nodes, float a5, int a6, int a7, int a8, int* returnCount, int a10);
int Path_FindPathFromTo(float* startPos, pathnode_t* pNodeTo, path_t* pPath, team_t eTeam, pathnode_t* pNodeFrom, float* vGoalPos, int bAllowNegotiationLinks, int bIgnoreBadplaces);
template <typename T>
class symbol

View File

@ -1590,6 +1590,14 @@ namespace game
pathlocal_t_circle circle;
};
struct CustomSearchInfo_FindPath
{
pathnode_t* m_pNodeTo;
float startPos[3];
float negotiationOverlapCost;
};
enum VariableType
{
VAR_UNDEFINED = 0x0,

View File

@ -12,6 +12,8 @@ namespace game
WEAK symbol<void(scriptInstance_t inst)> Scr_AddArray { 0x0, 0x69AA50 };
WEAK symbol<unsigned int(scriptInstance_t inst, char* string, int user, unsigned int len)> SL_GetStringOfSize { 0x0, 0x68DE50 };
WEAK symbol<int(path_t* pPath, team_t eTeam, const float* vStartPos, pathnode_t* pNodeFrom, const float* vGoalPos, int bAllowNegotiationLinks, CustomSearchInfo_FindPath* custom, int bIncludeGoalInPath, pathnode_t* bIgnoreBadPlaces)> Path_AStarAlgorithm_CustomSearchInfo_FindPath_{ 0x0, 0x4D3190 };
// Variables
WEAK symbol<cmd_function_s*> cmd_functions{ 0x0, 0x1F416F4 };
@ -25,6 +27,8 @@ namespace game
WEAK symbol<scrVmPub_t> scrVmPub{ 0x0, 0x3BD4700 };
WEAK symbol<dvar_s*> ai_pathNegotiationOverlapCost{ 0x0, 0x18FB224 };
namespace plutonium
{
}