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.

1212 lines
32 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"
#include "bullsquid.h"
9 years ago
#define SQUID_SPRINT_DIST 256 // how close the squid has to get before starting to sprint and refusing to swerve
8 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
//=========================================================
LINK_ENTITY_TO_CLASS( squidspit, CSquidSpit )
9 years ago
8 years ago
TYPEDESCRIPTION CSquidSpit::m_SaveData[] =
9 years ago
{
DEFINE_FIELD( CSquidSpit, m_maxFrame, FIELD_INTEGER ),
};
IMPLEMENT_SAVERESTORE( CSquidSpit, CBaseEntity )
9 years ago
8 years ago
void CSquidSpit::Spawn( void )
9 years ago
{
pev->movetype = MOVETYPE_FLY;
pev->classname = MAKE_STRING( "squidspit" );
8 years ago
9 years ago
pev->solid = SOLID_BBOX;
pev->rendermode = kRenderTransAlpha;
pev->renderamt = 255;
8 years ago
SET_MODEL( ENT( pev ), "sprites/bigspit.spr" );
9 years ago
pev->frame = 0;
pev->scale = 0.5;
8 years ago
UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) );
9 years ago
8 years ago
m_maxFrame = (float)MODEL_FRAMES( pev->modelindex ) - 1;
9 years ago
}
void CSquidSpit::Animate( void )
{
pev->nextthink = gpGlobals->time + 0.1;
8 years ago
if( pev->frame++ )
9 years ago
{
8 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();
8 years ago
9 years ago
UTIL_SetOrigin( pSpit->pev, vecStart );
pSpit->pev->velocity = vecVelocity;
8 years ago
pSpit->pev->owner = ENT( pevOwner );
9 years ago
pSpit->SetThink( &CSquidSpit::Animate );
pSpit->pev->nextthink = gpGlobals->time + 0.1;
}
8 years ago
void CSquidSpit::Touch( CBaseEntity *pOther )
9 years ago
{
TraceResult tr;
8 years ago
int iPitch;
9 years ago
// splat sound
iPitch = RANDOM_FLOAT( 90, 110 );
8 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_acid1.wav", 1, ATTN_NORM, 0, iPitch );
9 years ago
8 years ago
switch( RANDOM_LONG( 0, 1 ) )
9 years ago
{
case 0:
8 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_spithit1.wav", 1, ATTN_NORM, 0, iPitch );
9 years ago
break;
case 1:
8 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_spithit2.wav", 1, ATTN_NORM, 0, iPitch );
9 years ago
break;
}
8 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 );
8 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 );
8 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
8 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
{
8 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 )
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
//=========================================================
8 years ago
int CBullsquid::IgnoreConditions( void )
9 years ago
{
int iIgnore = CBaseMonster::IgnoreConditions();
8 years ago
if( gpGlobals->time - m_flLastHurtTime <= 20 )
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
{
8 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.
//=========================================================
8 years ago
int CBullsquid::IRelationship( CBaseEntity *pTarget )
9 years ago
{
8 years ago
if( gpGlobals->time - m_flLastHurtTime < 5 && 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;
}
8 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
//=========================================================
8 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 )
9 years ago
{
flDist = ( pev->origin - m_hEnemy->pev->origin ).Length2D();
8 years ago
if( flDist > SQUID_SPRINT_DIST )
9 years ago
{
8 years ago
flDist = ( pev->origin - m_Route[m_iRouteIndex].vecLocation ).Length2D();// reusing flDist.
9 years ago
8 years ago
if( FTriangulate( pev->origin, m_Route[m_iRouteIndex].vecLocation, flDist * 0.5, m_hEnemy, &vecApex ) )
9 years ago
{
InsertWaypoint( vecApex, bits_MF_TO_DETOUR | bits_MF_DONT_SIMPLIFY );
}
}
}
8 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;
}
8 years ago
return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType );
9 years ago
}
//=========================================================
// CheckRangeAttack1
//=========================================================
8 years ago
BOOL CBullsquid::CheckRangeAttack1( float flDot, float flDist )
9 years ago
{
8 years ago
if( IsMoving() && flDist >= 512 )
9 years ago
{
// squid will far too far behind if he stops running to spit at this distance from the enemy.
return FALSE;
}
8 years ago
if( flDist > 64 && flDist <= 784 && flDot >= 0.5 && gpGlobals->time >= m_flNextSpitTime )
9 years ago
{
if( m_hEnemy != 0 )
9 years ago
{
8 years ago
if( fabs( pev->origin.z - m_hEnemy->pev->origin.z ) > 256 )
9 years ago
{
// don't try to spit at someone up really high or down really low.
return FALSE;
}
}
8 years ago
if( IsMoving() )
9 years ago
{
// don't spit again for a long time, resume chasing enemy.
m_flNextSpitTime = gpGlobals->time + 5;
}
else
{
// not moving, so spit again pretty soon.
m_flNextSpitTime = gpGlobals->time + 0.5;
}
return TRUE;
}
return FALSE;
}
//=========================================================
// CheckMeleeAttack1 - bullsquid is a big guy, so has a longer
// melee range than most monsters. This is the tailwhip attack
//=========================================================
8 years ago
BOOL CBullsquid::CheckMeleeAttack1( float flDot, float flDist )
9 years ago
{
8 years ago
if( m_hEnemy->pev->health <= gSkillData.bullsquidDmgWhip && flDist <= 85 && flDot >= 0.7 )
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.
//=========================================================
8 years ago
BOOL CBullsquid::CheckMeleeAttack2( float flDot, float flDist )
9 years ago
{
8 years ago
if( flDist <= 85 && flDot >= 0.7 && !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;
8 years ago
}
9 years ago
//=========================================================
// FValidateHintType
//=========================================================
8 years ago
BOOL CBullsquid::FValidateHintType( short sHint )
9 years ago
{
size_t i;
9 years ago
static short sSquidHints[] =
{
HINT_WORLD_HUMAN_BLOOD,
};
8 years ago
for( i = 0; i < ARRAYSIZE( sSquidHints ); i++ )
9 years ago
{
8 years ago
if( sSquidHints[i] == sHint )
9 years ago
{
return TRUE;
}
}
8 years ago
ALERT( at_aiconsole, "Couldn't validate hint type" );
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.
//=========================================================
8 years ago
int CBullsquid::ISoundMask( void )
9 years ago
{
8 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.
//=========================================================
8 years ago
int CBullsquid::Classify( void )
9 years ago
{
8 years ago
return CLASS_ALIEN_PREDATOR;
9 years ago
}
//=========================================================
// IdleSound
//=========================================================
#define SQUID_ATTN_IDLE (float)1.5
8 years ago
void CBullsquid::IdleSound( void )
9 years ago
{
8 years ago
switch( RANDOM_LONG( 0, 4 ) )
9 years ago
{
8 years ago
case 0:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle1.wav", 1, SQUID_ATTN_IDLE );
9 years ago
break;
8 years ago
case 1:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle2.wav", 1, SQUID_ATTN_IDLE );
9 years ago
break;
8 years ago
case 2:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle3.wav", 1, SQUID_ATTN_IDLE );
9 years ago
break;
8 years ago
case 3:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle4.wav", 1, SQUID_ATTN_IDLE );
9 years ago
break;
8 years ago
case 4:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle5.wav", 1, SQUID_ATTN_IDLE );
9 years ago
break;
}
}
//=========================================================
// PainSound
//=========================================================
8 years ago
void CBullsquid::PainSound( void )
9 years ago
{
int iPitch = RANDOM_LONG( 85, 120 );
8 years ago
switch( RANDOM_LONG( 0, 3 ) )
9 years ago
{
8 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:
8 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_pain2.wav", 1, ATTN_NORM, 0, iPitch );
9 years ago
break;
case 2:
8 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_pain3.wav", 1, ATTN_NORM, 0, iPitch );
9 years ago
break;
case 3:
8 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_pain4.wav", 1, ATTN_NORM, 0, iPitch );
9 years ago
break;
}
}
//=========================================================
// AlertSound
//=========================================================
8 years ago
void CBullsquid::AlertSound( void )
9 years ago
{
int iPitch = RANDOM_LONG( 140, 160 );
8 years ago
switch( RANDOM_LONG( 0, 1 ) )
9 years ago
{
case 0:
8 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_idle1.wav", 1, ATTN_NORM, 0, iPitch );
9 years ago
break;
case 1:
8 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.
//=========================================================
8 years ago
void CBullsquid::SetYawSpeed( void )
9 years ago
{
int ys;
ys = 0;
switch ( m_Activity )
{
8 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.
//=========================================================
8 years ago
void CBullsquid::HandleAnimEvent( MonsterEvent_t *pEvent )
9 years ago
{
switch( pEvent->event )
{
case BSQUID_AE_SPIT:
{
8 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 + gpGlobals->v_forward * 37 + gpGlobals->v_up * 23 );
vecSpitOffset = ( pev->origin + vecSpitOffset );
vecSpitDir = ( ( m_hEnemy->pev->origin + m_hEnemy->pev->view_ofs ) - vecSpitOffset ).Normalize();
vecSpitDir.x += RANDOM_FLOAT( -0.05, 0.05 );
vecSpitDir.y += RANDOM_FLOAT( -0.05, 0.05 );
vecSpitDir.z += RANDOM_FLOAT( -0.05, 0 );
// 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 );
9 years ago
}
8 years ago
break;
case BSQUID_AE_BITE:
{
// SOUND HERE!
CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.bullsquidDmgBite, DMG_SLASH );
9 years ago
8 years ago
if( pHurt )
{
//pHurt->pev->punchangle.z = -15;
//pHurt->pev->punchangle.x = -45;
pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_forward * 100;
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_up * 100;
}
}
break;
9 years ago
case BSQUID_AE_TAILWHIP:
{
8 years ago
CBaseEntity *pHurt = CheckTraceHullAttack( 70, gSkillData.bullsquidDmgWhip, DMG_CLUB | DMG_ALWAYSGIB );
9 years ago
8 years ago
if( pHurt )
{
pHurt->pev->punchangle.z = -20;
pHurt->pev->punchangle.x = 20;
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * 200;
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_up * 100;
}
}
break;
9 years ago
case BSQUID_AE_BLINK:
{
8 years ago
// close eye.
pev->skin = 1;
9 years ago
}
8 years ago
break;
case BSQUID_AE_HOP:
{
float flGravity = g_psv_gravity->value;
9 years ago
8 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
8 years ago
// jump into air for 0.8 (24/30) seconds
//pev->velocity.z += ( 0.875 * flGravity ) * 0.5;
pev->velocity.z += ( 0.625 * flGravity ) * 0.5;
}
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 );
8 years ago
if( pHurt )
9 years ago
{
// croonchy bite sound
iPitch = RANDOM_FLOAT( 90, 110 );
8 years ago
switch( RANDOM_LONG( 0, 1 ) )
9 years ago
{
case 0:
8 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_bite2.wav", 1, ATTN_NORM, 0, iPitch );
9 years ago
break;
case 1:
8 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_bite3.wav", 1, ATTN_NORM, 0, iPitch );
9 years ago
break;
}
8 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.0, 1.5, 0.7, 2 );
8 years ago
if( pHurt->IsPlayer() )
9 years ago
{
UTIL_MakeVectors( pev->angles );
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_forward * 300 + gpGlobals->v_up * 300;
}
}
}
8 years ago
break;
9 years ago
default:
CBaseMonster::HandleAnimEvent( pEvent );
}
}
//=========================================================
// Spawn
//=========================================================
8 years ago
void CBullsquid::Spawn()
9 years ago
{
8 years ago
Precache();
9 years ago
8 years ago
SET_MODEL( ENT( pev ), "models/bullsquid.mdl" );
9 years ago
UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) );
8 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.2;// indicates the width of this monster's forward view cone ( as a dotproduct result )
m_MonsterState = MONSTERSTATE_NONE;
9 years ago
8 years ago
m_fCanThreatDisplay = TRUE;
9 years ago
m_flNextSpitTime = gpGlobals->time;
MonsterInit();
}
//=========================================================
// Precache - precaches all resources this monster needs
//=========================================================
8 years ago
void CBullsquid::Precache()
9 years ago
{
8 years ago
PRECACHE_MODEL( "models/bullsquid.mdl" );
9 years ago
8 years ago
PRECACHE_MODEL( "sprites/bigspit.spr" );// spit projectile.
9 years ago
8 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
8 years ago
PRECACHE_SOUND( "bullchicken/bc_attackgrowl.wav" );
PRECACHE_SOUND( "bullchicken/bc_attackgrowl2.wav" );
PRECACHE_SOUND( "bullchicken/bc_attackgrowl3.wav" );
9 years ago
8 years ago
PRECACHE_SOUND( "bullchicken/bc_acid1.wav" );
9 years ago
8 years ago
PRECACHE_SOUND( "bullchicken/bc_bite2.wav" );
PRECACHE_SOUND( "bullchicken/bc_bite3.wav" );
9 years ago
8 years ago
PRECACHE_SOUND( "bullchicken/bc_spithit1.wav" );
PRECACHE_SOUND( "bullchicken/bc_spithit2.wav" );
}
9 years ago
//=========================================================
// DeathSound
//=========================================================
8 years ago
void CBullsquid::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, "bullchicken/bc_die1.wav", 1, ATTN_NORM );
9 years ago
break;
case 1:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_die2.wav", 1, ATTN_NORM );
9 years ago
break;
case 2:
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_die3.wav", 1, ATTN_NORM );
9 years ago
break;
}
}
//=========================================================
// AttackSound
//=========================================================
8 years ago
void CBullsquid::AttackSound( 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, "bullchicken/bc_attack2.wav", 1, ATTN_NORM );
9 years ago
break;
case 1:
8 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.
//========================================================
8 years ago
void CBullsquid::RunAI( void )
9 years ago
{
// first, do base class stuff
8 years ago
CBaseMonster::RunAI();
9 years ago
8 years ago
if( pev->skin != 0 )
9 years ago
{
// close eye if it was open.
pev->skin = 0;
}
8 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
8 years ago
if( ( pev->origin - m_hEnemy->pev->origin).Length2D() < SQUID_SPRINT_DIST )
9 years ago
{
pev->framerate = 1.25;
}
}
}
//========================================================
// AI Schedules Specific to this monster
//=========================================================
// primary range attack
8 years ago
Task_t tlSquidRangeAttack1[] =
9 years ago
{
8 years ago
{ TASK_STOP_MOVING, 0 },
{ TASK_FACE_IDEAL, (float)0 },
{ TASK_RANGE_ATTACK1, (float)0 },
{ TASK_SET_ACTIVITY, (float)ACT_IDLE },
9 years ago
};
8 years ago
Schedule_t slSquidRangeAttack1[] =
9 years ago
{
8 years ago
{
9 years ago
tlSquidRangeAttack1,
8 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
8 years ago
Task_t tlSquidChaseEnemy1[] =
9 years ago
{
8 years ago
{ TASK_SET_FAIL_SCHEDULE, (float)SCHED_RANGE_ATTACK1 },// !!!OEM - this will stop nasty squid oscillation.
{ TASK_GET_PATH_TO_ENEMY, (float)0 },
{ TASK_RUN_PATH, (float)0 },
{ TASK_WAIT_FOR_MOVEMENT, (float)0 },
9 years ago
};
Schedule_t slSquidChaseEnemy[] =
{
8 years ago
{
9 years ago
tlSquidChaseEnemy1,
8 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,
8 years ago
bits_SOUND_DANGER |
9 years ago
bits_SOUND_MEAT,
"Squid Chase Enemy"
},
};
Task_t tlSquidHurtHop[] =
{
8 years ago
{ TASK_STOP_MOVING, (float)0 },
{ TASK_SOUND_WAKE, (float)0 },
{ TASK_SQUID_HOPTURN, (float)0 },
{ TASK_FACE_ENEMY, (float)0 },// in case squid didn't turn all the way in the air.
9 years ago
};
Schedule_t slSquidHurtHop[] =
{
{
tlSquidHurtHop,
8 years ago
ARRAYSIZE( tlSquidHurtHop ),
9 years ago
0,
0,
"SquidHurtHop"
}
};
Task_t tlSquidSeeCrab[] =
{
8 years ago
{ TASK_STOP_MOVING, (float)0 },
{ TASK_SOUND_WAKE, (float)0 },
{ TASK_PLAY_SEQUENCE, (float)ACT_EXCITED },
{ TASK_FACE_ENEMY, (float)0 },
9 years ago
};
Schedule_t slSquidSeeCrab[] =
{
{
tlSquidSeeCrab,
8 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[] =
{
8 years ago
{ TASK_STOP_MOVING, (float)0 },
{ TASK_EAT, (float)10 },// this is in case the squid can't get to the food
{ TASK_STORE_LASTPOSITION, (float)0 },
{ TASK_GET_PATH_TO_BESTSCENT, (float)0 },
{ TASK_WALK_PATH, (float)0 },
{ TASK_WAIT_FOR_MOVEMENT, (float)0 },
{ TASK_PLAY_SEQUENCE, (float)ACT_EAT },
{ TASK_PLAY_SEQUENCE, (float)ACT_EAT },
{ TASK_PLAY_SEQUENCE, (float)ACT_EAT },
{ TASK_EAT, (float)50 },
{ TASK_GET_PATH_TO_LASTPOSITION, (float)0 },
{ TASK_WALK_PATH, (float)0 },
{ TASK_WAIT_FOR_MOVEMENT, (float)0 },
{ TASK_CLEAR_LASTPOSITION, (float)0 },
9 years ago
};
Schedule_t slSquidEat[] =
{
{
tlSquidEat,
ARRAYSIZE( tlSquidEat ),
8 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.
8 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[] =
{
8 years ago
{ TASK_STOP_MOVING, (float)0 },
{ TASK_EAT, (float)10 },// this is in case the squid can't get to the food
{ TASK_PLAY_SEQUENCE, (float)ACT_DETECT_SCENT },
{ TASK_STORE_LASTPOSITION, (float)0 },
{ TASK_GET_PATH_TO_BESTSCENT, (float)0 },
{ TASK_WALK_PATH, (float)0 },
{ TASK_WAIT_FOR_MOVEMENT, (float)0 },
{ TASK_PLAY_SEQUENCE, (float)ACT_EAT },
{ TASK_PLAY_SEQUENCE, (float)ACT_EAT },
{ TASK_PLAY_SEQUENCE, (float)ACT_EAT },
{ TASK_EAT, (float)50 },
{ TASK_GET_PATH_TO_LASTPOSITION, (float)0 },
{ TASK_WALK_PATH, (float)0 },
{ TASK_WAIT_FOR_MOVEMENT, (float)0 },
{ TASK_CLEAR_LASTPOSITION, (float)0 },
9 years ago
};
Schedule_t slSquidSniffAndEat[] =
{
{
tlSquidSniffAndEat,
ARRAYSIZE( tlSquidSniffAndEat ),
8 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.
8 years ago
bits_SOUND_MEAT |
9 years ago
bits_SOUND_CARCASS,
"SquidSniffAndEat"
}
};
// squid does this to stinky things.
Task_t tlSquidWallow[] =
{
8 years ago
{ TASK_STOP_MOVING, (float)0 },
{ TASK_EAT, (float)10 },// this is in case the squid can't get to the stinkiness
{ TASK_STORE_LASTPOSITION, (float)0 },
{ TASK_GET_PATH_TO_BESTSCENT, (float)0 },
{ TASK_WALK_PATH, (float)0 },
{ TASK_WAIT_FOR_MOVEMENT, (float)0 },
{ TASK_PLAY_SEQUENCE, (float)ACT_INSPECT_FLOOR },
{ TASK_EAT, (float)50 },// keeps squid from eating or sniffing anything else for a while.
{ TASK_GET_PATH_TO_LASTPOSITION, (float)0 },
{ TASK_WALK_PATH, (float)0 },
{ TASK_WAIT_FOR_MOVEMENT, (float)0 },
{ TASK_CLEAR_LASTPOSITION, (float)0 },
9 years ago
};
Schedule_t slSquidWallow[] =
{
{
tlSquidWallow,
ARRAYSIZE( tlSquidWallow ),
8 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
//=========================================================
8 years ago
Schedule_t *CBullsquid::GetSchedule( void )
9 years ago
{
8 years ago
switch( m_MonsterState )
9 years ago
{
case MONSTERSTATE_ALERT:
{
8 years ago
if( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) )
9 years ago
{
8 years ago
return GetScheduleOfType( SCHED_SQUID_HURTHOP );
9 years ago
}
8 years ago
if( HasConditions( bits_COND_SMELL_FOOD ) )
9 years ago
{
8 years ago
CSound *pSound;
9 years ago
pSound = PBestScent();
8 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 );
}
8 years ago
if( HasConditions( bits_COND_SMELL ) )
9 years ago
{
// there's something stinky.
8 years ago
CSound *pSound;
9 years ago
pSound = PBestScent();
8 years ago
if( pSound )
return GetScheduleOfType( SCHED_SQUID_WALLOW );
9 years ago
}
break;
}
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_NEW_ENEMY ) )
9 years ago
{
8 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.
8 years ago
return GetScheduleOfType( SCHED_SQUID_SEECRAB );
9 years ago
}
else
{
8 years ago
return GetScheduleOfType( SCHED_WAKE_ANGRY );
9 years ago
}
}
8 years ago
if( HasConditions( bits_COND_SMELL_FOOD ) )
9 years ago
{
8 years ago
CSound *pSound;
9 years ago
pSound = PBestScent();
8 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 );
}
8 years ago
if( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) )
9 years ago
{
8 years ago
return GetScheduleOfType( SCHED_RANGE_ATTACK1 );
9 years ago
}
8 years ago
if( HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) )
9 years ago
{
8 years ago
return GetScheduleOfType( SCHED_MELEE_ATTACK1 );
9 years ago
}
8 years ago
if( HasConditions( bits_COND_CAN_MELEE_ATTACK2 ) )
9 years ago
{
8 years ago
return GetScheduleOfType( SCHED_MELEE_ATTACK2 );
9 years ago
}
8 years ago
return GetScheduleOfType( SCHED_CHASE_ENEMY );
9 years ago
break;
}
default:
break;
9 years ago
}
8 years ago
return CBaseMonster::GetSchedule();
9 years ago
}
//=========================================================
// GetScheduleOfType
//=========================================================
8 years ago
Schedule_t *CBullsquid::GetScheduleOfType( int Type )
9 years ago
{
8 years ago
switch( Type )
9 years ago
{
case SCHED_RANGE_ATTACK1:
8 years ago
return &slSquidRangeAttack1[0];
9 years ago
break;
case SCHED_SQUID_HURTHOP:
8 years ago
return &slSquidHurtHop[0];
9 years ago
break;
case SCHED_SQUID_SEECRAB:
8 years ago
return &slSquidSeeCrab[0];
9 years ago
break;
case SCHED_SQUID_EAT:
8 years ago
return &slSquidEat[0];
9 years ago
break;
case SCHED_SQUID_SNIFF_AND_EAT:
8 years ago
return &slSquidSniffAndEat[0];
9 years ago
break;
case SCHED_SQUID_WALLOW:
8 years ago
return &slSquidWallow[0];
9 years ago
break;
case SCHED_CHASE_ENEMY:
8 years ago
return &slSquidChaseEnemy[0];
9 years ago
break;
}
8 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.
//=========================================================
8 years ago
void CBullsquid::StartTask( Task_t *pTask )
9 years ago
{
m_iTaskStatus = TASKSTATUS_RUNNING;
8 years ago
switch( pTask->iTask )
9 years ago
{
case TASK_MELEE_ATTACK2:
{
8 years ago
switch( RANDOM_LONG( 0, 2 ) )
9 years ago
{
8 years ago
case 0:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_attackgrowl.wav", 1, ATTN_NORM );
9 years ago
break;
8 years ago
case 1:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_attackgrowl2.wav", 1, ATTN_NORM );
9 years ago
break;
8 years ago
case 2:
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "bullchicken/bc_attackgrowl3.wav", 1, ATTN_NORM );
9 years ago
break;
}
8 years ago
CBaseMonster::StartTask( pTask );
9 years ago
break;
}
case TASK_SQUID_HOPTURN:
{
8 years ago
SetActivity( ACT_HOP );
MakeIdealYaw( m_vecEnemyLKP );
9 years ago
break;
}
case TASK_GET_PATH_TO_ENEMY:
{
8 years ago
if( BuildRoute( m_hEnemy->pev->origin, bits_MF_TO_ENEMY, m_hEnemy ) )
9 years ago
{
m_iTaskStatus = TASKSTATUS_COMPLETE;
}
else
{
8 years ago
ALERT( at_aiconsole, "GetPathToEnemy failed!!\n" );
9 years ago
TaskFail();
}
break;
}
default:
{
8 years ago
CBaseMonster::StartTask( pTask );
9 years ago
break;
}
}
}
//=========================================================
// RunTask
//=========================================================
8 years ago
void CBullsquid::RunTask( Task_t *pTask )
9 years ago
{
8 years ago
switch( pTask->iTask )
9 years ago
{
case TASK_SQUID_HOPTURN:
{
MakeIdealYaw( m_vecEnemyLKP );
ChangeYaw( pev->yaw_speed );
8 years ago
if( m_fSequenceFinished )
9 years ago
{
m_iTaskStatus = TASKSTATUS_COMPLETE;
}
break;
}
default:
{
8 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.
//=========================================================
8 years ago
MONSTERSTATE CBullsquid::GetIdealState( void )
9 years ago
{
8 years ago
int iConditions;
9 years ago
iConditions = IScheduleFlags();
8 years ago
9 years ago
// If no schedule conditions, the new ideal state is probably the reason we're in here.
8 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
}
8 years ago
m_IdealMonsterState = CBaseMonster::GetIdealState();
9 years ago
return m_IdealMonsterState;
}