Add codecallback_actorspawned, and codecallback_hudelemspawned.

Reimplement the generatePath() builtin to use a custom implementation to handle drop down nodes.
This commit is contained in:
JezuzLizard
2023-04-28 20:22:44 -07:00
parent a80b6929cd
commit f23df3ca3f
10 changed files with 732 additions and 302 deletions

View File

@ -43,9 +43,57 @@ namespace game
push scriptInstance;
mov eax, codepos;
call call_addr;
add esp, 0xC;
}
}
void RemoveRefToObject(scriptInstance_t inst/*<ecx>*/, unsigned int id/*<eax>*/)
{
static const auto call_addr = SELECT(0x0, 0x690040);
__asm
{
mov ecx, inst;
mov eax, id;
call call_addr;
}
}
int Scr_LoadScript(const char* file, scriptInstance_t inst)
{
static const auto call_addr = SELECT(0x646DE0, 0x689C60);
int answer;
__asm
{
mov ecx, file;
mov edx, inst;
call call_addr;
mov answer, eax;
}
return answer;
}
unsigned int Scr_GetFunctionHandle/*<eax>*/(scriptInstance_t inst/*<ecx>*/, const char* file/*<eax>*/, const char* handle)
{
static const auto call_addr = SELECT(0x0, 0x6894B0);
unsigned int answer;
__asm
{
push handle;
mov eax, file;
mov ecx, inst;
call call_addr;
mov answer, eax;
add esp, 0x4;
}
return answer;
}
int Scr_GetInt(game::scriptInstance_t inst, unsigned int arg_index)
{
static const auto call_addr = SELECT(0x0, 0x699C50);
@ -71,7 +119,7 @@ namespace game
push value;
mov eax, inst;
call call_addr;
add esp, 4;
add esp, 0x4;
}
}
@ -100,7 +148,7 @@ namespace game
push value;
mov eax, inst;
call call_addr;
add esp, 4;
add esp, 0x4;
}
}
@ -129,7 +177,7 @@ namespace game
push string;
mov eax, inst;
call call_addr;
add esp, 4;
add esp, 0x4;
}
}
@ -172,7 +220,7 @@ namespace game
mov eax, inst;
call call_addr;
mov answer, cx;
add esp, 4;
add esp, 0x4;
}
return answer;
@ -200,7 +248,7 @@ namespace game
mov ecx, value;
mov eax, inst;
call call_addr;
add esp, 4;
add esp, 0x4;
}
}
@ -213,7 +261,7 @@ namespace game
push value;
mov eax, inst;
call call_addr;
add esp, 4;
add esp, 0x4;
}
}
@ -310,6 +358,24 @@ namespace game
Scr_AddEntityNum(inst, entid);
}
void Scr_AddHudElem(game_hudelem_s* hud)
{
int entId = Scr_GetEntityId(SCRIPTINSTANCE_SERVER, hud - g_hudelems, CLASS_NUM_HUDELEM, 0);
Scr_AddObject(SCRIPTINSTANCE_SERVER, entId);
}
void Scr_AddObject(scriptInstance_t inst/*<eax>*/, int entid/*<esi>*/)
{
static const auto call_addr = SELECT(0x0, 0x69A770);
__asm
{
mov esi, entid;
mov eax, inst;
call call_addr;
}
}
void Scr_MakeArray(scriptInstance_t inst)
{
static const auto call_addr = SELECT(0x0, 0x69A9D0);
@ -333,6 +399,46 @@ namespace game
}
}
unsigned short Scr_ExecThread/*<ax>*/(scriptInstance_t inst/*<edi>*/, int handle, int paramCount)
{
static const auto call_addr = SELECT(0x0, 0x699560);
unsigned short answer;
__asm
{
push paramCount;
push handle;
mov edi, inst;
call call_addr;
add esp, 0x8;
mov answer, ax;
}
return answer;
}
unsigned short Scr_ExecEntThread/*<ax>*/(scriptInstance_t inst/*<edi>*/, int entNum, int handle, int numParams, int entClass)
{
static const auto call_addr = SELECT(0x0, 0x699640);
unsigned short answer;
__asm
{
push entClass;
push numParams;
push handle;
push entNum;
mov edi, inst;
call call_addr;
add esp, 0x10;
mov answer, ax;
}
return answer;
}
unsigned int Scr_GetNumParam(scriptInstance_t inst)
{
return gScrVmPub[inst].outparamcount;
@ -364,7 +470,7 @@ namespace game
mov edi, inst;
mov ecx, err;
call call_addr;
add esp, 4;
add esp, 0x4;
}
}
@ -529,6 +635,57 @@ namespace game
return answer;
}
void /*__userpurge*/ Path_UpdateLookahead(path_t* pPath/*@<eax>*/, const float* vStartPos, int bReduceLookaheadAmount, int a4, int bAllowBacktrack)
{
static const auto call_addr = SELECT(0x0, 0x4D2120);
__asm
{
push bAllowBacktrack;
push a4;
push bReduceLookaheadAmount;
push vStartPos;
mov eax, pPath;
call call_addr;
}
}
void /*__usercall*/ Path_AddTrimmedAmount(const float* a1/*@<eax>*/, path_t* a2/*@<edi>*/)
{
static const auto call_addr = SELECT(0x0, 0x4CE560);
__asm
{
mov edi, a2;
mov eax, a1;
call call_addr;
}
}
void /*__stdcall*/ Path_TransferLookahead(path_t* a1, const float* a2)
{
static const auto call_addr = SELECT(0x0, 0x4CE980);
__asm
{
push a2;
push a1;
call call_addr;
}
}
void Sentient_GetVelocity(sentient_s* self, float* vVelOut)
{
static const auto call_addr = SELECT(0x0, 0x5662A0);
__asm
{
mov ecx, vVelOut;
mov eax, self;
call call_addr;
}
}
namespace plutonium
{
}

View File

@ -24,6 +24,9 @@ namespace game
extern std::map<std::string, team_t> team_map;
void Scr_PrintPrevCodePos(const char* codepos, int scriptInstance, con_channel_e channel, int index);
void RemoveRefToObject(scriptInstance_t inst, unsigned int id);
int Scr_LoadScript(const char* file, scriptInstance_t inst);
unsigned int Scr_GetFunctionHandle(scriptInstance_t inst, const char* file, const char* handle);
const char* Cmd_Argv(int index);
unsigned int Cmd_Argc();
@ -51,8 +54,12 @@ namespace game
void Scr_AddEntityNum(scriptInstance_t inst, unsigned int entid);
pathnode_t* Scr_GetPathnode(scriptInstance_t inst);
void Scr_AddPathnode(scriptInstance_t inst, pathnode_t* node);
void Scr_AddHudElem(game_hudelem_s* hud);
void Scr_AddObject(scriptInstance_t inst, int entid);
void Scr_MakeArray(scriptInstance_t inst);
void Scr_AddArrayStringIndexed(scriptInstance_t inst, unsigned short id);
unsigned short Scr_ExecThread(scriptInstance_t inst, int handle, int paramCount);
unsigned short Scr_ExecEntThread(scriptInstance_t inst, int entNum, int handle, int numParams, int entClass);
unsigned int Scr_GetNumParam(scriptInstance_t inst);
VariableType Scr_GetType(scriptInstance_t inst, unsigned int index);
void Scr_Error(const char* err, scriptInstance_t inst, bool is_terminal);
@ -62,6 +69,10 @@ namespace game
pathnode_t* Path_NearestNodeNotCrossPlanes(int typeFlags, int maxNodes, float* vOrigin, pathsort_t* nodes, float fMaxDist, float a6, float a7, int iPlaneCount, int* returnCount, nearestNodeHeightCheck heightCheck);
int Path_FindPathFromTo(float* startPos, pathnode_t* pNodeTo, path_t* pPath, team_t eTeam, pathnode_t* pNodeFrom, float* vGoalPos, int bAllowNegotiationLinks, int bIgnoreBadplaces);
int Path_GeneratePath(path_t* pPath, team_t eTeam, const float* vStartPos, float* vGoalPos, pathnode_t* pNodeFrom, pathnode_t* pNodeTo, int bIncludeGoalPos, int bAllowNegotiationLinks);
void Path_UpdateLookahead(path_t* pPath, const float* vStartPos, int bReduceLookaheadAmount, int a4, int bAllowBacktrack);
void Path_AddTrimmedAmount(const float* a1, path_t* a2);
void Path_TransferLookahead(path_t* a1, const float* a2);
void Sentient_GetVelocity(sentient_s* self, float* vVelOut);
template <typename T>
class symbol

View File

@ -636,10 +636,76 @@ namespace game
int icon;
};
enum he_type_t : __int32
{
HE_TYPE_FREE = 0x0,
HE_TYPE_TEXT = 0x1,
HE_TYPE_VALUE = 0x2,
HE_TYPE_DAMAGE_INDICATOR = 0x3,
HE_TYPE_MATERIAL = 0x4,
HE_TYPE_TIMER_DOWN = 0x5,
HE_TYPE_TIMER_UP = 0x6,
HE_TYPE_TENTHS_TIMER_DOWN = 0x7,
HE_TYPE_TENTHS_TIMER_UP = 0x8,
HE_TYPE_CLOCK_DOWN = 0x9,
HE_TYPE_CLOCK_UP = 0xA,
HE_TYPE_WAYPOINT = 0xB,
HE_TYPE_COUNT = 0xC,
};
struct hudelem_s
{
char gap0[171];
char field_AB;
he_type_t type;
float x;
float y;
float z;
int targetEntNum;
float fontScale;
float fromFontScale;
int fontScaleStartTime;
int fontScaleTime;
int font;
int alignOrg;
int alignScreen;
int color;
int fromColor;
int fadeStartTime;
int fadeTime;
int label;
int width;
int height;
int materialIndex;
int offscreenMaterialIdx;
int fromWidth;
int fromHeight;
int scaleStartTime;
int scaleTime;
float fromX;
float fromY;
int fromAlignOrg;
int fromAlignScreen;
int moveStartTime;
int moveTime;
int time;
int duration;
float value;
int text;
float sort;
int glowColor;
int fxBirthTime;
int fxLetterTime;
int fxDecayStartTime;
int fxDecayDuration;
int soundID;
int flags;
};
struct game_hudelem_s
{
hudelem_s elem;
int clientNum;
int team;
int archived;
};
struct __declspec(align(4)) playerState_s

View File

@ -21,6 +21,7 @@ namespace game
WEAK symbol<GameWorldSp*> gameWorldCurrent{ 0x0, 0x8E1D80 };
WEAK symbol<pathlocal_t> g_path{ 0x0, 0x1F2F700 };
WEAK symbol<gentity_s> g_entities{ 0x0, 0x176C6F0 };
WEAK symbol<game_hudelem_s> g_hudelems{ 0x0, 0x173C6F0 };
//WEAK symbol<scrVarPub_t> scrVarPub{ 0x0, 0x3882B70 };
WEAK symbol<scrVmPub_t> gScrVmPub{ 0x0, 0x3BD4700 };
WEAK symbol<level_locals_s> level{ 0x0, 0x18F5D88 };