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.

1269 lines
34 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.
*
****/
//=========================================================
// bullsquid - big, spotty tentacle-mouthed meanie.
//=========================================================
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "schedule.h"
#include "nodes.h"
#include "effects.h"
#include "decals.h"
#include "soundent.h"
#include "game.h"
#define SQUID_SPRINT_DIST 256.0f // how close the squid has to get before starting to sprint and refusing to swerve
9 years ago
9 years ago
int iSquidSpitSprite;
9 years ago
//=========================================================
// monster-specific schedule types
//=========================================================
enum
{
SCHED_SQUID_HURTHOP = LAST_COMMON_SCHEDULE + 1,
SCHED_SQUID_SMELLFOOD,
SCHED_SQUID_SEECRAB,
SCHED_SQUID_EAT,
SCHED_SQUID_SNIFF_AND_EAT,
SCHED_SQUID_WALLOW
9 years ago
};
//=========================================================
// monster-specific tasks
//=========================================================
enum
{
TASK_SQUID_HOPTURN = LAST_COMMON_TASK + 1
9 years ago
};
//=========================================================
// Bullsquid's spit projectile
//=========================================================
class CSquidSpit : public CBaseEntity
{
public:
void Spawn( void );
static void Shoot( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity );
void Touch( CBaseEntity *pOther );
void EXPORT Animate( void );
9 years ago
virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
9 years ago
9 years ago
int m_maxFrame;
9 years ago
};
LINK_ENTITY_TO_CLASS( squidspit, CSquidSpit )
9 years ago
9 years ago
TYPEDESCRIPTION CSquidSpit::m_SaveData[] =
9 years ago
{
DEFINE_FIELD( CSquidSpit, m_maxFrame, FIELD_INTEGER ),
};
IMPLEMENT_SAVERESTORE( CSquidSpit, CBaseEntity )
9 years ago
9 years ago
void CSquidSpit::Spawn( void )
9 years ago
{
pev->movetype = MOVETYPE_FLY;
pev->classname = MAKE_STRING( "squidspit" );
9 years ago
9 years ago
pev->solid = SOLID_BBOX;
pev->rendermode = kRenderTransAlpha;
pev->renderamt = 255;
9 years ago
SET_MODEL( ENT( pev ), "sprites/bigspit.spr" );
9 years ago
pev->frame = 0;
pev->scale = 0.5f;
9 years ago
9 years ago
UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) );
9 years ago
m_maxFrame = MODEL_FRAMES( pev->modelindex ) - 1;
9 years ago
}
void CSquidSpit::Animate( void )
{
pev->nextthink = gpGlobals->time + 0.1f;
9 years ago
9 years ago
if( pev->frame++ )
9 years ago
{
9 years ago
if( pev->frame > m_maxFrame )
9 years ago
{
pev->frame = 0;
}
}
}
void CSquidSpit::Shoot( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity )
{
CSquidSpit *pSpit = GetClassPtr( (CSquidSpit *)NULL );
pSpit->Spawn();
9 years ago
9 years ago
UTIL_SetOrigin( pSpit->pev, vecStart );
pSpit->pev->velocity = vecVelocity;
9 years ago
pSpit->pev->owner = ENT( pevOwner );
9 years ago
pSpit->SetThink( &CSquidSpit::Animate );
pSpit->pev->nextthink = gpGlobals->time + 0.1f;
9 years ago
}
9 years ago
void CSquidSpit::Touch( CBaseEntity *pOther )
9 years ago
{
TraceResult tr;
9 years ago
int iPitch;
9 years ago
// splat sound
iPitch = RANDOM_FLOAT( 90.0f, 110.0f );
9 years ago
9 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_acid1.wav", 1, ATTN_NORM, 0, iPitch );
9 years ago
9 years ago
switch( RANDOM_LONG( 0, 1 ) )
9 years ago
{
case 0:
9 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_spithit1.wav", 1, ATTN_NORM, 0, iPitch );
9 years ago
break;
case 1:
9 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_spithit2.wav", 1, ATTN_NORM, 0, iPitch );
9 years ago
break;
}
9 years ago
if( !pOther->pev->takedamage )
9 years ago
{
// make a splat on the wall
UTIL_TraceLine( pev->origin, pev->origin + pev->velocity * 10, dont_ignore_monsters, ENT( pev ), &tr );
9 years ago
UTIL_DecalTrace( &tr, DECAL_SPIT1 + RANDOM_LONG( 0, 1 ) );
9 years ago
// make some flecks
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, tr.vecEndPos );
WRITE_BYTE( TE_SPRITE_SPRAY );
9 years ago
WRITE_COORD( tr.vecEndPos.x ); // pos
WRITE_COORD( tr.vecEndPos.y );
WRITE_COORD( tr.vecEndPos.z );
WRITE_COORD( tr.vecPlaneNormal.x ); // dir
WRITE_COORD( tr.vecPlaneNormal.y );
WRITE_COORD( tr.vecPlaneNormal.z );
9 years ago
WRITE_SHORT( iSquidSpitSprite ); // model
9 years ago
WRITE_BYTE( 5 ); // count
WRITE_BYTE( 30 ); // speed
WRITE_BYTE( 80 ); // noise ( client will divide by 100 )
9 years ago
MESSAGE_END();
}
else
{
9 years ago
pOther->TakeDamage( pev, pev, gSkillData.bullsquidDmgSpit, DMG_GENERIC );
9 years ago
}
SetThink( &CBaseEntity::SUB_Remove );
pev->nextthink = gpGlobals->time;
}
//=========================================================
// Monster's Anim Events Go Here
//=========================================================
#define BSQUID_AE_SPIT ( 1 )
#define BSQUID_AE_BITE ( 2 )
#define BSQUID_AE_BLINK ( 3 )
#define BSQUID_AE_TAILWHIP ( 4 )
#define BSQUID_AE_HOP ( 5 )
#define BSQUID_AE_THROW ( 6 )
class CBullsquid : public CBaseMonster
{
public:
void Spawn( void );
void Precache( void );
void SetYawSpeed( void );
9 years ago
int ISoundMask( void );
int Classify( void );
9 years ago
void HandleAnimEvent( MonsterEvent_t *pEvent );
void IdleSound( void );
void PainSound( void );
void DeathSound( void );
9 years ago
void AlertSound( void );
9 years ago
void AttackSound( void );
9 years ago
void StartTask( Task_t *pTask );
void RunTask( Task_t *pTask );
BOOL CheckMeleeAttack1( float flDot, float flDist );
BOOL CheckMeleeAttack2( float flDot, float flDist );
BOOL CheckRangeAttack1( float flDot, float flDist );
9 years ago
void RunAI( void );
9 years ago
BOOL FValidateHintType( short sHint );
9 years ago
Schedule_t *GetSchedule( void );
9 years ago
Schedule_t *GetScheduleOfType( int Type );
9 years ago
int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
9 years ago
int IRelationship( CBaseEntity *pTarget );
int IgnoreConditions( void );
MONSTERSTATE GetIdealState( void );
9 years ago
9 years ago
int Save( CSave &save );
9 years ago
int Restore( CRestore &restore );
CUSTOM_SCHEDULES
9 years ago
static TYPEDESCRIPTION m_SaveData[];
BOOL m_fCanThreatDisplay;// this is so the squid only does the "I see a headcrab!" dance one time.
float m_flLastHurtTime;// we keep track of this, because if something hurts a squid, it will forget about its love of headcrabs for a while.
float m_flNextSpitTime;// last time the bullsquid used the spit attack.
};
LINK_ENTITY_TO_CLASS( monster_bullchicken, CBullsquid )
TYPEDESCRIPTION CBullsquid::m_SaveData[] =
9 years ago
{
DEFINE_FIELD( CBullsquid, m_fCanThreatDisplay, FIELD_BOOLEAN ),
DEFINE_FIELD( CBullsquid, m_flLastHurtTime, FIELD_TIME ),
DEFINE_FIELD( CBullsquid, m_flNextSpitTime, FIELD_TIME ),
};
IMPLEMENT_SAVERESTORE( CBullsquid, CBaseMonster )
9 years ago
//=========================================================
// IgnoreConditions
//=========================================================
9 years ago
int CBullsquid::IgnoreConditions( void )
9 years ago
{
int iIgnore = CBaseMonster::IgnoreConditions();
if( gpGlobals->time - m_flLastHurtTime <= 20.0f )
9 years ago
{
// haven't been hurt in 20 seconds, so let the squid care about stink.
iIgnore = bits_COND_SMELL | bits_COND_SMELL_FOOD;
}
if( m_hEnemy != 0 )
9 years ago
{
9 years ago
if( FClassnameIs( m_hEnemy->pev, "monster_headcrab" ) )
9 years ago
{
// (Unless after a tasty headcrab)
iIgnore = bits_COND_SMELL | bits_COND_SMELL_FOOD;
}
}
return iIgnore;
}
//=========================================================
// IRelationship - overridden for bullsquid so that it can
// be made to ignore its love of headcrabs for a while.
//=========================================================
9 years ago
int CBullsquid::IRelationship( CBaseEntity *pTarget )
9 years ago
{
if( gpGlobals->time - m_flLastHurtTime < 5.0f && FClassnameIs( pTarget->pev, "monster_headcrab" ) )
9 years ago
{
// if squid has been hurt in the last 5 seconds, and is getting relationship for a headcrab,
// tell squid to disregard crab.
return R_NO;
}
9 years ago
return CBaseMonster::IRelationship( pTarget );
9 years ago
}
//=========================================================
// TakeDamage - overridden for bullsquid so we can keep track
// of how much time has passed since it was last injured
//=========================================================
9 years ago
int CBullsquid::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
9 years ago
{
float flDist;
Vector vecApex;
// if the squid is running, has an enemy, was hurt by the enemy, hasn't been hurt in the last 3 seconds, and isn't too close to the enemy,
// it will swerve. (whew).
if( m_hEnemy != 0 && IsMoving() && pevAttacker == m_hEnemy->pev && gpGlobals->time - m_flLastHurtTime > 3.0f )
9 years ago
{
flDist = ( pev->origin - m_hEnemy->pev->origin ).Length2D();
9 years ago
if( flDist > SQUID_SPRINT_DIST )
9 years ago
{
9 years ago
flDist = ( pev->origin - m_Route[m_iRouteIndex].vecLocation ).Length2D();// reusing flDist.
9 years ago
if( FTriangulate( pev->origin, m_Route[m_iRouteIndex].vecLocation, flDist * 0.5f, m_hEnemy, &vecApex ) )
9 years ago
{
InsertWaypoint( vecApex, bits_MF_TO_DETOUR | bits_MF_DONT_SIMPLIFY );
}
}
}
9 years ago
if( !FClassnameIs( pevAttacker, "monster_headcrab" ) )
9 years ago
{
// don't forget about headcrabs if it was a headcrab that hurt the squid.
m_flLastHurtTime = gpGlobals->time;
}
9 years ago
return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType );
9 years ago
}
//=========================================================
// CheckRangeAttack1
//=========================================================
9 years ago
BOOL CBullsquid::CheckRangeAttack1( float flDot, float flDist )
9 years ago
{
if( IsMoving() && flDist >= 512.0f )
9 years ago
{
// squid will far too far behind if he stops running to spit at this distance from the enemy.
return FALSE;
}
if( flDist > 64.0f && flDist <= 784.0f && flDot >= 0.5f && gpGlobals->time >= m_flNextSpitTime )
9 years ago
{
if( m_hEnemy != 0 )
9 years ago
{
if( fabs( pev->origin.z - m_hEnemy->pev->origin.z ) > 256.0f )
9 years ago
{
// don't try to spit at someone up really high or down really low.
return FALSE;
}
}
9 years ago
if( IsMoving() )
9 years ago
{
// don't spit again for a long time, resume chasing enemy.
m_flNextSpitTime = gpGlobals->time + 5.0f;
9 years ago
}
else
{
// not moving, so spit again pretty soon.
m_flNextSpitTime = gpGlobals->time + 0.5f;
9 years ago
}
return TRUE;
}
return FALSE;
}
//=========================================================
// CheckMeleeAttack1 - bullsquid is a big guy, so has a longer
// melee range than most monsters. This is the tailwhip attack
//=========================================================
9 years ago
BOOL CBullsquid::CheckMeleeAttack1( float flDot, float flDist )
9 years ago
{
if( m_hEnemy->pev->health <= gSkillData.bullsquidDmgWhip && flDist <= 85.0f && flDot >= 0.7f )
9 years ago
{
return TRUE;
}
return FALSE;
}
//=========================================================
// CheckMeleeAttack2 - bullsquid is a big guy, so has a longer
// melee range than most monsters. This is the bite attack.
// this attack will not be performed if the tailwhip attack
// is valid.
//=========================================================
9 years ago
BOOL CBullsquid::CheckMeleeAttack2( float flDot, float flDist )
9 years ago
{
if( flDist <= 85.0f && flDot >= 0.7f && !HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) // The player & bullsquid can be as much as their bboxes
9 years ago
{ // apart (48 * sqrt(3)) and he can still attack (85 is a little more than 48*sqrt(3))
return TRUE;
}
return FALSE;
9 years ago
}
9 years ago
//=========================================================
// FValidateHintType
//=========================================================
9 years ago
BOOL CBullsquid::FValidateHintType( short sHint )
9 years ago
{
size_t i;
9 years ago
static short sSquidHints[] =
{
HINT_WORLD_HUMAN_BLOOD,
};
9 years ago
for( i = 0; i < ARRAYSIZE( sSquidHints ); i++ )
9 years ago
{
9 years ago
if( sSquidHints[i] == sHint )
9 years ago
{
return TRUE;
}
}
ALERT( at_aiconsole, "Couldn't validate hint type\n" );
9 years ago
return FALSE;
}
//=========================================================
// ISoundMask - returns a bit mask indicating which types
// of sounds this monster regards. In the base class implementation,
// monsters care about all sounds, but no scents.
//=========================================================
9 years ago
int CBullsquid::ISoundMask( void )
9 years ago
{
9 years ago
return bits_SOUND_WORLD |
bits_SOUND_COMBAT |
bits_SOUND_CARCASS |
bits_SOUND_MEAT |
bits_SOUND_GARBAGE |
bits_SOUND_PLAYER;
9 years ago
}
//=========================================================
// Classify - indicates this monster's place in the
// relationship table.
//=========================================================
9 years ago
int CBullsquid::Classify( void )
9 years ago
{
9 years ago
return CLASS_ALIEN_PREDATOR;
9 years ago
}
//=========================================================
// IdleSound
//=========================================================
#define SQUID_ATTN_IDLE (float)1.5
9 years ago
void CBullsquid::IdleSound( void )
9 years ago
{
9 years ago
switch( RANDOM_LONG( 0, 4 ) )
9 years ago
{
9 years ago
case 0:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle1.wav", 1, SQUID_ATTN_IDLE );
9 years ago
break;
9 years ago
case 1:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle2.wav", 1, SQUID_ATTN_IDLE );
9 years ago
break;
9 years ago
case 2:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle3.wav", 1, SQUID_ATTN_IDLE );
9 years ago
break;
9 years ago
case 3:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle4.wav", 1, SQUID_ATTN_IDLE );
9 years ago
break;
9 years ago
case 4:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle5.wav", 1, SQUID_ATTN_IDLE );
9 years ago
break;
}
}
//=========================================================
// PainSound
//=========================================================
9 years ago
void CBullsquid::PainSound( void )
9 years ago
{
int iPitch = RANDOM_LONG( 85, 120 );
9 years ago
switch( RANDOM_LONG( 0, 3 ) )
9 years ago
{
9 years ago
case 0:
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_pain1.wav", 1, ATTN_NORM, 0, iPitch );
9 years ago
break;
case 1:
9 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_pain2.wav", 1, ATTN_NORM, 0, iPitch );
9 years ago
break;
case 2:
9 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_pain3.wav", 1, ATTN_NORM, 0, iPitch );
9 years ago
break;
case 3:
9 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_pain4.wav", 1, ATTN_NORM, 0, iPitch );
9 years ago
break;
}
}
//=========================================================
// AlertSound
//=========================================================
9 years ago
void CBullsquid::AlertSound( void )
9 years ago
{
int iPitch = RANDOM_LONG( 140, 160 );
9 years ago
switch( RANDOM_LONG( 0, 1 ) )
9 years ago
{
case 0:
9 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle1.wav", 1, ATTN_NORM, 0, iPitch );
9 years ago
break;
case 1:
9 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle2.wav", 1, ATTN_NORM, 0, iPitch );
9 years ago
break;
}
}
//=========================================================
// SetYawSpeed - allows each sequence to have a different
// turn rate associated with it.
//=========================================================
9 years ago
void CBullsquid::SetYawSpeed( void )
9 years ago
{
int ys;
ys = 0;
switch( m_Activity )
9 years ago
{
9 years ago
case ACT_WALK:
ys = 90;
break;
case ACT_RUN:
ys = 90;
break;
case ACT_IDLE:
ys = 90;
break;
case ACT_RANGE_ATTACK1:
ys = 90;
break;
9 years ago
default:
ys = 90;
break;
}
pev->yaw_speed = ys;
}
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//=========================================================
9 years ago
void CBullsquid::HandleAnimEvent( MonsterEvent_t *pEvent )
9 years ago
{
switch( pEvent->event )
{
case BSQUID_AE_SPIT:
{
if( m_hEnemy == 0 )
return;
9 years ago
Vector vecSpitOffset;
Vector vecSpitDir;
UTIL_MakeVectors( pev->angles );
// !!!HACKHACK - the spot at which the spit originates (in front of the mouth) was measured in 3ds and hardcoded here.
// we should be able to read the position of bones at runtime for this info.
vecSpitOffset = ( gpGlobals->v_right * 8.0f + gpGlobals->v_forward * 37.0f + gpGlobals->v_up * 23.0f );
9 years ago
vecSpitOffset = ( pev->origin + vecSpitOffset );
vecSpitDir = ( ( m_hEnemy->pev->origin + m_hEnemy->pev->view_ofs ) - vecSpitOffset ).Normalize();
vecSpitDir.x += RANDOM_FLOAT( -0.05f, 0.05f );
vecSpitDir.y += RANDOM_FLOAT( -0.05f, 0.05f );
vecSpitDir.z += RANDOM_FLOAT( -0.05f, 0.0f );
9 years ago
// do stuff for this event.
AttackSound();
// spew the spittle temporary ents.
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpitOffset );
WRITE_BYTE( TE_SPRITE_SPRAY );
WRITE_COORD( vecSpitOffset.x ); // pos
WRITE_COORD( vecSpitOffset.y );
WRITE_COORD( vecSpitOffset.z );
WRITE_COORD( vecSpitDir.x ); // dir
WRITE_COORD( vecSpitDir.y );
WRITE_COORD( vecSpitDir.z );
WRITE_SHORT( iSquidSpitSprite ); // model
WRITE_BYTE( 15 ); // count
WRITE_BYTE( 210 ); // speed
WRITE_BYTE( 25 ); // noise ( client will divide by 100 )
MESSAGE_END();
CSquidSpit::Shoot( pev, vecSpitOffset, vecSpitDir * 900.0f );
9 years ago
}
9 years ago
break;
case BSQUID_AE_BITE:
{
// SOUND HERE!
CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.bullsquidDmgBite, DMG_SLASH );
9 years ago
9 years ago
if( pHurt )
{
//pHurt->pev->punchangle.z = -15.0f;
//pHurt->pev->punchangle.x = -45.0f;
pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_forward * 100.0f;
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_up * 100.0f;
9 years ago
}
}
break;
9 years ago
case BSQUID_AE_TAILWHIP:
{
9 years ago
CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.bullsquidDmgWhip, DMG_CLUB | DMG_ALWAYSGIB );
9 years ago
9 years ago
if( pHurt )
{
pHurt->pev->punchangle.z = -20.0f;
pHurt->pev->punchangle.x = 20.0f;
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * 200.0f;
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_up * 100.0f;
9 years ago
}
}
break;
9 years ago
case BSQUID_AE_BLINK:
{
9 years ago
// close eye.
pev->skin = 1;
9 years ago
}
9 years ago
break;
case BSQUID_AE_HOP:
{
float flGravity = g_psv_gravity->value;
9 years ago
9 years ago
// throw the squid up into the air on this frame.
if( FBitSet( pev->flags, FL_ONGROUND ) )
{
pev->flags -= FL_ONGROUND;
}
9 years ago
9 years ago
// jump into air for 0.8 (24/30) seconds
//pev->velocity.z += ( 0.875f * flGravity ) * 0.5f;
pev->velocity.z += ( 0.625f * flGravity ) * 0.5f;
9 years ago
}
break;
9 years ago
case BSQUID_AE_THROW:
{
int iPitch;
// squid throws its prey IF the prey is a client.
CBaseEntity *pHurt = CheckTraceHullAttack( 70, 0, 0 );
9 years ago
if( pHurt )
9 years ago
{
// croonchy bite sound
iPitch = RANDOM_FLOAT( 90.0f, 110.0f );
9 years ago
switch( RANDOM_LONG( 0, 1 ) )
9 years ago
{
case 0:
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_bite2.wav", 1.0f, ATTN_NORM, 0, iPitch );
9 years ago
break;
case 1:
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_bite3.wav", 1.0f, ATTN_NORM, 0, iPitch );
9 years ago
break;
}
9 years ago
//pHurt->pev->punchangle.x = RANDOM_LONG( 0, 34 ) - 5;
//pHurt->pev->punchangle.z = RANDOM_LONG( 0, 49 ) - 25;
//pHurt->pev->punchangle.y = RANDOM_LONG( 0, 89 ) - 45;
9 years ago
// screeshake transforms the viewmodel as well as the viewangle. No problems with seeing the ends of the viewmodels.
UTIL_ScreenShake( pHurt->pev->origin, 25.0f, 1.5f, 0.7f, 2.0f );
9 years ago
9 years ago
if( pHurt->IsPlayer() )
9 years ago
{
UTIL_MakeVectors( pev->angles );
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_forward * 300.0f + gpGlobals->v_up * 300.0f;
9 years ago
}
}
}
9 years ago
break;
9 years ago
default:
CBaseMonster::HandleAnimEvent( pEvent );
}
}
//=========================================================
// Spawn
//=========================================================
9 years ago
void CBullsquid::Spawn()
9 years ago
{
9 years ago
Precache();
9 years ago
9 years ago
SET_MODEL( ENT( pev ), "models/bullsquid.mdl" );
UTIL_SetSize( pev, Vector( -32.0f, -32.0f, 0.0f ), Vector( 32.0f, 32.0f, 64.0f ) );
9 years ago
9 years ago
pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_STEP;
m_bloodColor = BLOOD_COLOR_GREEN;
pev->effects = 0;
pev->health = gSkillData.bullsquidHealth;
m_flFieldOfView = 0.2f;// indicates the width of this monster's forward view cone ( as a dotproduct result )
9 years ago
m_MonsterState = MONSTERSTATE_NONE;
9 years ago
9 years ago
m_fCanThreatDisplay = TRUE;
9 years ago
m_flNextSpitTime = gpGlobals->time;
MonsterInit();
}
//=========================================================
// Precache - precaches all resources this monster needs
//=========================================================
9 years ago
void CBullsquid::Precache()
9 years ago
{
9 years ago
PRECACHE_MODEL( "models/bullsquid.mdl" );
9 years ago
9 years ago
PRECACHE_MODEL( "sprites/bigspit.spr" );// spit projectile.
9 years ago
9 years ago
iSquidSpitSprite = PRECACHE_MODEL( "sprites/tinyspit.spr" );// client side spittle.
PRECACHE_SOUND( "zombie/claw_miss2.wav" );// because we use the basemonster SWIPE animation event
PRECACHE_SOUND( "bullchicken/bc_attack2.wav" );
PRECACHE_SOUND( "bullchicken/bc_attack3.wav" );
PRECACHE_SOUND( "bullchicken/bc_die1.wav" );
PRECACHE_SOUND( "bullchicken/bc_die2.wav" );
PRECACHE_SOUND( "bullchicken/bc_die3.wav" );
PRECACHE_SOUND( "bullchicken/bc_idle1.wav" );
PRECACHE_SOUND( "bullchicken/bc_idle2.wav" );
PRECACHE_SOUND( "bullchicken/bc_idle3.wav" );
PRECACHE_SOUND( "bullchicken/bc_idle4.wav" );
PRECACHE_SOUND( "bullchicken/bc_idle5.wav" );
PRECACHE_SOUND( "bullchicken/bc_pain1.wav" );
PRECACHE_SOUND( "bullchicken/bc_pain2.wav" );
PRECACHE_SOUND( "bullchicken/bc_pain3.wav" );
PRECACHE_SOUND( "bullchicken/bc_pain4.wav" );
9 years ago
9 years ago
PRECACHE_SOUND( "bullchicken/bc_attackgrowl.wav" );
PRECACHE_SOUND( "bullchicken/bc_attackgrowl2.wav" );
PRECACHE_SOUND( "bullchicken/bc_attackgrowl3.wav" );
9 years ago
9 years ago
PRECACHE_SOUND( "bullchicken/bc_acid1.wav" );
9 years ago
9 years ago
PRECACHE_SOUND( "bullchicken/bc_bite2.wav" );
PRECACHE_SOUND( "bullchicken/bc_bite3.wav" );
9 years ago
9 years ago
PRECACHE_SOUND( "bullchicken/bc_spithit1.wav" );
PRECACHE_SOUND( "bullchicken/bc_spithit2.wav" );
}
9 years ago
//=========================================================
// DeathSound
//=========================================================
9 years ago
void CBullsquid::DeathSound( void )
9 years ago
{
9 years ago
switch( RANDOM_LONG( 0, 2 ) )
9 years ago
{
9 years ago
case 0:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_die1.wav", 1, ATTN_NORM );
9 years ago
break;
case 1:
9 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_die2.wav", 1, ATTN_NORM );
9 years ago
break;
case 2:
9 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_die3.wav", 1, ATTN_NORM );
9 years ago
break;
}
}
//=========================================================
// AttackSound
//=========================================================
9 years ago
void CBullsquid::AttackSound( void )
9 years ago
{
9 years ago
switch( RANDOM_LONG( 0, 1 ) )
9 years ago
{
case 0:
9 years ago
EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_attack2.wav", 1, ATTN_NORM );
9 years ago
break;
case 1:
9 years ago
EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_attack3.wav", 1, ATTN_NORM );
9 years ago
break;
}
}
//========================================================
// RunAI - overridden for bullsquid because there are things
// that need to be checked every think.
//========================================================
9 years ago
void CBullsquid::RunAI( void )
9 years ago
{
// first, do base class stuff
9 years ago
CBaseMonster::RunAI();
9 years ago
9 years ago
if( pev->skin != 0 )
9 years ago
{
// close eye if it was open.
pev->skin = 0;
}
9 years ago
if( RANDOM_LONG( 0, 39 ) == 0 )
9 years ago
{
pev->skin = 1;
}
if( m_hEnemy != 0 && m_Activity == ACT_RUN )
9 years ago
{
// chasing enemy. Sprint for last bit
9 years ago
if( ( pev->origin - m_hEnemy->pev->origin).Length2D() < SQUID_SPRINT_DIST )
9 years ago
{
pev->framerate = 1.25f;
9 years ago
}
}
}
//========================================================
// AI Schedules Specific to this monster
//=========================================================
// primary range attack
9 years ago
Task_t tlSquidRangeAttack1[] =
9 years ago
{
9 years ago
{ TASK_STOP_MOVING, 0 },
{ TASK_FACE_IDEAL, 0.0f },
{ TASK_RANGE_ATTACK1, 0.0f },
9 years ago
{ TASK_SET_ACTIVITY, (float)ACT_IDLE },
9 years ago
};
9 years ago
Schedule_t slSquidRangeAttack1[] =
9 years ago
{
9 years ago
{
9 years ago
tlSquidRangeAttack1,
9 years ago
ARRAYSIZE( tlSquidRangeAttack1 ),
bits_COND_NEW_ENEMY |
bits_COND_ENEMY_DEAD |
bits_COND_HEAVY_DAMAGE |
bits_COND_ENEMY_OCCLUDED |
9 years ago
bits_COND_NO_AMMO_LOADED,
0,
"Squid Range Attack1"
},
};
// Chase enemy schedule
9 years ago
Task_t tlSquidChaseEnemy1[] =
9 years ago
{
9 years ago
{ TASK_SET_FAIL_SCHEDULE, (float)SCHED_RANGE_ATTACK1 },// !!!OEM - this will stop nasty squid oscillation.
{ TASK_GET_PATH_TO_ENEMY, 0.0f },
{ TASK_RUN_PATH, 0.0f },
{ TASK_WAIT_FOR_MOVEMENT, 0.0f },
9 years ago
};
Schedule_t slSquidChaseEnemy[] =
{
9 years ago
{
9 years ago
tlSquidChaseEnemy1,
9 years ago
ARRAYSIZE( tlSquidChaseEnemy1 ),
bits_COND_NEW_ENEMY |
bits_COND_ENEMY_DEAD |
bits_COND_SMELL_FOOD |
bits_COND_CAN_RANGE_ATTACK1 |
bits_COND_CAN_MELEE_ATTACK1 |
bits_COND_CAN_MELEE_ATTACK2 |
bits_COND_TASK_FAILED |
9 years ago
bits_COND_HEAR_SOUND,
9 years ago
bits_SOUND_DANGER |
9 years ago
bits_SOUND_MEAT,
"Squid Chase Enemy"
},
};
Task_t tlSquidHurtHop[] =
{
{ TASK_STOP_MOVING, 0.0f },
{ TASK_SOUND_WAKE, 0.0f },
{ TASK_SQUID_HOPTURN, 0.0f },
{ TASK_FACE_ENEMY, 0.0f },// in case squid didn't turn all the way in the air.
9 years ago
};
Schedule_t slSquidHurtHop[] =
{
{
tlSquidHurtHop,
9 years ago
ARRAYSIZE( tlSquidHurtHop ),
9 years ago
0,
0,
"SquidHurtHop"
}
};
Task_t tlSquidSeeCrab[] =
{
{ TASK_STOP_MOVING, 0.0f },
{ TASK_SOUND_WAKE, 0.0f },
9 years ago
{ TASK_PLAY_SEQUENCE, (float)ACT_EXCITED },
{ TASK_FACE_ENEMY, 0.0f },
9 years ago
};
Schedule_t slSquidSeeCrab[] =
{
{
tlSquidSeeCrab,
9 years ago
ARRAYSIZE( tlSquidSeeCrab ),
bits_COND_LIGHT_DAMAGE |
9 years ago
bits_COND_HEAVY_DAMAGE,
0,
"SquidSeeCrab"
}
};
// squid walks to something tasty and eats it.
Task_t tlSquidEat[] =
{
{ TASK_STOP_MOVING, 0.0f },
{ TASK_EAT, 10.0f },// this is in case the squid can't get to the food
{ TASK_STORE_LASTPOSITION, 0.0f },
{ TASK_GET_PATH_TO_BESTSCENT, 0.0f },
{ TASK_WALK_PATH, 0.0f },
{ TASK_WAIT_FOR_MOVEMENT, 0.0f },
9 years ago
{ TASK_PLAY_SEQUENCE, (float)ACT_EAT },
{ TASK_PLAY_SEQUENCE, (float)ACT_EAT },
{ TASK_PLAY_SEQUENCE, (float)ACT_EAT },
{ TASK_EAT, 50.0f },
{ TASK_GET_PATH_TO_LASTPOSITION, 0.0f },
{ TASK_WALK_PATH, 0.0f },
{ TASK_WAIT_FOR_MOVEMENT, 0.0f },
{ TASK_CLEAR_LASTPOSITION, 0.0f },
9 years ago
};
Schedule_t slSquidEat[] =
{
{
tlSquidEat,
ARRAYSIZE( tlSquidEat ),
9 years ago
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE |
bits_COND_NEW_ENEMY,
9 years ago
// even though HEAR_SOUND/SMELL FOOD doesn't break this schedule, we need this mask
// here or the monster won't detect these sounds at ALL while running this schedule.
9 years ago
bits_SOUND_MEAT |
9 years ago
bits_SOUND_CARCASS,
"SquidEat"
}
};
// this is a bit different than just Eat. We use this schedule when the food is far away, occluded, or behind
// the squid. This schedule plays a sniff animation before going to the source of food.
Task_t tlSquidSniffAndEat[] =
{
{ TASK_STOP_MOVING, 0.0f },
{ TASK_EAT, 10.0f },// this is in case the squid can't get to the food
9 years ago
{ TASK_PLAY_SEQUENCE, (float)ACT_DETECT_SCENT },
{ TASK_STORE_LASTPOSITION, 0.0f },
{ TASK_GET_PATH_TO_BESTSCENT, 0.0f },
{ TASK_WALK_PATH, 0.0f },
{ TASK_WAIT_FOR_MOVEMENT, 0.0f },
9 years ago
{ TASK_PLAY_SEQUENCE, (float)ACT_EAT },
{ TASK_PLAY_SEQUENCE, (float)ACT_EAT },
{ TASK_PLAY_SEQUENCE, (float)ACT_EAT },
{ TASK_EAT, 50.0f },
{ TASK_GET_PATH_TO_LASTPOSITION, 0.0f },
{ TASK_WALK_PATH, 0.0f },
{ TASK_WAIT_FOR_MOVEMENT, 0.0f },
{ TASK_CLEAR_LASTPOSITION, 0.0f },
9 years ago
};
Schedule_t slSquidSniffAndEat[] =
{
{
tlSquidSniffAndEat,
ARRAYSIZE( tlSquidSniffAndEat ),
9 years ago
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE |
bits_COND_NEW_ENEMY,
9 years ago
// even though HEAR_SOUND/SMELL FOOD doesn't break this schedule, we need this mask
// here or the monster won't detect these sounds at ALL while running this schedule.
9 years ago
bits_SOUND_MEAT |
9 years ago
bits_SOUND_CARCASS,
"SquidSniffAndEat"
}
};
// squid does this to stinky things.
Task_t tlSquidWallow[] =
{
{ TASK_STOP_MOVING, 0.0f },
{ TASK_EAT, 10.0f },// this is in case the squid can't get to the stinkiness
{ TASK_STORE_LASTPOSITION, 0.0f },
{ TASK_GET_PATH_TO_BESTSCENT, 0.0f },
{ TASK_WALK_PATH, 0.0f },
{ TASK_WAIT_FOR_MOVEMENT, 0.0f },
9 years ago
{ TASK_PLAY_SEQUENCE, (float)ACT_INSPECT_FLOOR },
{ TASK_EAT, 50.0f },// keeps squid from eating or sniffing anything else for a while.
{ TASK_GET_PATH_TO_LASTPOSITION, 0.0f },
{ TASK_WALK_PATH, 0.0f },
{ TASK_WAIT_FOR_MOVEMENT, 0.0f },
{ TASK_CLEAR_LASTPOSITION, 0.0f },
9 years ago
};
Schedule_t slSquidWallow[] =
{
{
tlSquidWallow,
ARRAYSIZE( tlSquidWallow ),
9 years ago
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE |
bits_COND_NEW_ENEMY,
9 years ago
// even though HEAR_SOUND/SMELL FOOD doesn't break this schedule, we need this mask
// here or the monster won't detect these sounds at ALL while running this schedule.
bits_SOUND_GARBAGE,
"SquidWallow"
}
};
DEFINE_CUSTOM_SCHEDULES( CBullsquid )
{
slSquidRangeAttack1,
slSquidChaseEnemy,
slSquidHurtHop,
slSquidSeeCrab,
slSquidEat,
slSquidSniffAndEat,
slSquidWallow
};
IMPLEMENT_CUSTOM_SCHEDULES( CBullsquid, CBaseMonster )
9 years ago
//=========================================================
// GetSchedule
//=========================================================
9 years ago
Schedule_t *CBullsquid::GetSchedule( void )
9 years ago
{
9 years ago
switch( m_MonsterState )
9 years ago
{
case MONSTERSTATE_ALERT:
{
9 years ago
if( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) )
9 years ago
{
9 years ago
return GetScheduleOfType( SCHED_SQUID_HURTHOP );
9 years ago
}
9 years ago
if( HasConditions( bits_COND_SMELL_FOOD ) )
9 years ago
{
9 years ago
CSound *pSound;
9 years ago
pSound = PBestScent();
9 years ago
if( pSound && ( !FInViewCone( &pSound->m_vecOrigin ) || !FVisible( pSound->m_vecOrigin ) ) )
9 years ago
{
// scent is behind or occluded
return GetScheduleOfType( SCHED_SQUID_SNIFF_AND_EAT );
}
// food is right out in the open. Just go get it.
return GetScheduleOfType( SCHED_SQUID_EAT );
}
9 years ago
if( HasConditions( bits_COND_SMELL ) )
9 years ago
{
// there's something stinky.
9 years ago
CSound *pSound;
9 years ago
pSound = PBestScent();
9 years ago
if( pSound )
return GetScheduleOfType( SCHED_SQUID_WALLOW );
9 years ago
}
break;
}
case MONSTERSTATE_COMBAT:
{
// dead enemy
9 years ago
if( HasConditions( bits_COND_ENEMY_DEAD ) )
9 years ago
{
// call base class, all code to handle dead enemies is centralized there.
9 years ago
return CBaseMonster::GetSchedule();
9 years ago
}
9 years ago
if( HasConditions( bits_COND_NEW_ENEMY ) )
9 years ago
{
9 years ago
if( m_fCanThreatDisplay && IRelationship( m_hEnemy ) == R_HT )
9 years ago
{
// this means squid sees a headcrab!
m_fCanThreatDisplay = FALSE;// only do the headcrab dance once per lifetime.
9 years ago
return GetScheduleOfType( SCHED_SQUID_SEECRAB );
9 years ago
}
else
{
9 years ago
return GetScheduleOfType( SCHED_WAKE_ANGRY );
9 years ago
}
}
9 years ago
if( HasConditions( bits_COND_SMELL_FOOD ) )
9 years ago
{
9 years ago
CSound *pSound;
9 years ago
pSound = PBestScent();
9 years ago
if( pSound && ( !FInViewCone( &pSound->m_vecOrigin ) || !FVisible( pSound->m_vecOrigin ) ) )
9 years ago
{
// scent is behind or occluded
return GetScheduleOfType( SCHED_SQUID_SNIFF_AND_EAT );
}
// food is right out in the open. Just go get it.
return GetScheduleOfType( SCHED_SQUID_EAT );
}
9 years ago
if( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) )
9 years ago
{
9 years ago
return GetScheduleOfType( SCHED_RANGE_ATTACK1 );
9 years ago
}
9 years ago
if( HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) )
9 years ago
{
9 years ago
return GetScheduleOfType( SCHED_MELEE_ATTACK1 );
9 years ago
}
9 years ago
if( HasConditions( bits_COND_CAN_MELEE_ATTACK2 ) )
9 years ago
{
9 years ago
return GetScheduleOfType( SCHED_MELEE_ATTACK2 );
9 years ago
}
9 years ago
return GetScheduleOfType( SCHED_CHASE_ENEMY );
9 years ago
break;
}
default:
break;
9 years ago
}
9 years ago
return CBaseMonster::GetSchedule();
9 years ago
}
//=========================================================
// GetScheduleOfType
//=========================================================
9 years ago
Schedule_t *CBullsquid::GetScheduleOfType( int Type )
9 years ago
{
9 years ago
switch( Type )
9 years ago
{
case SCHED_RANGE_ATTACK1:
9 years ago
return &slSquidRangeAttack1[0];
9 years ago
break;
case SCHED_SQUID_HURTHOP:
9 years ago
return &slSquidHurtHop[0];
9 years ago
break;
case SCHED_SQUID_SEECRAB:
9 years ago
return &slSquidSeeCrab[0];
9 years ago
break;
case SCHED_SQUID_EAT:
9 years ago
return &slSquidEat[0];
9 years ago
break;
case SCHED_SQUID_SNIFF_AND_EAT:
9 years ago
return &slSquidSniffAndEat[0];
9 years ago
break;
case SCHED_SQUID_WALLOW:
9 years ago
return &slSquidWallow[0];
9 years ago
break;
case SCHED_CHASE_ENEMY:
9 years ago
return &slSquidChaseEnemy[0];
9 years ago
break;
}
9 years ago
return CBaseMonster::GetScheduleOfType( Type );
9 years ago
}
//=========================================================
// Start task - selects the correct activity and performs
// any necessary calculations to start the next task on the
// schedule. OVERRIDDEN for bullsquid because it needs to
// know explicitly when the last attempt to chase the enemy
// failed, since that impacts its attack choices.
//=========================================================
9 years ago
void CBullsquid::StartTask( Task_t *pTask )
9 years ago
{
m_iTaskStatus = TASKSTATUS_RUNNING;
9 years ago
switch( pTask->iTask )
9 years ago
{
case TASK_MELEE_ATTACK2:
{
9 years ago
switch( RANDOM_LONG( 0, 2 ) )
9 years ago
{
9 years ago
case 0:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_attackgrowl.wav", 1, ATTN_NORM );
9 years ago
break;
9 years ago
case 1:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_attackgrowl2.wav", 1, ATTN_NORM );
9 years ago
break;
9 years ago
case 2:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_attackgrowl3.wav", 1, ATTN_NORM );
9 years ago
break;
}
9 years ago
CBaseMonster::StartTask( pTask );
9 years ago
break;
}
case TASK_SQUID_HOPTURN:
{
9 years ago
SetActivity( ACT_HOP );
MakeIdealYaw( m_vecEnemyLKP );
9 years ago
break;
}
case TASK_GET_PATH_TO_ENEMY:
{
9 years ago
if( BuildRoute( m_hEnemy->pev->origin, bits_MF_TO_ENEMY, m_hEnemy ) )
9 years ago
{
m_iTaskStatus = TASKSTATUS_COMPLETE;
}
else
{
9 years ago
ALERT( at_aiconsole, "GetPathToEnemy failed!!\n" );
9 years ago
TaskFail();
}
break;
}
default:
{
9 years ago
CBaseMonster::StartTask( pTask );
9 years ago
break;
}
}
}
//=========================================================
// RunTask
//=========================================================
9 years ago
void CBullsquid::RunTask( Task_t *pTask )
9 years ago
{
9 years ago
switch( pTask->iTask )
9 years ago
{
case TASK_SQUID_HOPTURN:
{
MakeIdealYaw( m_vecEnemyLKP );
ChangeYaw( pev->yaw_speed );
9 years ago
if( m_fSequenceFinished )
9 years ago
{
m_iTaskStatus = TASKSTATUS_COMPLETE;
}
break;
}
default:
{
9 years ago
CBaseMonster::RunTask( pTask );
9 years ago
break;
}
}
}
//=========================================================
// GetIdealState - Overridden for Bullsquid to deal with
// the feature that makes it lose interest in headcrabs for
// a while if something injures it.
//=========================================================
9 years ago
MONSTERSTATE CBullsquid::GetIdealState( void )
9 years ago
{
9 years ago
int iConditions;
9 years ago
iConditions = IScheduleFlags();
9 years ago
9 years ago
// If no schedule conditions, the new ideal state is probably the reason we're in here.
9 years ago
switch( m_MonsterState )
9 years ago
{
case MONSTERSTATE_COMBAT:
/*
COMBAT goes to ALERT upon death of enemy
*/
{
if( m_hEnemy != 0 && ( iConditions & bits_COND_LIGHT_DAMAGE || iConditions & bits_COND_HEAVY_DAMAGE ) && FClassnameIs( m_hEnemy->pev, "monster_headcrab" ) )
9 years ago
{
// if the squid has a headcrab enemy and something hurts it, it's going to forget about the crab for a while.
m_hEnemy = NULL;
m_IdealMonsterState = MONSTERSTATE_ALERT;
}
break;
}
default:
break;
9 years ago
}
9 years ago
m_IdealMonsterState = CBaseMonster::GetIdealState();
9 years ago
return m_IdealMonsterState;
}