2004-05-26 05:15:40 +00:00
|
|
|
#include "engine.h"
|
|
|
|
|
|
|
|
bool incmd = false;
|
|
|
|
int DispatchUseForward = 0;
|
|
|
|
int SpawnForward = 0;
|
|
|
|
int PlaybackForward = 0;
|
|
|
|
int DispatchKeyForward = 0;
|
|
|
|
int pfnTouchForward = 0;
|
|
|
|
int pfnThinkForward = 0;
|
|
|
|
int PlayerPreThinkForward = 0;
|
|
|
|
int PlayerPostThinkForward = 0;
|
|
|
|
int ClientKillForward = 0;
|
2013-07-02 22:19:12 +00:00
|
|
|
int ClientImpulseForward = 0;
|
2013-07-02 23:00:52 +00:00
|
|
|
int CmdStartForward = 0;
|
2004-05-26 05:15:40 +00:00
|
|
|
int StartFrameForward = 0;
|
2004-06-29 03:22:38 +00:00
|
|
|
int VexdTouchForward = 0;
|
|
|
|
int VexdServerForward = 0;
|
2004-06-29 06:45:52 +00:00
|
|
|
CVector<Impulse *> Impulses;
|
|
|
|
CVector<EntClass *> Thinks;
|
|
|
|
CVector<Touch *> Touches;
|
2004-06-25 22:51:18 +00:00
|
|
|
KeyValueData *g_pkvd;
|
|
|
|
bool g_inKeyValue=false;
|
2004-10-27 19:06:43 +00:00
|
|
|
bool g_precachedStuff = false;
|
2004-06-25 22:51:18 +00:00
|
|
|
|
|
|
|
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<len1; i++)
|
|
|
|
{
|
|
|
|
if (s1[i] != s2[i])
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2005-09-05 22:05:23 +00:00
|
|
|
int Spawn(edict_t *pEntity)
|
|
|
|
{
|
2004-10-27 19:06:43 +00:00
|
|
|
if (!g_precachedStuff) {
|
|
|
|
// Used for SetView, added by JGHG
|
2006-08-18 14:02:07 +00:00
|
|
|
PRECACHE_MODEL("models/rpgrocket.mdl");
|
2004-10-27 19:06:43 +00:00
|
|
|
g_precachedStuff = true;
|
|
|
|
}
|
2004-08-29 17:55:11 +00:00
|
|
|
if (SpawnForward != -1) {
|
2004-05-26 05:15:40 +00:00
|
|
|
int retVal = 0;
|
|
|
|
int id = ENTINDEX(pEntity);
|
2005-10-18 21:05:15 +00:00
|
|
|
retVal = MF_ExecuteForward(SpawnForward, (cell)id);
|
2004-05-26 05:15:40 +00:00
|
|
|
if (retVal)
|
2013-07-27 18:36:33 +00:00
|
|
|
RETURN_META_VALUE(MRES_SUPERCEDE, -1);
|
2004-06-24 07:36:43 +00:00
|
|
|
}
|
2004-05-26 05:15:40 +00:00
|
|
|
RETURN_META_VALUE(MRES_IGNORED, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2004-08-29 17:55:11 +00:00
|
|
|
if (PlaybackForward != -1) {
|
2004-05-26 05:15:40 +00:00
|
|
|
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);
|
2006-02-13 20:03:39 +00:00
|
|
|
retVal = MF_ExecuteForward(PlaybackForward, (cell)flags, (cell)ENTINDEX(e), (cell)eventindex, delay, CellOrigin, CellAngles, fparam1, fparam2, (cell)iparam1, (cell)iparam2, (cell)bparam1, (cell)bparam2);
|
2004-05-26 05:15:40 +00:00
|
|
|
if (retVal)
|
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
}
|
|
|
|
RETURN_META(MRES_IGNORED);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void KeyValue(edict_t *pEntity, KeyValueData *pkvd)
|
|
|
|
{
|
2004-06-25 22:51:18 +00:00
|
|
|
int retVal = 0;
|
|
|
|
g_inKeyValue=true;
|
|
|
|
g_pkvd=pkvd;
|
|
|
|
int index = ENTINDEX(pEntity);
|
2004-08-29 17:55:11 +00:00
|
|
|
if (DispatchKeyForward != -1) {
|
2005-10-18 21:05:15 +00:00
|
|
|
retVal = MF_ExecuteForward(DispatchKeyForward, (cell)index);
|
2004-06-25 22:51:18 +00:00
|
|
|
g_inKeyValue=false;
|
2004-08-31 05:02:19 +00:00
|
|
|
if (retVal)
|
2004-05-26 05:15:40 +00:00
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
}
|
2004-06-25 22:51:18 +00:00
|
|
|
g_inKeyValue=false;
|
2004-08-31 05:02:19 +00:00
|
|
|
RETURN_META(MRES_IGNORED);
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
|
|
|
|
2004-08-11 12:17:39 +00:00
|
|
|
void StartFrame()
|
2004-05-26 05:15:40 +00:00
|
|
|
{
|
2004-08-29 17:55:11 +00:00
|
|
|
if (StartFrameForward != -1)
|
2004-05-26 05:15:40 +00:00
|
|
|
MF_ExecuteForward(StartFrameForward);
|
2004-08-29 17:55:11 +00:00
|
|
|
else if (VexdServerForward != -1)
|
2004-06-29 03:22:38 +00:00
|
|
|
MF_ExecuteForward(VexdServerForward);
|
2004-05-26 05:15:40 +00:00
|
|
|
|
|
|
|
RETURN_META(MRES_IGNORED);
|
|
|
|
}
|
|
|
|
|
2005-11-26 20:38:58 +00:00
|
|
|
void StartFrame_Post()
|
|
|
|
{
|
|
|
|
if (glinfo.bCheckLights)
|
|
|
|
{
|
|
|
|
if (glinfo.fNextLights < gpGlobals->time)
|
|
|
|
{
|
|
|
|
(g_engfuncs.pfnLightStyle)(0, (char *)glinfo.szLastLights);
|
|
|
|
glinfo.fNextLights = gpGlobals->time + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURN_META(MRES_IGNORED);
|
|
|
|
}
|
|
|
|
|
2004-05-26 05:15:40 +00:00
|
|
|
void CmdStart(const edict_t *player, const struct usercmd_s *_cmd, unsigned int random_seed)
|
|
|
|
{
|
2004-06-25 22:51:18 +00:00
|
|
|
unsigned int i = 0;
|
2004-05-26 05:15:40 +00:00
|
|
|
int retVal = 0;
|
|
|
|
edict_t *pEntity = (edict_t *)player;
|
2013-06-15 18:59:11 +00:00
|
|
|
g_cmd = (struct usercmd_s *)_cmd;
|
2004-08-31 05:02:19 +00:00
|
|
|
int origImpulse = g_cmd->impulse; // incase a plugin alters it
|
2004-06-25 22:51:18 +00:00
|
|
|
for (i=0; i<Impulses.size(); i++)
|
|
|
|
{
|
|
|
|
if (Impulses[i]->Check == g_cmd->impulse)
|
|
|
|
{
|
2005-10-18 21:05:15 +00:00
|
|
|
retVal = MF_ExecuteForward(Impulses[i]->Forward, (cell)ENTINDEX(pEntity), (cell)origImpulse);
|
2013-07-02 22:19:12 +00:00
|
|
|
|
|
|
|
// don't return SUPERCEDE in any way here,
|
|
|
|
// we don't want to break client_impulse forward and access to cmd with [g/s]et_usercmd
|
|
|
|
if (retVal)
|
|
|
|
g_cmd->impulse = 0;
|
2004-06-25 22:51:18 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-02 22:19:12 +00:00
|
|
|
|
2013-07-02 23:00:52 +00:00
|
|
|
// client_impulse
|
2013-07-02 22:19:12 +00:00
|
|
|
if (ClientImpulseForward != -1 && origImpulse != 0)
|
|
|
|
{
|
|
|
|
retVal = MF_ExecuteForward(ClientImpulseForward, (cell)ENTINDEX(pEntity), (cell)origImpulse);
|
|
|
|
|
|
|
|
if (retVal)
|
2004-05-26 05:15:40 +00:00
|
|
|
g_cmd->impulse = 0;
|
|
|
|
}
|
2013-07-02 22:19:12 +00:00
|
|
|
|
2013-07-02 23:00:52 +00:00
|
|
|
// client_CmdStart
|
|
|
|
if (CmdStartForward != -1)
|
|
|
|
{
|
|
|
|
incmd = true;
|
|
|
|
retVal = MF_ExecuteForward(CmdStartForward, (cell)ENTINDEX(pEntity));
|
|
|
|
incmd = false;
|
|
|
|
|
|
|
|
if (retVal)
|
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
}
|
|
|
|
|
2013-07-02 22:19:12 +00:00
|
|
|
RETURN_META(MRES_IGNORED);
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClientKill(edict_t *pEntity)
|
|
|
|
{
|
|
|
|
int retVal = 0;
|
|
|
|
|
2004-08-29 17:55:11 +00:00
|
|
|
if (ClientKillForward != -1) {
|
2005-10-18 21:05:15 +00:00
|
|
|
retVal = MF_ExecuteForward(ClientKillForward, (cell)ENTINDEX(pEntity));
|
2004-05-26 05:15:40 +00:00
|
|
|
if (retVal)
|
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURN_META(MRES_IGNORED);
|
|
|
|
}
|
|
|
|
|
2004-08-11 12:17:39 +00:00
|
|
|
void PlayerPreThink(edict_t *pEntity)
|
2004-05-26 05:15:40 +00:00
|
|
|
{
|
2005-10-18 21:05:15 +00:00
|
|
|
MF_ExecuteForward(PlayerPreThinkForward, (cell)ENTINDEX(pEntity));
|
2004-05-26 05:15:40 +00:00
|
|
|
RETURN_META(MRES_IGNORED);
|
|
|
|
}
|
2004-08-30 01:11:48 +00:00
|
|
|
|
2004-06-24 07:36:43 +00:00
|
|
|
void PlayerPostThink_Post(edict_t *pEntity)
|
2004-05-26 05:15:40 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-29 17:55:11 +00:00
|
|
|
if (PlayerPostThinkForward != -1)
|
2004-08-11 12:17:39 +00:00
|
|
|
{
|
2005-10-18 21:05:15 +00:00
|
|
|
if (MF_ExecuteForward(PlayerPostThinkForward, (cell)ENTINDEX(pEntity)))
|
2004-08-11 12:17:39 +00:00
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
}
|
2004-05-26 05:15:40 +00:00
|
|
|
|
|
|
|
RETURN_META(MRES_IGNORED);
|
|
|
|
}
|
|
|
|
|
2004-08-11 12:17:39 +00:00
|
|
|
void pfnTouch(edict_t *pToucher, edict_t *pTouched)
|
2004-05-26 05:15:40 +00:00
|
|
|
{
|
2004-06-25 22:51:18 +00:00
|
|
|
unsigned int i = 0;
|
2004-05-26 05:15:40 +00:00
|
|
|
int retVal = 0;
|
2004-06-25 22:51:18 +00:00
|
|
|
const char *ptrClass = STRING(pToucher->v.classname);
|
|
|
|
const char *ptdClass = STRING(pTouched->v.classname);
|
2005-07-23 20:16:29 +00:00
|
|
|
int ptrIndex = ENTINDEX(pToucher);
|
|
|
|
int ptdIndex = ENTINDEX(pTouched);
|
2004-08-31 05:02:19 +00:00
|
|
|
META_RES res=MRES_IGNORED;
|
2004-06-25 22:51:18 +00:00
|
|
|
for (i=0; i<Touches.size(); i++)
|
|
|
|
{
|
2004-09-08 21:13:04 +00:00
|
|
|
if (Touches[i]->Toucher.size() == 0)
|
2004-06-25 22:51:18 +00:00
|
|
|
{
|
2004-09-08 21:13:04 +00:00
|
|
|
if (Touches[i]->Touched.size() == 0)
|
2004-06-25 22:51:18 +00:00
|
|
|
{
|
2005-10-18 21:05:15 +00:00
|
|
|
retVal = MF_ExecuteForward(Touches[i]->Forward, (cell)ptrIndex, (cell)ptdIndex);
|
2004-08-31 05:02:19 +00:00
|
|
|
if (retVal & 2/*PLUGIN_HANDLED_MAIN*/)
|
2004-06-25 22:51:18 +00:00
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
2004-08-31 05:02:19 +00:00
|
|
|
else if (retVal)
|
|
|
|
res=MRES_SUPERCEDE;
|
2004-09-08 21:13:04 +00:00
|
|
|
} else if (Touches[i]->Touched.compare(ptdClass)==0) {
|
2005-10-18 21:05:15 +00:00
|
|
|
retVal = MF_ExecuteForward(Touches[i]->Forward, (cell)ptrIndex, (cell)ptdIndex);
|
2004-08-31 05:02:19 +00:00
|
|
|
if (retVal & 2/*PLUGIN_HANDLED_MAIN*/)
|
2004-06-25 22:51:18 +00:00
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
2004-08-31 05:02:19 +00:00
|
|
|
else if (retVal)
|
|
|
|
res=MRES_SUPERCEDE;
|
2004-06-25 22:51:18 +00:00
|
|
|
}
|
2004-09-08 21:13:04 +00:00
|
|
|
} else if (Touches[i]->Toucher.compare(ptrClass)==0) {
|
|
|
|
if (Touches[i]->Touched.size() == 0)
|
2004-06-25 22:51:18 +00:00
|
|
|
{
|
2005-10-18 21:05:15 +00:00
|
|
|
retVal = MF_ExecuteForward(Touches[i]->Forward, (cell)ptrIndex, (cell)ptdIndex);
|
2004-08-31 05:02:19 +00:00
|
|
|
if (retVal & 2/*PLUGIN_HANDLED_MAIN*/)
|
2004-06-25 22:51:18 +00:00
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
2004-08-31 05:02:19 +00:00
|
|
|
else if (retVal)
|
|
|
|
res=MRES_SUPERCEDE;
|
2004-09-08 21:13:04 +00:00
|
|
|
} else if (Touches[i]->Touched.compare(ptdClass)==0) {
|
2005-10-18 21:05:15 +00:00
|
|
|
retVal = MF_ExecuteForward(Touches[i]->Forward, (cell)ptrIndex, (cell)ptdIndex);
|
2004-08-31 05:02:19 +00:00
|
|
|
if (retVal & 2/*PLUGIN_HANDLED_MAIN*/)
|
2004-06-25 22:51:18 +00:00
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
2004-08-31 05:02:19 +00:00
|
|
|
else if (retVal)
|
|
|
|
res=MRES_SUPERCEDE;
|
2004-06-25 22:51:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-05-26 05:15:40 +00:00
|
|
|
/* Execute pfnTouch forwards */
|
2004-08-29 17:55:11 +00:00
|
|
|
if (pfnTouchForward != -1) {
|
2005-10-18 21:05:15 +00:00
|
|
|
retVal = MF_ExecuteForward(pfnTouchForward, (cell)ptrIndex, (cell)ptdIndex);
|
2004-05-26 05:15:40 +00:00
|
|
|
if (retVal)
|
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
2004-09-05 20:03:01 +00:00
|
|
|
}
|
|
|
|
if (VexdTouchForward != -1) {
|
2005-10-18 21:05:15 +00:00
|
|
|
retVal = MF_ExecuteForward(VexdTouchForward, (cell)ptrIndex, (cell)ptdIndex);
|
2004-06-29 03:22:38 +00:00
|
|
|
if (retVal)
|
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
|
|
|
|
2004-08-31 05:02:19 +00:00
|
|
|
RETURN_META(res);
|
2004-05-26 05:15:40 +00:00
|
|
|
}
|
|
|
|
|
2004-08-11 12:17:39 +00:00
|
|
|
void Think(edict_t *pent)
|
2004-05-26 05:15:40 +00:00
|
|
|
{
|
2004-06-25 22:51:18 +00:00
|
|
|
unsigned int i = 0;
|
|
|
|
const char *cls = STRING(pent->v.classname);
|
2004-08-31 05:02:19 +00:00
|
|
|
META_RES res=MRES_IGNORED;
|
|
|
|
int retVal=0;
|
2004-06-25 22:51:18 +00:00
|
|
|
for (i=0; i<Thinks.size(); i++)
|
|
|
|
{
|
2004-09-08 21:13:04 +00:00
|
|
|
if (Thinks[i]->Class.compare(cls)==0)
|
2004-06-25 22:51:18 +00:00
|
|
|
{
|
2005-10-18 21:05:15 +00:00
|
|
|
retVal=MF_ExecuteForward(Thinks[i]->Forward, (cell)ENTINDEX(pent));
|
2004-08-31 05:02:19 +00:00
|
|
|
if (retVal & 2/*PLUGIN_HANDLED_MAIN*/)
|
|
|
|
RETURN_META(MRES_SUPERCEDE);
|
|
|
|
else if (retVal)
|
|
|
|
res=MRES_SUPERCEDE;
|
2004-06-25 22:51:18 +00:00
|
|
|
}
|
|
|
|
}
|
2005-10-18 21:05:15 +00:00
|
|
|
retVal=MF_ExecuteForward(pfnThinkForward, (cell)ENTINDEX(pent));
|
2004-08-31 05:02:19 +00:00
|
|
|
if (retVal)
|
|
|
|
res=MRES_SUPERCEDE;
|
2004-05-26 05:15:40 +00:00
|
|
|
|
2004-08-31 05:02:19 +00:00
|
|
|
RETURN_META(res);
|
2004-06-29 06:26:56 +00:00
|
|
|
}
|