//
// Clean Suit Scientist
//
class CCleanSuitScientist : public CScientist
{
public:
void Spawn(void);
void Precache(void);
BOOL CanHeal(void);
};
This of course is our class and the functions it has. Notice that it is public CScientist. This gives our CCleanSuitScientist all the same funcions as a normal CScientist. However, we are overriding three of the CScientist functions with our own functions. We need a new Spawn function because this is where the model for the monster is set, and our cleansuit scientist has a cleansuit on, not a normal lab coat. A new Precache is needed because the cleansuits model file is precached here by the engine, and we wouldn't want to precache the wrong model, now would we? Finally, we have an overridden CanHeal function because the normal Opposing Force model doesn't have a needle to even heal you with, so having a cleansuit scientist heal you with nothing wouldn't make sense, right? So, now we need the actual bodies of these functions, which will go right below, but first don't forget the link function which adds your monster to an entity name!
LINK_ENTITY_TO_CLASS( monster_cleansuit_scientist , CCleanSuitScientist);
That should do, now for the three functions.
BOOL CCleanSuitScientist::CanHeal(void)
{
return FALSE;
}
Ok, this is our overridden CanHeal function. It always returns FALSE no matter what, so the scientist will never be able to heal you. Now for the Spawn function.
//=========================================================
// Spawn
//=========================================================
void CCleanSuitScientist::Spawn(void)
{
Precache( );
SET_MODEL(ENT(pev), "models/cleansuit_scientist.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.scientistHealth;
// position of the eyes relative to monster's origin.
pev->view_ofs = Vector ( 0, 0, 50 );
// NOTE: we need a wide field of view so scientists will notice player and say hello
m_flFieldOfView = VIEW_FIELD_WIDE;
m_MonsterState = MONSTERSTATE_NONE;
// m_flDistTooFar = 256.0;
m_afCapability = bits_CAP_HEAR | bits_CAP_TURN_HEAD | bits_CAP_OPEN_DOORS | bits_CAP_AUTO_DOORS | bits_CAP_USE;
// White hands
pev->skin = 0;
if ( pev->body == -1 )
{ // -1 chooses a random head
// pick a head, any head
pev->body = RANDOM_LONG(0, NUM_SCIENTIST_HEADS-1);
}
// Luther is black, make his hands black
if ( pev->body == HEAD_LUTHER )
pev->skin = 1;
MonsterInit();
SetUse( FollowerUse );
}
Notice that it is almost exactly like the normal scientists Spawn function, except we are setting the model to have a different model. Next up is the Precache function!
//=========================================================
// Precache - precaches all resources this monster needs
//=========================================================
void CCleanSuitScientist::Precache(void)
{
PRECACHE_MODEL("models/cleansuit_scientist.mdl");
PRECACHE_SOUND("scientist/sci_pain1.wav");
PRECACHE_SOUND("scientist/sci_pain2.wav");
PRECACHE_SOUND("scientist/sci_pain3.wav");
PRECACHE_SOUND("scientist/sci_pain4.wav");
PRECACHE_SOUND("scientist/sci_pain5.wav");
// every new scientist must call this, otherwise
// when a level is loaded, nobody will talk (time is reset to 0)
TalkInit();
CTalkMonster::Precache();
}
Again this is almost exactly like the CScientist's Spawn function, but we are precaching our cleansuit model and not the normal scientist model.You must log in to post a comment. You can login or register a new account.