Portable Half-Life SDK. GoldSource and Xash3D. Crossplatform.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1241 lines
29 KiB

9 years ago
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* This source code contains proprietary and confidential information of
* Valve LLC and its suppliers. Access to this code is restricted to
* persons who have executed a written SDK license with Valve. Any access,
* use or distribution of this code by or to any unlicensed person is illegal.
*
****/
//=========================================================
// Houndeye - spooky sonic dog.
//=========================================================
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "schedule.h"
#include "animation.h"
#include "nodes.h"
#include "squadmonster.h"
#include "soundent.h"
#include "game.h"
extern CGraph WorldGraph;
// houndeye does 20 points of damage spread over a sphere 384 units in diameter, and each additional
// squad member increases the BASE damage by 110%, per the spec.
#define HOUNDEYE_MAX_SQUAD_SIZE 4
#define HOUNDEYE_MAX_ATTACK_RADIUS 120.0f
#define HOUNDEYE_SQUAD_BONUS 1.1f
#define HOUNDEYE_MELEE_DAMAGE 7
9 years ago
#define HOUNDEYE_EYE_FRAMES 3 // how many different switchable maps for the eye
9 years ago
#define HOUNDEYE_SOUND_STARTLE_VOLUME 128 // how loud a sound has to be to badly scare a sleeping houndeye
//=========================================================
// monster-specific tasks
//=========================================================
enum
{
TASK_HOUND_CLOSE_EYE = LAST_COMMON_TASK + 1,
TASK_HOUND_OPEN_EYE,
TASK_HOUND_THREAT_DISPLAY,
TASK_HOUND_FALL_ASLEEP,
TASK_HOUND_WAKE_UP,
TASK_HOUND_HOP_BACK
};
//=========================================================
// monster-specific schedule types
//=========================================================
enum
{
SCHED_HOUND_AGITATED = LAST_COMMON_SCHEDULE + 1,
SCHED_HOUND_HOP_RETREAT,
SCHED_HOUND_FAIL
9 years ago
};
//=========================================================
// Monster's Anim Events Go Here
//=========================================================
#define HOUND_AE_WARN 1
8 years ago
#define HOUND_AE_STARTATTACK 2
9 years ago
#define HOUND_AE_THUMP 3
8 years ago
#define HOUND_AE_ANGERSOUND1 4
#define HOUND_AE_ANGERSOUND2 5
9 years ago
#define HOUND_AE_HOPBACK 6
#define HOUND_AE_CLOSE_EYE 7
class CHoundeye : public CSquadMonster
{
public:
void Spawn( void );
void Precache( void );
8 years ago
int Classify( void );
9 years ago
void HandleAnimEvent( MonsterEvent_t *pEvent );
8 years ago
void SetYawSpeed( void );
void WarmUpSound( void );
9 years ago
void AlertSound( void );
void DeathSound( void );
void WarnSound( void );
void PainSound( void );
void IdleSound( void );
void StartTask( Task_t *pTask );
8 years ago
void RunTask( Task_t *pTask );
9 years ago
void SonicAttack( void );
void PrescheduleThink( void );
8 years ago
void SetActivity( Activity NewActivity );
void WriteBeamColor( void );
BOOL CheckRangeAttack1( float flDot, float flDist );
BOOL FValidateHintType( short sHint );
BOOL FCanActiveIdle( void );
Schedule_t *GetScheduleOfType( int Type );
9 years ago
Schedule_t *GetSchedule( void );
int IRelationship(CBaseEntity *pTarget);
BOOL HasHumanGibs( void );
9 years ago
8 years ago
int Save( CSave &save );
9 years ago
int Restore( CRestore &restore );
CUSTOM_SCHEDULES
9 years ago
static TYPEDESCRIPTION m_SaveData[];
int m_iSpriteTexture;
BOOL m_fAsleep;// some houndeyes sleep in idle mode if this is set, the houndeye is lying down
BOOL m_fDontBlink;// don't try to open/close eye if this bit is set!
Vector m_vecPackCenter; // the center of the pack. The leader maintains this by averaging the origins of all pack members.
};
LINK_ENTITY_TO_CLASS( monster_houndeye, CHoundeye )
9 years ago
8 years ago
TYPEDESCRIPTION CHoundeye::m_SaveData[] =
9 years ago
{
DEFINE_FIELD( CHoundeye, m_iSpriteTexture, FIELD_INTEGER ),
DEFINE_FIELD( CHoundeye, m_fAsleep, FIELD_BOOLEAN ),
DEFINE_FIELD( CHoundeye, m_fDontBlink, FIELD_BOOLEAN ),
DEFINE_FIELD( CHoundeye, m_vecPackCenter, FIELD_POSITION_VECTOR ),
};
IMPLEMENT_SAVERESTORE( CHoundeye, CSquadMonster )
9 years ago
//=========================================================
// Classify - indicates this monster's place in the
// relationship table.
//=========================================================
8 years ago
int CHoundeye::Classify( void )
9 years ago
{
8 years ago
return CLASS_ALIEN_MONSTER;
9 years ago
}
//=========================================================
// FValidateHintType
//=========================================================
8 years ago
BOOL CHoundeye::FValidateHintType( short sHint )
9 years ago
{
size_t i;
9 years ago
static short sHoundHints[] =
{
HINT_WORLD_MACHINERY,
HINT_WORLD_BLINKING_LIGHT,
HINT_WORLD_HUMAN_BLOOD,
HINT_WORLD_ALIEN_BLOOD,
};
8 years ago
for( i = 0; i < ARRAYSIZE( sHoundHints ); i++ )
9 years ago
{
8 years ago
if( sHoundHints[i] == sHint )
9 years ago
{
return TRUE;
}
}
ALERT( at_aiconsole, "Couldn't validate hint type\n" );
9 years ago
return FALSE;
}
//=========================================================
// FCanActiveIdle
//=========================================================
8 years ago
BOOL CHoundeye::FCanActiveIdle( void )
9 years ago
{
8 years ago
if( InSquad() )
9 years ago
{
CSquadMonster *pSquadLeader = MySquadLeader();
8 years ago
for( int i = 0; i < MAX_SQUAD_MEMBERS; i++ )
9 years ago
{
8 years ago
CSquadMonster *pMember = pSquadLeader->MySquadMember( i );
if( pMember != NULL && pMember != this && pMember->m_iHintNode != NO_NODE )
9 years ago
{
// someone else in the group is active idling right now!
return FALSE;
}
}
return TRUE;
}
return TRUE;
}
//=========================================================
// CheckRangeAttack1 - overridden for houndeyes so that they
// try to get within half of their max attack radius before
// attacking, so as to increase their chances of doing damage.
//=========================================================
8 years ago
BOOL CHoundeye::CheckRangeAttack1( float flDot, float flDist )
9 years ago
{
if( flDist <= ( HOUNDEYE_MAX_ATTACK_RADIUS * 0.5f ) && flDot >= 0.3f )
9 years ago
{
return TRUE;
}
return FALSE;
}
//=========================================================
// SetYawSpeed - allows each sequence to have a different
// turn rate associated with it.
//=========================================================
8 years ago
void CHoundeye::SetYawSpeed( void )
9 years ago
{
int ys;
ys = 90;
8 years ago
switch( m_Activity )
9 years ago
{
case ACT_CROUCHIDLE://sleeping!
ys = 0;
break;
case ACT_IDLE:
ys = 60;
break;
case ACT_WALK:
case ACT_RUN:
case ACT_TURN_LEFT:
case ACT_TURN_RIGHT:
break;
default:
9 years ago
break;
}
pev->yaw_speed = ys;
}
//=========================================================
// SetActivity
//=========================================================
8 years ago
void CHoundeye::SetActivity( Activity NewActivity )
9 years ago
{
8 years ago
int iSequence;
9 years ago
8 years ago
if( NewActivity == m_Activity )
9 years ago
return;
8 years ago
if( m_MonsterState == MONSTERSTATE_COMBAT && NewActivity == ACT_IDLE && RANDOM_LONG( 0, 1 ) )
9 years ago
{
// play pissed idle.
iSequence = LookupSequence( "madidle" );
m_Activity = NewActivity; // Go ahead and set this so it doesn't keep trying when the anim is not present
// In case someone calls this with something other than the ideal activity
m_IdealActivity = m_Activity;
// Set to the desired anim, or default anim if the desired is not present
8 years ago
if( iSequence > ACTIVITY_NOT_AVAILABLE )
9 years ago
{
8 years ago
pev->sequence = iSequence; // Set to the reset anim (if it's there)
pev->frame = 0; // FIX: frame counter shouldn't be reset when its the same activity as before
9 years ago
ResetSequenceInfo();
SetYawSpeed();
}
}
else
{
8 years ago
CSquadMonster::SetActivity( NewActivity );
9 years ago
}
}
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//=========================================================
8 years ago
void CHoundeye::HandleAnimEvent( MonsterEvent_t *pEvent )
9 years ago
{
8 years ago
switch( pEvent->event )
9 years ago
{
case HOUND_AE_WARN:
// do stuff for this event.
WarnSound();
break;
case HOUND_AE_STARTATTACK:
WarmUpSound();
break;
case HOUND_AE_HOPBACK:
{
float flGravity = g_psv_gravity->value;
pev->flags &= ~FL_ONGROUND;
pev->velocity = gpGlobals->v_forward * -200.0f;
pev->velocity.z += ( 0.6f * flGravity ) * 0.5f;
9 years ago
break;
}
case HOUND_AE_THUMP:
// emit the shockwaves
SonicAttack();
9 years ago
break;
case HOUND_AE_ANGERSOUND1:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_pain3.wav", 1, ATTN_NORM );
9 years ago
break;
case HOUND_AE_ANGERSOUND2:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_pain1.wav", 1, ATTN_NORM );
9 years ago
break;
case HOUND_AE_CLOSE_EYE:
8 years ago
if( !m_fDontBlink )
9 years ago
{
pev->skin = HOUNDEYE_EYE_FRAMES - 1;
}
break;
default:
CSquadMonster::HandleAnimEvent( pEvent );
break;
}
}
//=========================================================
// Spawn
//=========================================================
8 years ago
void CHoundeye::Spawn()
9 years ago
{
8 years ago
Precache();
9 years ago
8 years ago
SET_MODEL( ENT( pev ), "models/houndeye.mdl" );
UTIL_SetSize( pev, Vector( -16, -16, 0 ), Vector( 16, 16, 36 ) );
9 years ago
8 years ago
pev->solid = SOLID_SLIDEBOX;
9 years ago
pev->movetype = MOVETYPE_STEP;
m_bloodColor = BLOOD_COLOR_RED;
9 years ago
pev->effects = 0;
8 years ago
pev->health = gSkillData.houndeyeHealth;
9 years ago
pev->yaw_speed = 5;//!!! should we put this in the monster's changeanim function since turn rates may vary with state/anim?
m_flFieldOfView = 0.5;// indicates the width of this monster's forward view cone ( as a dotproduct result )
m_MonsterState = MONSTERSTATE_NONE;
8 years ago
m_fAsleep = FALSE; // everyone spawns awake
9 years ago
m_fDontBlink = FALSE;
m_afCapability |= bits_CAP_SQUAD;
MonsterInit();
}
//=========================================================
// Precache - precaches all resources this monster needs
//=========================================================
8 years ago
void CHoundeye::Precache()
9 years ago
{
8 years ago
PRECACHE_MODEL( "models/houndeye.mdl" );
9 years ago
8 years ago
PRECACHE_SOUND( "houndeye/he_alert1.wav" );
PRECACHE_SOUND( "houndeye/he_alert2.wav" );
PRECACHE_SOUND( "houndeye/he_alert3.wav" );
9 years ago
8 years ago
PRECACHE_SOUND( "houndeye/he_die1.wav" );
PRECACHE_SOUND( "houndeye/he_die2.wav" );
PRECACHE_SOUND( "houndeye/he_die3.wav" );
9 years ago
8 years ago
PRECACHE_SOUND( "houndeye/he_idle1.wav" );
PRECACHE_SOUND( "houndeye/he_idle2.wav" );
PRECACHE_SOUND( "houndeye/he_idle3.wav" );
9 years ago
8 years ago
PRECACHE_SOUND( "houndeye/he_hunt1.wav" );
PRECACHE_SOUND( "houndeye/he_hunt2.wav" );
PRECACHE_SOUND( "houndeye/he_hunt3.wav" );
9 years ago
8 years ago
PRECACHE_SOUND( "houndeye/he_pain1.wav" );
PRECACHE_SOUND( "houndeye/he_pain3.wav" );
PRECACHE_SOUND( "houndeye/he_pain4.wav" );
PRECACHE_SOUND( "houndeye/he_pain5.wav" );
9 years ago
8 years ago
PRECACHE_SOUND( "houndeye/he_attack1.wav" );
PRECACHE_SOUND( "houndeye/he_attack3.wav" );
9 years ago
8 years ago
PRECACHE_SOUND( "houndeye/he_blast1.wav" );
PRECACHE_SOUND( "houndeye/he_blast2.wav" );
PRECACHE_SOUND( "houndeye/he_blast3.wav" );
9 years ago
m_iSpriteTexture = PRECACHE_MODEL( "sprites/shockwave.spr" );
}
//=========================================================
// IdleSound
//=========================================================
8 years ago
void CHoundeye::IdleSound( void )
9 years ago
{
8 years ago
switch( RANDOM_LONG( 0, 2 ) )
9 years ago
{
case 0:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_idle1.wav", 1, ATTN_NORM );
9 years ago
break;
case 1:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_idle2.wav", 1, ATTN_NORM );
9 years ago
break;
case 2:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_idle3.wav", 1, ATTN_NORM );
9 years ago
break;
}
}
//=========================================================
// IdleSound
//=========================================================
8 years ago
void CHoundeye::WarmUpSound( void )
9 years ago
{
8 years ago
switch( RANDOM_LONG( 0, 1 ) )
9 years ago
{
case 0:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "houndeye/he_attack1.wav", 0.7, ATTN_NORM );
9 years ago
break;
case 1:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "houndeye/he_attack3.wav", 0.7, ATTN_NORM );
9 years ago
break;
}
}
//=========================================================
// WarnSound
//=========================================================
8 years ago
void CHoundeye::WarnSound( void )
9 years ago
{
8 years ago
switch( RANDOM_LONG( 0, 2 ) )
9 years ago
{
case 0:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_hunt1.wav", 1, ATTN_NORM );
9 years ago
break;
case 1:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_hunt2.wav", 1, ATTN_NORM );
9 years ago
break;
case 2:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_hunt3.wav", 1, ATTN_NORM );
9 years ago
break;
}
}
//=========================================================
// AlertSound
//=========================================================
8 years ago
void CHoundeye::AlertSound( void )
9 years ago
{
8 years ago
if( InSquad() && !IsLeader() )
9 years ago
{
return; // only leader makes ALERT sound.
}
8 years ago
switch( RANDOM_LONG( 0, 2 ) )
9 years ago
{
case 0:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_alert1.wav", 1, ATTN_NORM );
9 years ago
break;
case 1:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_alert2.wav", 1, ATTN_NORM );
9 years ago
break;
case 2:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_alert3.wav", 1, ATTN_NORM );
9 years ago
break;
}
}
//=========================================================
// DeathSound
//=========================================================
8 years ago
void CHoundeye::DeathSound( void )
9 years ago
{
8 years ago
switch( RANDOM_LONG( 0, 2 ) )
9 years ago
{
8 years ago
case 0:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_die1.wav", 1, ATTN_NORM );
9 years ago
break;
case 1:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_die2.wav", 1, ATTN_NORM );
9 years ago
break;
case 2:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_die3.wav", 1, ATTN_NORM );
9 years ago
break;
}
}
//=========================================================
// PainSound
//=========================================================
8 years ago
void CHoundeye::PainSound( void )
9 years ago
{
8 years ago
switch( RANDOM_LONG( 0, 2 ) )
9 years ago
{
8 years ago
case 0:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_pain3.wav", 1, ATTN_NORM );
9 years ago
break;
case 1:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_pain4.wav", 1, ATTN_NORM );
9 years ago
break;
case 2:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "houndeye/he_pain5.wav", 1, ATTN_NORM );
9 years ago
break;
}
}
//=========================================================
// WriteBeamColor - writes a color vector to the network
// based on the size of the group.
//=========================================================
8 years ago
void CHoundeye::WriteBeamColor( void )
9 years ago
{
8 years ago
BYTE bRed, bGreen, bBlue;
9 years ago
8 years ago
if( InSquad() )
9 years ago
{
8 years ago
switch( SquadCount() )
9 years ago
{
case 2:
// no case for 0 or 1, cause those are impossible for monsters in Squads.
8 years ago
bRed = 101;
bGreen = 133;
bBlue = 221;
9 years ago
break;
case 3:
8 years ago
bRed = 67;
bGreen = 85;
bBlue = 255;
9 years ago
break;
case 4:
case 5:
8 years ago
bRed = 62;
bGreen = 33;
bBlue = 211;
9 years ago
break;
default:
8 years ago
ALERT( at_aiconsole, "Unsupported Houndeye SquadSize!\n" );
bRed = 188;
bGreen = 220;
bBlue = 255;
9 years ago
break;
}
}
else
{
// solo houndeye - weakest beam
8 years ago
bRed = 188;
bGreen = 220;
bBlue = 255;
9 years ago
}
8 years ago
WRITE_BYTE( bRed );
9 years ago
WRITE_BYTE( bGreen );
8 years ago
WRITE_BYTE( bBlue );
9 years ago
}
//=========================================================
// SonicAttack
//=========================================================
8 years ago
void CHoundeye::SonicAttack( void )
9 years ago
{
8 years ago
float flAdjustedDamage;
float flDist;
9 years ago
8 years ago
switch( RANDOM_LONG( 0, 2 ) )
9 years ago
{
8 years ago
case 0:
EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "houndeye/he_blast1.wav", 1, ATTN_NORM );
break;
case 1:
EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "houndeye/he_blast2.wav", 1, ATTN_NORM );
break;
case 2:
EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "houndeye/he_blast3.wav", 1, ATTN_NORM );
break;
9 years ago
}
CBaseEntity *pEntity = NULL;
// iterate on all entities in the vicinity.
8 years ago
while( ( pEntity = UTIL_FindEntityInSphere( pEntity, pev->origin, HOUNDEYE_MAX_ATTACK_RADIUS ) ) != NULL )
9 years ago
{
6 years ago
if( pEntity->pev->takedamage != DAMAGE_NO )
9 years ago
{
if( pEntity->IsPlayer() )
{
if( FVisible( pEntity ) )
pEntity->TakeDamage( pev, pev, HOUNDEYE_MELEE_DAMAGE, DMG_SONIC | DMG_ALWAYSGIB );
9 years ago
else
pEntity->TakeDamage( pev, pev, HOUNDEYE_MELEE_DAMAGE / 2, DMG_SONIC | DMG_ALWAYSGIB );
9 years ago
}
}
}
}
9 years ago
//=========================================================
// start task
//=========================================================
8 years ago
void CHoundeye::StartTask( Task_t *pTask )
9 years ago
{
m_iTaskStatus = TASKSTATUS_RUNNING;
8 years ago
switch( pTask->iTask )
9 years ago
{
case TASK_HOUND_FALL_ASLEEP:
{
m_fAsleep = TRUE; // signal that hound is lying down (must stand again before doing anything else!)
m_iTaskStatus = TASKSTATUS_COMPLETE;
break;
}
case TASK_HOUND_WAKE_UP:
{
m_fAsleep = FALSE; // signal that hound is standing again
m_iTaskStatus = TASKSTATUS_COMPLETE;
break;
}
case TASK_HOUND_OPEN_EYE:
{
m_fDontBlink = FALSE; // turn blinking back on and that code will automatically open the eye
m_iTaskStatus = TASKSTATUS_COMPLETE;
break;
}
case TASK_HOUND_CLOSE_EYE:
{
pev->skin = 0;
m_fDontBlink = TRUE; // tell blink code to leave the eye alone.
break;
}
case TASK_HOUND_THREAT_DISPLAY:
{
m_IdealActivity = ACT_IDLE_ANGRY;
break;
}
case TASK_HOUND_HOP_BACK:
{
m_IdealActivity = ACT_LEAP;
break;
}
case TASK_RANGE_ATTACK1:
{
m_IdealActivity = ACT_RANGE_ATTACK1;
/*
8 years ago
if( InSquad() )
9 years ago
{
// see if there is a battery to connect to.
CSquadMonster *pSquad = m_pSquadLeader;
8 years ago
while( pSquad )
9 years ago
{
8 years ago
if( pSquad->m_iMySlot == bits_SLOT_HOUND_BATTERY )
9 years ago
{
// draw a beam.
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_BEAMENTS );
WRITE_SHORT( ENTINDEX( this->edict() ) );
WRITE_SHORT( ENTINDEX( pSquad->edict() ) );
WRITE_SHORT( m_iSpriteTexture );
WRITE_BYTE( 0 ); // framestart
WRITE_BYTE( 0 ); // framerate
WRITE_BYTE( 10 ); // life
WRITE_BYTE( 40 ); // width
WRITE_BYTE( 10 ); // noise
8 years ago
WRITE_BYTE( 0 ); // r, g, b
9 years ago
WRITE_BYTE( 50 ); // r, g, b
WRITE_BYTE( 250); // r, g, b
WRITE_BYTE( 255 ); // brightness
WRITE_BYTE( 30 ); // speed
MESSAGE_END();
break;
}
pSquad = pSquad->m_pSquadNext;
}
}
*/
break;
}
case TASK_SPECIAL_ATTACK1:
{
m_IdealActivity = ACT_SPECIAL_ATTACK1;
break;
}
case TASK_GUARD:
{
m_IdealActivity = ACT_GUARD;
break;
}
default:
{
8 years ago
CSquadMonster::StartTask( pTask );
9 years ago
break;
}
}
}
//=========================================================
// RunTask
//=========================================================
8 years ago
void CHoundeye::RunTask( Task_t *pTask )
9 years ago
{
8 years ago
switch( pTask->iTask )
9 years ago
{
case TASK_HOUND_THREAT_DISPLAY:
{
8 years ago
MakeIdealYaw( m_vecEnemyLKP );
ChangeYaw( pev->yaw_speed );
9 years ago
8 years ago
if( m_fSequenceFinished )
9 years ago
{
TaskComplete();
}
break;
}
case TASK_HOUND_CLOSE_EYE:
{
8 years ago
if( pev->skin < HOUNDEYE_EYE_FRAMES - 1 )
9 years ago
{
pev->skin++;
}
if( pev->skin == HOUNDEYE_EYE_FRAMES - 1 )
{
TaskComplete();
}
9 years ago
break;
}
case TASK_HOUND_HOP_BACK:
{
8 years ago
if( m_fSequenceFinished )
9 years ago
{
TaskComplete();
}
break;
}
case TASK_SPECIAL_ATTACK1:
{
8 years ago
pev->skin = RANDOM_LONG( 0, HOUNDEYE_EYE_FRAMES - 1 );
MakeIdealYaw( m_vecEnemyLKP );
ChangeYaw( pev->yaw_speed );
9 years ago
float life;
8 years ago
life = ( ( 255 - pev->frame ) / ( pev->framerate * m_flFrameRate ) );
if( life < 0.1f )
life = 0.1f;
9 years ago
MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin );
8 years ago
WRITE_BYTE( TE_IMPLOSION );
WRITE_COORD( pev->origin.x );
WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z + 16.0f );
WRITE_BYTE( 50.0f * life + 100.0f ); // radius
WRITE_BYTE( pev->frame / 25.0f ); // count
WRITE_BYTE( life * 10.0f ); // life
9 years ago
MESSAGE_END();
8 years ago
if( m_fSequenceFinished )
9 years ago
{
SonicAttack();
TaskComplete();
}
break;
}
default:
{
8 years ago
CSquadMonster::RunTask( pTask );
9 years ago
break;
}
}
}
//=========================================================
// PrescheduleThink
//=========================================================
8 years ago
void CHoundeye::PrescheduleThink( void )
9 years ago
{
// if the hound is mad and is running, make hunt noises.
if( m_MonsterState == MONSTERSTATE_COMBAT && m_Activity == ACT_RUN && RANDOM_FLOAT( 0, 1 ) < 0.2f )
9 years ago
{
WarnSound();
}
// at random, initiate a blink if not already blinking or sleeping
8 years ago
if( !m_fDontBlink )
9 years ago
{
8 years ago
if( ( pev->skin == 0 ) && RANDOM_LONG( 0, 0x7F ) == 0 )
{
// start blinking!
9 years ago
pev->skin = HOUNDEYE_EYE_FRAMES - 1;
}
8 years ago
else if( pev->skin != 0 )
{
// already blinking
9 years ago
pev->skin--;
}
}
// if you are the leader, average the origins of each pack member to get an approximate center.
8 years ago
if( IsLeader() )
9 years ago
{
CSquadMonster *pSquadMember;
int iSquadCount = 0;
8 years ago
for( int i = 0; i < MAX_SQUAD_MEMBERS; i++ )
9 years ago
{
8 years ago
pSquadMember = MySquadMember( i );
9 years ago
8 years ago
if( pSquadMember )
9 years ago
{
iSquadCount++;
m_vecPackCenter = m_vecPackCenter + pSquadMember->pev->origin;
}
}
m_vecPackCenter = m_vecPackCenter / iSquadCount;
}
}
//=========================================================
// AI Schedules Specific to this monster
//=========================================================
8 years ago
Task_t tlHoundGuardPack[] =
9 years ago
{
{ TASK_STOP_MOVING, 0.0f },
{ TASK_GUARD, 0.0f },
9 years ago
};
Schedule_t slHoundGuardPack[] =
{
{
tlHoundGuardPack,
ARRAYSIZE ( tlHoundGuardPack ),
bits_COND_SEE_HATE |
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE |
bits_COND_PROVOKED |
bits_COND_HEAR_SOUND,
bits_SOUND_COMBAT |// sound flags
bits_SOUND_WORLD |
bits_SOUND_MEAT |
bits_SOUND_PLAYER,
"GuardPack"
},
};
// primary range attack
Task_t tlHoundYell1[] =
{
{ TASK_STOP_MOVING, (float)0 },
{ TASK_FACE_IDEAL, (float)0 },
{ TASK_RANGE_ATTACK1, (float)0 },
{ TASK_SET_SCHEDULE, (float)SCHED_HOUND_AGITATED },
};
Task_t tlHoundYell2[] =
{
{ TASK_STOP_MOVING, (float)0 },
{ TASK_FACE_IDEAL, (float)0 },
{ TASK_RANGE_ATTACK1, (float)0 },
};
Schedule_t slHoundRangeAttack[] =
{
{
tlHoundYell1,
ARRAYSIZE ( tlHoundYell1 ),
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE,
0,
"HoundRangeAttack1"
},
{
tlHoundYell2,
ARRAYSIZE ( tlHoundYell2 ),
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE,
0,
"HoundRangeAttack2"
},
};
// lie down and fall asleep
Task_t tlHoundSleep[] =
{
{ TASK_STOP_MOVING, (float)0 },
{ TASK_SET_ACTIVITY, (float)ACT_IDLE },
{ TASK_WAIT_RANDOM, (float)5 },
{ TASK_PLAY_SEQUENCE, (float)ACT_CROUCH },
{ TASK_SET_ACTIVITY, (float)ACT_CROUCHIDLE },
{ TASK_HOUND_FALL_ASLEEP, (float)0 },
{ TASK_WAIT_RANDOM, (float)25 },
{ TASK_HOUND_CLOSE_EYE, (float)0 },
{ TASK_WAIT_INDEFINITE, (float)0 },
9 years ago
//{ TASK_WAIT, (float)10 },
//{ TASK_WAIT_RANDOM, (float)10 },
};
Schedule_t slHoundSleep[] =
{
{
9 years ago
tlHoundSleep,
ARRAYSIZE ( tlHoundSleep ),
bits_COND_HEAR_SOUND |
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE |
bits_COND_NEW_ENEMY,
bits_SOUND_COMBAT |
bits_SOUND_PLAYER |
bits_SOUND_WORLD,
"Hound Sleep"
},
};
// wake and stand up lazily
Task_t tlHoundWakeLazy[] =
{
{ TASK_STOP_MOVING, (float)0 },
{ TASK_HOUND_OPEN_EYE, (float)0 },
{ TASK_WAIT_RANDOM, (float)2.5 },
{ TASK_PLAY_SEQUENCE, (float)ACT_STAND },
{ TASK_HOUND_WAKE_UP, (float)0 },
};
Schedule_t slHoundWakeLazy[] =
{
{
tlHoundWakeLazy,
ARRAYSIZE ( tlHoundWakeLazy ),
0,
0,
"WakeLazy"
},
};
// wake and stand up with great urgency!
Task_t tlHoundWakeUrgent[] =
{
{ TASK_HOUND_OPEN_EYE, (float)0 },
{ TASK_PLAY_SEQUENCE, (float)ACT_HOP },
{ TASK_FACE_IDEAL, (float)0 },
{ TASK_HOUND_WAKE_UP, (float)0 },
};
Schedule_t slHoundWakeUrgent[] =
{
{
tlHoundWakeUrgent,
ARRAYSIZE ( tlHoundWakeUrgent ),
0,
0,
"WakeUrgent"
},
};
Task_t tlHoundSpecialAttack1[] =
{
{ TASK_STOP_MOVING, 0 },
{ TASK_FACE_IDEAL, (float)0 },
{ TASK_SPECIAL_ATTACK1, (float)0 },
{ TASK_PLAY_SEQUENCE, (float)ACT_IDLE_ANGRY },
};
Schedule_t slHoundSpecialAttack1[] =
{
{
tlHoundSpecialAttack1,
ARRAYSIZE ( tlHoundSpecialAttack1 ),
bits_COND_NEW_ENEMY |
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE |
bits_COND_ENEMY_OCCLUDED,
0,
"Hound Special Attack1"
},
};
Task_t tlHoundAgitated[] =
{
{ TASK_STOP_MOVING, 0 },
{ TASK_HOUND_THREAT_DISPLAY, 0 },
};
Schedule_t slHoundAgitated[] =
{
{
tlHoundAgitated,
ARRAYSIZE ( tlHoundAgitated ),
bits_COND_NEW_ENEMY |
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE,
0,
"Hound Agitated"
},
};
Task_t tlHoundHopRetreat[] =
{
{ TASK_STOP_MOVING, 0 },
{ TASK_HOUND_HOP_BACK, 0 },
{ TASK_SET_SCHEDULE, (float)SCHED_TAKE_COVER_FROM_ENEMY },
};
Schedule_t slHoundHopRetreat[] =
{
{
tlHoundHopRetreat,
ARRAYSIZE ( tlHoundHopRetreat ),
0,
0,
"Hound Hop Retreat"
},
};
// hound fails in combat with client in the PVS
Task_t tlHoundCombatFailPVS[] =
{
{ TASK_STOP_MOVING, 0 },
{ TASK_HOUND_THREAT_DISPLAY, 0 },
{ TASK_WAIT_FACE_ENEMY, 1.0f },
9 years ago
};
Schedule_t slHoundCombatFailPVS[] =
{
{
tlHoundCombatFailPVS,
ARRAYSIZE( tlHoundCombatFailPVS ),
9 years ago
bits_COND_NEW_ENEMY |
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE,
0,
"HoundCombatFailPVS"
},
};
// hound fails in combat with no client in the PVS. Don't keep peeping!
Task_t tlHoundCombatFailNoPVS[] =
{
{ TASK_STOP_MOVING, 0 },
{ TASK_HOUND_THREAT_DISPLAY, 0 },
{ TASK_WAIT_FACE_ENEMY, (float)2 },
{ TASK_SET_ACTIVITY, (float)ACT_IDLE },
{ TASK_WAIT_PVS, 0 },
};
Schedule_t slHoundCombatFailNoPVS[] =
{
{
tlHoundCombatFailNoPVS,
ARRAYSIZE ( tlHoundCombatFailNoPVS ),
bits_COND_NEW_ENEMY |
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE,
0,
"HoundCombatFailNoPVS"
},
};
DEFINE_CUSTOM_SCHEDULES( CHoundeye )
{
slHoundGuardPack,
slHoundRangeAttack,
&slHoundRangeAttack[ 1 ],
slHoundSleep,
slHoundWakeLazy,
slHoundWakeUrgent,
slHoundSpecialAttack1,
slHoundAgitated,
slHoundHopRetreat,
slHoundCombatFailPVS,
slHoundCombatFailNoPVS,
};
IMPLEMENT_CUSTOM_SCHEDULES( CHoundeye, CSquadMonster )
9 years ago
//=========================================================
// GetScheduleOfType
//=========================================================
8 years ago
Schedule_t *CHoundeye::GetScheduleOfType( int Type )
9 years ago
{
8 years ago
if( m_fAsleep )
9 years ago
{
// if the hound is sleeping, must wake and stand!
8 years ago
if( HasConditions( bits_COND_HEAR_SOUND ) )
9 years ago
{
CSound *pWakeSound;
pWakeSound = PBestSound();
ASSERT( pWakeSound != NULL );
8 years ago
if( pWakeSound )
9 years ago
{
8 years ago
MakeIdealYaw( pWakeSound->m_vecOrigin );
9 years ago
8 years ago
if( FLSoundVolume( pWakeSound ) >= HOUNDEYE_SOUND_STARTLE_VOLUME )
9 years ago
{
// awakened by a loud sound
8 years ago
return &slHoundWakeUrgent[0];
9 years ago
}
}
// sound was not loud enough to scare the bejesus out of houndeye
8 years ago
return &slHoundWakeLazy[0];
9 years ago
}
8 years ago
else if( HasConditions( bits_COND_NEW_ENEMY ) )
9 years ago
{
// get up fast, to fight.
8 years ago
return &slHoundWakeUrgent[0];
9 years ago
}
else
{
// hound is waking up on its own
8 years ago
return &slHoundWakeLazy[0];
9 years ago
}
}
8 years ago
switch( Type )
9 years ago
{
case SCHED_IDLE_STAND:
{
// we may want to sleep instead of stand!
8 years ago
if( InSquad() && !IsLeader() && !m_fAsleep && RANDOM_LONG( 0, 29 ) < 1 )
9 years ago
{
8 years ago
return &slHoundSleep[0];
9 years ago
}
else
{
8 years ago
return CSquadMonster::GetScheduleOfType( Type );
9 years ago
}
}
case SCHED_RANGE_ATTACK1:
{
8 years ago
return &slHoundRangeAttack[0];
9 years ago
/*
8 years ago
if( InSquad() )
9 years ago
{
8 years ago
return &slHoundRangeAttack[RANDOM_LONG( 0, 1 )];
9 years ago
}
8 years ago
return &slHoundRangeAttack[1];
9 years ago
*/
}
case SCHED_SPECIAL_ATTACK1:
{
8 years ago
return &slHoundSpecialAttack1[0];
9 years ago
}
case SCHED_GUARD:
{
8 years ago
return &slHoundGuardPack[0];
9 years ago
}
case SCHED_HOUND_AGITATED:
{
8 years ago
return &slHoundAgitated[0];
9 years ago
}
case SCHED_HOUND_HOP_RETREAT:
{
8 years ago
return &slHoundHopRetreat[0];
9 years ago
}
case SCHED_FAIL:
{
8 years ago
if( m_MonsterState == MONSTERSTATE_COMBAT )
9 years ago
{
8 years ago
if( !FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) )
9 years ago
{
// client in PVS
8 years ago
return &slHoundCombatFailPVS[0];
9 years ago
}
else
{
// client has taken off!
8 years ago
return &slHoundCombatFailNoPVS[0];
9 years ago
}
}
else
{
8 years ago
return CSquadMonster::GetScheduleOfType( Type );
9 years ago
}
}
default:
{
8 years ago
return CSquadMonster::GetScheduleOfType( Type );
9 years ago
}
}
}
//=========================================================
// GetSchedule
//=========================================================
8 years ago
Schedule_t *CHoundeye::GetSchedule( void )
9 years ago
{
8 years ago
switch( m_MonsterState )
9 years ago
{
case MONSTERSTATE_COMBAT:
{
// dead enemy
8 years ago
if( HasConditions( bits_COND_ENEMY_DEAD ) )
9 years ago
{
// call base class, all code to handle dead enemies is centralized there.
8 years ago
return CBaseMonster::GetSchedule();
9 years ago
}
8 years ago
if( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) )
9 years ago
{
if( RANDOM_FLOAT( 0.0f, 1.0f ) <= 0.4f )
9 years ago
{
TraceResult tr;
UTIL_MakeVectors( pev->angles );
UTIL_TraceHull( pev->origin, pev->origin + gpGlobals->v_forward * -128, dont_ignore_monsters, head_hull, ENT( pev ), &tr );
if( tr.flFraction == 1.0f )
9 years ago
{
// it's clear behind, so the hound will jump
8 years ago
return GetScheduleOfType( SCHED_HOUND_HOP_RETREAT );
9 years ago
}
}
8 years ago
return GetScheduleOfType( SCHED_TAKE_COVER_FROM_ENEMY );
9 years ago
}
8 years ago
if( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) )
9 years ago
{
8 years ago
if( OccupySlot( bits_SLOTS_HOUND_ATTACK ) )
9 years ago
{
8 years ago
return GetScheduleOfType( SCHED_RANGE_ATTACK1 );
9 years ago
}
8 years ago
return GetScheduleOfType( SCHED_HOUND_AGITATED );
9 years ago
}
break;
}
default:
break;
9 years ago
}
8 years ago
return CSquadMonster::GetSchedule();
9 years ago
}
int CHoundeye::IRelationship( CBaseEntity *pTarget )
{
if( FClassnameIs( pTarget->pev, "monster_human_grunt" ) || FClassnameIs( pTarget->pev, "monster_grunt_repel" ) )
{
return R_NO;
}
return CSquadMonster::IRelationship( pTarget );
}
BOOL CHoundeye::HasHumanGibs( void )
{
return TRUE;
}