hlsdk-xash3d/dlls/bullsquid.cpp

1269 lines
34 KiB
C++
Raw Normal View History

2016-06-04 15:24:23 +02:00
/***
*
* 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"
2019-10-13 13:49:25 +02:00
#define SQUID_SPRINT_DIST 256.0f // how close the squid has to get before starting to sprint and refusing to swerve
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
int iSquidSpitSprite;
2016-06-04 15:24:23 +02:00
//=========================================================
// 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
2016-06-04 15:24:23 +02:00
};
//=========================================================
// monster-specific tasks
//=========================================================
enum
{
TASK_SQUID_HOPTURN = LAST_COMMON_TASK + 1
2016-06-04 15:24:23 +02:00
};
//=========================================================
// 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 );
2016-07-31 15:48:50 +02:00
virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
int m_maxFrame;
2016-06-04 15:24:23 +02:00
};
LINK_ENTITY_TO_CLASS( squidspit, CSquidSpit )
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
TYPEDESCRIPTION CSquidSpit::m_SaveData[] =
2016-06-04 15:24:23 +02:00
{
DEFINE_FIELD( CSquidSpit, m_maxFrame, FIELD_INTEGER ),
};
IMPLEMENT_SAVERESTORE( CSquidSpit, CBaseEntity )
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
void CSquidSpit::Spawn( void )
2016-06-04 15:24:23 +02:00
{
pev->movetype = MOVETYPE_FLY;
pev->classname = MAKE_STRING( "squidspit" );
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
pev->solid = SOLID_BBOX;
pev->rendermode = kRenderTransAlpha;
pev->renderamt = 255;
2016-07-31 15:48:50 +02:00
SET_MODEL( ENT( pev ), "sprites/bigspit.spr" );
2016-06-04 15:24:23 +02:00
pev->frame = 0;
2019-10-13 13:49:25 +02:00
pev->scale = 0.5f;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) );
2016-06-04 15:24:23 +02:00
m_maxFrame = MODEL_FRAMES( pev->modelindex ) - 1;
2016-06-04 15:24:23 +02:00
}
void CSquidSpit::Animate( void )
{
2019-10-13 13:49:25 +02:00
pev->nextthink = gpGlobals->time + 0.1f;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
if( pev->frame++ )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if( pev->frame > m_maxFrame )
2016-06-04 15:24:23 +02:00
{
pev->frame = 0;
}
}
}
void CSquidSpit::Shoot( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity )
{
CSquidSpit *pSpit = GetClassPtr( (CSquidSpit *)NULL );
pSpit->Spawn();
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
UTIL_SetOrigin( pSpit->pev, vecStart );
pSpit->pev->velocity = vecVelocity;
2016-07-31 15:48:50 +02:00
pSpit->pev->owner = ENT( pevOwner );
2016-06-04 15:24:23 +02:00
pSpit->SetThink( &CSquidSpit::Animate );
2019-10-13 13:49:25 +02:00
pSpit->pev->nextthink = gpGlobals->time + 0.1f;
2016-06-04 15:24:23 +02:00
}
2016-07-31 15:48:50 +02:00
void CSquidSpit::Touch( CBaseEntity *pOther )
2016-06-04 15:24:23 +02:00
{
TraceResult tr;
2016-07-31 15:48:50 +02:00
int iPitch;
2016-06-04 15:24:23 +02:00
// splat sound
2019-10-13 13:49:25 +02:00
iPitch = RANDOM_FLOAT( 90.0f, 110.0f );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_acid1.wav", 1, ATTN_NORM, 0, iPitch );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
switch( RANDOM_LONG( 0, 1 ) )
2016-06-04 15:24:23 +02:00
{
case 0:
2016-07-31 15:48:50 +02:00
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_spithit1.wav", 1, ATTN_NORM, 0, iPitch );
2016-06-04 15:24:23 +02:00
break;
case 1:
2016-07-31 15:48:50 +02:00
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_spithit2.wav", 1, ATTN_NORM, 0, iPitch );
2016-06-04 15:24:23 +02:00
break;
}
2016-07-31 15:48:50 +02:00
if( !pOther->pev->takedamage )
2016-06-04 15:24:23 +02:00
{
// make a splat on the wall
UTIL_TraceLine( pev->origin, pev->origin + pev->velocity * 10, dont_ignore_monsters, ENT( pev ), &tr );
2016-07-31 15:48:50 +02:00
UTIL_DecalTrace( &tr, DECAL_SPIT1 + RANDOM_LONG( 0, 1 ) );
2016-06-04 15:24:23 +02:00
// make some flecks
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, tr.vecEndPos );
WRITE_BYTE( TE_SPRITE_SPRAY );
2016-07-31 15:48:50 +02:00
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 );
2016-06-04 15:24:23 +02:00
WRITE_SHORT( iSquidSpitSprite ); // model
2016-07-31 15:48:50 +02:00
WRITE_BYTE( 5 ); // count
WRITE_BYTE( 30 ); // speed
WRITE_BYTE( 80 ); // noise ( client will divide by 100 )
2016-06-04 15:24:23 +02:00
MESSAGE_END();
}
else
{
2016-07-31 15:48:50 +02:00
pOther->TakeDamage( pev, pev, gSkillData.bullsquidDmgSpit, DMG_GENERIC );
2016-06-04 15:24:23 +02:00
}
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 );
2016-07-31 15:48:50 +02:00
int ISoundMask( void );
int Classify( void );
2016-06-04 15:24:23 +02:00
void HandleAnimEvent( MonsterEvent_t *pEvent );
void IdleSound( void );
void PainSound( void );
void DeathSound( void );
2016-07-31 15:48:50 +02:00
void AlertSound( void );
2016-06-04 15:24:23 +02:00
void AttackSound( void );
2016-07-31 15:48:50 +02:00
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 );
2016-06-04 15:24:23 +02:00
void RunAI( void );
2016-07-31 15:48:50 +02:00
BOOL FValidateHintType( short sHint );
2016-06-04 15:24:23 +02:00
Schedule_t *GetSchedule( void );
2016-07-31 15:48:50 +02:00
Schedule_t *GetScheduleOfType( int Type );
2016-06-04 15:24:23 +02:00
int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
2016-07-31 15:48:50 +02:00
int IRelationship( CBaseEntity *pTarget );
int IgnoreConditions( void );
MONSTERSTATE GetIdealState( void );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
int Save( CSave &save );
2016-06-04 15:24:23 +02:00
int Restore( CRestore &restore );
2016-06-25 20:21:01 +02:00
CUSTOM_SCHEDULES
2016-06-04 15:24:23 +02:00
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[] =
2016-06-04 15:24:23 +02:00
{
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 )
2016-06-04 15:24:23 +02:00
//=========================================================
// IgnoreConditions
//=========================================================
2016-07-31 15:48:50 +02:00
int CBullsquid::IgnoreConditions( void )
2016-06-04 15:24:23 +02:00
{
int iIgnore = CBaseMonster::IgnoreConditions();
2019-10-13 13:49:25 +02:00
if( gpGlobals->time - m_flLastHurtTime <= 20.0f )
2016-06-04 15:24:23 +02:00
{
// haven't been hurt in 20 seconds, so let the squid care about stink.
iIgnore = bits_COND_SMELL | bits_COND_SMELL_FOOD;
}
2017-06-29 15:56:03 +02:00
if( m_hEnemy != 0 )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if( FClassnameIs( m_hEnemy->pev, "monster_headcrab" ) )
2016-06-04 15:24:23 +02:00
{
// (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.
//=========================================================
2016-07-31 15:48:50 +02:00
int CBullsquid::IRelationship( CBaseEntity *pTarget )
2016-06-04 15:24:23 +02:00
{
2019-10-13 13:49:25 +02:00
if( gpGlobals->time - m_flLastHurtTime < 5.0f && FClassnameIs( pTarget->pev, "monster_headcrab" ) )
2016-06-04 15:24:23 +02:00
{
// 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;
}
2016-07-31 15:48:50 +02:00
return CBaseMonster::IRelationship( pTarget );
2016-06-04 15:24:23 +02:00
}
//=========================================================
// TakeDamage - overridden for bullsquid so we can keep track
// of how much time has passed since it was last injured
//=========================================================
2016-07-31 15:48:50 +02:00
int CBullsquid::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
2016-06-04 15:24:23 +02:00
{
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).
2019-10-13 13:49:25 +02:00
if( m_hEnemy != 0 && IsMoving() && pevAttacker == m_hEnemy->pev && gpGlobals->time - m_flLastHurtTime > 3.0f )
2016-06-04 15:24:23 +02:00
{
flDist = ( pev->origin - m_hEnemy->pev->origin ).Length2D();
2016-07-31 15:48:50 +02:00
if( flDist > SQUID_SPRINT_DIST )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
flDist = ( pev->origin - m_Route[m_iRouteIndex].vecLocation ).Length2D();// reusing flDist.
2016-06-04 15:24:23 +02:00
2019-10-13 13:49:25 +02:00
if( FTriangulate( pev->origin, m_Route[m_iRouteIndex].vecLocation, flDist * 0.5f, m_hEnemy, &vecApex ) )
2016-06-04 15:24:23 +02:00
{
InsertWaypoint( vecApex, bits_MF_TO_DETOUR | bits_MF_DONT_SIMPLIFY );
}
}
}
2016-07-31 15:48:50 +02:00
if( !FClassnameIs( pevAttacker, "monster_headcrab" ) )
2016-06-04 15:24:23 +02:00
{
// don't forget about headcrabs if it was a headcrab that hurt the squid.
m_flLastHurtTime = gpGlobals->time;
}
2016-07-31 15:48:50 +02:00
return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType );
2016-06-04 15:24:23 +02:00
}
//=========================================================
// CheckRangeAttack1
//=========================================================
2016-07-31 15:48:50 +02:00
BOOL CBullsquid::CheckRangeAttack1( float flDot, float flDist )
2016-06-04 15:24:23 +02:00
{
2019-10-13 13:49:25 +02:00
if( IsMoving() && flDist >= 512.0f )
2016-06-04 15:24:23 +02:00
{
// squid will far too far behind if he stops running to spit at this distance from the enemy.
return FALSE;
}
2019-10-13 13:49:25 +02:00
if( flDist > 64.0f && flDist <= 784.0f && flDot >= 0.5f && gpGlobals->time >= m_flNextSpitTime )
2016-06-04 15:24:23 +02:00
{
2017-06-29 15:56:03 +02:00
if( m_hEnemy != 0 )
2016-06-04 15:24:23 +02:00
{
2019-10-13 13:49:25 +02:00
if( fabs( pev->origin.z - m_hEnemy->pev->origin.z ) > 256.0f )
2016-06-04 15:24:23 +02:00
{
// don't try to spit at someone up really high or down really low.
return FALSE;
}
}
2016-07-31 15:48:50 +02:00
if( IsMoving() )
2016-06-04 15:24:23 +02:00
{
// don't spit again for a long time, resume chasing enemy.
2019-10-13 13:49:25 +02:00
m_flNextSpitTime = gpGlobals->time + 5.0f;
2016-06-04 15:24:23 +02:00
}
else
{
// not moving, so spit again pretty soon.
2019-10-13 13:49:25 +02:00
m_flNextSpitTime = gpGlobals->time + 0.5f;
2016-06-04 15:24:23 +02:00
}
return TRUE;
}
return FALSE;
}
//=========================================================
// CheckMeleeAttack1 - bullsquid is a big guy, so has a longer
// melee range than most monsters. This is the tailwhip attack
//=========================================================
2016-07-31 15:48:50 +02:00
BOOL CBullsquid::CheckMeleeAttack1( float flDot, float flDist )
2016-06-04 15:24:23 +02:00
{
2019-10-13 13:49:25 +02:00
if( m_hEnemy->pev->health <= gSkillData.bullsquidDmgWhip && flDist <= 85.0f && flDot >= 0.7f )
2016-06-04 15:24:23 +02:00
{
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.
//=========================================================
2016-07-31 15:48:50 +02:00
BOOL CBullsquid::CheckMeleeAttack2( float flDot, float flDist )
2016-06-04 15:24:23 +02:00
{
2019-10-13 13:49:25 +02:00
if( flDist <= 85.0f && flDot >= 0.7f && !HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) // The player & bullsquid can be as much as their bboxes
2016-06-04 15:24:23 +02:00
{ // apart (48 * sqrt(3)) and he can still attack (85 is a little more than 48*sqrt(3))
return TRUE;
}
return FALSE;
2016-07-31 15:48:50 +02:00
}
2016-06-04 15:24:23 +02:00
//=========================================================
// FValidateHintType
//=========================================================
2016-07-31 15:48:50 +02:00
BOOL CBullsquid::FValidateHintType( short sHint )
2016-06-04 15:24:23 +02:00
{
2017-06-29 15:56:03 +02:00
size_t i;
2016-06-04 15:24:23 +02:00
static short sSquidHints[] =
{
HINT_WORLD_HUMAN_BLOOD,
};
2016-07-31 15:48:50 +02:00
for( i = 0; i < ARRAYSIZE( sSquidHints ); i++ )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if( sSquidHints[i] == sHint )
2016-06-04 15:24:23 +02:00
{
return TRUE;
}
}
2019-07-07 16:03:04 +02:00
ALERT( at_aiconsole, "Couldn't validate hint type\n" );
2016-06-04 15:24:23 +02:00
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.
//=========================================================
2016-07-31 15:48:50 +02:00
int CBullsquid::ISoundMask( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
return bits_SOUND_WORLD |
bits_SOUND_COMBAT |
bits_SOUND_CARCASS |
bits_SOUND_MEAT |
bits_SOUND_GARBAGE |
bits_SOUND_PLAYER;
2016-06-04 15:24:23 +02:00
}
//=========================================================
// Classify - indicates this monster's place in the
// relationship table.
//=========================================================
2016-07-31 15:48:50 +02:00
int CBullsquid::Classify( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
return CLASS_ALIEN_PREDATOR;
2016-06-04 15:24:23 +02:00
}
//=========================================================
// IdleSound
//=========================================================
#define SQUID_ATTN_IDLE (float)1.5
2016-07-31 15:48:50 +02:00
void CBullsquid::IdleSound( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
switch( RANDOM_LONG( 0, 4 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
case 0:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle1.wav", 1, SQUID_ATTN_IDLE );
2016-06-04 15:24:23 +02:00
break;
2016-07-31 15:48:50 +02:00
case 1:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle2.wav", 1, SQUID_ATTN_IDLE );
2016-06-04 15:24:23 +02:00
break;
2016-07-31 15:48:50 +02:00
case 2:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle3.wav", 1, SQUID_ATTN_IDLE );
2016-06-04 15:24:23 +02:00
break;
2016-07-31 15:48:50 +02:00
case 3:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle4.wav", 1, SQUID_ATTN_IDLE );
2016-06-04 15:24:23 +02:00
break;
2016-07-31 15:48:50 +02:00
case 4:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle5.wav", 1, SQUID_ATTN_IDLE );
2016-06-04 15:24:23 +02:00
break;
}
}
//=========================================================
// PainSound
//=========================================================
2016-07-31 15:48:50 +02:00
void CBullsquid::PainSound( void )
2016-06-04 15:24:23 +02:00
{
int iPitch = RANDOM_LONG( 85, 120 );
2016-07-31 15:48:50 +02:00
switch( RANDOM_LONG( 0, 3 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
case 0:
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_pain1.wav", 1, ATTN_NORM, 0, iPitch );
2016-06-04 15:24:23 +02:00
break;
case 1:
2016-07-31 15:48:50 +02:00
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_pain2.wav", 1, ATTN_NORM, 0, iPitch );
2016-06-04 15:24:23 +02:00
break;
case 2:
2016-07-31 15:48:50 +02:00
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_pain3.wav", 1, ATTN_NORM, 0, iPitch );
2016-06-04 15:24:23 +02:00
break;
case 3:
2016-07-31 15:48:50 +02:00
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_pain4.wav", 1, ATTN_NORM, 0, iPitch );
2016-06-04 15:24:23 +02:00
break;
}
}
//=========================================================
// AlertSound
//=========================================================
2016-07-31 15:48:50 +02:00
void CBullsquid::AlertSound( void )
2016-06-04 15:24:23 +02:00
{
int iPitch = RANDOM_LONG( 140, 160 );
2016-07-31 15:48:50 +02:00
switch( RANDOM_LONG( 0, 1 ) )
2016-06-04 15:24:23 +02:00
{
case 0:
2016-07-31 15:48:50 +02:00
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle1.wav", 1, ATTN_NORM, 0, iPitch );
2016-06-04 15:24:23 +02:00
break;
case 1:
2016-07-31 15:48:50 +02:00
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle2.wav", 1, ATTN_NORM, 0, iPitch );
2016-06-04 15:24:23 +02:00
break;
}
}
//=========================================================
// SetYawSpeed - allows each sequence to have a different
// turn rate associated with it.
//=========================================================
2016-07-31 15:48:50 +02:00
void CBullsquid::SetYawSpeed( void )
2016-06-04 15:24:23 +02:00
{
int ys;
ys = 0;
2019-10-13 13:49:25 +02:00
switch( m_Activity )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
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;
2016-06-04 15:24:23 +02:00
default:
ys = 90;
break;
}
pev->yaw_speed = ys;
}
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//=========================================================
2016-07-31 15:48:50 +02:00
void CBullsquid::HandleAnimEvent( MonsterEvent_t *pEvent )
2016-06-04 15:24:23 +02:00
{
switch( pEvent->event )
{
case BSQUID_AE_SPIT:
{
2020-03-21 14:45:13 +01:00
if( m_hEnemy == 0 )
return;
2016-07-31 15:48:50 +02:00
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.
2019-10-13 13:49:25 +02:00
vecSpitOffset = ( gpGlobals->v_right * 8.0f + gpGlobals->v_forward * 37.0f + gpGlobals->v_up * 23.0f );
2016-07-31 15:48:50 +02:00
vecSpitOffset = ( pev->origin + vecSpitOffset );
vecSpitDir = ( ( m_hEnemy->pev->origin + m_hEnemy->pev->view_ofs ) - vecSpitOffset ).Normalize();
2019-10-13 13:49:25 +02:00
vecSpitDir.x += RANDOM_FLOAT( -0.05f, 0.05f );
vecSpitDir.y += RANDOM_FLOAT( -0.05f, 0.05f );
vecSpitDir.z += RANDOM_FLOAT( -0.05f, 0.0f );
2016-07-31 15:48:50 +02:00
// 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();
2019-10-13 13:49:25 +02:00
CSquidSpit::Shoot( pev, vecSpitOffset, vecSpitDir * 900.0f );
2016-06-04 15:24:23 +02:00
}
2016-07-31 15:48:50 +02:00
break;
case BSQUID_AE_BITE:
{
// SOUND HERE!
CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.bullsquidDmgBite, DMG_SLASH );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
if( pHurt )
{
2019-10-13 13:49:25 +02:00
//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;
2016-07-31 15:48:50 +02:00
}
}
break;
2016-06-04 15:24:23 +02:00
case BSQUID_AE_TAILWHIP:
{
2016-07-31 15:48:50 +02:00
CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.bullsquidDmgWhip, DMG_CLUB | DMG_ALWAYSGIB );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
if( pHurt )
{
2019-10-13 13:49:25 +02:00
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;
2016-07-31 15:48:50 +02:00
}
}
break;
2016-06-04 15:24:23 +02:00
case BSQUID_AE_BLINK:
{
2016-07-31 15:48:50 +02:00
// close eye.
pev->skin = 1;
2016-06-04 15:24:23 +02:00
}
2016-07-31 15:48:50 +02:00
break;
case BSQUID_AE_HOP:
{
float flGravity = g_psv_gravity->value;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
// throw the squid up into the air on this frame.
if( FBitSet( pev->flags, FL_ONGROUND ) )
{
pev->flags -= FL_ONGROUND;
}
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
// jump into air for 0.8 (24/30) seconds
2019-10-13 13:49:25 +02:00
//pev->velocity.z += ( 0.875f * flGravity ) * 0.5f;
pev->velocity.z += ( 0.625f * flGravity ) * 0.5f;
2016-07-31 15:48:50 +02:00
}
break;
2016-06-04 15:24:23 +02:00
case BSQUID_AE_THROW:
{
int iPitch;
// squid throws its prey IF the prey is a client.
CBaseEntity *pHurt = CheckTraceHullAttack( 70, 0, 0 );
2016-07-31 15:48:50 +02:00
if( pHurt )
2016-06-04 15:24:23 +02:00
{
// croonchy bite sound
2019-10-13 13:49:25 +02:00
iPitch = RANDOM_FLOAT( 90.0f, 110.0f );
2016-07-31 15:48:50 +02:00
switch( RANDOM_LONG( 0, 1 ) )
2016-06-04 15:24:23 +02:00
{
case 0:
2019-10-13 13:49:25 +02:00
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_bite2.wav", 1.0f, ATTN_NORM, 0, iPitch );
2016-06-04 15:24:23 +02:00
break;
case 1:
2019-10-13 13:49:25 +02:00
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_bite3.wav", 1.0f, ATTN_NORM, 0, iPitch );
2016-06-04 15:24:23 +02:00
break;
}
2016-07-31 15:48:50 +02:00
//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;
2016-06-04 15:24:23 +02:00
// screeshake transforms the viewmodel as well as the viewangle. No problems with seeing the ends of the viewmodels.
2019-10-13 13:49:25 +02:00
UTIL_ScreenShake( pHurt->pev->origin, 25.0f, 1.5f, 0.7f, 2.0f );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
if( pHurt->IsPlayer() )
2016-06-04 15:24:23 +02:00
{
UTIL_MakeVectors( pev->angles );
2019-10-13 13:49:25 +02:00
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_forward * 300.0f + gpGlobals->v_up * 300.0f;
2016-06-04 15:24:23 +02:00
}
}
}
2016-07-31 15:48:50 +02:00
break;
2016-06-04 15:24:23 +02:00
default:
CBaseMonster::HandleAnimEvent( pEvent );
}
}
//=========================================================
// Spawn
//=========================================================
2016-07-31 15:48:50 +02:00
void CBullsquid::Spawn()
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
Precache();
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
SET_MODEL( ENT( pev ), "models/bullsquid.mdl" );
2019-10-13 13:49:25 +02:00
UTIL_SetSize( pev, Vector( -32.0f, -32.0f, 0.0f ), Vector( 32.0f, 32.0f, 64.0f ) );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_STEP;
m_bloodColor = BLOOD_COLOR_GREEN;
pev->effects = 0;
pev->health = gSkillData.bullsquidHealth;
2019-10-13 13:49:25 +02:00
m_flFieldOfView = 0.2f;// indicates the width of this monster's forward view cone ( as a dotproduct result )
2016-07-31 15:48:50 +02:00
m_MonsterState = MONSTERSTATE_NONE;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
m_fCanThreatDisplay = TRUE;
2016-06-04 15:24:23 +02:00
m_flNextSpitTime = gpGlobals->time;
MonsterInit();
}
//=========================================================
// Precache - precaches all resources this monster needs
//=========================================================
2016-07-31 15:48:50 +02:00
void CBullsquid::Precache()
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
PRECACHE_MODEL( "models/bullsquid.mdl" );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
PRECACHE_MODEL( "sprites/bigspit.spr" );// spit projectile.
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
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" );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
PRECACHE_SOUND( "bullchicken/bc_attackgrowl.wav" );
PRECACHE_SOUND( "bullchicken/bc_attackgrowl2.wav" );
PRECACHE_SOUND( "bullchicken/bc_attackgrowl3.wav" );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
PRECACHE_SOUND( "bullchicken/bc_acid1.wav" );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
PRECACHE_SOUND( "bullchicken/bc_bite2.wav" );
PRECACHE_SOUND( "bullchicken/bc_bite3.wav" );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
PRECACHE_SOUND( "bullchicken/bc_spithit1.wav" );
PRECACHE_SOUND( "bullchicken/bc_spithit2.wav" );
}
2016-06-04 15:24:23 +02:00
//=========================================================
// DeathSound
//=========================================================
2016-07-31 15:48:50 +02:00
void CBullsquid::DeathSound( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
switch( RANDOM_LONG( 0, 2 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
case 0:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_die1.wav", 1, ATTN_NORM );
2016-06-04 15:24:23 +02:00
break;
case 1:
2016-07-31 15:48:50 +02:00
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_die2.wav", 1, ATTN_NORM );
2016-06-04 15:24:23 +02:00
break;
case 2:
2016-07-31 15:48:50 +02:00
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_die3.wav", 1, ATTN_NORM );
2016-06-04 15:24:23 +02:00
break;
}
}
//=========================================================
// AttackSound
//=========================================================
2016-07-31 15:48:50 +02:00
void CBullsquid::AttackSound( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
switch( RANDOM_LONG( 0, 1 ) )
2016-06-04 15:24:23 +02:00
{
case 0:
2016-07-31 15:48:50 +02:00
EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_attack2.wav", 1, ATTN_NORM );
2016-06-04 15:24:23 +02:00
break;
case 1:
2016-07-31 15:48:50 +02:00
EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_attack3.wav", 1, ATTN_NORM );
2016-06-04 15:24:23 +02:00
break;
}
}
//========================================================
// RunAI - overridden for bullsquid because there are things
// that need to be checked every think.
//========================================================
2016-07-31 15:48:50 +02:00
void CBullsquid::RunAI( void )
2016-06-04 15:24:23 +02:00
{
// first, do base class stuff
2016-07-31 15:48:50 +02:00
CBaseMonster::RunAI();
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
if( pev->skin != 0 )
2016-06-04 15:24:23 +02:00
{
// close eye if it was open.
pev->skin = 0;
}
2016-07-31 15:48:50 +02:00
if( RANDOM_LONG( 0, 39 ) == 0 )
2016-06-04 15:24:23 +02:00
{
pev->skin = 1;
}
2017-06-29 15:56:03 +02:00
if( m_hEnemy != 0 && m_Activity == ACT_RUN )
2016-06-04 15:24:23 +02:00
{
// chasing enemy. Sprint for last bit
2016-07-31 15:48:50 +02:00
if( ( pev->origin - m_hEnemy->pev->origin).Length2D() < SQUID_SPRINT_DIST )
2016-06-04 15:24:23 +02:00
{
2019-10-13 13:49:25 +02:00
pev->framerate = 1.25f;
2016-06-04 15:24:23 +02:00
}
}
}
//========================================================
// AI Schedules Specific to this monster
//=========================================================
// primary range attack
2016-07-31 15:48:50 +02:00
Task_t tlSquidRangeAttack1[] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{ TASK_STOP_MOVING, 0 },
2019-10-13 13:49:25 +02:00
{ TASK_FACE_IDEAL, 0.0f },
{ TASK_RANGE_ATTACK1, 0.0f },
2016-07-31 15:48:50 +02:00
{ TASK_SET_ACTIVITY, (float)ACT_IDLE },
2016-06-04 15:24:23 +02:00
};
2016-07-31 15:48:50 +02:00
Schedule_t slSquidRangeAttack1[] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlSquidRangeAttack1,
2016-07-31 15:48:50 +02:00
ARRAYSIZE( tlSquidRangeAttack1 ),
bits_COND_NEW_ENEMY |
bits_COND_ENEMY_DEAD |
bits_COND_HEAVY_DAMAGE |
bits_COND_ENEMY_OCCLUDED |
2016-06-04 15:24:23 +02:00
bits_COND_NO_AMMO_LOADED,
0,
"Squid Range Attack1"
},
};
// Chase enemy schedule
2016-07-31 15:48:50 +02:00
Task_t tlSquidChaseEnemy1[] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{ TASK_SET_FAIL_SCHEDULE, (float)SCHED_RANGE_ATTACK1 },// !!!OEM - this will stop nasty squid oscillation.
2019-10-13 13:49:25 +02:00
{ TASK_GET_PATH_TO_ENEMY, 0.0f },
{ TASK_RUN_PATH, 0.0f },
{ TASK_WAIT_FOR_MOVEMENT, 0.0f },
2016-06-04 15:24:23 +02:00
};
Schedule_t slSquidChaseEnemy[] =
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlSquidChaseEnemy1,
2016-07-31 15:48:50 +02:00
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 |
2016-06-04 15:24:23 +02:00
bits_COND_HEAR_SOUND,
2016-07-31 15:48:50 +02:00
bits_SOUND_DANGER |
2016-06-04 15:24:23 +02:00
bits_SOUND_MEAT,
"Squid Chase Enemy"
},
};
Task_t tlSquidHurtHop[] =
{
2019-10-13 13:49:25 +02:00
{ 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.
2016-06-04 15:24:23 +02:00
};
Schedule_t slSquidHurtHop[] =
{
{
tlSquidHurtHop,
2016-07-31 15:48:50 +02:00
ARRAYSIZE( tlSquidHurtHop ),
2016-06-04 15:24:23 +02:00
0,
0,
"SquidHurtHop"
}
};
Task_t tlSquidSeeCrab[] =
{
2019-10-13 13:49:25 +02:00
{ TASK_STOP_MOVING, 0.0f },
{ TASK_SOUND_WAKE, 0.0f },
2016-07-31 15:48:50 +02:00
{ TASK_PLAY_SEQUENCE, (float)ACT_EXCITED },
2019-10-13 13:49:25 +02:00
{ TASK_FACE_ENEMY, 0.0f },
2016-06-04 15:24:23 +02:00
};
Schedule_t slSquidSeeCrab[] =
{
{
tlSquidSeeCrab,
2016-07-31 15:48:50 +02:00
ARRAYSIZE( tlSquidSeeCrab ),
bits_COND_LIGHT_DAMAGE |
2016-06-04 15:24:23 +02:00
bits_COND_HEAVY_DAMAGE,
0,
"SquidSeeCrab"
}
};
// squid walks to something tasty and eats it.
Task_t tlSquidEat[] =
{
2019-10-13 13:49:25 +02:00
{ 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 },
2016-07-31 15:48:50 +02:00
{ TASK_PLAY_SEQUENCE, (float)ACT_EAT },
{ TASK_PLAY_SEQUENCE, (float)ACT_EAT },
{ TASK_PLAY_SEQUENCE, (float)ACT_EAT },
2019-10-13 13:49:25 +02:00
{ 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 },
2016-06-04 15:24:23 +02:00
};
Schedule_t slSquidEat[] =
{
{
tlSquidEat,
ARRAYSIZE( tlSquidEat ),
2016-07-31 15:48:50 +02:00
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE |
bits_COND_NEW_ENEMY,
2016-06-04 15:24:23 +02:00
// 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.
2016-07-31 15:48:50 +02:00
bits_SOUND_MEAT |
2016-06-04 15:24:23 +02:00
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[] =
{
2019-10-13 13:49:25 +02:00
{ TASK_STOP_MOVING, 0.0f },
{ TASK_EAT, 10.0f },// this is in case the squid can't get to the food
2016-07-31 15:48:50 +02:00
{ TASK_PLAY_SEQUENCE, (float)ACT_DETECT_SCENT },
2019-10-13 13:49:25 +02:00
{ TASK_STORE_LASTPOSITION, 0.0f },
{ TASK_GET_PATH_TO_BESTSCENT, 0.0f },
{ TASK_WALK_PATH, 0.0f },
{ TASK_WAIT_FOR_MOVEMENT, 0.0f },
2016-07-31 15:48:50 +02:00
{ TASK_PLAY_SEQUENCE, (float)ACT_EAT },
{ TASK_PLAY_SEQUENCE, (float)ACT_EAT },
{ TASK_PLAY_SEQUENCE, (float)ACT_EAT },
2019-10-13 13:49:25 +02:00
{ 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 },
2016-06-04 15:24:23 +02:00
};
Schedule_t slSquidSniffAndEat[] =
{
{
tlSquidSniffAndEat,
ARRAYSIZE( tlSquidSniffAndEat ),
2016-07-31 15:48:50 +02:00
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE |
bits_COND_NEW_ENEMY,
2016-06-04 15:24:23 +02:00
// 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.
2016-07-31 15:48:50 +02:00
bits_SOUND_MEAT |
2016-06-04 15:24:23 +02:00
bits_SOUND_CARCASS,
"SquidSniffAndEat"
}
};
// squid does this to stinky things.
Task_t tlSquidWallow[] =
{
2019-10-13 13:49:25 +02:00
{ 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 },
2016-07-31 15:48:50 +02:00
{ TASK_PLAY_SEQUENCE, (float)ACT_INSPECT_FLOOR },
2019-10-13 13:49:25 +02:00
{ 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 },
2016-06-04 15:24:23 +02:00
};
Schedule_t slSquidWallow[] =
{
{
tlSquidWallow,
ARRAYSIZE( tlSquidWallow ),
2016-07-31 15:48:50 +02:00
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE |
bits_COND_NEW_ENEMY,
2016-06-04 15:24:23 +02:00
// 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 )
2016-06-04 15:24:23 +02:00
//=========================================================
// GetSchedule
//=========================================================
2016-07-31 15:48:50 +02:00
Schedule_t *CBullsquid::GetSchedule( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
switch( m_MonsterState )
2016-06-04 15:24:23 +02:00
{
case MONSTERSTATE_ALERT:
{
2016-07-31 15:48:50 +02:00
if( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
return GetScheduleOfType( SCHED_SQUID_HURTHOP );
2016-06-04 15:24:23 +02:00
}
2016-07-31 15:48:50 +02:00
if( HasConditions( bits_COND_SMELL_FOOD ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
CSound *pSound;
2016-06-04 15:24:23 +02:00
pSound = PBestScent();
2016-07-31 15:48:50 +02:00
if( pSound && ( !FInViewCone( &pSound->m_vecOrigin ) || !FVisible( pSound->m_vecOrigin ) ) )
2016-06-04 15:24:23 +02:00
{
// 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 );
}
2016-07-31 15:48:50 +02:00
if( HasConditions( bits_COND_SMELL ) )
2016-06-04 15:24:23 +02:00
{
// there's something stinky.
2016-07-31 15:48:50 +02:00
CSound *pSound;
2016-06-04 15:24:23 +02:00
pSound = PBestScent();
2016-07-31 15:48:50 +02:00
if( pSound )
return GetScheduleOfType( SCHED_SQUID_WALLOW );
2016-06-04 15:24:23 +02:00
}
break;
}
case MONSTERSTATE_COMBAT:
{
2016-06-13 16:29:45 +02:00
// dead enemy
2016-07-31 15:48:50 +02:00
if( HasConditions( bits_COND_ENEMY_DEAD ) )
2016-06-04 15:24:23 +02:00
{
// call base class, all code to handle dead enemies is centralized there.
2016-07-31 15:48:50 +02:00
return CBaseMonster::GetSchedule();
2016-06-04 15:24:23 +02:00
}
2016-07-31 15:48:50 +02:00
if( HasConditions( bits_COND_NEW_ENEMY ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if( m_fCanThreatDisplay && IRelationship( m_hEnemy ) == R_HT )
2016-06-04 15:24:23 +02:00
{
// this means squid sees a headcrab!
m_fCanThreatDisplay = FALSE;// only do the headcrab dance once per lifetime.
2016-07-31 15:48:50 +02:00
return GetScheduleOfType( SCHED_SQUID_SEECRAB );
2016-06-04 15:24:23 +02:00
}
else
{
2016-07-31 15:48:50 +02:00
return GetScheduleOfType( SCHED_WAKE_ANGRY );
2016-06-04 15:24:23 +02:00
}
}
2016-07-31 15:48:50 +02:00
if( HasConditions( bits_COND_SMELL_FOOD ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
CSound *pSound;
2016-06-04 15:24:23 +02:00
pSound = PBestScent();
2016-07-31 15:48:50 +02:00
if( pSound && ( !FInViewCone( &pSound->m_vecOrigin ) || !FVisible( pSound->m_vecOrigin ) ) )
2016-06-04 15:24:23 +02:00
{
// 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 );
}
2016-07-31 15:48:50 +02:00
if( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
return GetScheduleOfType( SCHED_RANGE_ATTACK1 );
2016-06-04 15:24:23 +02:00
}
2016-07-31 15:48:50 +02:00
if( HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
return GetScheduleOfType( SCHED_MELEE_ATTACK1 );
2016-06-04 15:24:23 +02:00
}
2016-07-31 15:48:50 +02:00
if( HasConditions( bits_COND_CAN_MELEE_ATTACK2 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
return GetScheduleOfType( SCHED_MELEE_ATTACK2 );
2016-06-04 15:24:23 +02:00
}
2016-07-31 15:48:50 +02:00
return GetScheduleOfType( SCHED_CHASE_ENEMY );
2016-06-04 15:24:23 +02:00
break;
}
2016-06-13 16:29:45 +02:00
default:
break;
2016-06-04 15:24:23 +02:00
}
2016-07-31 15:48:50 +02:00
return CBaseMonster::GetSchedule();
2016-06-04 15:24:23 +02:00
}
//=========================================================
// GetScheduleOfType
//=========================================================
2016-07-31 15:48:50 +02:00
Schedule_t *CBullsquid::GetScheduleOfType( int Type )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
switch( Type )
2016-06-04 15:24:23 +02:00
{
case SCHED_RANGE_ATTACK1:
2016-07-31 15:48:50 +02:00
return &slSquidRangeAttack1[0];
2016-06-04 15:24:23 +02:00
break;
case SCHED_SQUID_HURTHOP:
2016-07-31 15:48:50 +02:00
return &slSquidHurtHop[0];
2016-06-04 15:24:23 +02:00
break;
case SCHED_SQUID_SEECRAB:
2016-07-31 15:48:50 +02:00
return &slSquidSeeCrab[0];
2016-06-04 15:24:23 +02:00
break;
case SCHED_SQUID_EAT:
2016-07-31 15:48:50 +02:00
return &slSquidEat[0];
2016-06-04 15:24:23 +02:00
break;
case SCHED_SQUID_SNIFF_AND_EAT:
2016-07-31 15:48:50 +02:00
return &slSquidSniffAndEat[0];
2016-06-04 15:24:23 +02:00
break;
case SCHED_SQUID_WALLOW:
2016-07-31 15:48:50 +02:00
return &slSquidWallow[0];
2016-06-04 15:24:23 +02:00
break;
case SCHED_CHASE_ENEMY:
2016-07-31 15:48:50 +02:00
return &slSquidChaseEnemy[0];
2016-06-04 15:24:23 +02:00
break;
}
2016-07-31 15:48:50 +02:00
return CBaseMonster::GetScheduleOfType( Type );
2016-06-04 15:24:23 +02:00
}
//=========================================================
// 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.
//=========================================================
2016-07-31 15:48:50 +02:00
void CBullsquid::StartTask( Task_t *pTask )
2016-06-04 15:24:23 +02:00
{
m_iTaskStatus = TASKSTATUS_RUNNING;
2016-07-31 15:48:50 +02:00
switch( pTask->iTask )
2016-06-04 15:24:23 +02:00
{
case TASK_MELEE_ATTACK2:
{
2016-07-31 15:48:50 +02:00
switch( RANDOM_LONG( 0, 2 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
case 0:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_attackgrowl.wav", 1, ATTN_NORM );
2016-06-04 15:24:23 +02:00
break;
2016-07-31 15:48:50 +02:00
case 1:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_attackgrowl2.wav", 1, ATTN_NORM );
2016-06-04 15:24:23 +02:00
break;
2016-07-31 15:48:50 +02:00
case 2:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_attackgrowl3.wav", 1, ATTN_NORM );
2016-06-04 15:24:23 +02:00
break;
}
2016-07-31 15:48:50 +02:00
CBaseMonster::StartTask( pTask );
2016-06-04 15:24:23 +02:00
break;
}
case TASK_SQUID_HOPTURN:
{
2016-07-31 15:48:50 +02:00
SetActivity( ACT_HOP );
MakeIdealYaw( m_vecEnemyLKP );
2016-06-04 15:24:23 +02:00
break;
}
case TASK_GET_PATH_TO_ENEMY:
{
2016-07-31 15:48:50 +02:00
if( BuildRoute( m_hEnemy->pev->origin, bits_MF_TO_ENEMY, m_hEnemy ) )
2016-06-04 15:24:23 +02:00
{
m_iTaskStatus = TASKSTATUS_COMPLETE;
}
else
{
2016-07-31 15:48:50 +02:00
ALERT( at_aiconsole, "GetPathToEnemy failed!!\n" );
2016-06-04 15:24:23 +02:00
TaskFail();
}
break;
}
default:
{
2016-07-31 15:48:50 +02:00
CBaseMonster::StartTask( pTask );
2016-06-04 15:24:23 +02:00
break;
}
}
}
//=========================================================
// RunTask
//=========================================================
2016-07-31 15:48:50 +02:00
void CBullsquid::RunTask( Task_t *pTask )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
switch( pTask->iTask )
2016-06-04 15:24:23 +02:00
{
case TASK_SQUID_HOPTURN:
{
MakeIdealYaw( m_vecEnemyLKP );
ChangeYaw( pev->yaw_speed );
2016-07-31 15:48:50 +02:00
if( m_fSequenceFinished )
2016-06-04 15:24:23 +02:00
{
m_iTaskStatus = TASKSTATUS_COMPLETE;
}
break;
}
default:
{
2016-07-31 15:48:50 +02:00
CBaseMonster::RunTask( pTask );
2016-06-04 15:24:23 +02:00
break;
}
}
}
//=========================================================
// GetIdealState - Overridden for Bullsquid to deal with
// the feature that makes it lose interest in headcrabs for
// a while if something injures it.
//=========================================================
2016-07-31 15:48:50 +02:00
MONSTERSTATE CBullsquid::GetIdealState( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
int iConditions;
2016-06-04 15:24:23 +02:00
iConditions = IScheduleFlags();
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
// If no schedule conditions, the new ideal state is probably the reason we're in here.
2016-07-31 15:48:50 +02:00
switch( m_MonsterState )
2016-06-04 15:24:23 +02:00
{
case MONSTERSTATE_COMBAT:
/*
COMBAT goes to ALERT upon death of enemy
*/
{
2017-06-29 15:56:03 +02:00
if( m_hEnemy != 0 && ( iConditions & bits_COND_LIGHT_DAMAGE || iConditions & bits_COND_HEAVY_DAMAGE ) && FClassnameIs( m_hEnemy->pev, "monster_headcrab" ) )
2016-06-04 15:24:23 +02:00
{
// 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;
}
2016-06-13 16:29:45 +02:00
default:
break;
2016-06-04 15:24:23 +02:00
}
2016-07-31 15:48:50 +02:00
m_IdealMonsterState = CBaseMonster::GetIdealState();
2016-06-04 15:24:23 +02:00
return m_IdealMonsterState;
}