|
|
@ -20,7 +20,6 @@ |
|
|
|
#include "cbase.h" |
|
|
|
#include "cbase.h" |
|
|
|
#include "monsters.h" |
|
|
|
#include "monsters.h" |
|
|
|
#include "schedule.h" |
|
|
|
#include "schedule.h" |
|
|
|
#include "talkmonster.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// For holograms, make them not solid so the player can walk through them
|
|
|
|
// For holograms, make them not solid so the player can walk through them
|
|
|
|
#define SF_GENERICMONSTER_NOTSOLID 4 |
|
|
|
#define SF_GENERICMONSTER_NOTSOLID 4 |
|
|
@ -29,8 +28,7 @@ |
|
|
|
//=========================================================
|
|
|
|
//=========================================================
|
|
|
|
// Monster's Anim Events Go Here
|
|
|
|
// Monster's Anim Events Go Here
|
|
|
|
//=========================================================
|
|
|
|
//=========================================================
|
|
|
|
|
|
|
|
class CGenericMonster : public CBaseMonster |
|
|
|
class CGenericMonster : public CTalkMonster |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
public: |
|
|
|
void Spawn( void ); |
|
|
|
void Spawn( void ); |
|
|
@ -39,10 +37,33 @@ public: |
|
|
|
int Classify( void ); |
|
|
|
int Classify( void ); |
|
|
|
void HandleAnimEvent( MonsterEvent_t *pEvent ); |
|
|
|
void HandleAnimEvent( MonsterEvent_t *pEvent ); |
|
|
|
int ISoundMask( void ); |
|
|
|
int ISoundMask( void ); |
|
|
|
|
|
|
|
void PlayScriptedSentence( const char *pszSentence, float duration, float volume, float attenuation, BOOL bConcurrent, CBaseEntity *pListener ); |
|
|
|
|
|
|
|
void IdleHeadTurn( Vector &vecFriend ); |
|
|
|
|
|
|
|
void EXPORT MonsterThink(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Save( CSave &save ); |
|
|
|
|
|
|
|
int Restore( CRestore &restore ); |
|
|
|
|
|
|
|
static TYPEDESCRIPTION m_SaveData[]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
float m_talkTime; |
|
|
|
|
|
|
|
EHANDLE m_hTalkTarget; |
|
|
|
|
|
|
|
float m_flIdealYaw; |
|
|
|
|
|
|
|
float m_flCurrentYaw; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
LINK_ENTITY_TO_CLASS( monster_generic, CGenericMonster ) |
|
|
|
LINK_ENTITY_TO_CLASS( monster_generic, CGenericMonster ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TYPEDESCRIPTION CGenericMonster::m_SaveData[] = |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
DEFINE_FIELD( CGenericMonster, m_talkTime, FIELD_FLOAT ), |
|
|
|
|
|
|
|
DEFINE_FIELD( CGenericMonster, m_hTalkTarget, FIELD_EHANDLE ), |
|
|
|
|
|
|
|
DEFINE_FIELD( CGenericMonster, m_flIdealYaw, FIELD_FLOAT ), |
|
|
|
|
|
|
|
DEFINE_FIELD( CGenericMonster, m_flCurrentYaw, FIELD_FLOAT ), |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_SAVERESTORE( CGenericMonster, CBaseMonster ) |
|
|
|
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
//=========================================================
|
|
|
|
// Classify - indicates this monster's place in the
|
|
|
|
// Classify - indicates this monster's place in the
|
|
|
|
// relationship table.
|
|
|
|
// relationship table.
|
|
|
@ -126,6 +147,8 @@ void CGenericMonster::Spawn() |
|
|
|
m_afCapability = bits_CAP_TURN_HEAD; |
|
|
|
m_afCapability = bits_CAP_TURN_HEAD; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_flIdealYaw = m_flCurrentYaw = 0; |
|
|
|
|
|
|
|
|
|
|
|
if( pev->spawnflags & SF_GENERICMONSTER_NOTSOLID ) |
|
|
|
if( pev->spawnflags & SF_GENERICMONSTER_NOTSOLID ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
pev->solid = SOLID_NOT; |
|
|
|
pev->solid = SOLID_NOT; |
|
|
@ -138,11 +161,67 @@ void CGenericMonster::Spawn() |
|
|
|
//=========================================================
|
|
|
|
//=========================================================
|
|
|
|
void CGenericMonster::Precache() |
|
|
|
void CGenericMonster::Precache() |
|
|
|
{ |
|
|
|
{ |
|
|
|
CTalkMonster::Precache(); |
|
|
|
|
|
|
|
TalkInit(); |
|
|
|
|
|
|
|
PRECACHE_MODEL( STRING( pev->model ) ); |
|
|
|
PRECACHE_MODEL( STRING( pev->model ) ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CGenericMonster::PlayScriptedSentence( const char *pszSentence, float duration, float volume, float attenuation, BOOL bConcurrent, CBaseEntity *pListener ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_talkTime = gpGlobals->time + duration; |
|
|
|
|
|
|
|
PlaySentence( pszSentence, duration, volume, attenuation ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_hTalkTarget = pListener; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CGenericMonster::IdleHeadTurn( Vector &vecFriend ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// turn head in desired direction only if ent has a turnable head
|
|
|
|
|
|
|
|
if( m_afCapability & bits_CAP_TURN_HEAD ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
float yaw = VecToYaw( vecFriend - pev->origin ) - pev->angles.y; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( yaw > 180 ) |
|
|
|
|
|
|
|
yaw -= 360; |
|
|
|
|
|
|
|
if( yaw < -180 ) |
|
|
|
|
|
|
|
yaw += 360; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_flIdealYaw = yaw; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CGenericMonster::MonsterThink() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( m_afCapability & bits_CAP_TURN_HEAD ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( m_hTalkTarget != 0 ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( gpGlobals->time > m_talkTime ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_flIdealYaw = 0; |
|
|
|
|
|
|
|
m_hTalkTarget = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
IdleHeadTurn( m_hTalkTarget->pev->origin ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( m_flCurrentYaw != m_flIdealYaw ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( m_flCurrentYaw <= m_flIdealYaw ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_flCurrentYaw += Q_min( m_flIdealYaw - m_flCurrentYaw, 20.0f ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_flCurrentYaw -= Q_min( m_flCurrentYaw - m_flIdealYaw, 20.0f ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SetBoneController( 0, m_flCurrentYaw ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CBaseMonster::MonsterThink(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
//=========================================================
|
|
|
|
// AI Schedules Specific to this monster
|
|
|
|
// AI Schedules Specific to this monster
|
|
|
|
//=========================================================
|
|
|
|
//=========================================================
|
|
|
|