2014-08-04 10:05:55 +00:00
|
|
|
// vim: set ts=4 sw=4 tw=99 noet:
|
|
|
|
//
|
|
|
|
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
|
|
|
|
// Copyright (C) The AMX Mod X Development Team.
|
|
|
|
//
|
|
|
|
// This software is licensed under the GNU General Public License, version 3 or higher.
|
|
|
|
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
|
|
|
// https://alliedmods.net/amxmodx-license
|
|
|
|
|
|
|
|
//
|
|
|
|
// Engine Module
|
|
|
|
//
|
|
|
|
|
2004-05-26 05:15:40 +00:00
|
|
|
#ifndef _ENGINE_INCLUDE_H
|
|
|
|
#define _ENGINE_INCLUDE_H
|
|
|
|
|
2008-08-16 09:48:39 +00:00
|
|
|
#include "amxxmodule.h"
|
2004-05-26 05:15:40 +00:00
|
|
|
#include <extdll.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <meta_api.h>
|
|
|
|
#include <sdk_util.h>
|
|
|
|
#include <usercmd.h>
|
|
|
|
#include "entity.h"
|
|
|
|
#include "gpglobals.h"
|
2013-06-15 20:02:24 +00:00
|
|
|
#include "entity_state.h"
|
2015-09-30 17:08:39 +00:00
|
|
|
#include <amtl/am-vector.h>
|
|
|
|
#include <amtl/am-string.h>
|
|
|
|
#include <CDetour/detours.h>
|
2015-10-06 22:10:48 +00:00
|
|
|
#include <HLTypeConversion.h>
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2004-08-11 12:17:39 +00:00
|
|
|
extern DLL_FUNCTIONS *g_pFunctionTable;
|
|
|
|
extern DLL_FUNCTIONS *g_pFunctionTable_Post;
|
|
|
|
extern enginefuncs_t *g_pengfuncsTable;
|
|
|
|
extern enginefuncs_t *g_pengfuncsTable_Post;
|
|
|
|
|
2004-05-26 05:15:40 +00:00
|
|
|
extern int SpawnForward;
|
|
|
|
extern int ChangelevelForward;
|
|
|
|
extern int PlaybackForward;
|
|
|
|
extern int DispatchKeyForward;
|
|
|
|
extern int pfnTouchForward;
|
|
|
|
extern int pfnThinkForward;
|
|
|
|
extern int PlayerPreThinkForward;
|
|
|
|
extern int PlayerPostThinkForward;
|
|
|
|
extern int ClientKillForward;
|
2013-07-02 22:19:12 +00:00
|
|
|
extern int ClientImpulseForward;
|
2013-07-02 23:00:52 +00:00
|
|
|
extern int CmdStartForward;
|
2004-05-26 05:15:40 +00:00
|
|
|
extern int StartFrameForward;
|
|
|
|
extern int DispatchUseForward;
|
2004-06-29 03:22:38 +00:00
|
|
|
extern int VexdTouchForward;
|
|
|
|
extern int VexdServerForward;
|
2004-02-07 21:23:24 +00:00
|
|
|
|
2015-06-11 14:08:46 +00:00
|
|
|
extern CDetour *LightStyleDetour;
|
2015-10-06 22:10:48 +00:00
|
|
|
extern HLTypeConversion TypeConversion;
|
2015-06-11 14:08:46 +00:00
|
|
|
|
2004-02-07 08:31:44 +00:00
|
|
|
#define AMS_OFFSET 0.01
|
|
|
|
|
2004-03-14 08:23:42 +00:00
|
|
|
#define GETINFOKEYBUFFER (*g_engfuncs.pfnGetInfoKeyBuffer)
|
2004-05-26 05:15:40 +00:00
|
|
|
#define INFO_KEY_BUFFER (*g_engfuncs.pfnGetInfoKeyBuffer)
|
|
|
|
#define INFO_KEY_VALUE (*g_engfuncs.pfnInfoKeyValue)
|
2004-03-14 08:23:42 +00:00
|
|
|
|
2004-02-07 08:31:44 +00:00
|
|
|
#define SPEAK_NORMAL 0
|
|
|
|
#define SPEAK_MUTED 1
|
|
|
|
#define SPEAK_ALL 2
|
|
|
|
#define SPEAK_LISTENALL 4
|
|
|
|
|
|
|
|
#define CAMERA_NONE 0
|
|
|
|
#define CAMERA_3RDPERSON 1
|
|
|
|
#define CAMERA_UPLEFT 2
|
|
|
|
#define CAMERA_TOPDOWN 3
|
|
|
|
|
2004-05-26 05:15:40 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
usercmd_float_start,
|
|
|
|
usercmd_forwardmove, // Float
|
|
|
|
usercmd_sidemove, // Float
|
|
|
|
usercmd_upmove, // Float
|
|
|
|
usercmd_float_end,
|
|
|
|
usercmd_int_start,
|
|
|
|
usercmd_lerp_msec, // short
|
|
|
|
usercmd_msec, // byte
|
|
|
|
usercmd_lightlevel, // byte
|
|
|
|
usercmd_buttons, // unsigned short
|
|
|
|
usercmd_impulse, // byte
|
|
|
|
usercmd_weaponselect, // byte
|
|
|
|
|
|
|
|
usercmd_impact_index, // in
|
|
|
|
usercmd_int_end,
|
|
|
|
usercmd_vec_start,
|
|
|
|
usercmd_viewangles, // Vector
|
|
|
|
usercmd_impact_position, // vec
|
|
|
|
usercmd_vec_end
|
2004-02-07 08:31:44 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2004-06-25 22:51:18 +00:00
|
|
|
// 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);
|
|
|
|
};
|
|
|
|
|
2004-05-26 05:15:40 +00:00
|
|
|
//These two structs are relics from VexD
|
2004-02-07 08:31:44 +00:00
|
|
|
struct PlayerInfo {
|
|
|
|
int iSpeakFlags;
|
|
|
|
edict_t *pViewEnt;
|
|
|
|
int iViewType;
|
2013-06-15 20:02:24 +00:00
|
|
|
//int iRenderMode;
|
|
|
|
//float fRenderAmt;
|
2004-02-07 08:31:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct GlobalInfo {
|
2013-09-06 00:51:52 +00:00
|
|
|
char szLastLights[128];
|
|
|
|
char szRealLights[128];
|
2004-05-26 05:15:40 +00:00
|
|
|
bool bCheckLights;
|
2004-02-07 08:31:44 +00:00
|
|
|
};
|
|
|
|
|
2004-06-25 22:51:18 +00:00
|
|
|
class Impulse
|
|
|
|
{
|
|
|
|
public:
|
2004-09-05 20:03:01 +00:00
|
|
|
~Impulse()
|
|
|
|
{
|
|
|
|
if (Forward != -1)
|
|
|
|
MF_UnregisterSPForward(Forward);
|
|
|
|
}
|
2004-06-25 22:51:18 +00:00
|
|
|
int Forward;
|
|
|
|
int Check;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Touch
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int Forward;
|
2014-08-09 18:30:31 +00:00
|
|
|
ke::AString Toucher;
|
|
|
|
ke::AString Touched;
|
2004-06-25 22:51:18 +00:00
|
|
|
~Touch()
|
|
|
|
{
|
2004-09-05 20:03:01 +00:00
|
|
|
if (Forward != -1)
|
|
|
|
MF_UnregisterSPForward(Forward);
|
2004-06-25 22:51:18 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class EntClass
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int Forward;
|
2014-08-09 18:30:31 +00:00
|
|
|
ke::AString Class;
|
2004-06-25 22:51:18 +00:00
|
|
|
~EntClass()
|
|
|
|
{
|
2004-09-08 21:13:04 +00:00
|
|
|
if (Forward != -1)
|
|
|
|
MF_UnregisterSPForward(Forward);
|
2004-06-25 22:51:18 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2004-05-26 05:15:40 +00:00
|
|
|
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);
|
2004-02-07 08:31:44 +00:00
|
|
|
|
2004-08-11 12:17:39 +00:00
|
|
|
extern int g_CameraCount;
|
2004-08-29 17:55:11 +00:00
|
|
|
|
2004-08-30 01:11:48 +00:00
|
|
|
int Spawn(edict_t *pEntity);
|
|
|
|
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);
|
|
|
|
void KeyValue(edict_t *pEntity, KeyValueData *pkvd);
|
|
|
|
void StartFrame();
|
|
|
|
void CmdStart(const edict_t *player, const struct usercmd_s *_cmd, unsigned int random_seed);
|
|
|
|
void ClientKill(edict_t *pEntity);
|
|
|
|
void PlayerPreThink(edict_t *pEntity);
|
|
|
|
void PlayerPostThink_Post(edict_t *pEntity);
|
|
|
|
void pfnTouch(edict_t *pToucher, edict_t *pTouched);
|
|
|
|
void Think(edict_t *pent);
|
2005-12-03 00:54:26 +00:00
|
|
|
void StartFrame_Post();
|
2004-08-30 01:11:48 +00:00
|
|
|
|
2006-08-28 11:08:18 +00:00
|
|
|
#define CHECK_ENTITY_SIMPLE(x) \
|
|
|
|
if (x < 0 || x > gpGlobals->maxEntities) { \
|
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
|
|
|
|
return 0; \
|
|
|
|
} else { \
|
2015-10-06 22:10:48 +00:00
|
|
|
if (x != 0 && FNullEnt(TypeConversion.id_to_edict(x))) { \
|
2006-08-28 11:08:18 +00:00
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
|
|
|
|
return 0; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2004-10-03 20:00:23 +00:00
|
|
|
#define CHECK_ENTITY(x) \
|
2004-10-03 23:21:54 +00:00
|
|
|
if (x < 0 || x > gpGlobals->maxEntities) { \
|
2004-10-03 20:00:23 +00:00
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
|
2004-10-04 05:51:27 +00:00
|
|
|
return 0; \
|
2004-10-03 20:00:23 +00:00
|
|
|
} else { \
|
2015-05-10 22:39:17 +00:00
|
|
|
if (x > 0 && x <= gpGlobals->maxClients) { \
|
2004-10-03 20:00:23 +00:00
|
|
|
if (!MF_IsPlayerIngame(x)) { \
|
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not in-game)", x); \
|
2004-10-04 05:51:27 +00:00
|
|
|
return 0; \
|
2004-10-03 20:00:23 +00:00
|
|
|
} \
|
|
|
|
} else { \
|
2015-10-06 22:10:48 +00:00
|
|
|
if (x != 0 && FNullEnt(TypeConversion.id_to_edict(x))) { \
|
2004-10-03 20:00:23 +00:00
|
|
|
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
|
2004-10-04 05:51:27 +00:00
|
|
|
return 0; \
|
2004-10-03 20:00:23 +00:00
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
2004-08-11 12:17:39 +00:00
|
|
|
|
2004-06-25 22:51:18 +00:00
|
|
|
extern bool g_inKeyValue;
|
2004-05-26 05:15:40 +00:00
|
|
|
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[];
|
2006-09-01 03:29:27 +00:00
|
|
|
extern AMX_NATIVE_INFO engine_NewNatives[];
|
2014-08-09 18:30:31 +00:00
|
|
|
extern ke::Vector<Impulse *> Impulses;
|
|
|
|
extern ke::Vector<EntClass *> Thinks;
|
|
|
|
extern ke::Vector<Touch *> Touches;
|
2004-02-07 08:31:44 +00:00
|
|
|
|
2004-08-30 22:24:43 +00:00
|
|
|
#endif //_ENGINE_INCLUDE_H
|
|
|
|
|