diff --git a/dlls/engine/amxxapi.cpp b/dlls/engine/amxxapi.cpp index 4fe47111..d5de1334 100755 --- a/dlls/engine/amxxapi.cpp +++ b/dlls/engine/amxxapi.cpp @@ -127,6 +127,10 @@ void ServerDeactivate() msgBlocks[i] = 0; } + Touches.clear(); + Impulses.clear(); + Thinks.clear(); + RETURN_META(MRES_IGNORED); } diff --git a/dlls/engine/engine.cpp b/dlls/engine/engine.cpp index 5fff7ca7..ed4e00ac 100755 --- a/dlls/engine/engine.cpp +++ b/dlls/engine/engine.cpp @@ -1,11 +1,11 @@ #include "engine.h" -bool inKeyValue=false; -KeyValueData *g_pkvd; struct usercmd_s *g_cmd; struct PlayerInfo plinfo[33]; struct GlobalInfo glinfo; +TraceResult g_tr; + void UTIL_SetSize(edict_t *pev, const Vector &vecMin, const Vector &vecMax) { SET_SIZE(ENT(pev), vecMin, vecMax); @@ -20,6 +20,65 @@ edict_t *UTIL_FindEntityInSphere(edict_t *pStart, const Vector &vecCenter, float return NULL; } +static cell AMX_NATIVE_CALL register_think(AMX *amx, cell *params) +{ + int len; + + EntClass *p = new EntClass; + const char *clsname = MF_GetAmxString(amx, params[1], 0, &len); + p->Class = new char[strlen(clsname)+1]; + strcpy(p->Class, clsname); + + p->Forward = MF_RegisterSPForwardByName(amx, MF_GetAmxString(amx, params[2], 0, &len), FP_CELL); + + Thinks.push_back(p); + + return p->Forward; +} + +static cell AMX_NATIVE_CALL register_impulse(AMX *amx, cell *params) +{ + int len; + + Impulse *p = new Impulse; + p->Check = params[1]; + + p->Forward = MF_RegisterSPForwardByName(amx, MF_GetAmxString(amx, params[2], 0, &len), FP_CELL); + + Impulses.push_back(p); + + return p->Forward; +} + +static cell AMX_NATIVE_CALL register_touch(AMX *amx, cell *params) +{ + int len; + + char *Toucher = MF_GetAmxString(amx, params[1], 0, &len); + char *Touched = MF_GetAmxString(amx, params[2], 1, &len); + + Touch *p = new Touch; + + if (!strlen(Toucher) || strcmp(Toucher, "*")==0) { + p->Toucher = 0; + } else { + p->Toucher = new char[strlen(Toucher)+1]; + strcpy(p->Toucher, Toucher); + } + if (!strlen(Touched) || strcmp(Touched, "*")==0) { + p->Touched = 0; + } else { + p->Touched = new char[strlen(Touched)+1]; + strcpy(p->Touched, Touched); + } + + p->Forward = MF_RegisterSPForwardByName(amx, MF_GetAmxString(amx, params[3], 2, &len), FP_CELL, FP_CELL); + + Touches.push_back(p); + + return p->Forward; +} + static cell AMX_NATIVE_CALL halflife_time(AMX *amx, cell *params) { REAL fVal = gpGlobals->time; @@ -643,13 +702,13 @@ static cell AMX_NATIVE_CALL get_usercmd(AMX *amx, cell *params) switch(type) { case usercmd_forwardmove: - *cRet = *(cell*)&g_cmd->forwardmove; + *cRet = amx_ftoc(g_cmd->forwardmove); return 1; case usercmd_sidemove: - *cRet = *(cell*)&g_cmd->sidemove; + *cRet = amx_ftoc(g_cmd->sidemove); return 1; case usercmd_upmove: - *cRet = *(cell*)&g_cmd->upmove; + *cRet = amx_ftoc(g_cmd->upmove); return 1; default: return 0; @@ -662,14 +721,14 @@ static cell AMX_NATIVE_CALL get_usercmd(AMX *amx, cell *params) switch (type) { case usercmd_viewangles: - cRet[0] = *(cell*)&g_cmd->viewangles.x; - cRet[1] = *(cell*)&g_cmd->viewangles.y; - cRet[2] = *(cell*)&g_cmd->viewangles.z; + cRet[0] = amx_ftoc(g_cmd->viewangles.x); + cRet[1] = amx_ftoc(g_cmd->viewangles.y); + cRet[2] = amx_ftoc(g_cmd->viewangles.z); return 1; case usercmd_impact_position: - cRet[0] = *(cell*)&g_cmd->impact_position.x; - cRet[1] = *(cell*)&g_cmd->impact_position.y; - cRet[2] = *(cell*)&g_cmd->impact_position.z; + cRet[0] = amx_ftoc(g_cmd->impact_position.x); + cRet[1] = amx_ftoc(g_cmd->impact_position.y); + cRet[2] = amx_ftoc(g_cmd->impact_position.z); return 1; default: return 0; @@ -757,6 +816,63 @@ static cell AMX_NATIVE_CALL set_usercmd(AMX *amx, cell *params) return 1; } +static cell AMX_NATIVE_CALL traceresult(AMX *amx, cell *params) +{ + int type = params[1]; + cell *cRet; +/* + TR_AllSolid, // (int) if true, plane is not valid + TR_StartSolid, // (int) if true, the initial point was in a solid area + TR_InOpen, // (int) + TR_InWater, // (int) + TR_Fraction, // (float) time completed, 1.0 = didn't hit anything + TR_EndPos, // (vector) final position + TR_PlaneDist, // (float) + TR_PlaneNormal, // (vector) surface normal at impact + TR_Hit, // (entity) entity the surface is on + TR_Hitgroup // (int) 0 == generic, non zero is specific body part +*/ + switch (type) + { + case TR_AllSolid: + return g_tr.fAllSolid; + case TR_StartSolid: + return g_tr.fStartSolid; + case TR_InOpen: + return g_tr.fInOpen; + case TR_InWater: + return g_tr.fInWater; + case TR_Hitgroup: + return g_tr.iHitgroup; + case TR_Hit: + if (!FNullEnt(g_tr.pHit)) + return ENTINDEX(g_tr.pHit); + else + return -1; + case TR_Fraction: + cRet = MF_GetAmxAddr(amx,params[2]); + cRet[0] = amx_ftoc(g_tr.flFraction); + return 1; + case TR_EndPos: + cRet = MF_GetAmxAddr(amx,params[2]); + cRet[0] = amx_ftoc(g_tr.vecEndPos[0]); + cRet[1] = amx_ftoc(g_tr.vecEndPos[1]); + cRet[2] = amx_ftoc(g_tr.vecEndPos[2]); + return 1; + case TR_PlaneDist: + cRet = MF_GetAmxAddr(amx,params[2]); + cRet[0] = amx_ftoc(g_tr.flPlaneDist); + return 1; + case TR_PlaneNormal: + cRet = MF_GetAmxAddr(amx,params[2]); + cRet[0] = amx_ftoc(g_tr.vecPlaneNormal[0]); + cRet[1] = amx_ftoc(g_tr.vecPlaneNormal[1]); + cRet[2] = amx_ftoc(g_tr.vecPlaneNormal[2]); + return 1; + } + return 0; +} + //(mahnsawce) static cell AMX_NATIVE_CALL take_damage(AMX *amx, cell *params) { @@ -778,6 +894,1191 @@ static cell AMX_NATIVE_CALL take_damage(AMX *amx, cell *params) return 1; } +//(mahnsawce) +static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params) +{ + // Variables I will need throughout all the different calls. + int type = params[1]; +// LOG_CONSOLE(PLID,"Called: %i %i",type,*params/sizeof(cell)); + int len; + char *temp; + char *temp2; + cell *cRet; + vec3_t Vec1; + vec3_t Vec2; + vec3_t Vec3; + vec3_t Vec4; + int iparam1; + int iparam2; + int iparam3; + int iparam4; + int iparam5; + int iparam6; + float fparam1; + float fparam2; + float fparam3; +// float fTemp[3]; + int index; + edict_t *pRet=NULL; + // Now start calling.. :/ + switch (type) + { + // pfnPrecacheModel + case EngFunc_PrecacheModel: // int ) (char* s); + temp = MF_GetAmxString(amx,params[2],0,&len); + if (temp[0]==0) + return 0; + return (*g_engfuncs.pfnPrecacheModel)((char*)STRING(ALLOC_STRING(temp))); + + + // pfnPrecacheSound + case EngFunc_PrecacheSound: // int ) (char* s); + temp = MF_GetAmxString(amx,params[2],0,&len); + if (temp[0]==0) + return 0; + return (*g_engfuncs.pfnPrecacheSound)((char*)STRING(ALLOC_STRING(temp))); + + + // pfnSetModel + case EngFunc_SetModel: // void ) (edict_t *e, const char *m); + temp = MF_GetAmxString(amx,params[3],0,&len); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + (*g_engfuncs.pfnSetModel)(INDEXENT(index),(char*)STRING(ALLOC_STRING(temp))); + return 1; + + + // pfnModelIndex + case EngFunc_ModelIndex: + temp = MF_GetAmxString(amx,params[2],0,&len); + return (*g_engfuncs.pfnModelIndex)(temp); + + + // pfnModelFrames + case EngFunc_ModelFrames: // int ) (int modelIndex); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + return (*g_engfuncs.pfnModelFrames)(index); + + + // pfnSetSize + case EngFunc_SetSize: // void ) (edict_t *e, const float *rgflMin, const float *rgflMax); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[3]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[4]); + Vec2[0]=amx_ctof(cRet[0]); + Vec2[1]=amx_ctof(cRet[1]); + Vec2[2]=amx_ctof(cRet[2]); + (*g_engfuncs.pfnSetSize)(INDEXENT(index),Vec1,Vec2); + return 1; + + + // pfnChangeLevel (is this needed?) + case EngFunc_ChangeLevel: // void ) (char* s1, char* s2); + temp = MF_GetAmxString(amx,params[2],0,&len); + temp2 = MF_GetAmxString(amx,params[3],1,&len); + (*g_engfuncs.pfnChangeLevel)(temp,temp2); + return 1; + + + // pfnVecToYaw + case EngFunc_VecToYaw: // float) (const float *rgflVector); + cRet = MF_GetAmxAddr(amx,params[2]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[3]); + fparam1= (*g_engfuncs.pfnVecToYaw)(Vec1); + cRet[0] = amx_ftoc(fparam1); + return 1; + + + // pfnVecToAngles + case EngFunc_VecToAngles: // void ) (const float *rgflVectorIn, float *rgflVectorOut); + cRet = MF_GetAmxAddr(amx,params[2]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + + (*g_engfuncs.pfnVecToAngles)(Vec1,Vec2); + cRet = MF_GetAmxAddr(amx,params[3]); + cRet[0]=amx_ftoc(Vec2[0]); + cRet[1]=amx_ftoc(Vec2[1]); + cRet[2]=amx_ftoc(Vec2[2]); + return 1; + + + // pfnMoveToOrigin + case EngFunc_MoveToOrigin: // void ) (edict_t *ent, const float *pflGoal, float dist, int iMoveType); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + cRet = MF_GetAmxAddr(amx,params[3]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[4]); + fparam1=amx_ctof(cRet[0]); + cRet = MF_GetAmxAddr(amx,params[5]); + iparam1=cRet[0]; + CHECK_ENTITY(index); + (*g_engfuncs.pfnMoveToOrigin)(INDEXENT(index),Vec1,fparam1,iparam1); + return 1; + + + // pfnChangeYaw + case EngFunc_ChangeYaw: // void ) (edict_t* ent); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + (*g_engfuncs.pfnChangeYaw)(INDEXENT(index)); + return 1; + + + // pfnChangePitch + case EngFunc_ChangePitch: // void ) (edict_t* ent); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + (*g_engfuncs.pfnChangePitch)(INDEXENT(index)); + return 1; + + + // pfnFindEntityByString + case EngFunc_FindEntityByString: // edict) (edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + temp = MF_GetAmxString(amx,params[3],0,&len); + temp2 = MF_GetAmxString(amx,params[4],1,&len); + pRet = (*g_engfuncs.pfnFindEntityByString)(index == -1 ? NULL : INDEXENT(index),temp,temp2); + if (pRet) + return ENTINDEX(pRet); + return -1; + + + // pfnGetEntityIllum + case EngFunc_GetEntityIllum: // int ) (edict_t* pEnt); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + return (*g_engfuncs.pfnGetEntityIllum)(INDEXENT(index)); + + + // pfnFindEntityInSphere + case EngFunc_FindEntityInSphere: // edict) (edict_t *pEdictStartSearchAfter, const float *org, float rad); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + cRet = MF_GetAmxAddr(amx,params[3]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[4]); + fparam1 = amx_ctof(cRet[0]); + pRet = (*g_engfuncs.pfnFindEntityInSphere)(index == -1 ? NULL : INDEXENT(index),Vec1,fparam1); + if (pRet) + return ENTINDEX(pRet); + return -1; + + + // pfnFindClientsInPVS + case EngFunc_FindClientInPVS: // edict) (edict_t *pEdict); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + pRet=(*g_engfuncs.pfnFindClientInPVS)(INDEXENT(index)); + return ENTINDEX(pRet); + + + // pfnEntitiesInPVS + case EngFunc_EntitiesInPVS: // edict) (edict_t *pplayer); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + pRet=(*g_engfuncs.pfnEntitiesInPVS)(INDEXENT(index)); + return ENTINDEX(pRet); + + + // pfnMakeVectors + case EngFunc_MakeVectors: // void ) (const float *rgflVector); + cRet = MF_GetAmxAddr(amx,params[2]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + (*g_engfuncs.pfnMakeVectors)(Vec1); + return 1; + + + // pfnAngleVectors + case EngFunc_AngleVectors: // void ) (const float *rgflVector, float *forward, float *right, float *up); + cRet = MF_GetAmxAddr(amx,params[2]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + (*g_engfuncs.pfnAngleVectors)(Vec1,Vec2,Vec3,Vec4); + cRet = MF_GetAmxAddr(amx,params[3]); + cRet[0] = amx_ftoc(Vec2[0]); + cRet[1] = amx_ftoc(Vec2[1]); + cRet[2] = amx_ftoc(Vec2[2]); + cRet = MF_GetAmxAddr(amx,params[4]); + cRet[0] = amx_ftoc(Vec3[0]); + cRet[1] = amx_ftoc(Vec3[1]); + cRet[2] = amx_ftoc(Vec3[2]); + cRet = MF_GetAmxAddr(amx,params[5]); + cRet[0] = amx_ftoc(Vec4[0]); + cRet[1] = amx_ftoc(Vec4[1]); + cRet[2] = amx_ftoc(Vec4[2]); + return 1; + + + // pfnCreateEntity + case EngFunc_CreateEntity: // edict) (void); + pRet = (*g_engfuncs.pfnCreateEntity)(); + if (pRet) + return ENTINDEX(pRet); + return 0; + + + // pfnRemoveEntity + case EngFunc_RemoveEntity: // void ) (edict_t* e); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + if (index == 0) + return 0; + (*g_engfuncs.pfnRemoveEntity)(INDEXENT(index)); + return 1; + + + // pfnCreateNamedEntity + case EngFunc_CreateNamedEntity: // edict) (int className); + cRet = MF_GetAmxAddr(amx,params[2]); + iparam1 = cRet[0]; + pRet = (*g_engfuncs.pfnCreateNamedEntity)(iparam1); + if (pRet) + return ENTINDEX(pRet); + return 0; + + + // pfnMakeStatic + case EngFunc_MakeStatic: // void ) (edict_t *ent); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + (*g_engfuncs.pfnMakeStatic)(INDEXENT(index)); + return 1; + + + // pfnEntIsOnFloor + case EngFunc_EntIsOnFloor: // int ) (edict_t *e); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + return (*g_engfuncs.pfnEntIsOnFloor)(INDEXENT(index)); + + + // pfnDropToFloor + case EngFunc_DropToFloor: // int ) (edict_t* e); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + return (*g_engfuncs.pfnDropToFloor)(INDEXENT(index)); + + + // pfnWalkMove + case EngFunc_WalkMove: // int ) (edict_t *ent, float yaw, float dist, int iMode); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[3]); + fparam1 = amx_ctof(cRet[0]); + cRet = MF_GetAmxAddr(amx,params[4]); + fparam2 = amx_ctof(cRet[0]); + cRet = MF_GetAmxAddr(amx,params[5]); + iparam1 = cRet[0]; + return (*g_engfuncs.pfnWalkMove)(INDEXENT(index),fparam1,fparam2,iparam1); + + + // pfnSetOrigin + case EngFunc_SetOrigin: // void ) (edict_t *e, const float *rgflOrigin); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[3]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + (*g_engfuncs.pfnSetOrigin)(INDEXENT(index),Vec1); + return 1; + + + // pfnEmitSound + case EngFunc_EmitSound: // void ) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[3]); + iparam1=cRet[0]; + temp = MF_GetAmxString(amx,params[4],0,&len); + cRet = MF_GetAmxAddr(amx,params[5]); + fparam1=amx_ctof(cRet[0]); + cRet = MF_GetAmxAddr(amx,params[6]); + fparam2=amx_ctof(cRet[0]); + cRet = MF_GetAmxAddr(amx,params[7]); + iparam2=cRet[0]; + cRet = MF_GetAmxAddr(amx,params[8]); + iparam3=cRet[0]; + (*g_engfuncs.pfnEmitSound)(INDEXENT(index),iparam1,temp,fparam1,fparam2,iparam2,iparam3); + return 1; + + + // pfnEmitAmbientSound + case EngFunc_EmitAmbientSound: // void ) (edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[3]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + temp = MF_GetAmxString(amx,params[4],0,&len); + cRet = MF_GetAmxAddr(amx,params[5]); + fparam1=amx_ctof(cRet[0]); + cRet = MF_GetAmxAddr(amx,params[6]); + fparam2=amx_ctof(cRet[0]); + cRet = MF_GetAmxAddr(amx,params[7]); + iparam1=cRet[0]; + cRet = MF_GetAmxAddr(amx,params[8]); + iparam2=cRet[0]; + (*g_engfuncs.pfnEmitAmbientSound)(INDEXENT(index),Vec1,temp,fparam1,fparam2,iparam1,iparam2); + return 1; + + // pfnTraceLine + case EngFunc_TraceLine: // void ) (const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); + cRet = MF_GetAmxAddr(amx,params[2]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[3]); + Vec2[0]=amx_ctof(cRet[0]); + Vec2[1]=amx_ctof(cRet[1]); + Vec2[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[4]); + iparam1=cRet[0]; + cRet = MF_GetAmxAddr(amx,params[5]); + index=cRet[0]; + (*g_engfuncs.pfnTraceLine)(Vec1,Vec2,iparam1,index != -1 ? INDEXENT(index) : NULL, &g_tr); + return 1; + + + // pfnTraceToss + case EngFunc_TraceToss: // void ) (edict_t* pent, edict_t* pentToIgnore, TraceResult *ptr); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[3]); + iparam1 = cRet[0]; + CHECK_ENTITY(index); + (*g_engfuncs.pfnTraceToss)(INDEXENT(index),iparam1 == -1 ? NULL : INDEXENT(iparam1),&g_tr); + return 1; + + + // pfnTraceMonsterHull + case EngFunc_TraceMonsterHull: // int ) (edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[3]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[4]); + Vec2[0]=amx_ctof(cRet[0]); + Vec2[1]=amx_ctof(cRet[1]); + Vec2[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[5]); + iparam1=cRet[0]; + cRet = MF_GetAmxAddr(amx,params[6]); + iparam2=cRet[0]; + (*g_engfuncs.pfnTraceMonsterHull)(INDEXENT(index),Vec1,Vec2,iparam1,iparam2 == 0 ? NULL : INDEXENT(iparam2),&g_tr); + return 1; + + + // pfnTraceHull + case EngFunc_TraceHull: // void ) (const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr); + cRet = MF_GetAmxAddr(amx,params[2]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[3]); + Vec2[0]=amx_ctof(cRet[0]); + Vec2[1]=amx_ctof(cRet[1]); + Vec2[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[4]); + iparam1 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[5]); + iparam2 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[6]); + iparam3 = cRet[0]; + (*g_engfuncs.pfnTraceHull)(Vec1,Vec2,iparam1,iparam2,iparam3 == 0 ? 0 : INDEXENT(iparam3),&g_tr); + return 1; + + + // pfnTraceModel + case EngFunc_TraceModel: // void ) (const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr); + cRet = MF_GetAmxAddr(amx,params[2]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[3]); + Vec2[0]=amx_ctof(cRet[0]); + Vec2[1]=amx_ctof(cRet[1]); + Vec2[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[4]); + iparam1 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[5]); + iparam2 = cRet[0]; + (*g_engfuncs.pfnTraceModel)(Vec1,Vec2,iparam1,iparam2 == 0 ? NULL : INDEXENT(iparam2),&g_tr); + return 1; + + + // pfnTraceTexture + case EngFunc_TraceTexture: // const char *) (edict_t *pTextureEntity, const float *v1, const float *v2 ); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[3]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[4]); + Vec2[0]=amx_ctof(cRet[0]); + Vec2[1]=amx_ctof(cRet[1]); + Vec2[2]=amx_ctof(cRet[2]); + temp = (char*)(*g_engfuncs.pfnTraceTexture)(INDEXENT(index),Vec1,Vec2); + cRet = MF_GetAmxAddr(amx,params[6]); + MF_SetAmxString(amx, params[5], temp, cRet[0]); + return 1; + + + // pfnTraceSphere + case EngFunc_TraceSphere: // void ) (const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr); + cRet = MF_GetAmxAddr(amx,params[2]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[3]); + Vec2[0]=amx_ctof(cRet[0]); + Vec2[1]=amx_ctof(cRet[1]); + Vec2[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[4]); + iparam1 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[5]); + fparam1 = amx_ctof(cRet[0]); + cRet = MF_GetAmxAddr(amx,params[6]); + index = cRet[0]; + (*g_engfuncs.pfnTraceSphere)(Vec1,Vec2,iparam1,fparam1,index == 0 ? NULL : INDEXENT(index),&g_tr); + return 1; + + + // pfnGetAimVector + case EngFunc_GetAimVector: // void ) (edict_t* ent, float speed, float *rgflReturn); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[3]); + fparam1 = amx_ctof(cRet[0]); + (*g_engfuncs.pfnGetAimVector)(INDEXENT(index),fparam1,Vec1); + cRet = MF_GetAmxAddr(amx,params[4]); + cRet[0] = amx_ftoc(Vec1[0]); + cRet[1] = amx_ftoc(Vec1[1]); + cRet[2] = amx_ftoc(Vec1[2]); + return 1; + + + // pfnParticleEffect + case EngFunc_ParticleEffect: // void ) (const float *org, const float *dir, float color, float count); + cRet = MF_GetAmxAddr(amx,params[2]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[3]); + Vec2[0]=amx_ctof(cRet[0]); + Vec2[1]=amx_ctof(cRet[1]); + Vec2[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[4]); + fparam1=amx_ctof(cRet[0]); + cRet = MF_GetAmxAddr(amx,params[5]); + fparam2=amx_ctof(cRet[0]); + (*g_engfuncs.pfnParticleEffect)(Vec1,Vec2,fparam1,fparam2); + return 1; + + + // pfnLightStyle + case EngFunc_LightStyle: // void ) (int style, char* val); + cRet = MF_GetAmxAddr(amx,params[2]); + iparam1=cRet[0]; + temp = MF_GetAmxString(amx,params[3],0,&len); + (*g_engfuncs.pfnLightStyle)(iparam1,temp); + return 1; + + + // pfnDecalIndex + case EngFunc_DecalIndex: // int ) (const char *name); + temp = MF_GetAmxString(amx,params[2],0,&len); + return (*g_engfuncs.pfnDecalIndex)(temp); + + + // pfnPointContents + case EngFunc_PointContents: // int ) (const float *rgflVector); + cRet = MF_GetAmxAddr(amx,params[2]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + return (*g_engfuncs.pfnPointContents)(Vec1); + + + // pfnFreeEntPrivateData + case EngFunc_FreeEntPrivateData: // void ) (edict_t *pEdict); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + (*g_engfuncs.pfnFreeEntPrivateData)(INDEXENT(index)); + + + // pfnSzFromIndex + case EngFunc_SzFromIndex: // const char * ) (int iString); + cRet = MF_GetAmxAddr(amx,params[2]); + iparam1 = cRet[0]; + temp = (char*)(*g_engfuncs.pfnSzFromIndex)(iparam1); + cRet = MF_GetAmxAddr(amx,params[4]); + MF_SetAmxString(amx, params[3], temp, cRet[0]); + return 1; + + + // pfnAllocString + case EngFunc_AllocString: // int ) (const char *szValue); + temp = MF_GetAmxString(amx,params[2],0,&len); + return (*g_engfuncs.pfnAllocString)((const char *)temp); + + + // pfnRegUserMsg + case EngFunc_RegUserMsg: // int ) (const char *pszName, int iSize); + temp = MF_GetAmxString(amx,params[2],0,&len); + cRet = MF_GetAmxAddr(amx,params[3]); + iparam1 = cRet[0]; + return (*g_engfuncs.pfnRegUserMsg)(temp,iparam1); + + + // pfnAnimationAutomove + case EngFunc_AnimationAutomove: // void ) (const edict_t* pEdict, float flTime); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[3]); + fparam1 = amx_ctof(cRet[0]); + (*g_engfuncs.pfnAnimationAutomove)(INDEXENT(index),fparam1); + return 1; + + + // pfnGetBonePosition + case EngFunc_GetBonePosition: // void ) (const edict_t* pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[3]); + iparam1=cRet[0]; + (*g_engfuncs.pfnGetBonePosition)(INDEXENT(index),iparam1,Vec1,Vec2); + cRet = MF_GetAmxAddr(amx,params[4]); + cRet[0]=amx_ftoc(Vec1[0]); + cRet[1]=amx_ftoc(Vec1[1]); + cRet[2]=amx_ftoc(Vec1[2]); + cRet = MF_GetAmxAddr(amx,params[5]); + cRet[0]=amx_ftoc(Vec2[0]); + cRet[1]=amx_ftoc(Vec2[1]); + cRet[2]=amx_ftoc(Vec2[2]); + return 1; + + + // pfnGetAttachment + case EngFunc_GetAttachment: // void ) (const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles ); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[3]); + iparam1=cRet[0]; + (*g_engfuncs.pfnGetAttachment)(INDEXENT(index),iparam1,Vec1,Vec2); + cRet = MF_GetAmxAddr(amx,params[4]); + cRet[0]=amx_ftoc(Vec1[0]); + cRet[1]=amx_ftoc(Vec1[1]); + cRet[2]=amx_ftoc(Vec1[2]); + cRet = MF_GetAmxAddr(amx,params[5]); + cRet[0]=amx_ftoc(Vec2[0]); + cRet[1]=amx_ftoc(Vec2[1]); + cRet[2]=amx_ftoc(Vec2[2]); + return 1; + + + // pfnSetView + case EngFunc_SetView: // void ) (const edict_t *pClient, const edict_t *pViewent ); + cRet = MF_GetAmxAddr(amx,params[2]); + iparam1 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[3]); + iparam2 = cRet[0]; + CHECK_ENTITY(iparam1); + CHECK_ENTITY(iparam2); + (*g_engfuncs.pfnSetView)(INDEXENT(iparam1),INDEXENT(iparam2)); + return 1; + + + // pfnTime + case EngFunc_Time: // float) ( void ); + fparam1 = (*g_engfuncs.pfnTime)(); + return amx_ftoc(fparam1); + + + // pfnCrosshairAngle + case EngFunc_CrosshairAngle: // void ) (const edict_t *pClient, float pitch, float yaw); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[3]); + fparam1 = amx_ctof(cRet[0]); + cRet = MF_GetAmxAddr(amx,params[4]); + fparam2 = amx_ctof(cRet[0]); + (*g_engfuncs.pfnCrosshairAngle)(INDEXENT(index),fparam1,fparam2); + return 1; + + + // pfnFadeClientVolume + case EngFunc_FadeClientVolume: // void ) (const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[3]); + iparam1 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[4]); + iparam2 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[5]); + iparam3 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[6]); + iparam4 = cRet[0]; + (*g_engfuncs.pfnFadeClientVolume)(INDEXENT(index),iparam1,iparam2,iparam3,iparam4); + return 1; + + + // pfnSetClientMaxSpeed + case EngFunc_SetClientMaxspeed: // void ) (const edict_t *pEdict, float fNewMaxspeed); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[3]); + fparam1 = amx_ctof(cRet[0]); + (*g_engfuncs.pfnSetClientMaxspeed)(INDEXENT(index),fparam1); + return 1; + + + // pfnCreateFakeClient + case EngFunc_CreateFakeClient: // edict) (const char *netname); // returns NULL if fake client can't be created + temp = MF_GetAmxString(amx,params[2],0,&len); + pRet = (*g_engfuncs.pfnCreateFakeClient)(STRING(ALLOC_STRING(temp))); + if (pRet == 0) + return 0; + return ENTINDEX(pRet); + + + // pfnRunPlayerMove + case EngFunc_RunPlayerMove: // void ) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec ); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[3]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[4]); + fparam1=amx_ctof(cRet[0]); + cRet = MF_GetAmxAddr(amx,params[5]); + fparam2=amx_ctof(cRet[0]); + cRet = MF_GetAmxAddr(amx,params[6]); + fparam3=amx_ctof(cRet[0]); + cRet = MF_GetAmxAddr(amx,params[7]); + iparam1 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[8]); + iparam2 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[9]); + iparam3 = cRet[0]; + (*g_engfuncs.pfnRunPlayerMove)(INDEXENT(index),Vec1,fparam1,fparam2,fparam3,iparam1,iparam2,iparam3); + return 1; + + + // pfnNumberOfEntities + case EngFunc_NumberOfEntities: // int ) (void); + return (*g_engfuncs.pfnNumberOfEntities)(); + + + // pfnStaticDecal + case EngFunc_StaticDecal: // void ) ( const float *origin, int decalIndex, int entityIndex, int modelIndex ); + cRet = MF_GetAmxAddr(amx,params[2]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[3]); + iparam1 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[4]); + iparam2 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[5]); + iparam3 = cRet[0]; + (*g_engfuncs.pfnStaticDecal)(Vec1,iparam1,iparam2,iparam3); + return 1; + + + // pfnPrecacheGeneric + case EngFunc_PrecacheGeneric: // int ) (char* s); + temp = MF_GetAmxString(amx,params[2],0,&len); + return (*g_engfuncs.pfnPrecacheGeneric)((char*)STRING(ALLOC_STRING(temp))); + + + // pfnBuildSoundMsg + case EngFunc_BuildSoundMsg: // void ) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[3]); + iparam1 = cRet[0]; + temp = MF_GetAmxString(amx,params[4],0,&len); + cRet = MF_GetAmxAddr(amx,params[5]); + fparam1 = amx_ctof(cRet[0]); + cRet = MF_GetAmxAddr(amx,params[6]); + fparam2 = amx_ctof(cRet[0]); + cRet = MF_GetAmxAddr(amx,params[7]); + iparam2 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[8]); + iparam3 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[9]); + iparam4 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[10]); + iparam5 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[11]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + cRet=MF_GetAmxAddr(amx,params[12]); + iparam6=cRet[0]; + /* don't check, it might not be included + CHECK_ENTITY(iparam5); + */ + (*g_engfuncs.pfnBuildSoundMsg)(INDEXENT(index),iparam1,temp,fparam1,fparam2,iparam2,iparam3,iparam4,iparam5,Vec1,iparam6 == 0 ? NULL : INDEXENT(iparam6)); + return 1; + + + // pfnGetPhysicsKeyValue + case EngFunc_GetPhysicsKeyValue: // const char* ) ( const edict_t *pClient, const char *key ); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + temp = MF_GetAmxString(amx,params[3],0,&len); + temp2 = (char*)(*g_engfuncs.pfnGetPhysicsKeyValue)(INDEXENT(index),(const char *)temp); + cRet = MF_GetAmxAddr(amx,params[5]); + MF_SetAmxString(amx,params[4],temp2,cRet[0]); + return 1; + + + // pfnSetPhysicsKeyValue + case EngFunc_SetPhysicsKeyValue: // void ) ( const edict_t *pClient, const char *key, const char *value ); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + temp = MF_GetAmxString(amx,params[3],0,&len); + temp2 = MF_GetAmxString(amx,params[4],0,&len); + (*g_engfuncs.pfnSetPhysicsKeyValue)(INDEXENT(index),STRING(ALLOC_STRING(temp)),STRING(ALLOC_STRING(temp2))); + return 1; + + + // pfnGetPhysicsInfoString + case EngFunc_GetPhysicsInfoString: // const char* ) ( const edict_t *pClient ); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + temp = (char*)(*g_engfuncs.pfnGetPhysicsInfoString)(INDEXENT(index)); + cRet = MF_GetAmxAddr(amx,params[4]); + + MF_SetAmxString(amx,params[3],temp,cRet[0]); + return 1; + + + // pfnPrecacheEvent + case EngFunc_PrecacheEvent: // unsigned short ) ( int type, const char*psz ); + cRet = MF_GetAmxAddr(amx,params[2]); + iparam1 = cRet[0]; + temp = MF_GetAmxString(amx,params[3],0,&len); + return (*g_engfuncs.pfnPrecacheEvent)(iparam1,(char*)STRING(ALLOC_STRING(temp))); + + + // pfnPlaybackEvent (grr) + case EngFunc_PlaybackEvent: // void ) + cRet = MF_GetAmxAddr(amx,params[2]); + iparam1 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[3]); + index = cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[4]); + iparam2 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[5]); + fparam1 = amx_ctof(cRet[0]); + cRet = MF_GetAmxAddr(amx,params[6]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[7]); + Vec2[0]=amx_ctof(cRet[0]); + Vec2[1]=amx_ctof(cRet[1]); + Vec2[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[8]); + fparam2 = amx_ctof(cRet[0]); + cRet = MF_GetAmxAddr(amx,params[9]); + fparam3 = amx_ctof(cRet[0]); + cRet = MF_GetAmxAddr(amx,params[10]); + iparam3 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[11]); + iparam4 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[12]); + iparam5 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[13]); + iparam6 = cRet[0]; + (*g_engfuncs.pfnPlaybackEvent)(iparam1,INDEXENT(index),iparam2,fparam1,Vec1,Vec2,fparam2,fparam3,iparam3,iparam4,iparam5,iparam6); + return 1; + + // pfnGetCurrentPlayer + case EngFunc_GetCurrentPlayer: // int ) ( void ); + return (*g_engfuncs.pfnGetCurrentPlayer)(); + + + // pfnCanSkipPlayer + case EngFunc_CanSkipPlayer: // int ) ( const edict_t *player ); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + return (*g_engfuncs.pfnCanSkipPlayer)(INDEXENT(index)); + + + // pfnSetGroupMask + case EngFunc_SetGroupMask: // void ) ( int mask, int op ); + cRet = MF_GetAmxAddr(amx,params[2]); + iparam1 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[3]); + iparam2 = cRet[0]; + (*g_engfuncs.pfnSetGroupMask)(iparam1,iparam2); + return 1; + + + // pfnGetClientListening + case EngFunc_GetClientListening: // bool (int iReceiver, int iSender) + cRet = MF_GetAmxAddr(amx,params[2]); + iparam1 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[3]); + iparam2 = cRet[0]; + return (*g_engfuncs.pfnVoice_GetClientListening)(iparam1,iparam2); + + + // pfnSetClientListening + case EngFunc_SetClientListening: // bool (int iReceiver, int iSender, bool Listen) + cRet = MF_GetAmxAddr(amx,params[2]); + iparam1 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[3]); + iparam2 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[4]); + iparam3 = cRet[0]; + return (*g_engfuncs.pfnVoice_SetClientListening)(iparam1,iparam2,iparam3); + + + // pfnMessageBegin (AMX doesn't support MSG_ONE_UNRELIABLE, so I should add this incase anyone needs it.) + case EngFunc_MessageBegin: // void (int msg_dest, int msg_type, const float *pOrigin, edict_t *ed) + cRet = MF_GetAmxAddr(amx,params[2]); + iparam1 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[3]); + iparam2 = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[4]); + Vec1[0]=amx_ctof(cRet[0]); + Vec1[1]=amx_ctof(cRet[1]); + Vec1[2]=amx_ctof(cRet[2]); + cRet = MF_GetAmxAddr(amx,params[5]); + index = cRet[0]; + (*g_engfuncs.pfnMessageBegin)(iparam1,iparam2,Vec1,index == 0 ? NULL : INDEXENT(index)); + return 1; + + + // pfnWriteCoord + case EngFunc_WriteCoord: // void (float) + cRet = MF_GetAmxAddr(amx,params[2]); + fparam1 = amx_ctof(cRet[0]); + (*g_engfuncs.pfnWriteCoord)(fparam1); + return 1; + + + // pfnWriteAngle + case EngFunc_WriteAngle: // void (float) + cRet = MF_GetAmxAddr(amx,params[2]); + fparam1 = amx_ctof(cRet[0]); + (*g_engfuncs.pfnWriteAngle)(fparam1); + return 1; + case EngFunc_InfoKeyValue: // char* ) (char *infobuffer, char *key); + // Modify the syntax a bit. + // index, key + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + cRet = MF_GetAmxAddr(amx,params[5]); + iparam1 = cRet[0]; + CHECK_ENTITY(index); + temp2 = MF_GetAmxString(amx,params[3],0,&len); + temp = (*g_engfuncs.pfnInfoKeyValue)((*g_engfuncs.pfnGetInfoKeyBuffer)(INDEXENT(index)),temp2); + MF_SetAmxString(amx,params[4],temp,iparam1); + return 1; + + case EngFunc_SetKeyValue: // void ) (char *infobuffer, char *key, char *value); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + temp = MF_GetAmxString(amx,params[3],0,&len); + temp2 = MF_GetAmxString(amx,params[4],1,&len); + (*g_engfuncs.pfnSetKeyValue)((*g_engfuncs.pfnGetInfoKeyBuffer)(INDEXENT(index)),temp,temp2); + return 1; + case EngFunc_SetClientKeyValue: // void ) (int clientIndex, char *infobuffer, char *key, char *value); + cRet = MF_GetAmxAddr(amx,params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + temp = MF_GetAmxString(amx,params[3],0,&len); + temp2 = MF_GetAmxString(amx,params[4],1,&len); + (*g_engfuncs.pfnSetClientKeyValue)(index,(*g_engfuncs.pfnGetInfoKeyBuffer)(INDEXENT(index)),temp,temp2); + return 1; + + default: + LOG_CONSOLE(PLID,"[NS2AMX] Unknown engfunc type provided."); + return 0; + } +} + +//by mahnsawce +static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params) +{ + int type; + int index; + int indexb; + char *temp = ""; + char *temp2 = ""; + char *temp3 = ""; + vec3_t Vec1; + vec3_t Vec2; + int iparam1; + int len; + cell *cRet; + type = params[1]; + switch(type) + { + + // pfnGameInit + case DLLFunc_GameInit: // void) ( void ); + gpGamedllFuncs->dllapi_table->pfnGameInit(); + return 1; + + // pfnSpawn + case DLLFunc_Spawn: // int ) ( edict_t *pent ); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + return gpGamedllFuncs->dllapi_table->pfnSpawn(INDEXENT(index)); + + // pfnThink + case DLLFunc_Think: // void ) ( edict_t *pent ); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + gpGamedllFuncs->dllapi_table->pfnThink(INDEXENT(index)); + return 1; + + // pfnUse + case DLLFunc_Use: // void ) ( edict_t *pentUsed, edict_t *pentOther ); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[2]); + indexb=cRet[0]; + CHECK_ENTITY(indexb); + gpGamedllFuncs->dllapi_table->pfnUse(INDEXENT(index),INDEXENT(indexb)); + return 1; + + // pfnTouch + case DLLFunc_Touch: // void ) ( edict_t *pentTouched, edict_t *pentOther ); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[2]); + indexb=cRet[0]; + CHECK_ENTITY(indexb); + gpGamedllFuncs->dllapi_table->pfnTouch(INDEXENT(index),INDEXENT(indexb)); + return 1; + + case DLLFunc_Blocked: // void ) ( edict_t *pentBlocked, edict_t *pentOther ); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + cRet = MF_GetAmxAddr(amx,params[2]); + indexb=cRet[0]; + CHECK_ENTITY(indexb); + gpGamedllFuncs->dllapi_table->pfnBlocked(INDEXENT(index),INDEXENT(indexb)); + return 1; + + + case DLLFunc_SetAbsBox: // void ) ( edict_t *pent ); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + gpGamedllFuncs->dllapi_table->pfnSetAbsBox(INDEXENT(index)); + return 1; + + case DLLFunc_ClientConnect: // bool) ( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); + // index,szName,szAddress,szRetRejectReason,size + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + temp = MF_GetAmxString(amx,params[3],0,&len); + temp2 = MF_GetAmxString(amx,params[4],1,&len); + //temp3 = GET_AMXSTRING(amx,params[5],2,len); + iparam1 = MDLL_ClientConnect(INDEXENT(index),STRING(ALLOC_STRING(temp)),STRING(ALLOC_STRING(temp2)),temp3); + cRet = MF_GetAmxAddr(amx,params[6]); + MF_SetAmxString(amx,params[5],temp3,cRet[0]); + return 1; + + case DLLFunc_ClientDisconnect: // void ) ( edict_t *pEntity ); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + gpGamedllFuncs->dllapi_table->pfnClientDisconnect(INDEXENT(index)); + return 1; + + case DLLFunc_ClientKill: // void ) ( edict_t *pEntity ); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + gpGamedllFuncs->dllapi_table->pfnClientKill(INDEXENT(index)); + return 1; + + case DLLFunc_ClientPutInServer: // void ) ( edict_t *pEntity ); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + gpGamedllFuncs->dllapi_table->pfnClientPutInServer(INDEXENT(index)); + return 1; + + case DLLFunc_ServerDeactivate: // void) ( void ); + gpGamedllFuncs->dllapi_table->pfnServerDeactivate(); + return 1; + + case DLLFunc_PlayerPreThink: // void ) ( edict_t *pEntity ); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + gpGamedllFuncs->dllapi_table->pfnPlayerPreThink(INDEXENT(index)); + return 1; + + case DLLFunc_PlayerPostThink: // void ) ( edict_t *pEntity ); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + gpGamedllFuncs->dllapi_table->pfnPlayerPostThink(INDEXENT(index)); + return 1; + + case DLLFunc_StartFrame: // void ) ( void ); + gpGamedllFuncs->dllapi_table->pfnStartFrame(); + return 1; + + case DLLFunc_ParmsNewLevel: // void ) ( void ); + gpGamedllFuncs->dllapi_table->pfnParmsNewLevel(); + + + case DLLFunc_ParmsChangeLevel: // void ) ( void ); + gpGamedllFuncs->dllapi_table->pfnParmsChangeLevel(); + + // Returns string describing current .dll. E.g., TeamFotrress 2, Half-Life + case DLLFunc_GetGameDescription: // const char * )( void ); + temp = (char*)gpGamedllFuncs->dllapi_table->pfnGetGameDescription(); + cRet = MF_GetAmxAddr(amx,params[3]); + MF_SetAmxString(amx,params[2],temp,cRet[0]); + return 1; + + // Spectator funcs + case DLLFunc_SpectatorConnect: // void) ( edict_t *pEntity ); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + gpGamedllFuncs->dllapi_table->pfnSpectatorConnect(INDEXENT(index)); + return 1; + case DLLFunc_SpectatorDisconnect: // void ) ( edict_t *pEntity ); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + gpGamedllFuncs->dllapi_table->pfnSpectatorDisconnect(INDEXENT(index)); + return 1; + case DLLFunc_SpectatorThink: // void ) ( edict_t *pEntity ); + cRet = MF_GetAmxAddr(amx,params[2]); + index=cRet[0]; + CHECK_ENTITY(index); + gpGamedllFuncs->dllapi_table->pfnSpectatorThink(INDEXENT(index)); + return 1; + + // Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint. + case DLLFunc_Sys_Error: // void ) ( const char *error_string ); + temp = MF_GetAmxString(amx,params[2],0,&len); + gpGamedllFuncs->dllapi_table->pfnSys_Error(STRING(ALLOC_STRING(temp))); + return 1; + + case DLLFunc_PM_FindTextureType: // char )( char *name ); + temp = MF_GetAmxString(amx,params[2],0,&len); + return gpGamedllFuncs->dllapi_table->pfnPM_FindTextureType(temp); + + case DLLFunc_RegisterEncoders: // void ) ( void ); + gpGamedllFuncs->dllapi_table->pfnRegisterEncoders; + return 1; + + // Enumerates player hulls. Returns 0 if the hull number doesn't exist, 1 otherwise + case DLLFunc_GetHullBounds: // int) ( int hullnumber, float *mins, float *maxs ); + cRet = MF_GetAmxAddr(amx,params[2]); + iparam1 = gpGamedllFuncs->dllapi_table->pfnGetHullBounds(cRet[0],Vec1,Vec2); + cRet = MF_GetAmxAddr(amx,params[3]); + cRet[0]=amx_ftoc(Vec1[0]); + cRet[1]=amx_ftoc(Vec1[1]); + cRet[2]=amx_ftoc(Vec1[2]); + cRet = MF_GetAmxAddr(amx,params[4]); + cRet[0]=amx_ftoc(Vec2[0]); + cRet[1]=amx_ftoc(Vec2[1]); + cRet[2]=amx_ftoc(Vec2[2]); + return iparam1; + + // Create baselines for certain "unplaced" items. + case DLLFunc_CreateInstancedBaselines: // void ) ( void ); + gpGamedllFuncs->dllapi_table->pfnCreateInstancedBaselines(); + return 1; + + case DLLFunc_pfnAllowLagCompensation: // int )( void ); + return gpGamedllFuncs->dllapi_table->pfnAllowLagCompensation(); + // I know this doesn't fit with dllfunc, but I dont want to create another native JUST for this. + case MetaFunc_CallGameEntity: // bool (plid_t plid, const char *entStr,entvars_t *pev); + temp = MF_GetAmxString(amx,params[2],0,&len); + cRet = MF_GetAmxAddr(amx,params[3]); + index = cRet[0]; + CHECK_ENTITY(index); + iparam1 = gpMetaUtilFuncs->pfnCallGameEntity(PLID,STRING(ALLOC_STRING(temp)),VARS(INDEXENT(index))); + return iparam1; + default: + MF_Log("Unknown dllfunc entry."); + MF_RaiseAmxError(amx, AMX_ERR_NATIVE); + return 0; + } +} + AMX_NATIVE_INFO engine_Natives[] = { {"halflife_time", halflife_time}, @@ -792,6 +2093,7 @@ AMX_NATIVE_INFO engine_Natives[] = { {"trace_normal", trace_normal}, {"trace_line", trace_line}, {"trace_hull", trace_hull}, + {"traceresult", traceresult}, {"take_damage", take_damage}, {"set_speak", set_speak}, @@ -812,6 +2114,13 @@ AMX_NATIVE_INFO engine_Natives[] = { {"get_usercmd", get_usercmd}, {"set_usercmd", set_usercmd}, + {"engfunc", engfunc}, + {"dllfunc", dllfunc}, + + {"register_impulse", register_impulse}, + {"register_think", register_think}, + {"register_touch", register_touch}, + {NULL, NULL}, /////////////////// }; diff --git a/dlls/engine/engine.h b/dlls/engine/engine.h index c577928c..a6bbcb57 100755 --- a/dlls/engine/engine.h +++ b/dlls/engine/engine.h @@ -18,6 +18,8 @@ #include "entity.h" #include "gpglobals.h" +#define CHECK_ENTITY(x) if (x != 0 && (FNullEnt(INDEXENT(x)) || x < 0 || x > gpGlobals->maxEntities)) { MF_RaiseAmxError(amx,AMX_ERR_NATIVE); return 0; } + extern int SpawnForward; extern int ChangelevelForward; extern int PlaybackForward; @@ -75,6 +77,155 @@ enum }; +enum { + EngFunc_PrecacheModel, // int ) (char* s); + EngFunc_PrecacheSound, // int ) (char* s); + EngFunc_SetModel, // void ) (edict_t *e, const char *m); + EngFunc_ModelIndex, // int ) (const char *m); + EngFunc_ModelFrames, // int ) (int modelIndex); + EngFunc_SetSize, // void ) (edict_t *e, const float *rgflMin, const float *rgflMax); + EngFunc_ChangeLevel, // void ) (char* s1, char* s2); + EngFunc_VecToYaw, // float) (const float *rgflVector); + EngFunc_VecToAngles, // void ) (const float *rgflVectorIn, float *rgflVectorOut); + EngFunc_MoveToOrigin, // void ) (edict_t *ent, const float *pflGoal, float dist, int iMoveType); + EngFunc_ChangeYaw, // void ) (edict_t* ent); + EngFunc_ChangePitch, // void ) (edict_t* ent); + EngFunc_FindEntityByString, // edict) (edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue); + EngFunc_GetEntityIllum, // int ) (edict_t* pEnt); + EngFunc_FindEntityInSphere, // edict) (edict_t *pEdictStartSearchAfter, const float *org, float rad); + EngFunc_FindClientInPVS, // edict) (edict_t *pEdict); + EngFunc_EntitiesInPVS, // edict) (edict_t *pplayer); + EngFunc_MakeVectors, // void ) (const float *rgflVector); + EngFunc_AngleVectors, // void ) (const float *rgflVector, float *forward, float *right, float *up); + EngFunc_CreateEntity, // edict) (void); + EngFunc_RemoveEntity, // void ) (edict_t* e); + EngFunc_CreateNamedEntity, // edict) (int className); + EngFunc_MakeStatic, // void ) (edict_t *ent); + EngFunc_EntIsOnFloor, // int ) (edict_t *e); + EngFunc_DropToFloor, // int ) (edict_t* e); + EngFunc_WalkMove, // int ) (edict_t *ent, float yaw, float dist, int iMode); + EngFunc_SetOrigin, // void ) (edict_t *e, const float *rgflOrigin); + EngFunc_EmitSound, // void ) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch); + EngFunc_EmitAmbientSound, // void ) (edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch); + EngFunc_TraceLine, // void ) (const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); + EngFunc_TraceToss, // void ) (edict_t* pent, edict_t* pentToIgnore, TraceResult *ptr); + EngFunc_TraceMonsterHull, // int ) (edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr); + EngFunc_TraceHull, // void ) (const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr); + EngFunc_TraceModel, // void ) (const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr); + EngFunc_TraceTexture, // const char *) (edict_t *pTextureEntity, const float *v1, const float *v2 ); + EngFunc_TraceSphere, // void ) (const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr); + EngFunc_GetAimVector, // void ) (edict_t* ent, float speed, float *rgflReturn); + EngFunc_ParticleEffect, // void ) (const float *org, const float *dir, float color, float count); + EngFunc_LightStyle, // void ) (int style, char* val); + EngFunc_DecalIndex, // int ) (const char *name); + EngFunc_PointContents, // int ) (const float *rgflVector); + EngFunc_FreeEntPrivateData, // void ) (edict_t *pEdict); + EngFunc_SzFromIndex, // const char * ) (int iString); + EngFunc_AllocString, // int ) (const char *szValue); + EngFunc_RegUserMsg, // int ) (const char *pszName, int iSize); + EngFunc_AnimationAutomove, // void ) (const edict_t* pEdict, float flTime); + EngFunc_GetBonePosition, // void ) (const edict_t* pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); + EngFunc_GetAttachment, // void ) (const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles ); + EngFunc_SetView, // void ) (const edict_t *pClient, const edict_t *pViewent ); + EngFunc_Time, // float) ( void ); + EngFunc_CrosshairAngle, // void ) (const edict_t *pClient, float pitch, float yaw); + EngFunc_FadeClientVolume, // void ) (const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds); + EngFunc_SetClientMaxspeed, // void ) (const edict_t *pEdict, float fNewMaxspeed); + EngFunc_CreateFakeClient, // edict) (const char *netname); // returns NULL if fake client can't be created + EngFunc_RunPlayerMove, // void ) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec ); + EngFunc_NumberOfEntities, // int ) (void); + EngFunc_StaticDecal, // void ) ( const float *origin, int decalIndex, int entityIndex, int modelIndex ); + EngFunc_PrecacheGeneric, // int ) (char* s); + EngFunc_BuildSoundMsg, // void ) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed); + EngFunc_GetPhysicsKeyValue, // const char* ) ( const edict_t *pClient, const char *key ); + EngFunc_SetPhysicsKeyValue, // void ) ( const edict_t *pClient, const char *key, const char *value ); + EngFunc_GetPhysicsInfoString,// const char* ) ( const edict_t *pClient ); + EngFunc_PrecacheEvent, // unsigned short ) ( int type, const char*psz ); + EngFunc_PlaybackEvent, // void ) ( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); + EngFunc_CheckVisibility, //) ( const edict_t *entity, unsigned char *pset ); + EngFunc_GetCurrentPlayer, //) ( void ); + EngFunc_CanSkipPlayer, //) ( const edict_t *player ); + EngFunc_SetGroupMask, //) ( int mask, int op ); + EngFunc_GetClientListening, // bool (int iReceiver, int iSender) + EngFunc_SetClientListening, // bool (int iReceiver, int iSender, bool Listen) + EngFunc_MessageBegin, // void (int msg_dest, int msg_type, const float *pOrigin, edict_t *ed) + EngFunc_WriteCoord, // void (float) + EngFunc_WriteAngle, // void (float) + EngFunc_InfoKeyValue, // char* ) (char *infobuffer, char *key); + EngFunc_SetKeyValue, // void ) (char *infobuffer, char *key, char *value); + EngFunc_SetClientKeyValue // void ) (int clientIndex, char *infobuffer, char *key, char *value); +}; +enum +{ + DLLFunc_GameInit, // void) ( void ); + DLLFunc_Spawn, // int ) ( edict_t *pent ); + DLLFunc_Think, // void ) ( edict_t *pent ); + DLLFunc_Use, // void ) ( edict_t *pentUsed, edict_t *pentOther ); + DLLFunc_Touch, // void ) ( edict_t *pentTouched, edict_t *pentOther ); + DLLFunc_Blocked, // void ) ( edict_t *pentBlocked, edict_t *pentOther ); + DLLFunc_KeyValue, // void ) ( edict_t *pentKeyvalue, KeyValueData *pkvd ); + DLLFunc_SetAbsBox, // void ) ( edict_t *pent ); + DLLFunc_ClientConnect, // bool) ( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); + + DLLFunc_ClientDisconnect, // void ) ( edict_t *pEntity ); + DLLFunc_ClientKill, // void ) ( edict_t *pEntity ); + DLLFunc_ClientPutInServer, // void ) ( edict_t *pEntity ); + DLLFunc_ClientCommand, // void ) ( edict_t *pEntity ); + + DLLFunc_ServerDeactivate, // void) ( void ); + + DLLFunc_PlayerPreThink, // void ) ( edict_t *pEntity ); + DLLFunc_PlayerPostThink, // void ) ( edict_t *pEntity ); + + DLLFunc_StartFrame, // void ) ( void ); + DLLFunc_ParmsNewLevel, // void ) ( void ); + DLLFunc_ParmsChangeLevel, // void ) ( void ); + + // Returns string describing current .dll. E.g., TeamFotrress 2, Half-Life + DLLFunc_GetGameDescription, // const char * )( void ); + + // Spectator funcs + DLLFunc_SpectatorConnect, // void) ( edict_t *pEntity ); + DLLFunc_SpectatorDisconnect, // void ) ( edict_t *pEntity ); + DLLFunc_SpectatorThink, // void ) ( edict_t *pEntity ); + + // Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint. + DLLFunc_Sys_Error, // void ) ( const char *error_string ); + + DLLFunc_PM_FindTextureType, // char )( char *name ); + DLLFunc_RegisterEncoders, // void ) ( void ); + + // Enumerates player hulls. Returns 0 if the hull number doesn't exist, 1 otherwise + DLLFunc_GetHullBounds, // int) ( int hullnumber, float *mins, float *maxs ); + + // Create baselines for certain "unplaced" items. + DLLFunc_CreateInstancedBaselines, // void ) ( void ); + DLLFunc_pfnAllowLagCompensation, // int )( void ); + // I know this does not fit with DLLFUNC(), but I dont want another native just for it. + MetaFunc_CallGameEntity // bool (plid_t plid, const char *entStr,entvars_t *pev); +}; + +// Used by the traceresult() native. +enum +{ + TR_AllSolid, // (int) if true, plane is not valid + TR_StartSolid, // (int) if true, the initial point was in a solid area + TR_InOpen, // (int) + TR_InWater, // (int) + TR_Fraction, // (float) time completed, 1.0 = didn't hit anything + TR_EndPos, // (vector) final position + TR_PlaneDist, // (float) + TR_PlaneNormal, // (vector) surface normal at impact + TR_Hit, // (entity) entity the surface is on + TR_Hitgroup // (int) 0 == generic, non zero is specific body part +}; +enum { + Meta_GetUserMsgID, // int ) (plid_t plid, const char *msgname, int *size); + Meta_GetUserMsgName, // const char *) (plid_t plid, int msgid, int *size); + Meta_GetPluginPath, // const char *) (plid_t plid); + Meta_GetGameInfo // const char *) (plid_t plid, ginfo_t tag); +}; + //These two structs are relics from VexD struct PlayerInfo { int iSpeakFlags; @@ -92,16 +243,60 @@ struct GlobalInfo { bool bCheckLights; }; +class Impulse +{ +public: + int Forward; + int Check; +}; + +class Touch +{ +public: + int Forward; + char *Toucher; + char *Touched; + ~Touch() + { + if (Toucher) { + delete [] Toucher; + Toucher = 0; + } + if (Touched) { + delete [] Touched; + Touched = 0; + } + } +}; + +class EntClass +{ +public: + int Forward; + char *Class; + ~EntClass() + { + if (Class) { + delete [] Class; + Class = 0; + } + } +}; + int is_ent_valid(int iEnt); int AmxStringToEngine(AMX *amx, cell param, int &len); edict_t *UTIL_FindEntityInSphere(edict_t *pStart, const Vector &vecCenter, float flRadius); -extern bool inKeyValue; +extern bool g_inKeyValue; extern KeyValueData *g_pkvd; extern bool incmd; extern struct usercmd_s *g_cmd; extern struct PlayerInfo plinfo[33]; extern struct GlobalInfo glinfo; extern AMX_NATIVE_INFO engine_Natives[]; +extern std::vector Impulses; +extern std::vector Thinks; +extern std::vector Uses; +extern std::vector Touches; #endif //_ENGINE_INCLUDE_H \ No newline at end of file diff --git a/dlls/engine/entity.cpp b/dlls/engine/entity.cpp index 64796b0b..d8d16dac 100755 --- a/dlls/engine/entity.cpp +++ b/dlls/engine/entity.cpp @@ -182,6 +182,21 @@ static cell AMX_NATIVE_CALL get_keyvalue(AMX *amx, cell *params) return MF_SetAmxString(amx, params[3], INFO_KEY_VALUE(INFO_KEY_BUFFER(pEntity),char1), params[4]); } +static cell AMX_NATIVE_CALL copy_keyvalue(AMX *amx, cell *params) +{ + if (!g_inKeyValue) + return 0; + + if (g_pkvd->szClassName) + MF_SetAmxString(amx, params[1], g_pkvd->szClassName, params[2]); + if (g_pkvd->szKeyName) + MF_SetAmxString(amx, params[3], g_pkvd->szKeyName, params[4]); + if (g_pkvd->szValue) + MF_SetAmxString(amx, params[5], g_pkvd->szValue, params[6]); + + return 1; +} + static cell AMX_NATIVE_CALL DispatchSpawn(AMX *amx, cell *params) { int iEnt = params[1]; @@ -1785,6 +1800,8 @@ AMX_NATIVE_INFO ent_Natives[] = { {"find_ent_by_owner", find_ent_by_owner}, {"get_grenade_id", get_grenade_id}, + {"copy_keyvalue", copy_keyvalue}, + {NULL, NULL}, /////////////////// }; \ No newline at end of file diff --git a/dlls/engine/forwards.cpp b/dlls/engine/forwards.cpp index 7aeab332..c07eb9ea 100755 --- a/dlls/engine/forwards.cpp +++ b/dlls/engine/forwards.cpp @@ -13,6 +13,27 @@ int PlayerPostThinkForward = 0; int ClientKillForward = 0; int CmdStartForward = 0; int StartFrameForward = 0; +std::vector Impulses; +std::vector Thinks; +std::vector Uses; +std::vector Touches; +KeyValueData *g_pkvd; +bool g_inKeyValue=false; + +int fstrcmp(const char *s1, const char *s2) +{ + int i=0; + int len1 = strlen(s1); + int len2 = strlen(s2); + if (len1 != len2) + return 0; + for (i=0; i 0) RETURN_META(MRES_SUPERCEDE); + else + RETURN_META(MRES_HANDLED); } + g_inKeyValue=false; RETURN_META(MRES_HANDLED); } -#endif void StartFrame_Post() { @@ -110,9 +132,21 @@ void StartFrame_Post() void CmdStart(const edict_t *player, const struct usercmd_s *_cmd, unsigned int random_seed) { + unsigned int i = 0; int retVal = 0; edict_t *pEntity = (edict_t *)player; struct usercmd_s *g_cmd = (struct usercmd_s *)_cmd; + for (i=0; iCheck == g_cmd->impulse) + { + retVal = MF_ExecuteForward(Impulses[i]->Forward, ENTINDEX(pEntity)); + if (retVal) + RETURN_META(MRES_SUPERCEDE); + else + RETURN_META(MRES_IGNORED); + } + } if (CmdStartForward) { incmd = true; retVal = MF_ExecuteForward(CmdStartForward, ENTINDEX(pEntity), g_cmd->impulse); @@ -192,7 +226,45 @@ void PlayerPostThink_Post(edict_t *pEntity) void DispatchTouch(edict_t *pToucher, edict_t *pTouched) { + unsigned int i = 0; int retVal = 0; + const char *ptrClass = STRING(pToucher->v.classname); + const char *ptdClass = STRING(pTouched->v.classname); + for (i=0; iToucher = 0) + { + if (Touches[i]->Touched = 0) + { + retVal = MF_ExecuteForward(Touches[i]->Forward, ENTINDEX(pToucher), ENTINDEX(pTouched)); + if (retVal) + RETURN_META(MRES_SUPERCEDE); + else + RETURN_META(MRES_IGNORED); + } else if (fstrcmp(Touches[i]->Touched, ptdClass)) { + retVal = MF_ExecuteForward(Touches[i]->Forward, ENTINDEX(pToucher), ENTINDEX(pTouched)); + if (retVal) + RETURN_META(MRES_SUPERCEDE); + else + RETURN_META(MRES_IGNORED); + } + } else if (fstrcmp(Touches[i]->Toucher, ptrClass)) { + if (Touches[i]->Touched = 0) + { + retVal = MF_ExecuteForward(Touches[i]->Forward, ENTINDEX(pToucher), ENTINDEX(pTouched)); + if (retVal) + RETURN_META(MRES_SUPERCEDE); + else + RETURN_META(MRES_IGNORED); + } else if (fstrcmp(Touches[i]->Touched, ptdClass)) { + retVal = MF_ExecuteForward(Touches[i]->Forward, ENTINDEX(pToucher), ENTINDEX(pTouched)); + if (retVal) + RETURN_META(MRES_SUPERCEDE); + else + RETURN_META(MRES_IGNORED); + } + } + } /* Execute pfnTouch forwards */ if (pfnTouchForward) { retVal = MF_ExecuteForward(pfnTouchForward, ENTINDEX(pToucher), ENTINDEX(pTouched)); @@ -205,6 +277,16 @@ void DispatchTouch(edict_t *pToucher, edict_t *pTouched) void DispatchThink_Post(edict_t *pent) { + unsigned int i = 0; + const char *cls = STRING(pent->v.classname); + for (i=0; iClass)) + { + MF_ExecuteForward(Thinks[i]->Forward, ENTINDEX(pent)); + RETURN_META(MRES_IGNORED); + } + } MF_ExecuteForward(pfnThinkForward, ENTINDEX(pent)); RETURN_META(MRES_IGNORED);