|
Half-Life 2 SDK For developments focused around the Half-Life 2 engine
|
|
RealBot Author
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
|
Directly usable engine functions? -
10-12-2004
Well, i figured you could do engine->functionname() and it would work. Atleast it did for CreateFakeClient.
So, i looked up where all functions where, eiface.h, doh. Here is a list:
Code:
//-----------------------------------------------------------------------------
// Purpose: Interface the engine exposes to the game DLL
//-----------------------------------------------------------------------------
class IVEngineServer
{
public:
// Tell engine to change level ( "changelevel s1\n" or "changelevel2 s1 s2\n" )
virtual void ChangeLevel( const char *s1, const char *s2 ) = 0;
// Ask engine whether the specified map is a valid map file (exists and has valid version number).
virtual int IsMapValid( const char *filename ) = 0;
// Is this a dedicated server?
virtual bool IsDedicatedServer( void ) = 0;
// Is in Hammer editing mode?
virtual int IsInEditMode( void ) = 0;
// Add to the server/client lookup/precache table, the specified string is given a unique index
// NOTE: The indices for PrecacheModel are 1 based
// a 0 returned from those methods indicates the model or sound was not correctly precached
// However, generic and decal are 0 based
// If preload is specified, the file is loaded into the server/client's cache memory before level startup, otherwise
// it'll only load when actually used (which can cause a disk i/o hitch if it occurs during play of a level).
virtual int PrecacheModel( const char *s, bool preload = false ) = 0;
virtual int PrecacheSentenceFile( const char *s, bool preload = false ) = 0;
virtual int PrecacheDecal( const char *name, bool preload = false ) = 0;
virtual int PrecacheGeneric( const char *s, bool preload = false ) = 0;
// Check's if the name is precached, but doesn't actually precache the name if not...
virtual bool IsModelPrecached( char const *s ) const = 0;
virtual bool IsDecalPrecached( char const *s ) const = 0;
virtual bool IsGenericPrecached( char const *s ) const = 0;
// Note that sounds are precached using the IEngineSound interface
// Special purpose PVS checking
// Get the cluster # for the specified position
virtual int GetClusterForOrigin( const Vector &org ) = 0;
// Get the PVS bits for a specified cluster and copy the bits into outputpvs. Returns the number of bytes needed to pack the PVS
virtual int GetPVSForCluster( int cluster, int outputpvslength, unsigned char *outputpvs ) = 0;
// Check whether the specified origin is inside the specified PVS
virtual bool CheckOriginInPVS( const Vector &org, const unsigned char *checkpvs, int checkpvssize ) = 0;
// Check whether the specified worldspace bounding box is inside the specified PVS
virtual bool CheckBoxInPVS( const Vector &mins, const Vector &maxs, const unsigned char *checkpvs, int checkpvssize ) = 0;
// 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 players.
virtual int GetPlayerUserId( const edict_t *e ) = 0;
virtual const char *GetPlayerNetworkIDString( const edict_t *e ) = 0;
// Return the current number of used edict slots
virtual int GetEntityCount( void ) = 0;
// Given an edict, returns the entity index
virtual int IndexOfEdict( const edict_t *pEdict ) = 0;
// Given and entity index, returns the corresponding edict pointer
virtual edict_t *PEntityOfEntIndex( int iEntIndex ) = 0;
// Get stats info interface for a client netchannel
virtual INetChannelInfo* GetPlayerNetInfo( int playerIndex ) = 0;
// Allocate space for string and return index/offset of string in global string list
// If iForceEdictIndex is not -1, then it will return the edict with that index. If that edict index
// is already used, it'll return null.
virtual edict_t *CreateEdict( int iForceEdictIndex = -1 ) = 0;
// Remove the specified edict and place back into the free edict list
virtual void RemoveEdict( edict_t *e ) = 0;
// Memory allocation for entity class data
virtual void *PvAllocEntPrivateData( long cb ) = 0;
virtual void FreeEntPrivateData( void *pEntity ) = 0;
// Save/restore uses a special memory allocator (which zeroes newly allocated memory, etc.)
virtual void *SaveAllocMemory( size_t num, size_t size ) = 0;
virtual void SaveFreeMemory( void *pSaveMem ) = 0;
// Emit an ambient sound associated with the specified entity
virtual void EmitAmbientSound( int entindex, const Vector &pos, const char *samp, float vol, soundlevel_t soundlevel, int fFlags, int pitch, float delay = 0.0f ) = 0;
// Fade out the client's volume level toward silence (or fadePercent)
virtual void FadeClientVolume( const edict_t *pEdict, float fadePercent, float fadeOutSeconds, float holdTime, float fadeInSeconds ) = 0;
// Sentences / sentence groups
virtual int SentenceGroupPick( int groupIndex, char *name, int nameBufLen ) = 0;
virtual int SentenceGroupPickSequential( int groupIndex, char *name, int nameBufLen, int sentenceIndex, int reset ) = 0;
virtual int SentenceIndexFromName( const char *pSentenceName ) = 0;
virtual const char *SentenceNameFromIndex( int sentenceIndex ) = 0;
virtual int SentenceGroupIndexFromName( const char *pGroupName ) = 0;
virtual const char *SentenceGroupNameFromIndex( int groupIndex ) = 0;
virtual float SentenceLength( int sentenceIndex ) = 0;
// Issue a command to the command parser as if it was typed at the server console.
virtual void ServerCommand( const char *str ) = 0;
// Execute any commands currently in the command parser immediately (instead of once per frame)
virtual void ServerExecute( void ) = 0;
// Issue the specified command to the specified client (mimics that client typing the command at the console).
virtual void ClientCommand( edict_t *pEdict, const char *szFmt, ... ) = 0;
// Set the lightstyle to the specified value and network the change to any connected clients. Note that val must not
// change place in memory (use MAKE_STRING) for anything that's not compiled into your mod.
virtual void LightStyle( int style, const char *val ) = 0;
// Project a static decal onto the specified entity / model (for level placed decals in the .bsp)
virtual void StaticDecal( const Vector &originInEntitySpace, int decalIndex, int entityIndex, int modelIndex, bool lowpriority ) = 0;
// Given the current PVS(or PAS) and origin, determine which players should hear/receive the message
virtual void Message_DetermineMulticastRecipients( bool usepas, const Vector& origin, CBitVec< ABSOLUTE_PLAYER_LIMIT >& playerbits ) = 0;
// Begin a message from a server side entity to its client side counterpart (func_breakable glass, e.g.)
virtual bf_write *EntityMessageBegin( int ent_index, ServerClass * ent_class, bool reliable ) = 0;
// Begin a usermessage from the server to the client .dll
virtual bf_write *UserMessageBegin( IRecipientFilter *filter, int msg_type ) = 0;
// Finish the Entity or UserMessage and dispatch to network layer
virtual void MessageEnd( void ) = 0;
// Print szMsg to the client console.
virtual void ClientPrintf( edict_t *pEdict, const char *szMsg ) = 0;
// SINGLE PLAYER/LISTEN SERVER ONLY (just matching the client .dll api for this)
// Prints the formatted string to the notification area of the screen ( down the right hand edge
// numbered lines starting at position 0
virtual void Con_NPrintf( int pos, const char *fmt, ... ) = 0;
// SINGLE PLAYER/LISTEN SERVER ONLY(just matching the client .dll api for this)
// Similar to Con_NPrintf, but allows specifying custom text color and duration information
virtual void Con_NXPrintf( const struct con_nprint_s *info, const char *fmt, ... ) = 0;
// For ConCommand parsing or parsing client commands issued by players typing at their console
// Retrieves the raw command string (untokenized)
virtual const char *Cmd_Args( void ) = 0;
// Returns the number of tokens in the command string
virtual int Cmd_Argc( void ) = 0;
// Retrieves a specified token
virtual char *Cmd_Argv( int argc ) = 0;
// Change a specified player's "view entity" (i.e., use the view entity position/orientation for rendering the client view)
virtual void SetView( const edict_t *pClient, const edict_t *pViewent ) = 0;
// Get a high precision timer for doing profiling work
virtual float Time( void ) = 0;
// Set the player's crosshair angle
virtual void CrosshairAngle( const edict_t *pClient, float pitch, float yaw ) = 0;
// Get the current game directory (hl2, tf2, hl1, cstrike, etc.)
virtual void GetGameDir( char *szGetGameDir, int maxlength ) = 0;
// Used by AI node graph code to determine if .bsp and .ain files are out of date
virtual int CompareFileTime( const char *filename1, const char *filename2, int *iCompare ) = 0;
// Locks/unlocks the network string tables (.e.g, when adding bots to server, this needs to happen).
// Be sure to reset the lock after executing your code!!!
virtual bool LockNetworkStringTables( bool lock ) = 0;
// Create a bot with the given name. Returns NULL if fake client can't be created
virtual edict_t *CreateFakeClient( const char *netname ) = 0;
// Get a convar keyvalue for s specified client
virtual const char *GetClientConVarValue( int clientIndex, const char *name ) = 0;
// Parse a token from a file
virtual const char *ParseFile( const char *data, char *token, int maxlen ) = 0;
// Copies a file
virtual bool CopyFile( const char *source, const char *destination ) = 0;
// Reset the pvs, pvssize is the size in bytes of the buffer pointed to by pvs.
// This should be called right before any calls to AddOriginToPVS
virtual void ResetPVS( byte *pvs, int pvssize ) = 0;
// Merge the pvs bits into the current accumulated pvs based on the specified origin ( not that each pvs origin has an 8 world unit fudge factor )
virtual void AddOriginToPVS( const Vector &origin ) = 0;
// Mark a specified area portal as open/closes
virtual void SetAreaPortalState( int portalNumber, int isOpen ) = 0;
// Queue a temp entity for transmission
virtual void PlaybackTempEntity( IRecipientFilter& filter, float delay, const void *pSender, const SendTable *pST, int classID ) = 0;
// Given a node number and the specified PVS, return with the node is in the PVS
virtual int CheckHeadnodeVisible( int nodenum, const byte *pvs, int vissize ) = 0;
// Using area bits, cheeck whether area1 flows into area2 and vice versa (depends on area portal state)
virtual int CheckAreasConnected( int area1, int area2 ) = 0;
// Given an origin, determine which area index the origin is within
virtual int GetArea( const Vector &origin ) = 0;
// Get area portal bit set
virtual void GetAreaBits( int area, unsigned char *bits, int buflen ) = 0;
// Given a view origin (which tells us the area to start looking in) and a portal key,
// fill in the plane that leads out of this area (it points into whatever area it leads to).
virtual bool GetAreaPortalPlane( Vector const &vViewOrigin, int portalKey, VPlane *pPlane ) = 0;
// Apply a modification to the terrain.
virtual void ApplyTerrainMod( TerrainModType type, CTerrainModParams const ¶ms ) = 0;
// Save/restore wrapper - FIXME: At some point we should move this to it's own interface
virtual bool LoadGameState( char const *pMapName, bool createPlayers ) = 0;
virtual void LoadAdjacentEnts( const char *pOldLevel, const char *pLandmarkName ) = 0;
virtual void ClearSaveDir() = 0;
// Get the pristine map entity lump string. (e.g., used by CS to reload the map entities when restarting a round.)
virtual const char* GetMapEntitiesString() = 0;
// Text message system -- lookup the text message of the specified name
virtual client_textmessage_t *TextMessageGet( const char *pName ) = 0;
// Print a message to the server log file
virtual void LogPrint( const char *msg ) = 0;
// Builds PVS information for an entity
virtual void BuildEntityClusterList( edict_t *pEdict, PVSInfo_t *pPVSInfo ) = 0;
// A solid entity moved, update spatial partition
virtual void SolidMoved( edict_t *pSolidEnt, ICollideable *pSolidCollide, const Vector* pPrevAbsOrigin ) = 0;
// A trigger entity moved, update spatial partition
virtual void TriggerMoved( edict_t *pTriggerEnt ) = 0;
// Create/destroy a custom spatial partition
virtual ISpatialPartition *CreateSpatialPartition( const Vector& worldmin, const Vector& worldmax ) = 0;
virtual void DestroySpatialPartition( ISpatialPartition * ) = 0;
// Draw the brush geometry in the map into the scratch pad.
// Flags is currently unused.
virtual void DrawMapToScratchPad( IScratchPad3D *pPad, unsigned long iFlags ) = 0;
// This returns which entities, to the best of the server's knowledge, the client currently knows about.
// This is really which entities were in the snapshot that this client last acked.
// This returns a bit vector with one bit for each entity.
//
// USE WITH CARE. Whatever tick the client is really currently on is subject to timing and
// ordering differences, so you should account for about a quarter-second discrepancy in here.
// Also, this will return NULL if the client doesn't exist or if this client hasn't acked any frames yet.
//
// iClientIndex is the CLIENT index, so if you use pPlayer->entindex(), subtract 1.
virtual const CBitVec<MAX_EDICTS>* GetEntityTransmitBitsForClient( int iClientIndex ) = 0;
// Is the game paused?
virtual bool IsPaused() = 0;
// Marks the filename for consistency checking. This should be called after precaching the file.
virtual void ForceExactFile( const char *s ) = 0;
virtual void ForceModelBounds( const char *s, const Vector &mins, const Vector &maxs ) = 0;
};
I don't know if all can be executed. Ie, i tried clientcommand, for a bot. But i figured just that botman has found out a similiar RunPlayerMove function, so... thats interesting. Perhaps then bots will actually execute the command (or it has effect). I am gonna toy a bit more, but i think this is very interesting.
|
|
|
|
|
Roi de France
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
|
Re: Directly usable engine functions? -
10-12-2004
holy shit! indeed !
I'm glad to see they did a nice work of commenting out their sources !!! that will help a lot the community !
RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
|
|
|
|
|
RealBot Author
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
|
Re: Directly usable engine functions? -
10-12-2004
yes, the comments are very helpfull!
|
|
|
|
|
Council Member, Author of JoeBOT
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
|
Re: Directly usable engine functions? -
10-12-2004
nice ...
I guess pierre doesnt like those tons of "virtual"s
|
|
|
|
|
RealBot Author
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
|
Re: Directly usable engine functions? -
10-12-2004
well, the hl2sdk is FULL of it.
|
|
|
|
|
Roi de France
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
|
Re: Directly usable engine functions? -
10-12-2004
I don't care... they will of course be part of the interface to my bot, but the bot code itself won't need them since it's engine independent now. They could even be specifically x86/SSE optimized ASM, C#, BASIC, Perl or LISP, I don't give a damn hehe
RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
|
|
|
|
|
Council Member, Author of JoeBOT
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
|
Re: Directly usable engine functions? -
10-12-2004
maybe sometime even pierre will see the advantages of virtual functions and other oo stuff ...
just installed HL2, too and browsing the files ( although that might be a big fault, next week I write an exam ). That class you were quoting looks like the engine interface, like this whatever_t with pointers to functions you had in HL. the single functions look pretty similar to those on HL1, looks like porting old stuff won't be that much work.
back to theoretical mechanics :/
Last edited by @$3.1415rin; 10-12-2004 at 22:36..
|
|
|
|
|
RealBot Author
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
|
Re: Directly usable engine functions? -
10-12-2004
a lot looks the same, but i also think internally they changed some principle. When we understand that princple, it will be a matter of writing code. From now off, i still have no real clue how the entire HL2 SDK works heh. I am glad when i know the plugin code, i begin to understand it pretty well now. Thanks to lots of comments in the code.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Powered by vBulletin® Version 3.8.2 Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com
|
|