@PointClass base(Targetname) iconsprite("sprites/lightbulb.spr") size(-16 -16 -16, 16 16 16) = env_elight : "Model light"
[
renderamt(integer) : "Radius" : 15
rendercolor(color255) : "Render Color" : "255 255 255"
spawnflags(flags) =
[
1 : "Start On" : 0
]
]
We'll also need to edit the delta.lst file, as we're introducing a new effects flag for the entity in const.h. The delta.lst file manages how certain entity properties are encoded and sent to the clients, and by default it is set to encode only 8 bytes for the pev->effects variable, but we need more than that. If your mod doesn't have a delta.lst file in the mod folder, just go to the "Half-Life/valve" folder and copy the delta.lst file from there to your mod folder.DEFINE_DELTA( effects, DT_INTEGER, 8, 1.0 ),
DEFINE_DELTA( effects, DT_INTEGER, 16, 1.0 ),
#define EF_NODRAW 128 // don't draw entity
And right after it, add this new flag:
#define EF_ENVELIGHT 256 // env_elight entity
This new flag will be used to identify the env_elight entity on the client. Now go into effects.cpp, and at the very end of the file add the class definition of the env_elight entity:
//=========================================================`
// env_elight
//=========================================================
#define SF_ELIGHT_STARTON 1
class CEnvELight : public CPointEntity
{
public:
void Spawn( void );
void Precache( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
};
LINK_ENTITY_TO_CLASS( env_elight, CEnvELight );
void CEnvELight:: Spawn( void )
{
Precache();
pev->solid = SOLID_NOT;
SET_MODEL(ENT(pev), "sprites/null.spr");
if(!FStringNull(pev->targetname) && !(pev->spawnflags & SF_ELIGHT_STARTON))
pev->effects = EF_NODRAW;
else
pev->effects = EF_ENVELIGHT;
}
void CEnvELight:: Precache( void )
{
PRECACHE_MODEL("sprites/null.spr");
}
void CEnvELight::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
switch( useType )
{
case USE_ON:
pev->effects = EF_ENVELIGHT;
break;
case USE_OFF:
pev->effects = EF_NODRAW;
break;
default:
if(pev->effects & EF_NODRAW)
pev->effects = EF_ENVELIGHT;
else
pev->effects = EF_NODRAW;
break;
}
}
This concludes our work on the server side. Now go to your client library, and add the new .h and .cpp files from your client folder if you haven't done so already. Next, we'll be opening up entity.cpp. At the very top, add the #include for the new header:
#include "elights.h"
Now go to the "HUD_CreateEntities", and at the end of the function, add this call:
// Manage any elights
gELightManager.Think();
Once this is done, open up hud.cpp, and at the top, add:
#include "elights.h"
Now at the end of the CHud :: Init function, add this call:
gELightManager.Init();
Go to CHud :: VidInit, and at the very end, add the following call:
gELightManager.VidInit();
Now once this is done, compile your libraries, and copy the .dll files to their destinations in "modfolder/cl_dlls" and "modfolder/dlls", each respectively. Now if you haven't done so already, copy the "elighttest.bsp" file to your maps folder, and load the test map up, and observe the env_elight effect on models.You must log in to post a comment. You can login or register a new account.