New registers for impulse, think, and touch.

Fixed DispatchKeyValue related natives and forwards.
This commit is contained in:
David Anderson 2004-06-25 22:51:18 +00:00
parent 932dec9dee
commit 9c59ece7a4
5 changed files with 1627 additions and 20 deletions

View File

@ -127,6 +127,10 @@ void ServerDeactivate()
msgBlocks[i] = 0;
}
Touches.clear();
Impulses.clear();
Thinks.clear();
RETURN_META(MRES_IGNORED);
}

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,8 @@
#include "entity.h"
#include "gpglobals.h"
#define CHECK_ENTITY(x) if (x != 0 && (FNullEnt(INDEXENT(x)) || x < 0 || x > gpGlobals->maxEntities)) { MF_RaiseAmxError(amx,AMX_ERR_NATIVE); return 0; }
extern int SpawnForward;
extern int ChangelevelForward;
extern int PlaybackForward;
@ -75,6 +77,155 @@ enum
};
enum {
EngFunc_PrecacheModel, // int ) (char* s);
EngFunc_PrecacheSound, // int ) (char* s);
EngFunc_SetModel, // void ) (edict_t *e, const char *m);
EngFunc_ModelIndex, // int ) (const char *m);
EngFunc_ModelFrames, // int ) (int modelIndex);
EngFunc_SetSize, // void ) (edict_t *e, const float *rgflMin, const float *rgflMax);
EngFunc_ChangeLevel, // void ) (char* s1, char* s2);
EngFunc_VecToYaw, // float) (const float *rgflVector);
EngFunc_VecToAngles, // void ) (const float *rgflVectorIn, float *rgflVectorOut);
EngFunc_MoveToOrigin, // void ) (edict_t *ent, const float *pflGoal, float dist, int iMoveType);
EngFunc_ChangeYaw, // void ) (edict_t* ent);
EngFunc_ChangePitch, // void ) (edict_t* ent);
EngFunc_FindEntityByString, // edict) (edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue);
EngFunc_GetEntityIllum, // int ) (edict_t* pEnt);
EngFunc_FindEntityInSphere, // edict) (edict_t *pEdictStartSearchAfter, const float *org, float rad);
EngFunc_FindClientInPVS, // edict) (edict_t *pEdict);
EngFunc_EntitiesInPVS, // edict) (edict_t *pplayer);
EngFunc_MakeVectors, // void ) (const float *rgflVector);
EngFunc_AngleVectors, // void ) (const float *rgflVector, float *forward, float *right, float *up);
EngFunc_CreateEntity, // edict) (void);
EngFunc_RemoveEntity, // void ) (edict_t* e);
EngFunc_CreateNamedEntity, // edict) (int className);
EngFunc_MakeStatic, // void ) (edict_t *ent);
EngFunc_EntIsOnFloor, // int ) (edict_t *e);
EngFunc_DropToFloor, // int ) (edict_t* e);
EngFunc_WalkMove, // int ) (edict_t *ent, float yaw, float dist, int iMode);
EngFunc_SetOrigin, // void ) (edict_t *e, const float *rgflOrigin);
EngFunc_EmitSound, // void ) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch);
EngFunc_EmitAmbientSound, // void ) (edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch);
EngFunc_TraceLine, // void ) (const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr);
EngFunc_TraceToss, // void ) (edict_t* pent, edict_t* pentToIgnore, TraceResult *ptr);
EngFunc_TraceMonsterHull, // int ) (edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr);
EngFunc_TraceHull, // void ) (const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr);
EngFunc_TraceModel, // void ) (const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr);
EngFunc_TraceTexture, // const char *) (edict_t *pTextureEntity, const float *v1, const float *v2 );
EngFunc_TraceSphere, // void ) (const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr);
EngFunc_GetAimVector, // void ) (edict_t* ent, float speed, float *rgflReturn);
EngFunc_ParticleEffect, // void ) (const float *org, const float *dir, float color, float count);
EngFunc_LightStyle, // void ) (int style, char* val);
EngFunc_DecalIndex, // int ) (const char *name);
EngFunc_PointContents, // int ) (const float *rgflVector);
EngFunc_FreeEntPrivateData, // void ) (edict_t *pEdict);
EngFunc_SzFromIndex, // const char * ) (int iString);
EngFunc_AllocString, // int ) (const char *szValue);
EngFunc_RegUserMsg, // int ) (const char *pszName, int iSize);
EngFunc_AnimationAutomove, // void ) (const edict_t* pEdict, float flTime);
EngFunc_GetBonePosition, // void ) (const edict_t* pEdict, int iBone, float *rgflOrigin, float *rgflAngles );
EngFunc_GetAttachment, // void ) (const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles );
EngFunc_SetView, // void ) (const edict_t *pClient, const edict_t *pViewent );
EngFunc_Time, // float) ( void );
EngFunc_CrosshairAngle, // void ) (const edict_t *pClient, float pitch, float yaw);
EngFunc_FadeClientVolume, // void ) (const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds);
EngFunc_SetClientMaxspeed, // void ) (const edict_t *pEdict, float fNewMaxspeed);
EngFunc_CreateFakeClient, // edict) (const char *netname); // returns NULL if fake client can't be created
EngFunc_RunPlayerMove, // void ) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec );
EngFunc_NumberOfEntities, // int ) (void);
EngFunc_StaticDecal, // void ) ( const float *origin, int decalIndex, int entityIndex, int modelIndex );
EngFunc_PrecacheGeneric, // int ) (char* s);
EngFunc_BuildSoundMsg, // void ) (edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed);
EngFunc_GetPhysicsKeyValue, // const char* ) ( const edict_t *pClient, const char *key );
EngFunc_SetPhysicsKeyValue, // void ) ( const edict_t *pClient, const char *key, const char *value );
EngFunc_GetPhysicsInfoString,// const char* ) ( const edict_t *pClient );
EngFunc_PrecacheEvent, // unsigned short ) ( int type, const char*psz );
EngFunc_PlaybackEvent, // void ) ( int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
EngFunc_CheckVisibility, //) ( const edict_t *entity, unsigned char *pset );
EngFunc_GetCurrentPlayer, //) ( void );
EngFunc_CanSkipPlayer, //) ( const edict_t *player );
EngFunc_SetGroupMask, //) ( int mask, int op );
EngFunc_GetClientListening, // bool (int iReceiver, int iSender)
EngFunc_SetClientListening, // bool (int iReceiver, int iSender, bool Listen)
EngFunc_MessageBegin, // void (int msg_dest, int msg_type, const float *pOrigin, edict_t *ed)
EngFunc_WriteCoord, // void (float)
EngFunc_WriteAngle, // void (float)
EngFunc_InfoKeyValue, // char* ) (char *infobuffer, char *key);
EngFunc_SetKeyValue, // void ) (char *infobuffer, char *key, char *value);
EngFunc_SetClientKeyValue // void ) (int clientIndex, char *infobuffer, char *key, char *value);
};
enum
{
DLLFunc_GameInit, // void) ( void );
DLLFunc_Spawn, // int ) ( edict_t *pent );
DLLFunc_Think, // void ) ( edict_t *pent );
DLLFunc_Use, // void ) ( edict_t *pentUsed, edict_t *pentOther );
DLLFunc_Touch, // void ) ( edict_t *pentTouched, edict_t *pentOther );
DLLFunc_Blocked, // void ) ( edict_t *pentBlocked, edict_t *pentOther );
DLLFunc_KeyValue, // void ) ( edict_t *pentKeyvalue, KeyValueData *pkvd );
DLLFunc_SetAbsBox, // void ) ( edict_t *pent );
DLLFunc_ClientConnect, // bool) ( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] );
DLLFunc_ClientDisconnect, // void ) ( edict_t *pEntity );
DLLFunc_ClientKill, // void ) ( edict_t *pEntity );
DLLFunc_ClientPutInServer, // void ) ( edict_t *pEntity );
DLLFunc_ClientCommand, // void ) ( edict_t *pEntity );
DLLFunc_ServerDeactivate, // void) ( void );
DLLFunc_PlayerPreThink, // void ) ( edict_t *pEntity );
DLLFunc_PlayerPostThink, // void ) ( edict_t *pEntity );
DLLFunc_StartFrame, // void ) ( void );
DLLFunc_ParmsNewLevel, // void ) ( void );
DLLFunc_ParmsChangeLevel, // void ) ( void );
// Returns string describing current .dll. E.g., TeamFotrress 2, Half-Life
DLLFunc_GetGameDescription, // const char * )( void );
// Spectator funcs
DLLFunc_SpectatorConnect, // void) ( edict_t *pEntity );
DLLFunc_SpectatorDisconnect, // void ) ( edict_t *pEntity );
DLLFunc_SpectatorThink, // void ) ( edict_t *pEntity );
// Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint.
DLLFunc_Sys_Error, // void ) ( const char *error_string );
DLLFunc_PM_FindTextureType, // char )( char *name );
DLLFunc_RegisterEncoders, // void ) ( void );
// Enumerates player hulls. Returns 0 if the hull number doesn't exist, 1 otherwise
DLLFunc_GetHullBounds, // int) ( int hullnumber, float *mins, float *maxs );
// Create baselines for certain "unplaced" items.
DLLFunc_CreateInstancedBaselines, // void ) ( void );
DLLFunc_pfnAllowLagCompensation, // int )( void );
// I know this does not fit with DLLFUNC(), but I dont want another native just for it.
MetaFunc_CallGameEntity // bool (plid_t plid, const char *entStr,entvars_t *pev);
};
// Used by the traceresult() native.
enum
{
TR_AllSolid, // (int) if true, plane is not valid
TR_StartSolid, // (int) if true, the initial point was in a solid area
TR_InOpen, // (int)
TR_InWater, // (int)
TR_Fraction, // (float) time completed, 1.0 = didn't hit anything
TR_EndPos, // (vector) final position
TR_PlaneDist, // (float)
TR_PlaneNormal, // (vector) surface normal at impact
TR_Hit, // (entity) entity the surface is on
TR_Hitgroup // (int) 0 == generic, non zero is specific body part
};
enum {
Meta_GetUserMsgID, // int ) (plid_t plid, const char *msgname, int *size);
Meta_GetUserMsgName, // const char *) (plid_t plid, int msgid, int *size);
Meta_GetPluginPath, // const char *) (plid_t plid);
Meta_GetGameInfo // const char *) (plid_t plid, ginfo_t tag);
};
//These two structs are relics from VexD
struct PlayerInfo {
int iSpeakFlags;
@ -92,16 +243,60 @@ struct GlobalInfo {
bool bCheckLights;
};
class Impulse
{
public:
int Forward;
int Check;
};
class Touch
{
public:
int Forward;
char *Toucher;
char *Touched;
~Touch()
{
if (Toucher) {
delete [] Toucher;
Toucher = 0;
}
if (Touched) {
delete [] Touched;
Touched = 0;
}
}
};
class EntClass
{
public:
int Forward;
char *Class;
~EntClass()
{
if (Class) {
delete [] Class;
Class = 0;
}
}
};
int is_ent_valid(int iEnt);
int AmxStringToEngine(AMX *amx, cell param, int &len);
edict_t *UTIL_FindEntityInSphere(edict_t *pStart, const Vector &vecCenter, float flRadius);
extern bool inKeyValue;
extern bool g_inKeyValue;
extern KeyValueData *g_pkvd;
extern bool incmd;
extern struct usercmd_s *g_cmd;
extern struct PlayerInfo plinfo[33];
extern struct GlobalInfo glinfo;
extern AMX_NATIVE_INFO engine_Natives[];
extern std::vector<Impulse *> Impulses;
extern std::vector<EntClass *> Thinks;
extern std::vector<EntClass *> Uses;
extern std::vector<Touch *> Touches;
#endif //_ENGINE_INCLUDE_H

View File

@ -182,6 +182,21 @@ static cell AMX_NATIVE_CALL get_keyvalue(AMX *amx, cell *params)
return MF_SetAmxString(amx, params[3], INFO_KEY_VALUE(INFO_KEY_BUFFER(pEntity),char1), params[4]);
}
static cell AMX_NATIVE_CALL copy_keyvalue(AMX *amx, cell *params)
{
if (!g_inKeyValue)
return 0;
if (g_pkvd->szClassName)
MF_SetAmxString(amx, params[1], g_pkvd->szClassName, params[2]);
if (g_pkvd->szKeyName)
MF_SetAmxString(amx, params[3], g_pkvd->szKeyName, params[4]);
if (g_pkvd->szValue)
MF_SetAmxString(amx, params[5], g_pkvd->szValue, params[6]);
return 1;
}
static cell AMX_NATIVE_CALL DispatchSpawn(AMX *amx, cell *params)
{
int iEnt = params[1];
@ -1785,6 +1800,8 @@ AMX_NATIVE_INFO ent_Natives[] = {
{"find_ent_by_owner", find_ent_by_owner},
{"get_grenade_id", get_grenade_id},
{"copy_keyvalue", copy_keyvalue},
{NULL, NULL},
///////////////////
};

View File

@ -13,6 +13,27 @@ int PlayerPostThinkForward = 0;
int ClientKillForward = 0;
int CmdStartForward = 0;
int StartFrameForward = 0;
std::vector<Impulse *> Impulses;
std::vector<EntClass *> Thinks;
std::vector<EntClass *> Uses;
std::vector<Touch *> Touches;
KeyValueData *g_pkvd;
bool g_inKeyValue=false;
int fstrcmp(const char *s1, const char *s2)
{
int i=0;
int len1 = strlen(s1);
int len2 = strlen(s2);
if (len1 != len2)
return 0;
for (i=0; i<len1; i++)
{
if (s1[i] != s2[i])
return 0;
}
return 1;
}
void DispatchUse(edict_t *pentUsed, edict_t *pentOther)
{
@ -76,22 +97,23 @@ void PlaybackEvent(int flags, const edict_t *pInvoker, unsigned short eventindex
}
#if 0
void KeyValue(edict_t *pEntity, KeyValueData *pkvd)
{
if (DispatchKeyForward) {
inKeyValue=true;
int retVal = 0;
g_inKeyValue=true;
g_pkvd=pkvd;
int index = ENTINDEX(pEntity);
if (DispatchKeyForward) {
retVal = MF_ExecuteForward(DispatchKeyForward, index);
inKeyValue=false;
if (retVal)
g_inKeyValue=false;
if (retVal > 0)
RETURN_META(MRES_SUPERCEDE);
}
else
RETURN_META(MRES_HANDLED);
}
g_inKeyValue=false;
RETURN_META(MRES_HANDLED);
}
#endif
void StartFrame_Post()
{
@ -110,9 +132,21 @@ void StartFrame_Post()
void CmdStart(const edict_t *player, const struct usercmd_s *_cmd, unsigned int random_seed)
{
unsigned int i = 0;
int retVal = 0;
edict_t *pEntity = (edict_t *)player;
struct usercmd_s *g_cmd = (struct usercmd_s *)_cmd;
for (i=0; i<Impulses.size(); i++)
{
if (Impulses[i]->Check == g_cmd->impulse)
{
retVal = MF_ExecuteForward(Impulses[i]->Forward, ENTINDEX(pEntity));
if (retVal)
RETURN_META(MRES_SUPERCEDE);
else
RETURN_META(MRES_IGNORED);
}
}
if (CmdStartForward) {
incmd = true;
retVal = MF_ExecuteForward(CmdStartForward, ENTINDEX(pEntity), g_cmd->impulse);
@ -192,7 +226,45 @@ void PlayerPostThink_Post(edict_t *pEntity)
void DispatchTouch(edict_t *pToucher, edict_t *pTouched)
{
unsigned int i = 0;
int retVal = 0;
const char *ptrClass = STRING(pToucher->v.classname);
const char *ptdClass = STRING(pTouched->v.classname);
for (i=0; i<Touches.size(); i++)
{
if (Touches[i]->Toucher = 0)
{
if (Touches[i]->Touched = 0)
{
retVal = MF_ExecuteForward(Touches[i]->Forward, ENTINDEX(pToucher), ENTINDEX(pTouched));
if (retVal)
RETURN_META(MRES_SUPERCEDE);
else
RETURN_META(MRES_IGNORED);
} else if (fstrcmp(Touches[i]->Touched, ptdClass)) {
retVal = MF_ExecuteForward(Touches[i]->Forward, ENTINDEX(pToucher), ENTINDEX(pTouched));
if (retVal)
RETURN_META(MRES_SUPERCEDE);
else
RETURN_META(MRES_IGNORED);
}
} else if (fstrcmp(Touches[i]->Toucher, ptrClass)) {
if (Touches[i]->Touched = 0)
{
retVal = MF_ExecuteForward(Touches[i]->Forward, ENTINDEX(pToucher), ENTINDEX(pTouched));
if (retVal)
RETURN_META(MRES_SUPERCEDE);
else
RETURN_META(MRES_IGNORED);
} else if (fstrcmp(Touches[i]->Touched, ptdClass)) {
retVal = MF_ExecuteForward(Touches[i]->Forward, ENTINDEX(pToucher), ENTINDEX(pTouched));
if (retVal)
RETURN_META(MRES_SUPERCEDE);
else
RETURN_META(MRES_IGNORED);
}
}
}
/* Execute pfnTouch forwards */
if (pfnTouchForward) {
retVal = MF_ExecuteForward(pfnTouchForward, ENTINDEX(pToucher), ENTINDEX(pTouched));
@ -205,6 +277,16 @@ void DispatchTouch(edict_t *pToucher, edict_t *pTouched)
void DispatchThink_Post(edict_t *pent)
{
unsigned int i = 0;
const char *cls = STRING(pent->v.classname);
for (i=0; i<Thinks.size(); i++)
{
if (fstrcmp(cls, Thinks[i]->Class))
{
MF_ExecuteForward(Thinks[i]->Forward, ENTINDEX(pent));
RETURN_META(MRES_IGNORED);
}
}
MF_ExecuteForward(pfnThinkForward, ENTINDEX(pent));
RETURN_META(MRES_IGNORED);