For this tutorial I will show you how to add glowshell to an entity. This effect can be useful for when you want an entity to be obvious to the player, for example, weapons in a dark room.
We will start by adding glowshell to a zombie.
Here is the half-life zombie. He doesn't have glowshell by default.
Now we will look at the zombie code which is zombie.cpp in the dlls folder of the SDK.
There are many parts of zombie.cpp
public:
void Spawn( void );
void Precache( void );
void SetYawSpeed( void );
int Classify ( void );
void HandleAnimEvent( MonsterEvent_t *pEvent );
int IgnoreConditions ( void );
float m_flNextFlinch;
void PainSound( void );
void AlertSound( void );
void IdleSound( void );
void AttackSound( void );
static const char *pAttackSounds[];
static const char *pIdleSounds[];
static const char *pAlertSounds[];
static const char *pPainSounds[];
static const char *pAttackHitSounds[];
static const char *pAttackMissSounds[];
For this tutorial, however, we will only need to change spawn. So go to void CZombie :: Spawn() on line 270
It should look like this:
//=========================================================
// Spawn
//=========================================================
void CZombie :: Spawn()
{
Precache( );
SET_MODEL(ENT(pev), "models/system/monsters/zombie.mdl");
UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX );
pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_STEP;
m_bloodColor = BLOOD_COLOR_RED;
pev->health = gSkillData.zombieHealth;
pev->view_ofs = VEC_VIEW;// position of the eyes relative to monster's origin.
m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result )
m_MonsterState = MONSTERSTATE_NONE;
m_afCapability = bits_CAP_DOORS_GROUP;
MonsterInit();
}
Go to the end of spawn, right after MonsterInit();
add this
pev->renderfx = kRenderFxGlowShell;
Compile the code and the zombie should now look like this:
Congratulations! You now have a glowing zombie!
But wait...
What if we want to make the glow a different color?
It's simple.
You put these under the pev->renderfx = kRenderFxGlowShell; line
pev->rendercolor.x = (NUMBER HERE);
pev->rendercolor.y = (NUMBER HERE);
pev->rendercolor.z = (NUMBER HERE);
These might look confusing, but they're just values for RGB color.
rendercolor.x is red
rendercolor.y is green
rendercolor.z is blue
For example,
pev->rendercolor.x = 255;
would make red glowshell:
pev->rendercolor.y = 255;
would make green glowshell:
pev->rendercolor.z = 255;
would make blue glowshell:
pev->rendercolor.x = 128;
pev->rendercolor.z = 128;
would make purple glowshell:
and so on.
Hope this tutorial helped. If you have any questions or if anything was unclear leave a comment or PM me.
Nice tutorial, and very well explained, really easy to understand.
Thanks for a tutorial on this!
Is there any way to do this on guns in multiplayer even if only i see it :S ?
You mean v_ models? I'm pretty sure there's a way to do it but I'm not sure how.
Yep thats what i want to know on v_models
Look in DMC source code, It's somewhere in there. I'll update the tutorial if I find it.
DMC source code? Is that available?
GIMME GIMME GIMME
almost one year later still nothing :D
Good job. I'm going to use it for my mod.
That's great! It's a cool effect that isn't used all that much.
This comment is currently awaiting admin approval, join now to view.
Works like a charm. I have an addition. Below "pev->renderfx" you can also add a line "pev->renderamt = 25;" which I assume ranges from 0 to 255 (from transparent to opaque). And to my surprise it was not about the transparency of the whole model but only the shell effect! I set it to 25 to have just a little bit of that nice shiny glow and it worked perfectly.