#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; int VexdTouchForward = 0; int VexdServerForward = 0; CVector Impulses; CVector Thinks; CVector Touches; KeyValueData *g_pkvd; bool g_inKeyValue=false; int fstrcmp(const char *s1, const char *s2) { int i=0; int len1 = strlen(s1); int len2 = strlen(s2); if (len1 != len2) return 0; for (i=0; itime + 1; } } if (StartFrameForward != -1) MF_ExecuteForward(StartFrameForward); else if (VexdServerForward != -1) MF_ExecuteForward(VexdServerForward); RETURN_META(MRES_IGNORED); } void CmdStart(const edict_t *player, const struct usercmd_s *_cmd, unsigned int random_seed) { unsigned int i = 0; int retVal = 0; edict_t *pEntity = (edict_t *)player; struct usercmd_s *g_cmd = (struct usercmd_s *)_cmd; META_RES res = MRES_IGNORED; int origImpulse = g_cmd->impulse; // incase a plugin alters it for (i=0; iCheck == g_cmd->impulse) { retVal = MF_ExecuteForward(Impulses[i]->Forward, ENTINDEX(pEntity),origImpulse); if (retVal & 2 /*PLUGIN_HANDLED_MAIN*/) { g_cmd->impulse=0; RETURN_META(MRES_SUPERCEDE); } else if (retVal) res = MRES_SUPERCEDE; } } if (CmdStartForward != -1) { incmd = true; retVal = MF_ExecuteForward(CmdStartForward, ENTINDEX(pEntity), origImpulse); incmd = false; if (retVal) { g_cmd->impulse = 0; RETURN_META(MRES_SUPERCEDE); } } if (res == MRES_SUPERCEDE) g_cmd->impulse=0; RETURN_META(res); } void ClientKill(edict_t *pEntity) { int retVal = 0; if (ClientKillForward != -1) { retVal = MF_ExecuteForward(ClientKillForward, ENTINDEX(pEntity)); if (retVal) RETURN_META(MRES_SUPERCEDE); } RETURN_META(MRES_IGNORED); } void PlayerPreThink(edict_t *pEntity) { MF_ExecuteForward(PlayerPreThinkForward, ENTINDEX(pEntity)); RETURN_META(MRES_IGNORED); } void PlayerPostThink_Post(edict_t *pEntity) { 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 (PlayerPostThinkForward != -1) { if (MF_ExecuteForward(PlayerPostThinkForward, ENTINDEX(pEntity))) RETURN_META(MRES_SUPERCEDE); } RETURN_META(MRES_IGNORED); } void pfnTouch(edict_t *pToucher, edict_t *pTouched) { unsigned int i = 0; int retVal = 0; const char *ptrClass = STRING(pToucher->v.classname); const char *ptdClass = STRING(pTouched->v.classname); META_RES res=MRES_IGNORED; for (i=0; iToucher == 0) { if (Touches[i]->Touched == 0) { retVal = MF_ExecuteForward(Touches[i]->Forward, ENTINDEX(pToucher), ENTINDEX(pTouched)); if (retVal & 2/*PLUGIN_HANDLED_MAIN*/) RETURN_META(MRES_SUPERCEDE); else if (retVal) res=MRES_SUPERCEDE; } else if (fstrcmp(Touches[i]->Touched, ptdClass)) { retVal = MF_ExecuteForward(Touches[i]->Forward, ENTINDEX(pToucher), ENTINDEX(pTouched)); if (retVal & 2/*PLUGIN_HANDLED_MAIN*/) RETURN_META(MRES_SUPERCEDE); else if (retVal) res=MRES_SUPERCEDE; } } else if (fstrcmp(Touches[i]->Toucher, ptrClass)) { if (Touches[i]->Touched == 0) { retVal = MF_ExecuteForward(Touches[i]->Forward, ENTINDEX(pToucher), ENTINDEX(pTouched)); if (retVal & 2/*PLUGIN_HANDLED_MAIN*/) RETURN_META(MRES_SUPERCEDE); else if (retVal) res=MRES_SUPERCEDE; } else if (fstrcmp(Touches[i]->Touched, ptdClass)) { retVal = MF_ExecuteForward(Touches[i]->Forward, ENTINDEX(pToucher), ENTINDEX(pTouched)); if (retVal & 2/*PLUGIN_HANDLED_MAIN*/) RETURN_META(MRES_SUPERCEDE); else if (retVal) res=MRES_SUPERCEDE; } } } /* Execute pfnTouch forwards */ if (pfnTouchForward != -1) { retVal = MF_ExecuteForward(pfnTouchForward, ENTINDEX(pToucher), ENTINDEX(pTouched)); if (retVal) RETURN_META(MRES_SUPERCEDE); } if (VexdTouchForward != -1) { retVal = MF_ExecuteForward(VexdTouchForward, ENTINDEX(pToucher), ENTINDEX(pTouched)); if (retVal) RETURN_META(MRES_SUPERCEDE); } RETURN_META(res); } void Think(edict_t *pent) { unsigned int i = 0; const char *cls = STRING(pent->v.classname); META_RES res=MRES_IGNORED; int retVal=0; for (i=0; iClass)) { retVal=MF_ExecuteForward(Thinks[i]->Forward, ENTINDEX(pent)); if (retVal & 2/*PLUGIN_HANDLED_MAIN*/) RETURN_META(MRES_SUPERCEDE); else if (retVal) res=MRES_SUPERCEDE; } } retVal=MF_ExecuteForward(pfnThinkForward, ENTINDEX(pent)); if (retVal) res=MRES_SUPERCEDE; RETURN_META(res); }