Half-life SDK, where are the constants?

This is a discussion on Half-life SDK, where are the constants? within the Game Programming forums, part of the General Programming Boards category; I just downloaded the smaller HL SDK, which is about 15mb. I was just skimming over the code, getting a ...

  1. #1
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401

    Half-life SDK, where are the constants?

    I just downloaded the smaller HL SDK, which is about 15mb. I was just skimming over the code, getting a feel for it, and then I decided to just muck around a bit. I wanted to change the damage inflicted by an MP5 bullet, so I found the MP5 class, found the shooting method, and followed the code until I actually found the function that is passed the damage value. Unfortunately, it was a member variable of a struct that seems to be intialized outside of the code I have.

    I was hoping that someone familiar with the SDK would be able to point me in the direction of that damage constant.

    More specifically, a method is declared in a struct in a header file, and I can't find the definition of it. Here's the struct:

    Code:
    // Engine hands this to DLLs for functionality callbacks
    typedef struct enginefuncs_s
    {
    	int			(*pfnPrecacheModel)			(char* s);
    	int			(*pfnPrecacheSound)			(char* s);
    	void		(*pfnSetModel)				(edict_t *e, const char *m);
    	int			(*pfnModelIndex)			(const char *m);
    	int			(*pfnModelFrames)			(int modelIndex);
    	void		(*pfnSetSize)				(edict_t *e, const float *rgflMin, const float *rgflMax);
    	void		(*pfnChangeLevel)			(char* s1, char* s2);
    	void		(*pfnGetSpawnParms)			(edict_t *ent);
    	void		(*pfnSaveSpawnParms)		(edict_t *ent);
    	float		(*pfnVecToYaw)				(const float *rgflVector);
    	void		(*pfnVecToAngles)			(const float *rgflVectorIn, float *rgflVectorOut);
    	void		(*pfnMoveToOrigin)			(edict_t *ent, const float *pflGoal, float dist, int iMoveType);
    	void		(*pfnChangeYaw)				(edict_t* ent);
    	void		(*pfnChangePitch)			(edict_t* ent);
    	edict_t*	(*pfnFindEntityByString)	(edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue);
    	int			(*pfnGetEntityIllum)		(edict_t* pEnt);
    	edict_t*	(*pfnFindEntityInSphere)	(edict_t *pEdictStartSearchAfter, const float *org, float rad);
    	edict_t*	(*pfnFindClientInPVS)		(edict_t *pEdict);
    	edict_t* (*pfnEntitiesInPVS)			(edict_t *pplayer);
    	void		(*pfnMakeVectors)			(const float *rgflVector);
    	void		(*pfnAngleVectors)			(const float *rgflVector, float *forward, float *right, float *up);
    	edict_t*	(*pfnCreateEntity)			(void);
    	void		(*pfnRemoveEntity)			(edict_t* e);
    	edict_t*	(*pfnCreateNamedEntity)		(int className);
    	void		(*pfnMakeStatic)			(edict_t *ent);
    	int			(*pfnEntIsOnFloor)			(edict_t *e);
    	int			(*pfnDropToFloor)			(edict_t* e);
    	int			(*pfnWalkMove)				(edict_t *ent, float yaw, float dist, int iMode);
    	void		(*pfnSetOrigin)				(edict_t *e, const float *rgflOrigin);
    	void		(*pfnEmitSound)				(edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch);
    	void		(*pfnEmitAmbientSound)		(edict_t *entity, float *pos, const char *samp, float vol, float attenuation, int fFlags, int pitch);
    	void		(*pfnTraceLine)				(const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr);
    	void		(*pfnTraceToss)				(edict_t* pent, edict_t* pentToIgnore, TraceResult *ptr);
    	int			(*pfnTraceMonsterHull)		(edict_t *pEdict, const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr);
    	void		(*pfnTraceHull)				(const float *v1, const float *v2, int fNoMonsters, int hullNumber, edict_t *pentToSkip, TraceResult *ptr);
    	void		(*pfnTraceModel)			(const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr);
    	const char *(*pfnTraceTexture)			(edict_t *pTextureEntity, const float *v1, const float *v2 );
    	void		(*pfnTraceSphere)			(const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr);
    	void		(*pfnGetAimVector)			(edict_t* ent, float speed, float *rgflReturn);
    	void		(*pfnServerCommand)			(char* str);
    	void		(*pfnServerExecute)			(void);
    	void		(*pfnClientCommand)			(edict_t* pEdict, char* szFmt, ...);
    	void		(*pfnParticleEffect)		(const float *org, const float *dir, float color, float count);
    	void		(*pfnLightStyle)			(int style, char* val);
    	int			(*pfnDecalIndex)			(const char *name);
    	int			(*pfnPointContents)			(const float *rgflVector);
    	void		(*pfnMessageBegin)			(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed);
    	void		(*pfnMessageEnd)			(void);
    	void		(*pfnWriteByte)				(int iValue);
    	void		(*pfnWriteChar)				(int iValue);
    	void		(*pfnWriteShort)			(int iValue);
    	void		(*pfnWriteLong)				(int iValue);
    	void		(*pfnWriteAngle)			(float flValue);
    	void		(*pfnWriteCoord)			(float flValue);
    	void		(*pfnWriteString)			(const char *sz);
    	void		(*pfnWriteEntity)			(int iValue);
    	void		(*pfnCVarRegister)			(cvar_t *pCvar);
    	float		(*pfnCVarGetFloat)			(const char *szVarName);
    	const char*	(*pfnCVarGetString)			(const char *szVarName);
    	void		(*pfnCVarSetFloat)			(const char *szVarName, float flValue);
    	void		(*pfnCVarSetString)			(const char *szVarName, const char *szValue);
    	void		(*pfnAlertMessage)			(ALERT_TYPE atype, char *szFmt, ...);
    	void		(*pfnEngineFprintf)			(FILE *pfile, char *szFmt, ...);
    	void*		(*pfnPvAllocEntPrivateData)	(edict_t *pEdict, long cb);
    	void*		(*pfnPvEntPrivateData)		(edict_t *pEdict);
    	void		(*pfnFreeEntPrivateData)	(edict_t *pEdict);
    	const char*	(*pfnSzFromIndex)			(int iString);
    	int			(*pfnAllocString)			(const char *szValue);
    	struct entvars_s*	(*pfnGetVarsOfEnt)			(edict_t *pEdict);
    	edict_t*	(*pfnPEntityOfEntOffset)	(int iEntOffset);
    	int			(*pfnEntOffsetOfPEntity)	(const edict_t *pEdict);
    	int			(*pfnIndexOfEdict)			(const edict_t *pEdict);
    	edict_t*	(*pfnPEntityOfEntIndex)		(int iEntIndex);
    	edict_t*	(*pfnFindEntityByVars)		(struct entvars_s* pvars);
    	void*		(*pfnGetModelPtr)			(edict_t* pEdict);
    	int			(*pfnRegUserMsg)			(const char *pszName, int iSize);
    	void		(*pfnAnimationAutomove)		(const edict_t* pEdict, float flTime);
    	void		(*pfnGetBonePosition)		(const edict_t* pEdict, int iBone, float *rgflOrigin, float *rgflAngles );
    	unsigned long (*pfnFunctionFromName)	( const char *pName );
    	const char *(*pfnNameForFunction)		( unsigned long function );
    	void		(*pfnClientPrintf)			( edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg ); // JOHN: engine callbacks so game DLL can print messages to individual clients
    	void		(*pfnServerPrint)			( const char *szMsg );
    	const char *(*pfnCmd_Args)				( void );		// these 3 added 
    	const char *(*pfnCmd_Argv)				( int argc );	// so game DLL can easily 
    	int			(*pfnCmd_Argc)				( void );		// access client 'cmd' strings
    	void		(*pfnGetAttachment)			(const edict_t *pEdict, int iAttachment, float *rgflOrigin, float *rgflAngles );
    	void		(*pfnCRC32_Init)			(CRC32_t *pulCRC);
    	void        (*pfnCRC32_ProcessBuffer)   (CRC32_t *pulCRC, void *p, int len);
    	void		(*pfnCRC32_ProcessByte)     (CRC32_t *pulCRC, unsigned char ch);
    	CRC32_t		(*pfnCRC32_Final)			(CRC32_t pulCRC);
    	long		(*pfnRandomLong)			(long  lLow,  long  lHigh);
    	float		(*pfnRandomFloat)			(float flLow, float flHigh);
    	void		(*pfnSetView)				(const edict_t *pClient, const edict_t *pViewent );
    	float		(*pfnTime)					( void );
    	void		(*pfnCrosshairAngle)		(const edict_t *pClient, float pitch, float yaw);
    	byte *      (*pfnLoadFileForMe)         (char *filename, int *pLength);
    	void        (*pfnFreeFile)              (void *buffer);
    	void        (*pfnEndSection)            (const char *pszSectionName); // trigger_endsection
    	int 		(*pfnCompareFileTime)       (char *filename1, char *filename2, int *iCompare);
    	void        (*pfnGetGameDir)            (char *szGetGameDir);
    	void		(*pfnCvar_RegisterVariable) (cvar_t *variable);
    	void        (*pfnFadeClientVolume)      (const edict_t *pEdict, int fadePercent, int fadeOutSeconds, int holdTime, int fadeInSeconds);
    	void        (*pfnSetClientMaxspeed)     (const edict_t *pEdict, float fNewMaxspeed);
    	edict_t *	(*pfnCreateFakeClient)		(const char *netname);	// returns NULL if fake client can't be created
    	void		(*pfnRunPlayerMove)			(edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec );
    	int			(*pfnNumberOfEntities)		(void);
    	char*		(*pfnGetInfoKeyBuffer)		(edict_t *e);	// passing in NULL gets the serverinfo
    	char*		(*pfnInfoKeyValue)			(char *infobuffer, char *key);
    	void		(*pfnSetKeyValue)			(char *infobuffer, char *key, char *value);
    	void		(*pfnSetClientKeyValue)		(int clientIndex, char *infobuffer, char *key, char *value);
    	int			(*pfnIsMapValid)			(char *filename);
    	void		(*pfnStaticDecal)			( const float *origin, int decalIndex, int entityIndex, int modelIndex );
    	int			(*pfnPrecacheGeneric)		(char* s);
    	int			(*pfnGetPlayerUserId)		(edict_t *e ); // returns the server assigned userid for this player.  useful for logging frags, etc.  returns -1 if the edict couldn't be found in the list of clients
    	void		(*pfnBuildSoundMsg)			(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);
    	int			(*pfnIsDedicatedServer)		(void);// is this a dedicated server?
    	cvar_t		*(*pfnCVarGetPointer)		(const char *szVarName);
    	unsigned int (*pfnGetPlayerWONId)		(edict_t *e); // returns the server assigned WONid for this player.  useful for logging frags, etc.  returns -1 if the edict couldn't be found in the list of clients
    
    	// YWB 8/1/99 TFF Physics additions
    	void		(*pfnInfo_RemoveKey)		( char *s, const char *key );
    	const char *(*pfnGetPhysicsKeyValue)	( const edict_t *pClient, const char *key );
    	void		(*pfnSetPhysicsKeyValue)	( const edict_t *pClient, const char *key, const char *value );
    	const char *(*pfnGetPhysicsInfoString)	( const edict_t *pClient );
    	unsigned short (*pfnPrecacheEvent)		( int type, const char*psz );
    	void		(*pfnPlaybackEvent)			( 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 );
    
    	unsigned char *(*pfnSetFatPVS)			( float *org );
    	unsigned char *(*pfnSetFatPAS)			( float *org );
    
    	int			(*pfnCheckVisibility )		( const edict_t *entity, unsigned char *pset );
    
    	void		(*pfnDeltaSetField)			( struct delta_s *pFields, const char *fieldname );
    	void		(*pfnDeltaUnsetField)		( struct delta_s *pFields, const char *fieldname );
    	void		(*pfnDeltaAddEncoder)		( char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) );
    	int			(*pfnGetCurrentPlayer)		( void );
    	int			(*pfnCanSkipPlayer)			( const edict_t *player );
    	int			(*pfnDeltaFindField)		( struct delta_s *pFields, const char *fieldname );
    	void		(*pfnDeltaSetFieldByIndex)	( struct delta_s *pFields, int fieldNumber );
    	void		(*pfnDeltaUnsetFieldByIndex)( struct delta_s *pFields, int fieldNumber );
    
    	void		(*pfnSetGroupMask)			( int mask, int op );
    
    	int			(*pfnCreateInstancedBaseline) ( int classname, struct entity_state_s *baseline );
    	void		(*pfnCvar_DirectSet)		( struct cvar_s *var, char *value );
    
    	// Forces the client and server to be running with the same version of the specified file
    	//  ( e.g., a player model ).
    	// Calling this has no effect in single player
    	void		(*pfnForceUnmodified)		( FORCE_TYPE type, float *mins, float *maxs, const char *filename );
    
    	void		(*pfnGetPlayerStats)		( const edict_t *pClient, int *ping, int *packet_loss );
    } enginefuncs_t;
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    There are a few things you could do. Instead of finding the constant, you could just multiply it by something which you define in the function. Or, just run a find on all the SDK files searching for the name of the constant. In VC++ this can be done with the "Find in Files" command, or you can just use the Windows search thing.
    Away.

  3. #3
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Yeah I've searched everywhere. I don't think I'd be able to find the definition of that function, because it would be in hl.exe, the engine file. Not that I need to use that. I could just as easily replace the function call with a constant value, but fussy as I am, I have to work out what's happening.

    Do you thing it's possible that the actual constants are stored in hl.exe? It seems unlikely to me because that would reduce the ability to quickly modify the game constants.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  4. #4
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    Is that some kind of C based script or is it real C?

  5. #5
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    It's pure C++.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  6. #6
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    pure C, not C++, it's the quake2 engine buddy.

    I've spent half of my life modifying those engines

  7. #7
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Actually it's the HL engine, which may be similar to Q2, but not exactly the same. Also, we're not talking about the engine here. We're talking about external .dll files.

    Plus, it is C++. Classes were only introduced in C++, and all the HL SDK code is based around classes.

    Game, set, match.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  8. #8
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    the hl engine is quake2, which was completely written in C. dl q2 source and try putting new or bool in there...i dare u...

  9. #9
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Okay, we're clearly talking about different things. You're talking about the engine, which if you say so, is written in C. I'm talking about the .dll files that you can download in the SDK, like mp.dll, and client.dll. I KNOW those are in C++, because they have classes and the new and delete operators.

    I'm not saying you don't know your stuff or anything, I'm just pretty sure of this.

    And, if you know so much, could you answer the question that this thread is about?
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  10. #10
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    I'm not trying to get too off topic but...it is based on Quake1.

    http://collective.valve-erc.com/index.php?go=q1_or_q2
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  11. #11
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    HL engine is written in C++ (least my full copy of the HL SDK is C++)

    As to finding a constant in the 690Mb of SDK.

    How about a hint on what the value or name is of the constant.
    How do you know it is a constant?

    The header file const.h is 26K. I need something to narrow it down.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  12. #12
    Grammar Police HybridM's Avatar
    Join Date
    Jan 2003
    Posts
    355
    yes QUAKE 1 not 2. Pretty nice job they did with the Q1 engine, Especially as so many people mistake it for Quake 2 engine.
    Thor's self help tip:
    Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.

    OS: Windows XP
    Compiler: MSVC

  13. #13
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Originally posted by novacain
    HL engine is written in C++ (least my full copy of the HL SDK is C++)

    As to finding a constant in the 690Mb of SDK.

    How about a hint on what the value or name is of the constant.
    How do you know it is a constant?

    The header file const.h is 26K. I need something to narrow it down.
    Where can I get that version of the SDK? I only know of the 15mb and 70mb versions.

    The variable I was looking for was "sk_plr_9mmAR_bullet".
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  14. #14
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    I've toyed with the quake 3 sdk a bit - and I've had a look at modifying quake 1 as well. If half life is indeed from the quake 1 engine - or anything ported it is very likely to be similer in concept.

    Everything is struct based in the q3sdk - and theres just tons and tons of functions you just keep passing structs too till you get a playable game. The weapon and damage systems are found in the missile.c file which basicly initiates the bolt structures for weapons with initial damages - and vectors etc.

    Simply - You will never find damage constants or speed constants in most cases. Rather you will find firing functions or initiation functions that give appropriate values - they wont be located in the same convienant place.

    I'll have a look around the hl sdk myself to see if i can find it.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  15. #15
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    Btw- the small size sdk is available here:

    http://www.fileplanet.com/files/40000/44992.shtml


    I'll be modifying this post in a couple minutes with my findings.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. half life 2 modification looking for coders
    By pantsOFFinPUBLI in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 07-28-2005, 01:32 AM
  2. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 06:05 PM
  3. Half Life 2 book(and programming)
    By nbk in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 10-06-2004, 10:12 AM
  4. Half life Problem which I am right and the teacher is wrong
    By Shadow12345 in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 11-06-2002, 03:28 PM
  5. Half Life Blue Shift Problem
    By biosninja in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 08-23-2002, 09:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21