New version of Engine.
This commit is contained in:
parent
7bb4c78a33
commit
37a08f66b0
136
dlls/engine/amxxapi.cpp
Executable file
136
dlls/engine/amxxapi.cpp
Executable file
|
@ -0,0 +1,136 @@
|
|||
#include "engine.h"
|
||||
|
||||
int AmxStringToEngine(AMX *amx, cell param, int &len)
|
||||
{
|
||||
char *szString = MF_GetAmxString(amx, param, 0, &len);
|
||||
char *szCopy = new char[len+1];
|
||||
|
||||
memset(szCopy, 0, len+1);
|
||||
strcpy(szCopy, szString);
|
||||
|
||||
return MAKE_STRING(szCopy);
|
||||
}
|
||||
|
||||
void OnAmxxAttach()
|
||||
{
|
||||
pfnTouchForward = 0;
|
||||
pfnThinkForward = 0;
|
||||
PlayerPreThinkForward = 0;
|
||||
PlayerPostThinkForward = 0;
|
||||
ClientKillForward = 0;
|
||||
CmdStartForward = 0;
|
||||
StartFrameForward = 0;
|
||||
MF_AddNatives(msg_Natives);
|
||||
MF_AddNatives(ent_Natives);
|
||||
MF_AddNatives(engine_Natives);
|
||||
MF_AddNatives(global_Natives);
|
||||
memset(glinfo.szLastLights, 0x0, 128);
|
||||
memset(glinfo.szRealLights, 0x0, 128);
|
||||
glinfo.bLights = false;
|
||||
glinfo.fNextLights = 0;
|
||||
glinfo.bCheckLights = false;
|
||||
}
|
||||
|
||||
void OnPluginsLoaded()
|
||||
{
|
||||
pfnThinkForward = MF_RegisterForward("pfnThink", ET_STOP, FP_CELL, FP_DONE);
|
||||
PlayerPreThinkForward = MF_RegisterForward("client_PreThink", ET_STOP, FP_CELL, FP_DONE);
|
||||
PlayerPostThinkForward = MF_RegisterForward("client_PostThink", ET_STOP, FP_CELL, FP_DONE);
|
||||
ClientKillForward = MF_RegisterForward("client_kill", ET_STOP, FP_CELL, FP_DONE);
|
||||
CmdStartForward = MF_RegisterForward("client_impulse", ET_STOP, FP_CELL, FP_CELL, FP_DONE);
|
||||
StartFrameForward = MF_RegisterForward("ServerFrame", ET_IGNORE, FP_DONE);
|
||||
DispatchKeyForward = MF_RegisterForward("Dispatch_KeyVal", ET_STOP, FP_CELL, FP_DONE);
|
||||
PlaybackForward = MF_RegisterForward("PlaybackEvent", ET_STOP, FP_CELL, FP_CELL, FP_CELL, FP_FLOAT, FP_ARRAY, FP_ARRAY, FP_FLOAT, FP_FLOAT, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
|
||||
ChangelevelForward = MF_RegisterForward("server_changelevel", ET_STOP, FP_STRING, FP_DONE);
|
||||
SpawnForward = MF_RegisterForward("pfnSpawn", ET_IGNORE, FP_CELL, FP_DONE);
|
||||
DispatchUseForward = MF_RegisterForward("pfnUse", ET_STOP, FP_CELL, FP_CELL, FP_DONE);
|
||||
pfnTouchForward = MF_RegisterForward("pfnTouch", ET_STOP, FP_CELL, FP_CELL, FP_DONE);
|
||||
MF_Log("pfnTouch Forward: %d", pfnTouchForward);
|
||||
}
|
||||
|
||||
qboolean Voice_SetClientListening(int iReceiver, int iSender, qboolean bListen)
|
||||
{
|
||||
if((plinfo[iSender].iSpeakFlags & SPEAK_MUTED) != 0) {
|
||||
(g_engfuncs.pfnVoice_SetClientListening)(iReceiver, iSender, false);
|
||||
RETURN_META_VALUE(MRES_SUPERCEDE, false);
|
||||
}
|
||||
|
||||
if((plinfo[iSender].iSpeakFlags & SPEAK_ALL) != 0) {
|
||||
(g_engfuncs.pfnVoice_SetClientListening)(iReceiver, iSender, true);
|
||||
RETURN_META_VALUE(MRES_SUPERCEDE, true);
|
||||
}
|
||||
|
||||
if((plinfo[iReceiver].iSpeakFlags & SPEAK_LISTENALL) != 0) {
|
||||
(g_engfuncs.pfnVoice_SetClientListening)(iReceiver, iSender, true);
|
||||
RETURN_META_VALUE(MRES_SUPERCEDE, true);
|
||||
}
|
||||
|
||||
RETURN_META_VALUE(MRES_IGNORED, bListen);
|
||||
}
|
||||
|
||||
int AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet)
|
||||
{
|
||||
if(ent == host) {
|
||||
if(FStrEq(STRING(ent->v.classname), "player")) {
|
||||
if(plinfo[ENTINDEX(ent)].iViewType != CAMERA_NONE) {
|
||||
ent->v.rendermode = kRenderTransTexture;
|
||||
ent->v.renderamt = 100;
|
||||
RETURN_META_VALUE(MRES_IGNORED, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(FStrEq(STRING(ent->v.classname), "player")) {
|
||||
if(plinfo[ENTINDEX(ent)].iViewType != CAMERA_NONE) {
|
||||
ent->v.rendermode = plinfo[ENTINDEX(ent)].iRenderMode;
|
||||
ent->v.renderamt = plinfo[ENTINDEX(ent)].fRenderAmt;
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_META_VALUE(MRES_IGNORED, 0);
|
||||
}
|
||||
|
||||
void ClientDisconnect(edict_t *pEntity)
|
||||
{
|
||||
int id = ENTINDEX(pEntity);
|
||||
|
||||
plinfo[id].iSpeakFlags = SPEAK_NORMAL;
|
||||
plinfo[id].iViewType = CAMERA_NONE;
|
||||
plinfo[id].iRenderMode = 0;
|
||||
plinfo[id].fRenderAmt = 0;
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
BOOL ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128])
|
||||
{
|
||||
int id = ENTINDEX(pEntity);
|
||||
|
||||
plinfo[id].iSpeakFlags = SPEAK_NORMAL;
|
||||
plinfo[id].iViewType = CAMERA_NONE;
|
||||
plinfo[id].pViewEnt = NULL;
|
||||
plinfo[id].iRenderMode = 0;
|
||||
plinfo[id].fRenderAmt = 0;
|
||||
|
||||
RETURN_META_VALUE(MRES_IGNORED, 0);
|
||||
}
|
||||
|
||||
void ServerDeactivate()
|
||||
{
|
||||
memset(glinfo.szLastLights, 0x0, 128);
|
||||
memset(glinfo.szRealLights, 0x0, 128);
|
||||
glinfo.bLights = false;
|
||||
glinfo.fNextLights = 0;
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
|
||||
}
|
||||
|
||||
void LightStyle(int style, char *val) {
|
||||
if (!style) {
|
||||
memset(glinfo.szRealLights, 0x0, 128);
|
||||
memcpy(glinfo.szRealLights, val, strlen(val));
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
|
@ -34,6 +34,9 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <new>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "amxxmodule.h"
|
||||
|
||||
/************* METAMOD SUPPORT *************/
|
||||
|
@ -2469,6 +2472,12 @@ PFN_AMX_ALLOT g_fn_AmxAllot;
|
|||
PFN_AMX_FINDPUBLIC g_fn_AmxFindPublic;
|
||||
PFN_LOAD_AMXSCRIPT g_fn_LoadAmxScript;
|
||||
PFN_UNLOAD_AMXSCRIPT g_fn_UnloadAmxScript;
|
||||
PFN_REAL_TO_CELL g_fn_RealToCell;
|
||||
PFN_CELL_TO_REAL g_fn_CellToReal;
|
||||
PFN_REGISTER_SPFORWARD g_fn_RegisterSPForward;
|
||||
PFN_REGISTER_SPFORWARD_BYNAME g_fn_RegisterSPForwardByName;
|
||||
PFN_UNREGISTER_SPFORWARD g_fn_UnregisterSPForward;
|
||||
|
||||
// *** Exports ***
|
||||
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
|
||||
{
|
||||
|
@ -2536,6 +2545,9 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
|
|||
REQFUNC("AddNatives", g_fn_AddNatives, PFN_ADD_NATIVES);
|
||||
REQFUNC("RaiseAmxError", g_fn_RaiseAmxError, PFN_RAISE_AMXERROR);
|
||||
REQFUNC("RegisterForward", g_fn_RegisterForward, PFN_REGISTER_FORWARD);
|
||||
REQFUNC("RegisterSPForward", g_fn_RegisterSPForward, PFN_REGISTER_SPFORWARD);
|
||||
REQFUNC("RegisterSPForwardByName", g_fn_RegisterSPForwardByName, PFN_REGISTER_SPFORWARD_BYNAME);
|
||||
REQFUNC("UnregisterSPForward", g_fn_UnregisterSPForward, PFN_UNREGISTER_SPFORWARD);
|
||||
REQFUNC("ExecuteForward", g_fn_ExecuteForward, PFN_EXECUTE_FORWARD);
|
||||
REQFUNC("PrepareCellArray", g_fn_PrepareCellArray, PFN_PREPARE_CELLARRAY);
|
||||
REQFUNC("PrepareCharArray", g_fn_PrepareCharArray, PFN_PREPARE_CHARARRAY);
|
||||
|
@ -2566,6 +2578,9 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
|
|||
REQFUNC_OPT("Reallocator", g_fn_Reallocator, PFN_REALLOCATOR);
|
||||
REQFUNC_OPT("Deallocator", g_fn_Deallocator, PFN_DEALLOCATOR);
|
||||
|
||||
REQFUNC("CellToReal", g_fn_CellToReal, PFN_CELL_TO_REAL);
|
||||
REQFUNC("RealToCell", g_fn_RealToCell, PFN_REAL_TO_CELL);
|
||||
|
||||
#ifdef FN_AMXX_ATTACH
|
||||
FN_AMXX_ATTACH();
|
||||
#endif // FN_AMXX_ATACH
|
||||
|
@ -2593,8 +2608,6 @@ C_DLLEXPORT int AMXX_PluginsLoaded()
|
|||
// Advanced MF functions
|
||||
void MF_Log(const char *fmt, ...)
|
||||
{
|
||||
ASSERT(g_fn_Log);
|
||||
|
||||
// :TODO: Overflow possible here
|
||||
char msg[3072];
|
||||
va_list arglst;
|
||||
|
@ -2609,7 +2622,7 @@ void MF_Log(const char *fmt, ...)
|
|||
#ifdef _DEBUG
|
||||
// validate macros
|
||||
// Makes sure compiler reports errors when macros are invalid
|
||||
void ValidateMacros()
|
||||
void ValidateMacros_DontCallThis_Smiley()
|
||||
{
|
||||
MF_BuildPathname("str", "str", 0);
|
||||
MF_FormatAmxString(NULL, 0, 0, NULL);
|
||||
|
@ -2655,6 +2668,9 @@ void ValidateMacros()
|
|||
MF_AmxAllot(0, 0, 0, 0);
|
||||
MF_LoadAmxScript(0, 0, 0, 0);
|
||||
MF_UnloadAmxScript(0, 0);
|
||||
MF_RegisterSPForward(0, 0, 0, 0, 0, 0);
|
||||
MF_RegisterSPForwardByName(0, 0, 0, 0, 0, 0);
|
||||
MF_UnregisterSPForward(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -106,21 +106,17 @@ struct amxx_module_info_s
|
|||
|
||||
|
||||
|
||||
#if defined BIT16
|
||||
#define SMALL_CELL_SIZE 16 /* for backward compatibility */
|
||||
#endif
|
||||
#if !defined SMALL_CELL_SIZE
|
||||
#define SMALL_CELL_SIZE 32 /* by default, use 32-bit cells */
|
||||
#endif
|
||||
#if SMALL_CELL_SIZE==16
|
||||
typedef uint16_t ucell;
|
||||
typedef int16_t cell;
|
||||
#elif SMALL_CELL_SIZE==32
|
||||
#if SMALL_CELL_SIZE==32
|
||||
typedef uint32_t ucell;
|
||||
typedef int32_t cell;
|
||||
typedef float REAL;
|
||||
#elif SMALL_CELL_SIZE==64
|
||||
typedef uint64_t ucell;
|
||||
typedef int64_t cell;
|
||||
typedef double REAL;
|
||||
#else
|
||||
#error Unsupported cell size (SMALL_CELL_SIZE)
|
||||
#endif
|
||||
|
@ -244,32 +240,6 @@ enum {
|
|||
AMX_ERR_DOMAIN, /* domain error, expression result does not fit in range */
|
||||
};
|
||||
|
||||
/* for native functions that use floating point parameters, the following
|
||||
* two macros are convenient for casting a "cell" into a "float" type _without_
|
||||
* changing the bit pattern
|
||||
*/
|
||||
#if SMALL_CELL_SIZE==32
|
||||
inline cell amx_ftoc(float f)
|
||||
{
|
||||
return *(cell*)&f;
|
||||
}
|
||||
inline float amx_ctof(cell c)
|
||||
{
|
||||
return *(float*)&c;
|
||||
}
|
||||
#elif SMALL_CELL_SIZE==64
|
||||
inline cell amx_ftoc(double f)
|
||||
{
|
||||
return *(cell*)&f;
|
||||
}
|
||||
inline double amx_ctof(cell c)
|
||||
{
|
||||
return *(double*)&c;
|
||||
}
|
||||
#else
|
||||
#error Unsupported cell size
|
||||
#endif
|
||||
|
||||
|
||||
// ***** declare functions *****
|
||||
|
||||
|
@ -1979,6 +1949,11 @@ typedef int (*PFN_AMX_ALLOT) (AMX* /*amx*/, int /*length*/, cell* /*amx_ad
|
|||
typedef int (*PFN_AMX_FINDPUBLIC) (AMX* /*amx*/, char* /*func name*/, int* /*index*/);
|
||||
typedef int (*PFN_LOAD_AMXSCRIPT) (AMX* /*amx*/, void** /*code*/, const char* /*path*/, char[64] /*error info*/);
|
||||
typedef int (*PFN_UNLOAD_AMXSCRIPT) (AMX* /*amx*/,void** /*code*/);
|
||||
typedef cell (*PFN_REAL_TO_CELL) (REAL /*x*/);
|
||||
typedef REAL (*PFN_CELL_TO_REAL) (cell /*x*/);
|
||||
typedef int (*PFN_REGISTER_SPFORWARD) (AMX * /*amx*/, int /*func*/, ... /*params*/);
|
||||
typedef int (*PFN_REGISTER_SPFORWARD_BYNAME) (AMX * /*amx*/, const char * /*funcName*/, ... /*params*/);
|
||||
typedef void (*PFN_UNREGISTER_SPFORWARD) (int /*id*/);
|
||||
|
||||
extern PFN_ADD_NATIVES g_fn_AddNatives;
|
||||
extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
|
||||
|
@ -2019,6 +1994,17 @@ extern PFN_IS_PLAYER_CONNECTING g_fn_IsPlayerConnecting;
|
|||
extern PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV;
|
||||
extern PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
|
||||
extern PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
|
||||
extern PFN_AMX_EXEC g_fn_AmxExec;
|
||||
extern PFN_AMX_EXECV g_fn_AmxExecv;
|
||||
extern PFN_AMX_ALLOT g_fn_AmxAllot;
|
||||
extern PFN_AMX_FINDPUBLIC g_fn_AmxFindPublic;
|
||||
extern PFN_LOAD_AMXSCRIPT g_fn_LoadAmxScript;
|
||||
extern PFN_UNLOAD_AMXSCRIPT g_fn_UnloadAmxScript;
|
||||
extern PFN_REAL_TO_CELL g_fn_RealToCell;
|
||||
extern PFN_CELL_TO_REAL g_fn_CellToReal;
|
||||
extern PFN_REGISTER_SPFORWARD g_fn_RegisterSPForward;
|
||||
extern PFN_REGISTER_SPFORWARD_BYNAME g_fn_RegisterSPForwardByName;
|
||||
extern PFN_UNREGISTER_SPFORWARD g_fn_UnregisterSPForward;
|
||||
|
||||
#ifdef MAY_NEVER_BE_DEFINED
|
||||
// Function prototypes for intellisense and similar systems
|
||||
|
@ -2062,6 +2048,11 @@ int MF_IsPlayerConnecting (int id) { }
|
|||
int MF_IsPlayerHLTV (int id) { }
|
||||
int MF_GetPlayerArmor (int id) { }
|
||||
int MF_GetPlayerHealth (int id) { }
|
||||
REAL amx_ctof (cell x) { }
|
||||
cell amx_ftoc (float x) { }
|
||||
int MF_RegisterSPForwardByName (AMX * amx, const char *str, ...) { }
|
||||
int MF_RegisterSPForward (AMX * amx, int func, ...) { }
|
||||
void MF_UnregisterSPForward (int id) { }
|
||||
#endif // MAY_NEVER_BE_DEFINED
|
||||
|
||||
#define MF_AddNatives g_fn_AddNatives
|
||||
|
@ -2109,6 +2100,11 @@ void MF_Log(const char *fmt, ...);
|
|||
#define MF_AmxAllot g_fn_AmxAllot
|
||||
#define MF_LoadAmxScript g_fn_LoadAmxScript
|
||||
#define MF_UnloadAmxScript g_fn_UnloadAmxScript
|
||||
#define amx_ctof g_fn_CellToReal
|
||||
#define amx_ftoc g_fn_RealToCell
|
||||
#define MF_RegisterSPForwardByName g_fn_RegisterSPForwardByName
|
||||
#define MF_RegisterSPForward g_fn_RegisterSPForward
|
||||
#define MF_UnregisterSPForward g_fn_UnregisterSPForward
|
||||
|
||||
/*** Memory ***/
|
||||
void *operator new(size_t reportedSize);
|
||||
|
|
816
dlls/engine/engine.cpp
Executable file
816
dlls/engine/engine.cpp
Executable file
|
@ -0,0 +1,816 @@
|
|||
#include "engine.h"
|
||||
|
||||
bool inKeyValue=false;
|
||||
KeyValueData *g_pkvd;
|
||||
struct usercmd_s *g_cmd;
|
||||
struct PlayerInfo plinfo[33];
|
||||
struct GlobalInfo glinfo;
|
||||
|
||||
void UTIL_SetSize(edict_t *pev, const Vector &vecMin, const Vector &vecMax)
|
||||
{
|
||||
SET_SIZE(ENT(pev), vecMin, vecMax);
|
||||
}
|
||||
|
||||
edict_t *UTIL_FindEntityInSphere(edict_t *pStart, const Vector &vecCenter, float flRadius) {
|
||||
if (!pStart) pStart = NULL;
|
||||
|
||||
pStart = FIND_ENTITY_IN_SPHERE(pStart, vecCenter, flRadius);
|
||||
|
||||
if (!FNullEnt(pStart)) return pStart;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL halflife_time(AMX *amx, cell *params)
|
||||
{
|
||||
REAL fVal = gpGlobals->time;
|
||||
|
||||
return amx_ftoc(fVal);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL VelocityByAim(AMX *amx, cell *params)
|
||||
{
|
||||
int iEnt = params[1];
|
||||
int iVelocity = params[2];
|
||||
cell *vRet = MF_GetAmxAddr(amx, params[3]);
|
||||
Vector vVector = Vector(0, 0, 0);
|
||||
|
||||
if (!is_ent_valid(iEnt)) {
|
||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
edict_t *pEnt = INDEXENT(iEnt);
|
||||
|
||||
MAKE_VECTORS(pEnt->v.v_angle);
|
||||
vVector = gpGlobals->v_forward * iVelocity;
|
||||
|
||||
vRet[0] = amx_ftoc(vVector.x);
|
||||
vRet[1] = amx_ftoc(vVector.y);
|
||||
vRet[2] = amx_ftoc(vVector.z);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// RadiusDamage. Damages players within a certain radius. ToDo: add the
|
||||
// damage messaging so players know where the damage is coming from
|
||||
// (the red arrow-like things on the screen).
|
||||
//(vexd)
|
||||
static cell AMX_NATIVE_CALL RadiusDamage(AMX *amx, cell *params) {
|
||||
cell *cAddr = MF_GetAmxAddr(amx,params[1]);
|
||||
|
||||
REAL fCurrentX = amx_ctof(cAddr[0]);
|
||||
REAL fCurrentY = amx_ctof(cAddr[1]);
|
||||
REAL fCurrentZ = amx_ctof(cAddr[2]);
|
||||
int iDamageMultiplier = params[2];
|
||||
int iRadiusMultiplier = params[3];
|
||||
|
||||
Vector vOrigin = Vector(fCurrentX, fCurrentY, fCurrentZ);
|
||||
|
||||
edict_t *pSearchEnt = NULL;
|
||||
while((pSearchEnt = UTIL_FindEntityInSphere(pSearchEnt, vOrigin, 5 * iRadiusMultiplier)) != NULL) {
|
||||
if(FStrEq(STRING(pSearchEnt->v.classname), "player")) {
|
||||
if(pSearchEnt->v.takedamage != DAMAGE_NO) {
|
||||
pSearchEnt->v.health -= 10 + RANDOM_FLOAT(0,1 * iDamageMultiplier);
|
||||
if(pSearchEnt->v.health < 1) {
|
||||
pSearchEnt->v.health = 1;
|
||||
MDLL_ClientKill(pSearchEnt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pSearchEnt = NULL;
|
||||
|
||||
while((pSearchEnt = UTIL_FindEntityInSphere(pSearchEnt, vOrigin, 4 * iRadiusMultiplier)) != NULL) {
|
||||
if(FStrEq(STRING(pSearchEnt->v.classname), "player")) {
|
||||
if(pSearchEnt->v.takedamage != DAMAGE_NO) {
|
||||
pSearchEnt->v.health -= 25 + RANDOM_FLOAT(0,2 * iDamageMultiplier);
|
||||
if(pSearchEnt->v.health < 1) {
|
||||
pSearchEnt->v.health = 1;
|
||||
MDLL_ClientKill(pSearchEnt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pSearchEnt = NULL;
|
||||
|
||||
while((pSearchEnt = UTIL_FindEntityInSphere(pSearchEnt, vOrigin, 3 * iRadiusMultiplier)) != NULL) {
|
||||
if(FStrEq(STRING(pSearchEnt->v.classname), "player")) {
|
||||
if(pSearchEnt->v.takedamage != DAMAGE_NO) {
|
||||
pSearchEnt->v.health -= 50 + RANDOM_FLOAT(0,3 * iDamageMultiplier);
|
||||
if(pSearchEnt->v.health < 1) {
|
||||
pSearchEnt->v.health = 1;
|
||||
MDLL_ClientKill(pSearchEnt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pSearchEnt = NULL;
|
||||
|
||||
while((pSearchEnt = UTIL_FindEntityInSphere(pSearchEnt, vOrigin, 2 * iRadiusMultiplier)) != NULL) {
|
||||
if(FStrEq(STRING(pSearchEnt->v.classname), "player")) {
|
||||
if(pSearchEnt->v.takedamage != DAMAGE_NO) MDLL_ClientKill(pSearchEnt);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL PointContents(AMX *amx, cell *params)
|
||||
{
|
||||
cell *cAddr = MF_GetAmxAddr(amx, params[1]);
|
||||
|
||||
REAL fX = amx_ctof(cAddr[0]);
|
||||
REAL fY = amx_ctof(cAddr[1]);
|
||||
REAL fZ = amx_ctof(cAddr[2]);
|
||||
|
||||
Vector vPoint = Vector(fX, fY, fZ);
|
||||
|
||||
return POINT_CONTENTS(vPoint);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL vector_to_angle(AMX *amx, cell *params)
|
||||
{
|
||||
cell *cAddr = MF_GetAmxAddr(amx, params[1]);
|
||||
|
||||
REAL fX = amx_ctof(cAddr[0]);
|
||||
REAL fY = amx_ctof(cAddr[1]);
|
||||
REAL fZ = amx_ctof(cAddr[2]);
|
||||
|
||||
Vector vVector = Vector(fX, fY, fZ);
|
||||
Vector vAngle = Vector(0, 0, 0);
|
||||
VEC_TO_ANGLES(vVector, vAngle);
|
||||
|
||||
cell *vRet = MF_GetAmxAddr(amx, params[2]);
|
||||
vRet[0] = amx_ftoc(vAngle.x);
|
||||
vRet[1] = amx_ftoc(vAngle.y);
|
||||
vRet[2] = amx_ftoc(vAngle.z);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL vector_length(AMX *amx, cell *params)
|
||||
{
|
||||
cell *cAddr = MF_GetAmxAddr(amx, params[1]);
|
||||
|
||||
REAL fX = amx_ctof(cAddr[0]);
|
||||
REAL fY = amx_ctof(cAddr[1]);
|
||||
REAL fZ = amx_ctof(cAddr[2]);
|
||||
|
||||
Vector vVector = Vector(fX, fY, fZ);
|
||||
|
||||
REAL fLength = vVector.Length();
|
||||
|
||||
return amx_ftoc(fLength);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL vector_distance(AMX *amx, cell *params)
|
||||
{
|
||||
cell *cAddr = MF_GetAmxAddr(amx, params[1]);
|
||||
cell *cAddr2 = MF_GetAmxAddr(amx, params[2]);
|
||||
|
||||
REAL fX = amx_ctof(cAddr[0]);
|
||||
REAL fY = amx_ctof(cAddr[1]);
|
||||
REAL fZ = amx_ctof(cAddr[2]);
|
||||
REAL fX2 = amx_ctof(cAddr2[0]);
|
||||
REAL fY2 = amx_ctof(cAddr2[1]);
|
||||
REAL fZ2 = amx_ctof(cAddr2[2]);
|
||||
|
||||
Vector vVector = Vector(fX, fY, fZ);
|
||||
Vector vVector2 = Vector(fX2, fY2, fZ2);
|
||||
|
||||
REAL fLength = (vVector - vVector2).Length();
|
||||
|
||||
return amx_ftoc(fLength);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL trace_normal(AMX *amx, cell *params)
|
||||
{
|
||||
int iEnt = params[1];
|
||||
|
||||
cell *cStart = MF_GetAmxAddr(amx, params[2]);
|
||||
cell *cEnd = MF_GetAmxAddr(amx, params[3]);
|
||||
REAL fStartX = amx_ctof(cStart[0]);
|
||||
REAL fStartY = amx_ctof(cStart[1]);
|
||||
REAL fStartZ = amx_ctof(cStart[2]);
|
||||
REAL fEndX = amx_ctof(cEnd[0]);
|
||||
REAL fEndY = amx_ctof(cEnd[1]);
|
||||
REAL fEndZ = amx_ctof(cEnd[2]);
|
||||
|
||||
cell *vRet = MF_GetAmxAddr(amx, params[4]);
|
||||
|
||||
Vector vStart = Vector(fStartX, fStartY, fStartZ);
|
||||
Vector vEnd = Vector(fEndX, fEndY, fEndZ);
|
||||
|
||||
TraceResult tr;
|
||||
TRACE_LINE(vStart, vEnd, dont_ignore_monsters, INDEXENT(iEnt), &tr);
|
||||
|
||||
vRet[0] = amx_ftoc(tr.vecPlaneNormal.x);
|
||||
vRet[1] = amx_ftoc(tr.vecPlaneNormal.y);
|
||||
vRet[2] = amx_ftoc(tr.vecPlaneNormal.z);
|
||||
|
||||
if (tr.flFraction >= 1.0)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL trace_line(AMX *amx, cell *params)
|
||||
{
|
||||
int iEnt = params[1];
|
||||
|
||||
cell *cStart = MF_GetAmxAddr(amx, params[2]);
|
||||
cell *cEnd = MF_GetAmxAddr(amx, params[3]);
|
||||
REAL fStartX = amx_ctof(cStart[0]);
|
||||
REAL fStartY = amx_ctof(cStart[1]);
|
||||
REAL fStartZ = amx_ctof(cStart[2]);
|
||||
REAL fEndX = amx_ctof(cEnd[0]);
|
||||
REAL fEndY = amx_ctof(cEnd[1]);
|
||||
REAL fEndZ = amx_ctof(cEnd[2]);
|
||||
|
||||
cell *vRet = MF_GetAmxAddr(amx, params[4]);
|
||||
|
||||
Vector vStart = Vector(fStartX, fStartY, fStartZ);
|
||||
Vector vEnd = Vector(fEndX, fEndY, fEndZ);
|
||||
|
||||
TraceResult tr;
|
||||
|
||||
if (iEnt == -1)
|
||||
TRACE_LINE(vStart, vEnd, ignore_monsters, NULL, &tr);
|
||||
else
|
||||
TRACE_LINE(vStart, vEnd, dont_ignore_monsters, INDEXENT(iEnt), &tr);
|
||||
|
||||
edict_t *pHit = tr.pHit;
|
||||
|
||||
vRet[0] = amx_ftoc(tr.vecEndPos.x);
|
||||
vRet[1] = amx_ftoc(tr.vecEndPos.y);
|
||||
vRet[2] = amx_ftoc(tr.vecEndPos.z);
|
||||
|
||||
if (FNullEnt(pHit))
|
||||
return 0;
|
||||
|
||||
return ENTINDEX(pHit);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL set_speak(AMX *amx, cell *params) {
|
||||
int iIndex = params[1];
|
||||
int iNewSpeakFlags = params[2];
|
||||
|
||||
if (iIndex> 32 || !is_ent_valid(iIndex)) {
|
||||
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
plinfo[iIndex].iSpeakFlags = iNewSpeakFlags;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_speak(AMX *amx, cell *params) {
|
||||
int iIndex = params[1];
|
||||
|
||||
if (!is_ent_valid(iIndex) || iIndex > 32) {
|
||||
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return plinfo[iIndex].iSpeakFlags;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_decal_index(AMX *amx, cell *params)
|
||||
{
|
||||
int len;
|
||||
char *szDecal = MF_GetAmxString(amx, params[1], 0, &len);
|
||||
return DECAL_INDEX(szDecal);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL precache_event(AMX *amx, cell *params)
|
||||
{
|
||||
int len;
|
||||
char *szEvent = MF_FormatAmxString(amx, params, 2, &len);
|
||||
PRECACHE_EVENT(params[1], (char *)STRING(ALLOC_STRING(szEvent)));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_info_keybuffer(AMX *amx, cell *params)
|
||||
{
|
||||
int iEnt = params[1];
|
||||
|
||||
if (!is_ent_valid(iEnt)) {
|
||||
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
edict_t *e = INDEXENT(iEnt);
|
||||
|
||||
char *info = GETINFOKEYBUFFER(e);
|
||||
|
||||
return MF_SetAmxString(amx, params[2], info, params[3]);
|
||||
}
|
||||
|
||||
//from jghg, who says it doesn't work
|
||||
static cell AMX_NATIVE_CALL drop_to_floor(AMX *amx, cell *params)
|
||||
{
|
||||
int iEnt = params[1];
|
||||
|
||||
if (!is_ent_valid(iEnt)) {
|
||||
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
edict_t *e = INDEXENT(iEnt);
|
||||
|
||||
return DROP_TO_FLOOR(e);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL precache_generic(AMX *amx, cell *params)
|
||||
{
|
||||
int len;
|
||||
char* szPreCache = MF_GetAmxString(amx,params[1],0,&len);
|
||||
PRECACHE_GENERIC((char*)STRING(ALLOC_STRING(szPreCache)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Attachview, this allows you to attach a player's view to an entity.
|
||||
// use AttachView(player, player) to reset view.
|
||||
//(vexd)
|
||||
static cell AMX_NATIVE_CALL attach_view(AMX *amx, cell *params)
|
||||
{
|
||||
int iIndex = params[1];
|
||||
int iTargetIndex = params[2];
|
||||
|
||||
if (iIndex > 32 || !is_ent_valid(iIndex)) {
|
||||
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!is_ent_valid(iTargetIndex)) {
|
||||
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SET_VIEW(INDEXENT(iIndex), INDEXENT(iTargetIndex));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// SetView, this sets the view of a player. This is done by
|
||||
// Creating a camera entity, which follows the player.
|
||||
//(vexd)
|
||||
static cell AMX_NATIVE_CALL set_view(AMX *amx, cell *params) {
|
||||
int iIndex = params[1];
|
||||
int iCameraType = params[2];
|
||||
|
||||
if (iIndex > 32 || !is_ent_valid(iIndex)) {
|
||||
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
edict_t *pPlayer = INDEXENT(iIndex);
|
||||
edict_t *pNewCamera;
|
||||
|
||||
switch(iCameraType)
|
||||
{
|
||||
case CAMERA_NONE:
|
||||
SET_VIEW(pPlayer, pPlayer);
|
||||
if(plinfo[ENTINDEX(pPlayer)].pViewEnt) {
|
||||
REMOVE_ENTITY(plinfo[ENTINDEX(pPlayer)].pViewEnt);
|
||||
}
|
||||
plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_NONE;
|
||||
plinfo[ENTINDEX(pPlayer)].pViewEnt = NULL;
|
||||
|
||||
pPlayer->v.rendermode = plinfo[ENTINDEX(pPlayer)].iRenderMode;
|
||||
pPlayer->v.renderamt = plinfo[ENTINDEX(pPlayer)].fRenderAmt;
|
||||
|
||||
plinfo[ENTINDEX(pPlayer)].iRenderMode = 0;
|
||||
plinfo[ENTINDEX(pPlayer)].fRenderAmt = 0;
|
||||
|
||||
return 1;
|
||||
break;
|
||||
case CAMERA_3RDPERSON:
|
||||
if(plinfo[ENTINDEX(pPlayer)].iViewType != CAMERA_NONE) {
|
||||
plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_3RDPERSON;
|
||||
return 1;
|
||||
}
|
||||
|
||||
plinfo[ENTINDEX(pPlayer)].iRenderMode = pPlayer->v.rendermode;
|
||||
plinfo[ENTINDEX(pPlayer)].fRenderAmt = pPlayer->v.renderamt;
|
||||
|
||||
plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_3RDPERSON;
|
||||
pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
|
||||
pNewCamera->v.classname = MAKE_STRING("VexdCam");
|
||||
|
||||
SET_MODEL(pNewCamera, "models/rpgrocket.mdl");
|
||||
SET_SIZE(pNewCamera, Vector(0, 0, 0), Vector(0, 0, 0));
|
||||
|
||||
pNewCamera->v.movetype = MOVETYPE_NOCLIP;
|
||||
pNewCamera->v.solid = SOLID_NOT;
|
||||
pNewCamera->v.takedamage = DAMAGE_NO;
|
||||
pNewCamera->v.gravity = 0;
|
||||
pNewCamera->v.owner = pPlayer;
|
||||
pNewCamera->v.rendermode = kRenderTransColor;
|
||||
pNewCamera->v.renderamt = 0;
|
||||
pNewCamera->v.renderfx = kRenderFxNone;
|
||||
|
||||
SET_VIEW(pPlayer, pNewCamera);
|
||||
|
||||
plinfo[ENTINDEX(pPlayer)].pViewEnt = pNewCamera;
|
||||
break;
|
||||
case CAMERA_UPLEFT:
|
||||
if(plinfo[ENTINDEX(pPlayer)].iViewType != CAMERA_NONE) {
|
||||
plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_UPLEFT;
|
||||
return 1;
|
||||
}
|
||||
|
||||
plinfo[ENTINDEX(pPlayer)].iRenderMode = pPlayer->v.rendermode;
|
||||
plinfo[ENTINDEX(pPlayer)].fRenderAmt = pPlayer->v.renderamt;
|
||||
|
||||
plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_3RDPERSON;
|
||||
pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
|
||||
pNewCamera->v.classname = MAKE_STRING("VexdCam");
|
||||
|
||||
SET_MODEL(pNewCamera, "models/rpgrocket.mdl");
|
||||
SET_SIZE(pNewCamera, Vector(0, 0, 0), Vector(0, 0, 0));
|
||||
|
||||
pNewCamera->v.movetype = MOVETYPE_NOCLIP;
|
||||
pNewCamera->v.solid = SOLID_NOT;
|
||||
pNewCamera->v.takedamage = DAMAGE_NO;
|
||||
pNewCamera->v.gravity = 0;
|
||||
pNewCamera->v.owner = pPlayer;
|
||||
pNewCamera->v.rendermode = kRenderTransColor;
|
||||
pNewCamera->v.renderamt = 0;
|
||||
pNewCamera->v.renderfx = kRenderFxNone;
|
||||
|
||||
SET_VIEW(pPlayer, pNewCamera);
|
||||
|
||||
plinfo[ENTINDEX(pPlayer)].pViewEnt = pNewCamera;
|
||||
break;
|
||||
case CAMERA_TOPDOWN:
|
||||
if(plinfo[ENTINDEX(pPlayer)].iViewType != CAMERA_NONE) {
|
||||
plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_TOPDOWN;
|
||||
return 1;
|
||||
}
|
||||
|
||||
plinfo[ENTINDEX(pPlayer)].iRenderMode = pPlayer->v.rendermode;
|
||||
plinfo[ENTINDEX(pPlayer)].fRenderAmt = pPlayer->v.renderamt;
|
||||
|
||||
plinfo[ENTINDEX(pPlayer)].iViewType = CAMERA_TOPDOWN;
|
||||
pNewCamera = CREATE_NAMED_ENTITY(MAKE_STRING("info_target"));
|
||||
pNewCamera->v.classname = MAKE_STRING("VexdCam");
|
||||
|
||||
SET_MODEL(pNewCamera, "models/rpgrocket.mdl");
|
||||
SET_SIZE(pNewCamera, Vector(0, 0, 0), Vector(0, 0, 0));
|
||||
|
||||
pNewCamera->v.movetype = MOVETYPE_NOCLIP;
|
||||
pNewCamera->v.solid = SOLID_NOT;
|
||||
pNewCamera->v.takedamage = DAMAGE_NO;
|
||||
pNewCamera->v.gravity = 0;
|
||||
pNewCamera->v.owner = pPlayer;
|
||||
pNewCamera->v.rendermode = kRenderTransColor;
|
||||
pNewCamera->v.renderamt = 0;
|
||||
pNewCamera->v.renderfx = kRenderFxNone;
|
||||
|
||||
SET_VIEW(pPlayer, pNewCamera);
|
||||
|
||||
plinfo[ENTINDEX(pPlayer)].pViewEnt = pNewCamera;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// SetLights, this sets the lights for the map.
|
||||
//(vexd)
|
||||
static cell AMX_NATIVE_CALL set_lights(AMX *amx, cell *params) {
|
||||
int iLength;
|
||||
char *szLights = MF_GetAmxString(amx, params[1], 0, &iLength);
|
||||
|
||||
if (FStrEq(szLights, "#OFF")) {
|
||||
glinfo.bLights = false;
|
||||
memset(glinfo.szLastLights, 0x0, 128);
|
||||
(g_engfuncs.pfnLightStyle)(0, (char *)glinfo.szRealLights);
|
||||
return 1;
|
||||
}
|
||||
|
||||
glinfo.bLights = true;
|
||||
glinfo.bCheckLights = true;
|
||||
|
||||
//Reset LastLights
|
||||
memset(glinfo.szLastLights, 0x0, 128);
|
||||
//Store the previous lighting.
|
||||
memcpy(glinfo.szLastLights, szLights, strlen(szLights));
|
||||
|
||||
(g_engfuncs.pfnLightStyle)(0, szLights);
|
||||
|
||||
// These make it so that players/weaponmodels look like whatever the lighting is
|
||||
// at. otherwise it would color players under the skybox to these values.
|
||||
SERVER_COMMAND("sv_skycolor_r 0\n");
|
||||
SERVER_COMMAND("sv_skycolor_g 0\n");
|
||||
SERVER_COMMAND("sv_skycolor_b 0\n");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//(mahnsawce)
|
||||
static cell AMX_NATIVE_CALL trace_hull(AMX *amx,cell *params)
|
||||
{
|
||||
int iResult=0;
|
||||
TraceResult tr;
|
||||
Vector vPos;
|
||||
cell *vCell;
|
||||
|
||||
vCell = MF_GetAmxAddr(amx, params[1]);
|
||||
|
||||
vPos.x = amx_ctof(vCell[0]);
|
||||
vPos.y = amx_ctof(vCell[1]);
|
||||
vPos.z = amx_ctof(vCell[2]);
|
||||
|
||||
TRACE_HULL(vPos,vPos, params[4], params[2], params[3] > 0 ? INDEXENT(params[3]) : 0 , &tr);
|
||||
|
||||
if (tr.fStartSolid) {
|
||||
iResult += 1;
|
||||
}
|
||||
if (tr.fAllSolid) {
|
||||
iResult += 2;
|
||||
}
|
||||
if (!tr.fInOpen) {
|
||||
iResult += 4;
|
||||
}
|
||||
return iResult;
|
||||
}
|
||||
|
||||
//(mahnsawce)
|
||||
static cell AMX_NATIVE_CALL playback_event(AMX *amx, cell *params)
|
||||
{
|
||||
/* Params:
|
||||
* native playback_event(flags,invoker,eventindex,Float:delay,Float:origin[3],Float:angles[3],Float:fparam1,Float:fparam2,iparam1,iparam2,bparam1,bparam2)
|
||||
* 1 2 3 4 5 6 7 8 9 10 11 12
|
||||
*/
|
||||
int flags;
|
||||
edict_t *pInvoker;
|
||||
unsigned short eventindex;
|
||||
REAL delay;
|
||||
vec3_t origin;
|
||||
vec3_t angles;
|
||||
REAL fparam1;
|
||||
REAL fparam2;
|
||||
int iparam1;
|
||||
int iparam2;
|
||||
int bparam1;
|
||||
int bparam2;
|
||||
flags = params[1];
|
||||
pInvoker=INDEXENT(params[2]);
|
||||
eventindex=params[3];
|
||||
delay=amx_ctof(params[4]);
|
||||
cell *cOrigin=MF_GetAmxAddr(amx, params[5]);
|
||||
cell *cAngles=MF_GetAmxAddr(amx, params[6]);
|
||||
origin.x=amx_ctof(cOrigin[0]);
|
||||
origin.y=amx_ctof(cOrigin[1]);
|
||||
origin.z=amx_ctof(cOrigin[2]);
|
||||
angles.x=amx_ctof(cAngles[0]);
|
||||
angles.y=amx_ctof(cAngles[1]);
|
||||
angles.z=amx_ctof(cAngles[2]);
|
||||
fparam1=amx_ctof(params[7]);
|
||||
fparam2=amx_ctof(params[8]);
|
||||
iparam1=params[9];
|
||||
iparam2=params[10];
|
||||
bparam1=params[11];
|
||||
bparam2=params[12];
|
||||
PLAYBACK_EVENT_FULL(flags, pInvoker,eventindex, delay, origin, angles, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//(mahnsawce)
|
||||
static cell AMX_NATIVE_CALL ns2amx_anglevector(AMX *amx, cell *params)
|
||||
{
|
||||
Vector v_angles,v_forward,v_right,v_up,v_return;
|
||||
cell *vCell = MF_GetAmxAddr(amx, params[1]);
|
||||
v_angles.x = amx_ctof(vCell[0]);
|
||||
v_angles.y = amx_ctof(vCell[1]);
|
||||
v_angles.z = amx_ctof(vCell[2]);
|
||||
g_engfuncs.pfnAngleVectors(v_angles,v_forward,v_right,v_up);
|
||||
if (params[2] == ANGLEVECTORS_FORWARD)
|
||||
v_return = v_forward;
|
||||
if (params[2] == ANGLEVECTORS_RIGHT)
|
||||
v_return = v_right;
|
||||
if (params[2] == ANGLEVECTORS_UP)
|
||||
v_return = v_up;
|
||||
vCell = MF_GetAmxAddr(amx,params[3]);
|
||||
vCell[0] = amx_ftoc(v_return.x);
|
||||
vCell[1] = amx_ftoc(v_return.y);
|
||||
vCell[2] = amx_ftoc(v_return.z);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//(mahnsawce)
|
||||
static cell AMX_NATIVE_CALL get_usercmd(AMX *amx, cell *params)
|
||||
{
|
||||
if (!incmd)
|
||||
return 0;
|
||||
int type = params[1];
|
||||
if (type > usercmd_int_start && type < usercmd_int_end)
|
||||
{
|
||||
// Requesting an integer value...
|
||||
switch(type)
|
||||
{
|
||||
case usercmd_lerp_msec:
|
||||
return g_cmd->lerp_msec;
|
||||
case usercmd_msec:
|
||||
return g_cmd->msec;
|
||||
case usercmd_lightlevel:
|
||||
return g_cmd->lightlevel;
|
||||
case usercmd_buttons:
|
||||
return g_cmd->buttons;
|
||||
case usercmd_weaponselect:
|
||||
return g_cmd->weaponselect;
|
||||
case usercmd_impact_index:
|
||||
return g_cmd->impact_index;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (type > usercmd_float_start && type < usercmd_float_end)
|
||||
{
|
||||
// Requesting a single float value
|
||||
// The second parameter needs to be the float variable.
|
||||
|
||||
cell *cRet = MF_GetAmxAddr(amx, params[2]);
|
||||
switch(type)
|
||||
{
|
||||
case usercmd_forwardmove:
|
||||
*cRet = *(cell*)&g_cmd->forwardmove;
|
||||
return 1;
|
||||
case usercmd_sidemove:
|
||||
*cRet = *(cell*)&g_cmd->sidemove;
|
||||
return 1;
|
||||
case usercmd_upmove:
|
||||
*cRet = *(cell*)&g_cmd->upmove;
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (type > usercmd_vec_start && type < usercmd_vec_end)
|
||||
{
|
||||
// Requesting a Vector value.
|
||||
cell *cRet = MF_GetAmxAddr(amx,params[2]);
|
||||
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;
|
||||
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;
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL set_usercmd(AMX *amx, cell *params)
|
||||
{
|
||||
if (!incmd)
|
||||
return 0;
|
||||
int type = params[1];
|
||||
if (type > usercmd_int_start && type < usercmd_int_end)
|
||||
{
|
||||
// Setting an integer value...
|
||||
cell *blah = MF_GetAmxAddr(amx,params[2]);
|
||||
int iValue = blah[0];
|
||||
switch(type)
|
||||
{
|
||||
case usercmd_lerp_msec:
|
||||
g_cmd->lerp_msec = iValue;
|
||||
return 1;
|
||||
case usercmd_msec:
|
||||
g_cmd->msec = iValue;
|
||||
return 1;
|
||||
case usercmd_lightlevel:
|
||||
g_cmd->lightlevel = iValue;
|
||||
return 1;
|
||||
case usercmd_buttons:
|
||||
g_cmd->buttons = iValue;
|
||||
return 1;
|
||||
case usercmd_weaponselect:
|
||||
g_cmd->weaponselect = iValue;
|
||||
return 1;
|
||||
case usercmd_impact_index:
|
||||
g_cmd->impact_index = iValue;
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (type > usercmd_float_start && type < usercmd_float_end)
|
||||
{
|
||||
// Requesting a single float value
|
||||
// The second parameter needs to be the float variable.
|
||||
|
||||
cell *blah = MF_GetAmxAddr(amx,params[2]);
|
||||
REAL fValue = amx_ctof(blah[0]);
|
||||
switch(type)
|
||||
{
|
||||
case usercmd_forwardmove:
|
||||
g_cmd->forwardmove = fValue;
|
||||
return 1;
|
||||
case usercmd_sidemove:
|
||||
g_cmd->sidemove = fValue;
|
||||
return 1;
|
||||
case usercmd_upmove:
|
||||
g_cmd->upmove = fValue;
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (type > usercmd_vec_start && type < usercmd_vec_end)
|
||||
{
|
||||
// Requesting a Vector value.
|
||||
Vector vValue;
|
||||
cell *blah = MF_GetAmxAddr(amx,params[2]);
|
||||
vValue.x = amx_ctof(blah[0]);
|
||||
vValue.y = amx_ctof(blah[1]);
|
||||
vValue.z = amx_ctof(blah[2]);
|
||||
switch (type)
|
||||
{
|
||||
case usercmd_viewangles:
|
||||
g_cmd->viewangles = vValue;
|
||||
return 1;
|
||||
case usercmd_impact_position:
|
||||
g_cmd->impact_position = vValue;
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//(mahnsawce)
|
||||
static cell AMX_NATIVE_CALL take_damage(AMX *amx, cell *params)
|
||||
{
|
||||
int indexa = params[1];
|
||||
int indexb = params[2];
|
||||
int indexc = params[3];
|
||||
if (!is_ent_valid(indexa) || !is_ent_valid(indexb) || !is_ent_valid(indexc)) {
|
||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
REAL fnDamage = amx_ctof(params[4]);
|
||||
int inType = params[5];
|
||||
edict_t* pEntitya = INDEXENT(indexa);
|
||||
edict_t* pEntityb = INDEXENT(indexb);
|
||||
edict_t* pEntityc = INDEXENT(indexc);
|
||||
CBaseEntity *pCEntity = NULL;
|
||||
pCEntity = CBaseEntity::Instance(INDEXENT(indexa));
|
||||
pCEntity->TakeDamage(VARS(pEntityb),VARS(pEntityc),fnDamage,inType);
|
||||
return 1;
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO engine_Natives[] = {
|
||||
{"halflife_time", halflife_time},
|
||||
|
||||
//These are mostly from original VexD
|
||||
{"VelocityByAim", VelocityByAim},
|
||||
{"RadiusDamage", RadiusDamage},
|
||||
{"PointContents", PointContents},
|
||||
{"vector_to_angle", vector_to_angle},
|
||||
{"vector_length", vector_length},
|
||||
{"vector_distance", vector_distance},
|
||||
{"trace_normal", trace_normal},
|
||||
{"trace_line", trace_line},
|
||||
{"trace_hull", trace_hull},
|
||||
{"take_damage", take_damage},
|
||||
|
||||
{"set_speak", set_speak},
|
||||
{"get_speak", get_speak},
|
||||
|
||||
{"precache_event", precache_event},
|
||||
{"precache_generic", precache_generic},
|
||||
{"playback_event", playback_event},
|
||||
|
||||
{"set_view", set_view},
|
||||
{"attach_view", attach_view},
|
||||
|
||||
{"get_decal_index", get_decal_index},
|
||||
{"get_info_keybuffer", get_info_keybuffer},
|
||||
{"set_lights", set_lights},
|
||||
{"drop_to_floor", drop_to_floor},
|
||||
|
||||
{"get_usercmd", get_usercmd},
|
||||
{"set_usercmd", set_usercmd},
|
||||
|
||||
{NULL, NULL},
|
||||
///////////////////
|
||||
};
|
|
@ -90,10 +90,34 @@ LINK32=link.exe
|
|||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\amxxapi.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\amxxmodule.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\engine.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\entity.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\forwards.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\globals.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\messages.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\meta_api.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
|
@ -110,6 +134,18 @@ SOURCE=.\engine.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\entity.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gpglobals.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\messages.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\moduleconfig.h
|
||||
# End Source File
|
||||
# End Group
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -3,57 +3,43 @@
|
|||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="engine"
|
||||
ProjectGUID="{7CAE7BDF-52CB-49D0-B82E-568259869811}"
|
||||
SccProjectName=""
|
||||
SccLocalPath="">
|
||||
ProjectGUID="{B3F4467B-6148-4EBF-B897-168D81CF8D9B}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;ENGINE_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\Release/engine.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
BrowseInformation="1"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;ENGINE_EXPORTS"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="release/engine_amx.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ModuleDefinitionFile=".\engine_amx.def"
|
||||
ProgramDatabaseFile=".\Release/engine_amx.pdb"
|
||||
ImportLibrary=".\Release/engine_amx.lib"
|
||||
OutputFile="$(OutDir)/engine_amxx.dll"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/engine.pdb"
|
||||
SubSystem="2"
|
||||
ImportLibrary="$(OutDir)/engine.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Release/engine.tlb"
|
||||
HeaderFileName=""/>
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
|
@ -61,9 +47,7 @@
|
|||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"/>
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
|
@ -76,47 +60,33 @@
|
|||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;ENGINE_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\Debug/engine.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;ENGINE_EXPORTS"
|
||||
RuntimeLibrary="4"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\Debug/engine_amxx.dll"
|
||||
OutputFile="$(OutDir)/engine.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ModuleDefinitionFile=".\engine_amx.def"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\Debug/engine.pdb"
|
||||
ImportLibrary=".\Debug/engine.lib"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
ImportLibrary="$(OutDir)/engine.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\Debug/engine.tlb"
|
||||
HeaderFileName=""/>
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
|
@ -124,9 +94,7 @@
|
|||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"/>
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
|
@ -142,51 +110,63 @@
|
|||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath=".\amxxapi.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\engine.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\entity.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\forwards.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\globals.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\messages.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl">
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
||||
<File
|
||||
RelativePath=".\amxxmodule.h">
|
||||
RelativePath=".\engine.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="engine.h">
|
||||
RelativePath=".\entity.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="meta_api.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;ENGINE_EXPORTS;$(NoInherit)"
|
||||
BrowseInformation="1"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;ENGINE_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
RelativePath=".\gpglobals.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\moduleconfig.h">
|
||||
RelativePath=".\messages.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
|
||||
<File
|
||||
RelativePath="engine.inc">
|
||||
</File>
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
|
||||
Name="amxx"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\amxxmodule.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\amxxmodule.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\moduleconfig.h">
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
|
|
1788
dlls/engine/entity.cpp
Executable file
1788
dlls/engine/entity.cpp
Executable file
File diff suppressed because it is too large
Load Diff
155
dlls/engine/entity.h
Executable file
155
dlls/engine/entity.h
Executable file
|
@ -0,0 +1,155 @@
|
|||
#ifndef _INCLUDE_ENGINE_ENTSTUFF
|
||||
#define _INCLUDE_ENGINE_ENTSTUFF
|
||||
|
||||
#include "engine.h"
|
||||
|
||||
enum {
|
||||
gamestate,
|
||||
oldbuttons,
|
||||
groupinfo,
|
||||
iuser1,
|
||||
iuser2,
|
||||
iuser3,
|
||||
iuser4,
|
||||
weaponanim,
|
||||
pushmsec,
|
||||
bInDuck,
|
||||
flTimeStepSound,
|
||||
flSwimTime,
|
||||
flDuckTime,
|
||||
iStepLeft,
|
||||
movetype,
|
||||
solid,
|
||||
skin,
|
||||
body,
|
||||
effects,
|
||||
light_level,
|
||||
sequence,
|
||||
gaitsequence,
|
||||
modelindex,
|
||||
playerclass,
|
||||
waterlevel,
|
||||
watertype,
|
||||
spawnflags,
|
||||
flags,
|
||||
colormap,
|
||||
team,
|
||||
fixangle,
|
||||
weapons,
|
||||
rendermode,
|
||||
renderfx,
|
||||
button,
|
||||
impulse,
|
||||
deadflag,
|
||||
};
|
||||
|
||||
enum {
|
||||
impacttime,
|
||||
starttime,
|
||||
idealpitch,
|
||||
pitch_speed,
|
||||
ideal_yaw,
|
||||
yaw_speed,
|
||||
ltime,
|
||||
nextthink,
|
||||
gravity,
|
||||
friction,
|
||||
frame,
|
||||
animtime,
|
||||
framerate,
|
||||
health,
|
||||
frags,
|
||||
takedamage,
|
||||
max_health,
|
||||
teleport_time,
|
||||
armortype,
|
||||
armorvalue,
|
||||
dmg_take,
|
||||
dmg_save,
|
||||
dmg,
|
||||
dmgtime,
|
||||
speed,
|
||||
air_finished,
|
||||
pain_finished,
|
||||
radsuit_finished,
|
||||
scale,
|
||||
renderamt,
|
||||
maxspeed,
|
||||
fov,
|
||||
flFallVelocity,
|
||||
fuser1,
|
||||
fuser2,
|
||||
fuser3,
|
||||
fuser4,
|
||||
};
|
||||
|
||||
enum {
|
||||
origin,
|
||||
oldorigin,
|
||||
velocity,
|
||||
basevelocity,
|
||||
clbasevelocity,
|
||||
movedir,
|
||||
angles,
|
||||
avelocity,
|
||||
punchangle,
|
||||
v_angle,
|
||||
endpos,
|
||||
startpos,
|
||||
absmin,
|
||||
absmax,
|
||||
mins,
|
||||
maxs,
|
||||
size,
|
||||
rendercolor,
|
||||
view_ofs,
|
||||
vuser1,
|
||||
vuser2,
|
||||
vuser3,
|
||||
vuser4,
|
||||
};
|
||||
|
||||
enum {
|
||||
chain,
|
||||
dmg_inflictor,
|
||||
enemy,
|
||||
aiment,
|
||||
owner,
|
||||
groundentity,
|
||||
pContainingEntity,
|
||||
euser1,
|
||||
euser2,
|
||||
euser3,
|
||||
euser4,
|
||||
};
|
||||
|
||||
enum {
|
||||
classname,
|
||||
globalname,
|
||||
model,
|
||||
target,
|
||||
targetname,
|
||||
netname,
|
||||
message,
|
||||
noise,
|
||||
noise1,
|
||||
noise2,
|
||||
noise3,
|
||||
viewmodel,
|
||||
weaponmodel,
|
||||
};
|
||||
|
||||
enum {
|
||||
controller1,
|
||||
controller2,
|
||||
controller3,
|
||||
controller4,
|
||||
blending1,
|
||||
blending2,
|
||||
};
|
||||
|
||||
void UTIL_SetSize(edict_t *pev, const Vector &vecMin, const Vector &vecMax);
|
||||
|
||||
extern AMX_NATIVE_INFO ent_Natives[];
|
||||
|
||||
#endif //_INCLUDE_ENGINE_ENTSTUFF
|
229
dlls/engine/forwards.cpp
Executable file
229
dlls/engine/forwards.cpp
Executable file
|
@ -0,0 +1,229 @@
|
|||
#include "engine.h"
|
||||
|
||||
bool incmd = false;
|
||||
int DispatchUseForward = 0;
|
||||
int SpawnForward = 0;
|
||||
int ChangelevelForward = 0;
|
||||
int PlaybackForward = 0;
|
||||
int DispatchKeyForward = 0;
|
||||
int pfnTouchForward = 0;
|
||||
int pfnThinkForward = 0;
|
||||
int PlayerPreThinkForward = 0;
|
||||
int PlayerPostThinkForward = 0;
|
||||
int ClientKillForward = 0;
|
||||
int CmdStartForward = 0;
|
||||
int StartFrameForward = 0;
|
||||
|
||||
void DispatchUse(edict_t *pentUsed, edict_t *pentOther)
|
||||
{
|
||||
if (DispatchUseForward) {
|
||||
int retVal = 0;
|
||||
int used = ENTINDEX(pentUsed);
|
||||
int user = ENTINDEX(pentOther);
|
||||
retVal = MF_ExecuteForward(DispatchUseForward, user, used);
|
||||
if (retVal)
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
int DispatchSpawn(edict_t *pEntity) {
|
||||
if (SpawnForward) {
|
||||
int retVal = 0;
|
||||
int id = ENTINDEX(pEntity);
|
||||
retVal = MF_ExecuteForward(SpawnForward, id);
|
||||
if (retVal)
|
||||
RETURN_META_VALUE(MRES_SUPERCEDE, 0);
|
||||
}
|
||||
RETURN_META_VALUE(MRES_IGNORED, 0);
|
||||
}
|
||||
|
||||
void ChangeLevel(char* s1, char* s2)
|
||||
{
|
||||
if (ChangelevelForward) {
|
||||
int retVal = 0;
|
||||
char *map = s1;
|
||||
cell amxMap = MF_PrepareCharArray(map, strlen(map));
|
||||
retVal = MF_ExecuteForward(ChangelevelForward, amxMap);
|
||||
if (retVal)
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void PlaybackEvent(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)
|
||||
{
|
||||
if (PlaybackForward) {
|
||||
edict_t *e = (edict_t *)pInvoker;
|
||||
int retVal = 0;
|
||||
static cell cOrigin[3];
|
||||
static cell cAngles[3];
|
||||
Vector vOrigin = (Vector)origin;
|
||||
Vector vAngles = (Vector)angles;
|
||||
cOrigin[0] = amx_ftoc(vOrigin.x);
|
||||
cOrigin[1] = amx_ftoc(vOrigin.y);
|
||||
cOrigin[2] = amx_ftoc(vOrigin.z);
|
||||
cAngles[0] = amx_ftoc(vAngles.x);
|
||||
cAngles[1] = amx_ftoc(vAngles.y);
|
||||
cAngles[2] = amx_ftoc(vAngles.z);
|
||||
cell CellOrigin = MF_PrepareCellArray(cOrigin, 3);
|
||||
cell CellAngles = MF_PrepareCellArray(cAngles, 3);
|
||||
retVal = MF_ExecuteForward(PlaybackForward, flags, ENTINDEX(e), eventindex, amx_ftoc(delay), CellOrigin, CellAngles, amx_ftoc(fparam1), amx_ftoc(fparam2), iparam1, iparam2, bparam2);
|
||||
if (retVal)
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
RETURN_META(MRES_IGNORED);
|
||||
|
||||
}
|
||||
|
||||
#if 0
|
||||
void KeyValue(edict_t *pEntity, KeyValueData *pkvd)
|
||||
{
|
||||
if (DispatchKeyForward) {
|
||||
inKeyValue=true;
|
||||
int retVal = 0;
|
||||
g_pkvd=pkvd;
|
||||
int index = ENTINDEX(pEntity);
|
||||
retVal = MF_ExecuteForward(DispatchKeyForward, index);
|
||||
inKeyValue=false;
|
||||
if (retVal)
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
RETURN_META(MRES_HANDLED);
|
||||
}
|
||||
#endif
|
||||
|
||||
void StartFrame()
|
||||
{
|
||||
if (glinfo.bCheckLights) {
|
||||
if (!FStrEq((const char*)glinfo.szLastLights, "")) {
|
||||
(g_engfuncs.pfnLightStyle)(0, (char *)glinfo.szLastLights);
|
||||
glinfo.fNextLights = gpGlobals->time + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (StartFrameForward)
|
||||
MF_ExecuteForward(StartFrameForward);
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void CmdStart(const edict_t *player, const struct usercmd_s *_cmd, unsigned int random_seed)
|
||||
{
|
||||
int retVal = 0;
|
||||
edict_t *pEntity = (edict_t *)player;
|
||||
struct usercmd_s *g_cmd = (struct usercmd_s *)_cmd;
|
||||
if (CmdStartForward) {
|
||||
incmd = true;
|
||||
retVal = MF_ExecuteForward(CmdStartForward, ENTINDEX(pEntity), g_cmd->impulse);
|
||||
incmd = false;
|
||||
if (retVal) {
|
||||
g_cmd->impulse = 0;
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void ClientKill(edict_t *pEntity)
|
||||
{
|
||||
int retVal = 0;
|
||||
|
||||
if (ClientKillForward) {
|
||||
retVal = MF_ExecuteForward(ClientKillForward, ENTINDEX(pEntity));
|
||||
if (retVal)
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void PlayerPreThink(edict_t *pEntity)
|
||||
{
|
||||
int retVal = 0;
|
||||
|
||||
if (pfnTouchForward) {
|
||||
retVal = MF_ExecuteForward(PlayerPreThinkForward, ENTINDEX(pEntity));
|
||||
if (retVal)
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void PlayerPostThink(edict_t *pEntity)
|
||||
{
|
||||
int retVal = 0;
|
||||
|
||||
if(plinfo[ENTINDEX(pEntity)].pViewEnt) {
|
||||
edict_t *pCamEnt = plinfo[ENTINDEX(pEntity)].pViewEnt;
|
||||
|
||||
MAKE_VECTORS(pEntity->v.v_angle + pEntity->v.punchangle);
|
||||
Vector vecSrc = pEntity->v.origin + pEntity->v.view_ofs;
|
||||
Vector vecAiming = gpGlobals->v_forward;
|
||||
TraceResult tr;
|
||||
|
||||
switch(plinfo[ENTINDEX(pEntity)].iViewType) {
|
||||
case CAMERA_3RDPERSON:
|
||||
TRACE_LINE(vecSrc, vecSrc - (vecAiming * 128), ignore_monsters, ENT(pEntity), &tr);
|
||||
SET_VIEW(pEntity, pCamEnt);
|
||||
pCamEnt->v.origin = tr.vecEndPos;
|
||||
pCamEnt->v.angles = pEntity->v.v_angle;
|
||||
break;
|
||||
case CAMERA_UPLEFT:
|
||||
TRACE_LINE(vecSrc, vecSrc - ((vecAiming * 32) - ((gpGlobals->v_right * 15) + (gpGlobals->v_up * 15))), ignore_monsters, ENT(pEntity), &tr);
|
||||
SET_VIEW(pEntity, pCamEnt);
|
||||
pCamEnt->v.origin = tr.vecEndPos;
|
||||
pCamEnt->v.angles = pEntity->v.v_angle;
|
||||
break;
|
||||
case CAMERA_TOPDOWN:
|
||||
TRACE_LINE(vecSrc, vecSrc + Vector(0,0,2048), dont_ignore_monsters, ENT(pEntity), &tr);
|
||||
SET_VIEW(pEntity, pCamEnt);
|
||||
pCamEnt->v.origin = tr.vecEndPos;
|
||||
pCamEnt->v.origin.z -= 40;
|
||||
pCamEnt->v.angles = Vector(90,pEntity->v.v_angle.y,0);
|
||||
break;
|
||||
default:
|
||||
SET_VIEW(pEntity, pEntity);
|
||||
REMOVE_ENTITY(plinfo[ENTINDEX(pEntity)].pViewEnt);
|
||||
plinfo[ENTINDEX(pEntity)].iViewType = CAMERA_NONE;
|
||||
plinfo[ENTINDEX(pEntity)].pViewEnt = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pfnTouchForward) {
|
||||
retVal = MF_ExecuteForward(PlayerPostThinkForward, ENTINDEX(pEntity));
|
||||
if (retVal)
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void DispatchTouch(edict_t *pToucher, edict_t *pTouched)
|
||||
{
|
||||
int retVal = 0;
|
||||
/* Execute pfnTouch forwards */
|
||||
if (pfnTouchForward) {
|
||||
retVal = MF_ExecuteForward(pfnTouchForward, ENTINDEX(pToucher), ENTINDEX(pTouched));
|
||||
if (retVal)
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void DispatchThink(edict_t *pent)
|
||||
{
|
||||
int retVal = 0;
|
||||
|
||||
if (pfnThinkForward) {
|
||||
retVal = MF_ExecuteForward(pfnThinkForward, ENTINDEX(pent));
|
||||
if (retVal)
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
177
dlls/engine/globals.cpp
Executable file
177
dlls/engine/globals.cpp
Executable file
|
@ -0,0 +1,177 @@
|
|||
#include "gpglobals.h"
|
||||
|
||||
static cell AMX_NATIVE_CALL get_global_float(AMX *amx, cell *params)
|
||||
{
|
||||
int global = params[1];
|
||||
|
||||
REAL returnValue;
|
||||
|
||||
switch (params[1]) {
|
||||
case GL_coop:
|
||||
returnValue = gpGlobals->coop;
|
||||
break;
|
||||
case GL_deathmatch:
|
||||
returnValue = gpGlobals->deathmatch;
|
||||
break;
|
||||
case GL_force_retouch:
|
||||
returnValue = gpGlobals->force_retouch;
|
||||
break;
|
||||
case GL_found_secrets:
|
||||
returnValue = gpGlobals->found_secrets;
|
||||
break;
|
||||
case GL_frametime:
|
||||
returnValue = gpGlobals->frametime;
|
||||
break;
|
||||
case GL_serverflags:
|
||||
returnValue = gpGlobals->serverflags;
|
||||
break;
|
||||
case GL_teamplay:
|
||||
returnValue = gpGlobals->teamplay;
|
||||
break;
|
||||
case GL_time:
|
||||
returnValue = gpGlobals->time;
|
||||
break;
|
||||
case GL_trace_allsolid:
|
||||
returnValue = gpGlobals->trace_allsolid;
|
||||
break;
|
||||
case GL_trace_fraction:
|
||||
returnValue = gpGlobals->trace_fraction;
|
||||
break;
|
||||
case GL_trace_inopen:
|
||||
returnValue = gpGlobals->trace_inopen;
|
||||
break;
|
||||
case GL_trace_inwater:
|
||||
returnValue = gpGlobals->trace_inwater;
|
||||
break;
|
||||
case GL_trace_plane_dist:
|
||||
returnValue = gpGlobals->trace_plane_dist;
|
||||
break;
|
||||
case GL_trace_startsolid:
|
||||
returnValue = gpGlobals->trace_startsolid;
|
||||
break;
|
||||
default:
|
||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return amx_ftoc(returnValue);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_global_int(AMX *amx, cell *params)
|
||||
{
|
||||
int returnValue = 0;
|
||||
|
||||
switch (params[1]) {
|
||||
case GL_cdAudioTrack:
|
||||
returnValue = gpGlobals->cdAudioTrack;
|
||||
break;
|
||||
case GL_maxClients:
|
||||
returnValue = gpGlobals->maxClients;
|
||||
break;
|
||||
case GL_maxEntities:
|
||||
returnValue = gpGlobals->maxEntities;
|
||||
break;
|
||||
case GL_msg_entity:
|
||||
returnValue = gpGlobals->msg_entity;
|
||||
break;
|
||||
case GL_trace_flags:
|
||||
returnValue = gpGlobals->trace_flags;
|
||||
break;
|
||||
case GL_trace_hitgroup:
|
||||
returnValue = gpGlobals->trace_hitgroup;
|
||||
break;
|
||||
default:
|
||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_global_string(AMX *amx, cell *params)
|
||||
{
|
||||
string_t* returnValue;
|
||||
|
||||
switch(params[1]) {
|
||||
case GL_pStringBase: // const char *, so no string_t
|
||||
return MF_SetAmxString(amx, params[2], gpGlobals->pStringBase, params[3]);
|
||||
// The rest are string_t:s...
|
||||
case GL_mapname:
|
||||
returnValue = &(gpGlobals->mapname);
|
||||
break;
|
||||
case GL_startspot:
|
||||
returnValue = &(gpGlobals->startspot);
|
||||
break;
|
||||
default:
|
||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return MF_SetAmxString(amx, params[2], STRING(*returnValue), params[3]);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_global_vector(AMX *amx, cell *params) // globals_get_vector(variable, Float:vector[3]); = 2 params
|
||||
{
|
||||
cell *cRet = MF_GetAmxAddr(amx, params[2]);
|
||||
vec3_t fetchedVector;
|
||||
|
||||
switch (params[1]) {
|
||||
case GL_trace_endpos:
|
||||
fetchedVector = gpGlobals->trace_endpos;
|
||||
break;
|
||||
case GL_trace_plane_normal:
|
||||
fetchedVector = gpGlobals->trace_plane_normal;
|
||||
break;
|
||||
case GL_v_forward:
|
||||
fetchedVector = gpGlobals->v_forward;
|
||||
break;
|
||||
case GL_v_right:
|
||||
fetchedVector = gpGlobals->v_right;
|
||||
break;
|
||||
case GL_v_up:
|
||||
fetchedVector = gpGlobals->v_up;
|
||||
break;
|
||||
case GL_vecLandmarkOffset:
|
||||
fetchedVector = gpGlobals->vecLandmarkOffset;
|
||||
break;
|
||||
default:
|
||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cRet[0] = amx_ftoc(fetchedVector.x);
|
||||
cRet[1] = amx_ftoc(fetchedVector.y);
|
||||
cRet[2] = amx_ftoc(fetchedVector.z);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_global_edict(AMX *amx, cell *params) // globals_get_edict(variable); = 1 param
|
||||
{
|
||||
edict_t* pReturnEntity;
|
||||
|
||||
switch (params[1]) {
|
||||
case GL_trace_ent:
|
||||
pReturnEntity = gpGlobals->trace_ent;
|
||||
break;
|
||||
default:
|
||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Will crash if ENTINDEX() is called on bad pointer?
|
||||
if(!FNullEnt(pReturnEntity))
|
||||
return ENTINDEX(pReturnEntity);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO global_Natives[] = {
|
||||
{"get_global_float", get_global_float},
|
||||
{"get_global_int", get_global_int},
|
||||
{"get_global_string", get_global_string},
|
||||
{"get_global_edict", get_global_edict},
|
||||
{"get_global_vector", get_global_vector},
|
||||
{NULL, NULL},
|
||||
///////////////////
|
||||
};
|
53
dlls/engine/gpglobals.h
Executable file
53
dlls/engine/gpglobals.h
Executable file
|
@ -0,0 +1,53 @@
|
|||
#ifndef _INCLUDE_ENGINE_GLOBAL
|
||||
#define _INCLUDE_ENGINE_GLOBAL
|
||||
|
||||
#include "engine.h"
|
||||
|
||||
enum globals {
|
||||
// Edict
|
||||
GL_trace_ent = 0,
|
||||
|
||||
// Float
|
||||
GL_coop,
|
||||
GL_deathmatch,
|
||||
GL_force_retouch,
|
||||
GL_found_secrets,
|
||||
GL_frametime,
|
||||
GL_serverflags,
|
||||
GL_teamplay,
|
||||
GL_time,
|
||||
GL_trace_allsolid,
|
||||
GL_trace_fraction,
|
||||
GL_trace_inopen,
|
||||
GL_trace_inwater,
|
||||
GL_trace_plane_dist,
|
||||
GL_trace_startsolid,
|
||||
|
||||
// Int
|
||||
GL_cdAudioTrack,
|
||||
GL_maxClients,
|
||||
GL_maxEntities,
|
||||
GL_msg_entity,
|
||||
GL_trace_flags,
|
||||
GL_trace_hitgroup,
|
||||
|
||||
// String
|
||||
GL_pStringBase,
|
||||
GL_mapname,
|
||||
GL_startspot,
|
||||
|
||||
// Vector
|
||||
GL_trace_endpos,
|
||||
GL_trace_plane_normal,
|
||||
GL_v_forward,
|
||||
GL_v_right,
|
||||
GL_v_up,
|
||||
GL_vecLandmarkOffset,
|
||||
|
||||
// Void (not supported)
|
||||
GL_pSaveData
|
||||
};
|
||||
|
||||
extern AMX_NATIVE_INFO global_Natives[];
|
||||
|
||||
#endif //_INCLUDE_ENGINE_GLOBAL
|
477
dlls/engine/messages.cpp
Executable file
477
dlls/engine/messages.cpp
Executable file
|
@ -0,0 +1,477 @@
|
|||
#include "messages.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
std::vector<argMsg*> Msg;
|
||||
int msgDest;
|
||||
int msgType;
|
||||
float *msgOrigin;
|
||||
edict_t *msgpEntity;
|
||||
int msgHooks[256] = {0};
|
||||
int msgBlocks[256] = {0};
|
||||
bool inhook = false;
|
||||
bool inblock = false;
|
||||
unsigned int msgCount = 0;
|
||||
|
||||
argMsg::argMsg()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
void argMsg::Reset()
|
||||
{
|
||||
iData = 0;
|
||||
fData = 0.0;
|
||||
cData.clear();
|
||||
type = 0;
|
||||
}
|
||||
|
||||
void argMsg::Send()
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case arg_byte:
|
||||
WRITE_BYTE(iData);
|
||||
break;
|
||||
case arg_char:
|
||||
WRITE_CHAR(iData);
|
||||
break;
|
||||
case arg_short:
|
||||
WRITE_SHORT(iData);
|
||||
break;
|
||||
case arg_long:
|
||||
WRITE_LONG(iData);
|
||||
break;
|
||||
case arg_angle:
|
||||
WRITE_ANGLE(fData);
|
||||
break;
|
||||
case arg_coord:
|
||||
WRITE_COORD(fData);
|
||||
break;
|
||||
case arg_string:
|
||||
WRITE_STRING(cData.c_str());
|
||||
break;
|
||||
case arg_entity:
|
||||
WRITE_ENTITY(iData);
|
||||
break;
|
||||
}
|
||||
Reset();
|
||||
}
|
||||
|
||||
int argMsg::Type()
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case arg_byte:
|
||||
return type_int;
|
||||
break;
|
||||
case arg_char:
|
||||
return type_int;
|
||||
break;
|
||||
case arg_short:
|
||||
return type_int;
|
||||
break;
|
||||
case arg_long:
|
||||
return type_int;
|
||||
break;
|
||||
case arg_angle:
|
||||
return type_float;
|
||||
break;
|
||||
case arg_coord:
|
||||
return type_float;
|
||||
break;
|
||||
case arg_string:
|
||||
return type_string;
|
||||
break;
|
||||
case arg_entity:
|
||||
return type_int;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed)
|
||||
{
|
||||
if (msgBlocks[msg_type]) {
|
||||
inblock = true;
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
} else if (msgHooks[msg_type]) {
|
||||
inhook = true;
|
||||
msgCount = 0;
|
||||
msgDest = msg_dest;
|
||||
msgType = msg_type;
|
||||
msgOrigin = (float *)pOrigin;
|
||||
msgpEntity = ed;
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void WriteByte(int iValue)
|
||||
{
|
||||
if (inblock) {
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
} else if (inhook) {
|
||||
if (++msgCount > Msg.size()) {
|
||||
argMsg *p = new argMsg();
|
||||
p->iData = iValue;
|
||||
p->type = arg_byte;
|
||||
Msg.push_back(p);
|
||||
} else {
|
||||
Msg.at(msgCount-1)->iData = iValue;
|
||||
Msg.at(msgCount-1)->type = arg_byte;
|
||||
}
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void WriteChar(int iValue)
|
||||
{
|
||||
if (inblock) {
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
} else if (inhook) {
|
||||
if (++msgCount > Msg.size()) {
|
||||
argMsg *p = new argMsg();
|
||||
p->iData = iValue;
|
||||
p->type = arg_char;
|
||||
Msg.push_back(p);
|
||||
} else {
|
||||
Msg.at(msgCount-1)->iData = iValue;
|
||||
Msg.at(msgCount-1)->type = arg_char;
|
||||
}
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void WriteShort(int iValue)
|
||||
{
|
||||
if (inblock) {
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
} else if (inhook) {
|
||||
if (++msgCount > Msg.size()) {
|
||||
argMsg *p = new argMsg();
|
||||
p->iData = iValue;
|
||||
p->type = arg_short;
|
||||
Msg.push_back(p);
|
||||
} else {
|
||||
Msg.at(msgCount-1)->iData = iValue;
|
||||
Msg.at(msgCount-1)->type = arg_short;
|
||||
}
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void WriteLong(int iValue)
|
||||
{
|
||||
if (inblock) {
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
} else if (inhook) {
|
||||
if (++msgCount > Msg.size()) {
|
||||
argMsg *p = new argMsg();
|
||||
p->iData = iValue;
|
||||
p->type = arg_long;
|
||||
Msg.push_back(p);
|
||||
} else {
|
||||
Msg.at(msgCount-1)->iData = iValue;
|
||||
Msg.at(msgCount-1)->type = arg_long;
|
||||
}
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void WriteAngle(float flValue)
|
||||
{
|
||||
if (inblock) {
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
} else if (inhook) {
|
||||
if (++msgCount > Msg.size()) {
|
||||
argMsg *p = new argMsg();
|
||||
p->fData = flValue;
|
||||
p->type = arg_angle;
|
||||
Msg.push_back(p);
|
||||
} else {
|
||||
Msg.at(msgCount-1)->fData = flValue;
|
||||
Msg.at(msgCount-1)->type = arg_angle;
|
||||
}
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void WriteCoord(float flValue)
|
||||
{
|
||||
if (inblock) {
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
} else if (inhook) {
|
||||
if (++msgCount > Msg.size()) {
|
||||
argMsg *p = new argMsg();
|
||||
p->fData = flValue;
|
||||
p->type = arg_coord;
|
||||
Msg.push_back(p);
|
||||
} else {
|
||||
Msg.at(msgCount-1)->fData = flValue;
|
||||
Msg.at(msgCount-1)->type = arg_coord;
|
||||
}
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void WriteString(const char *sz)
|
||||
{
|
||||
if (inblock) {
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
} else if (inhook) {
|
||||
if (++msgCount > Msg.size()) {
|
||||
argMsg *p = new argMsg();
|
||||
p->cData.assign(sz);
|
||||
p->type = arg_string;
|
||||
Msg.push_back(p);
|
||||
} else {
|
||||
Msg.at(msgCount-1)->cData.assign(sz);
|
||||
Msg.at(msgCount-1)->type = arg_string;
|
||||
}
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void WriteEntity(int iValue)
|
||||
{
|
||||
if (inblock) {
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
} else if (inhook) {
|
||||
if (++msgCount > Msg.size()) {
|
||||
argMsg *p = new argMsg();
|
||||
p->iData = iValue;
|
||||
p->type = arg_entity;
|
||||
Msg.push_back(p);
|
||||
} else {
|
||||
Msg.at(msgCount-1)->iData = iValue;
|
||||
Msg.at(msgCount-1)->type = arg_entity;
|
||||
}
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
void MessageEnd(void)
|
||||
{
|
||||
int mres = 0;
|
||||
int mct = msgCount;
|
||||
unsigned int i = 0;
|
||||
if (inblock) {
|
||||
if (msgBlocks[msgType] == BLOCK_ONCE)
|
||||
msgBlocks[msgType] = BLOCK_NOT;
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
} else if (inhook) {
|
||||
inhook = false;
|
||||
mres = MF_ExecuteForward(msgHooks[msgType], msgType, msgDest, ENTINDEX(msgpEntity));
|
||||
MF_Log("Executing forward: %d with retval %d", msgHooks[msgType], mres);
|
||||
if (mres & 1)
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
MESSAGE_BEGIN(msgDest, msgType, msgOrigin, msgpEntity);
|
||||
for (i=0; i<msgCount; i++) {
|
||||
Msg.at(i)->Send();
|
||||
Msg.at(i)->Reset();
|
||||
}
|
||||
MESSAGE_END();
|
||||
RETURN_META(MRES_SUPERCEDE);
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL register_message(AMX *amx, cell *params)
|
||||
{
|
||||
int len;
|
||||
if (params[1]>0 && params[1] < 256) {
|
||||
int id = MF_RegisterSPForwardByName(amx, MF_GetAmxString(amx, params[2], 0, &len), FP_CELL, FP_CELL, FP_CELL, FP_DONE);
|
||||
MF_Log("Registering message %d with result %d", params[1], id);
|
||||
msgHooks[params[1]] = id;
|
||||
return id;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL set_msg_block(AMX *amx, cell *params)
|
||||
{
|
||||
int msgid = params[1];
|
||||
int block = params[2];
|
||||
|
||||
if (msgid < 1 || msgid > 255) {
|
||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
msgBlocks[msgid] = block;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_msg_block(AMX *amx, cell *params)
|
||||
{
|
||||
int msgid = params[1];
|
||||
int block = params[2];
|
||||
|
||||
if (msgid < 1 || msgid > 255) {
|
||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return msgBlocks[msgid];
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_msg_args(AMX *amx, cell *params)
|
||||
{
|
||||
return msgCount;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_msg_argtype(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int argn = params[1];
|
||||
|
||||
if (!inhook || argn >= Msg.size()) {
|
||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Msg.at(argn-1)->Type();
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_msg_arg_int(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int argn = params[1];
|
||||
|
||||
if (!inhook || argn >= Msg.size()) {
|
||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iVal = Msg.at(argn-1)->iData;
|
||||
|
||||
return iVal;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL set_msg_arg_int(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int argn = params[1];
|
||||
|
||||
if (!inhook || argn >= Msg.size()) {
|
||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Msg.at(argn-1)->iData = params[2];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_msg_arg_float(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int argn = params[1];
|
||||
|
||||
if (!inhook || argn >= Msg.size()) {
|
||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return amx_ftoc(Msg.at(argn-1)->fData);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL set_msg_arg_float(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int argn = params[1];
|
||||
|
||||
if (!inhook || argn >= Msg.size()) {
|
||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
REAL fVal = amx_ctof(params[2]);
|
||||
|
||||
Msg.at(argn-1)->fData = fVal;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_msg_arg_string(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int argn = params[1];
|
||||
|
||||
if (!inhook || argn >= Msg.size()) {
|
||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *szVal = Msg.at(argn-1)->cData.c_str();
|
||||
|
||||
return MF_SetAmxString(amx, params[2], szVal, params[3]);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL set_msg_arg_string(AMX *amx, cell *params)
|
||||
{
|
||||
unsigned int argn = params[1];
|
||||
int iLen;
|
||||
|
||||
if (!inhook || argn >= Msg.size()) {
|
||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *szVal = MF_GetAmxString(amx, params[2], 0, &iLen);
|
||||
|
||||
Msg.at(argn-1)->cData.assign(szVal);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_msg_origin(AMX *amx, cell *params)
|
||||
{
|
||||
if (!inhook) {
|
||||
MF_RaiseAmxError(amx, AMX_ERR_NATIVE);
|
||||
return 0;
|
||||
}
|
||||
vec3_t vRet = (Vector)msgOrigin;
|
||||
cell *cAddr = MF_GetAmxAddr(amx, params[1]);
|
||||
|
||||
cAddr[0] = amx_ftoc(vRet.x);
|
||||
cAddr[1] = amx_ftoc(vRet.y);
|
||||
cAddr[2] = amx_ftoc(vRet.z);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO msg_Natives[] = {
|
||||
{"register_message", register_message},
|
||||
|
||||
{"set_msg_block", set_msg_block},
|
||||
{"get_msg_block", get_msg_block},
|
||||
|
||||
{"get_msg_args", get_msg_args},
|
||||
{"get_msg_argtype", get_msg_argtype},
|
||||
{"get_msg_arg_int", get_msg_arg_int},
|
||||
{"set_msg_arg_int", set_msg_arg_int},
|
||||
{"get_msg_arg_float", get_msg_arg_float},
|
||||
{"set_msg_arg_float", set_msg_arg_float},
|
||||
{"get_msg_arg_string", get_msg_arg_string},
|
||||
{"set_msg_arg_string", set_msg_arg_string},
|
||||
{"get_msg_origin", get_msg_origin},
|
||||
|
||||
{NULL, NULL},
|
||||
};
|
45
dlls/engine/messages.h
Executable file
45
dlls/engine/messages.h
Executable file
|
@ -0,0 +1,45 @@
|
|||
#ifndef _MSGS_INCLUDE_H
|
||||
#define _MSGS_INCLUDE_H
|
||||
|
||||
#include "engine.h"
|
||||
|
||||
#define MAX_MESSAGES 255
|
||||
|
||||
#define BLOCK_NOT 0
|
||||
#define BLOCK_ONCE 1
|
||||
#define BLOCK_SET 2
|
||||
|
||||
enum {
|
||||
arg_byte = 1,
|
||||
arg_char,
|
||||
arg_short,
|
||||
arg_long,
|
||||
arg_angle,
|
||||
arg_coord,
|
||||
arg_string,
|
||||
arg_entity,
|
||||
};
|
||||
|
||||
enum {
|
||||
type_int = 1,
|
||||
type_float,
|
||||
type_string,
|
||||
};
|
||||
|
||||
class argMsg
|
||||
{
|
||||
public:
|
||||
argMsg();
|
||||
void Reset();
|
||||
void Send();
|
||||
int Type();
|
||||
|
||||
int type;
|
||||
REAL fData;
|
||||
std::string cData;
|
||||
int iData;
|
||||
};
|
||||
|
||||
extern AMX_NATIVE_INFO msg_Natives[];
|
||||
|
||||
#endif //_MSGS_INCLUDE_H
|
|
@ -2901,8 +2901,19 @@ static cell AMX_NATIVE_CALL get_speak(AMX *amx, cell *params) {
|
|||
return PlInfo[iIndex].iSpeakFlags;
|
||||
}
|
||||
|
||||
/********************************************
|
||||
static cell AMX_NATIVE_CALL trace_hull(AMX *amx, cell *params)
|
||||
{
|
||||
int res = 0;
|
||||
TraceResult v;
|
||||
}
|
||||
|
||||
/* *****************************************
|
||||
*****************************************
|
||||
*****************************************
|
||||
METAMOD HOOKED FUNCTIONS
|
||||
*****************************************
|
||||
*****************************************
|
||||
*****************************************
|
||||
*****************************************/
|
||||
|
||||
// This checks who can hear who through voice comm. this reads flags set,
|
||||
|
@ -3423,6 +3434,7 @@ AMX_NATIVE_INFO Engine_Natives[] = {
|
|||
{"halflife_time", halflife_time},
|
||||
{"fake_touch", fake_touch},
|
||||
{"get_grenade_id", get_grenade_id},
|
||||
{"trace_hull", trace_hull},
|
||||
|
||||
{"create_entity", create_entity},
|
||||
{"remove_entity", remove_entity},
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#define __MODULECONFIG_H__
|
||||
|
||||
// Module info
|
||||
#define MODULE_NAME "Engine"
|
||||
#define MODULE_NAME "ENGINE"
|
||||
#define MODULE_VERSION "0.20"
|
||||
#define MODULE_AUTHOR "AMX Mod X Dev Team"
|
||||
#define MODULE_URL "www.amxmodx.org"
|
||||
|
@ -32,7 +32,7 @@
|
|||
//#define FN_AMXX_DETTACH OnAmxxDettach
|
||||
// All plugins loaded
|
||||
// Do forward functions init here (MF_RegisterForward)
|
||||
//#define FN_AMXX_PLUGINSLOADED OnPluginsLoaded
|
||||
#define FN_AMXX_PLUGINSLOADED OnPluginsLoaded
|
||||
|
||||
/**** METAMOD ****/
|
||||
// If your module doesn't use metamod, you may close the file now :)
|
||||
|
@ -54,12 +54,12 @@
|
|||
// (wd) are Will Day's notes
|
||||
// - GetEntityAPI2 functions
|
||||
// #define FN_GameDLLInit GameDLLInit /* pfnGameInit() */
|
||||
// #define FN_DispatchSpawn DispatchSpawn /* pfnSpawn() */
|
||||
// #define FN_DispatchThink DispatchThink /* pfnThink() */
|
||||
// #define FN_DispatchUse DispatchUse /* pfnUse() */
|
||||
#define FN_DispatchSpawn DispatchSpawn /* pfnSpawn() */
|
||||
#define FN_DispatchThink DispatchThink /* pfnThink() */
|
||||
#define FN_DispatchUse DispatchUse /* pfnUse() */
|
||||
#define FN_DispatchTouch DispatchTouch /* pfnTouch() */
|
||||
// #define FN_DispatchBlocked DispatchBlocked /* pfnBlocked() */
|
||||
// #define FN_DispatchKeyValue DispatchKeyValue /* pfnKeyValue() */
|
||||
//#define FN_DispatchKeyValue KeyValue /* pfnKeyValue() */
|
||||
// #define FN_DispatchSave DispatchSave /* pfnSave() */
|
||||
// #define FN_DispatchRestore DispatchRestore /* pfnRestore() */
|
||||
// #define FN_DispatchObjectCollsionBox DispatchObjectCollsionBox /* pfnSetAbsBox() */
|
||||
|
@ -73,8 +73,8 @@
|
|||
#define FN_ClientKill ClientKill /* pfnClientKill() (wd) Player has typed "kill" */
|
||||
// #define FN_ClientPutInServer ClientPutInServer /* pfnClientPutInServer() (wd) Client is entering the game */
|
||||
// #define FN_ClientCommand ClientCommand /* pfnClientCommand() (wd) Player has sent a command (typed or from a bind) */
|
||||
#define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */
|
||||
#define FN_ServerActivate ServerActivate /* pfnServerActivate() (wd) Server is starting a new map */
|
||||
// #define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */
|
||||
// #define FN_ServerActivate ServerActivate /* pfnServerActivate() (wd) Server is starting a new map */
|
||||
#define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */
|
||||
#define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */
|
||||
#define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */
|
||||
|
@ -123,7 +123,7 @@
|
|||
// #define FN_ClientConnect_Post ClientConnect_Post
|
||||
// #define FN_ClientDisconnect_Post ClientDisconnect_Post
|
||||
// #define FN_ClientKill_Post ClientKill_Post
|
||||
#define FN_ClientPutInServer_Post ClientPutInServer_Post
|
||||
// #define FN_ClientPutInServer_Post ClientPutInServer_Post
|
||||
// #define FN_ClientCommand_Post ClientCommand_Post
|
||||
// #define FN_ClientUserInfoChanged_Post ClientUserInfoChanged_Post
|
||||
// #define FN_ServerActivate_Post ServerActivate_Post
|
||||
|
@ -163,7 +163,7 @@
|
|||
// #define FN_ModelIndex ModelIndex
|
||||
// #define FN_ModelFrames ModelFrames
|
||||
// #define FN_SetSize SetSize
|
||||
// #define FN_ChangeLevel ChangeLevel
|
||||
#define FN_ChangeLevel ChangeLevel
|
||||
// #define FN_GetSpawnParms GetSpawnParms
|
||||
// #define FN_SaveSpawnParms SaveSpawnParms
|
||||
// #define FN_VecToYaw VecToYaw
|
||||
|
@ -280,7 +280,7 @@
|
|||
// #define FN_SetPhysicsKeyValue SetPhysicsKeyValue
|
||||
// #define FN_GetPhysicsInfoString GetPhysicsInfoString
|
||||
// #define FN_PrecacheEvent PrecacheEvent
|
||||
// #define FN_PlaybackEvent PlaybackEvent
|
||||
#define FN_PlaybackEvent PlaybackEvent
|
||||
// #define FN_SetFatPVS SetFatPVS
|
||||
// #define FN_SetFatPAS SetFatPAS
|
||||
// #define FN_CheckVisibility CheckVisibility
|
||||
|
|
Loading…
Reference in New Issue
Block a user