mirror of
https://github.com/JezuzLizard/T4SP-Server-Plugin.git
synced 2025-04-20 13:35:43 +00:00
Add more path structs.
Add getlinkednodes method for a node. getnodenumber method. getnodebynumber function. generatepath function.
This commit is contained in:
parent
ffdf2c48ba
commit
bb8233cf86
@ -188,7 +188,6 @@ namespace gsc
|
|||||||
std::string string(answer);
|
std::string string(answer);
|
||||||
|
|
||||||
string += " haha funny"s;
|
string += " haha funny"s;
|
||||||
printf((string + "\n"s).data());
|
|
||||||
game::Scr_AddIString(game::SCRIPTINSTANCE_SERVER, string.data());
|
game::Scr_AddIString(game::SCRIPTINSTANCE_SERVER, string.data());
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -210,13 +209,6 @@ namespace gsc
|
|||||||
{
|
{
|
||||||
game::pathnode_t* node = game::Scr_GetPathnode(game::SCRIPTINSTANCE_SERVER);
|
game::pathnode_t* node = game::Scr_GetPathnode(game::SCRIPTINSTANCE_SERVER);
|
||||||
|
|
||||||
printf("Node: %d\n" + node->constant.type);
|
|
||||||
printf("Node: %f\n", node->constant.fRadius);
|
|
||||||
|
|
||||||
printf("Node Targetname %s\n", SL_ConvertToString( game::SCRIPTINSTANCE_SERVER, node->constant.targetname));
|
|
||||||
|
|
||||||
printf("0\n");
|
|
||||||
|
|
||||||
game::Scr_AddPathnode(game::SCRIPTINSTANCE_SERVER, node);
|
game::Scr_AddPathnode(game::SCRIPTINSTANCE_SERVER, node);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -256,7 +248,7 @@ namespace gsc
|
|||||||
|
|
||||||
method::add("entitytest", [](game::scr_entref_s ent)
|
method::add("entitytest", [](game::scr_entref_s ent)
|
||||||
{
|
{
|
||||||
if (ent.classnum != 0)
|
if (ent.classnum != game::CLASS_NUM_ENTITY)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -265,6 +257,86 @@ namespace gsc
|
|||||||
|
|
||||||
game::Scr_AddEntity(game::SCRIPTINSTANCE_SERVER, ent2);
|
game::Scr_AddEntity(game::SCRIPTINSTANCE_SERVER, ent2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
method::add("getlinkednodes", [](game::scr_entref_s ent)
|
||||||
|
{
|
||||||
|
if (ent.classnum != game::CLASS_NUM_PATHNODE)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto primary_node = &(*game::gameWorldCurrent)->path.nodes[ent.entnum];
|
||||||
|
|
||||||
|
game::Scr_MakeArray(game::SCRIPTINSTANCE_SERVER);
|
||||||
|
|
||||||
|
for (auto i = 0; i < primary_node->constant.totalLinkCount; i++)
|
||||||
|
{
|
||||||
|
auto linked_node = &(*game::gameWorldCurrent)->path.nodes[primary_node->constant.Links[i].nodeNum];
|
||||||
|
|
||||||
|
game::Scr_AddPathnode(game::SCRIPTINSTANCE_SERVER, linked_node);
|
||||||
|
game::Scr_AddArray(game::SCRIPTINSTANCE_SERVER);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
method::add("getnodenumber", [](game::scr_entref_s ent)
|
||||||
|
{
|
||||||
|
if (ent.classnum != game::CLASS_NUM_PATHNODE)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto node = &(*game::gameWorldCurrent)->path.nodes[ent.entnum];
|
||||||
|
|
||||||
|
auto entnum = node - (*game::gameWorldCurrent)->path.nodes;
|
||||||
|
|
||||||
|
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, entnum);
|
||||||
|
});
|
||||||
|
|
||||||
|
function::add("getnodebynumber", []()
|
||||||
|
{
|
||||||
|
auto node_num = game::Scr_GetInt(game::SCRIPTINSTANCE_SERVER, 0);
|
||||||
|
|
||||||
|
if (node_num < 0 || node_num >= game::g_path->actualNodeCount)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto node = &(*game::gameWorldCurrent)->path.nodes[node_num];
|
||||||
|
|
||||||
|
game::Scr_AddPathnode(game::SCRIPTINSTANCE_SERVER, node);
|
||||||
|
});
|
||||||
|
|
||||||
|
function::add("generatepath", []()
|
||||||
|
{
|
||||||
|
auto path = std::make_unique<game::path_t>();
|
||||||
|
|
||||||
|
float start_pos[3] = {};
|
||||||
|
|
||||||
|
float goal_pos[3] = {};
|
||||||
|
|
||||||
|
auto team = game::TEAM_ALLIES;
|
||||||
|
|
||||||
|
game::Scr_GetVector(game::SCRIPTINSTANCE_SERVER, 0, start_pos);
|
||||||
|
game::Scr_GetVector(game::SCRIPTINSTANCE_SERVER, 1, goal_pos);
|
||||||
|
|
||||||
|
auto success = game::Path_FindPath(path.get(), team, start_pos, goal_pos, true);
|
||||||
|
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
game::Scr_MakeArray(game::SCRIPTINSTANCE_SERVER);
|
||||||
|
|
||||||
|
for (auto i = 0; i < path->wPathLen; i++)
|
||||||
|
{
|
||||||
|
auto node_in_path = &(*game::gameWorldCurrent)->path.nodes[path->pts[i].iNodeNum];
|
||||||
|
|
||||||
|
game::Scr_AddPathnode(game::SCRIPTINSTANCE_SERVER, node_in_path);
|
||||||
|
game::Scr_AddArray(game::SCRIPTINSTANCE_SERVER);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -282,11 +282,8 @@ namespace game
|
|||||||
|
|
||||||
void Scr_AddPathnode(scriptInstance_t inst, pathnode_t* node)
|
void Scr_AddPathnode(scriptInstance_t inst, pathnode_t* node)
|
||||||
{
|
{
|
||||||
printf("Scr_AddPathnode Targetname %s\n", SL_ConvertToString(game::SCRIPTINSTANCE_SERVER, node->constant.targetname));
|
|
||||||
int entnum = node - (*gameWorldCurrent)->path.nodes;
|
int entnum = node - (*gameWorldCurrent)->path.nodes;
|
||||||
printf("1 entnum: %d\n", entnum);
|
|
||||||
int entid = Scr_GetEntityId(inst, entnum, CLASS_NUM_PATHNODE, 0);
|
int entid = Scr_GetEntityId(inst, entnum, CLASS_NUM_PATHNODE, 0);
|
||||||
printf("2 entid: %d\n", entid);
|
|
||||||
Scr_AddEntityNum(inst, entid);
|
Scr_AddEntityNum(inst, entid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,6 +377,26 @@ namespace game
|
|||||||
return Dvar_RegisterVariant(name, game::DVAR_TYPE_STRING, flags, dvar_value, limits, desc);
|
return Dvar_RegisterVariant(name, game::DVAR_TYPE_STRING, flags, dvar_value, limits, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Path_FindPath(path_t* pPath, team_t eTeam, float* vStartPos, float* vGoalPos, int bAllowNegotiationLinks)
|
||||||
|
{
|
||||||
|
static const auto call_addr = SELECT(0x0, 0x4CF280);
|
||||||
|
|
||||||
|
int answer;
|
||||||
|
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
push bAllowNegotiationLinks;
|
||||||
|
push vGoalPos;
|
||||||
|
push vStartPos;
|
||||||
|
mov edx, eTeam;
|
||||||
|
mov ecx, pPath;
|
||||||
|
call call_addr;
|
||||||
|
mov answer, eax;
|
||||||
|
}
|
||||||
|
|
||||||
|
return answer;
|
||||||
|
}
|
||||||
|
|
||||||
namespace plutonium
|
namespace plutonium
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,8 @@ namespace game
|
|||||||
void Scr_AddArrayStringIndexed(scriptInstance_t inst, unsigned short id); //testing
|
void Scr_AddArrayStringIndexed(scriptInstance_t inst, unsigned short id); //testing
|
||||||
const char* SL_ConvertToString(scriptInstance_t inst, int id); //testing
|
const char* SL_ConvertToString(scriptInstance_t inst, int id); //testing
|
||||||
|
|
||||||
|
int Path_FindPath(path_t* pPath, team_t eTeam, float* vStartPos, float* vGoalPos, int bAllowNegotiationLinks);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class symbol
|
class symbol
|
||||||
{
|
{
|
||||||
|
@ -1417,7 +1417,7 @@ namespace game
|
|||||||
float fOrientLerp;
|
float fOrientLerp;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum nodeType : __int32
|
enum nodeType
|
||||||
{
|
{
|
||||||
NODE_BADNODE = 0x0,
|
NODE_BADNODE = 0x0,
|
||||||
NODE_PATHNODE = 0x1,
|
NODE_PATHNODE = 0x1,
|
||||||
@ -1550,4 +1550,41 @@ namespace game
|
|||||||
PathData path;
|
PathData path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PathLinkInfo
|
||||||
|
{
|
||||||
|
unsigned __int16 from;
|
||||||
|
unsigned __int16 to;
|
||||||
|
unsigned __int16 prev;
|
||||||
|
unsigned __int16 next;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct pathsort_t
|
||||||
|
{
|
||||||
|
pathnode_t* node;
|
||||||
|
float metric;
|
||||||
|
float distMetric;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct pathlocal_t_circle
|
||||||
|
{
|
||||||
|
float origin[3];
|
||||||
|
float maxDist;
|
||||||
|
float maxDistSq;
|
||||||
|
float maxHeight;
|
||||||
|
float maxHeightSq;
|
||||||
|
int typeFlags;
|
||||||
|
pathsort_t* nodes;
|
||||||
|
int maxNodes;
|
||||||
|
int nodeCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct __declspec(align(128)) pathlocal_t
|
||||||
|
{
|
||||||
|
PathLinkInfo pathLinkInfoArray[2048];
|
||||||
|
int pathLinkInfoArrayInited;
|
||||||
|
unsigned int actualNodeCount;
|
||||||
|
unsigned int extraNodes;
|
||||||
|
unsigned int originErrors;
|
||||||
|
pathlocal_t_circle circle;
|
||||||
|
};
|
||||||
}
|
}
|
@ -19,6 +19,8 @@ namespace game
|
|||||||
|
|
||||||
WEAK symbol<GameWorldSp*> gameWorldCurrent{ 0x0, 0x8E1D80 };
|
WEAK symbol<GameWorldSp*> gameWorldCurrent{ 0x0, 0x8E1D80 };
|
||||||
|
|
||||||
|
WEAK symbol<pathlocal_t> g_path{ 0x0, 0x1F2F700 };
|
||||||
|
|
||||||
WEAK symbol<gentity_s> g_entities{ 0x0, 0x176C6F0 };
|
WEAK symbol<gentity_s> g_entities{ 0x0, 0x176C6F0 };
|
||||||
|
|
||||||
namespace plutonium
|
namespace plutonium
|
||||||
|
Loading…
x
Reference in New Issue
Block a user