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.
 
 
 
 
 
 

815 lines
22 KiB

/***
*
* Copyright (c) 1996-2001, 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.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
//=========================================================
// Gonome.cpp
//=========================================================
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "schedule.h"
#include "player.h"
#include "bullsquid.h"
#include "decals.h"
#include "animation.h"
#include "studio.h"
#include "zombie.h"
#include "game.h"
int iGonomeSpitSprite;
#define GONOME_SPRINT_DIST 256 // how close the squid has to get before starting to sprint and refusing to swerve
#define GONOME_TOLERANCE_MELEE1_RANGE 85
#define GONOME_TOLERANCE_MELEE2_RANGE 48
#define GONOME_TOLERANCE_MELEE1_DOT 0.7
#define GONOME_TOLERANCE_MELEE2_DOT 0.7
#define GONOME_MELEE_ATTACK_RADIUS 70
enum
{
TASK_GONOME_GET_PATH_TO_ENEMY_CORPSE = LAST_COMMON_TASK + 1
};
//=========================================================
// Monster's Anim Events Go Here
//=========================================================
#define GONOME_AE_SLASH ( 4 )
#define GONOME_AE_THROW ( 6 )
#define GONOME_AE_SPIT ( 1 )
#define GONOME_AE_BITE ( 2 )
//=========================================================
// Gonome's guts projectile
//=========================================================
class CGonomeGuts : public CSquidSpit
{
public:
void Spawn(void);
static void Shoot(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity);
void Touch(CBaseEntity *pOther);
};
void CGonomeGuts::Spawn()
{
pev->movetype = MOVETYPE_FLY;
pev->classname = MAKE_STRING( "gonomeguts" );
pev->solid = SOLID_BBOX;
pev->rendermode = kRenderTransAlpha;
pev->renderamt = 255;
SET_MODEL( ENT( pev ), "sprites/blood_chnk.spr" );
pev->frame = 0;
pev->scale = 0.5;
UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) );
m_maxFrame = (float)MODEL_FRAMES( pev->modelindex ) - 1;
}
void CGonomeGuts::Shoot( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity )
{
CGonomeGuts *pSpit = GetClassPtr( (CGonomeGuts *)NULL );
pSpit->Spawn();
UTIL_SetOrigin( pSpit->pev, vecStart );
pSpit->pev->velocity = vecVelocity;
pSpit->pev->owner = ENT( pevOwner );
pSpit->SetThink( &CSquidSpit::Animate );
pSpit->pev->nextthink = gpGlobals->time + 0.1f;
}
void CGonomeGuts::Touch( CBaseEntity *pOther )
{
TraceResult tr;
int iPitch;
// splat sound
iPitch = RANDOM_FLOAT( 90, 110 );
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "bullchicken/bc_acid1.wav", 1, ATTN_NORM, 0, iPitch );
switch( RANDOM_LONG( 0, 1 ) )
{
case 0:
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_spithit1.wav", 1, ATTN_NORM, 0, iPitch );
break;
case 1:
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_spithit2.wav", 1, ATTN_NORM, 0, iPitch );
break;
}
if( !pOther->pev->takedamage )
{
// make a splat on the wall
UTIL_TraceLine( pev->origin, pev->origin + pev->velocity * 10, dont_ignore_monsters, ENT( pev ), &tr );
UTIL_BloodDecalTrace( &tr, BLOOD_COLOR_RED );
UTIL_BloodDrips( tr.vecEndPos, UTIL_RandomBloodVector(), BLOOD_COLOR_RED, 35 );
}
else
{
pOther->TakeDamage( pev, pev, gSkillData.bullsquidDmgSpit, DMG_GENERIC );
}
SetThink( &CBaseEntity::SUB_Remove );
pev->nextthink = gpGlobals->time;
}
//=========================================================
// CGonome
//=========================================================
class CGonome : public CZombie
{
public:
void Spawn(void);
void Precache(void);
void HandleAnimEvent(MonsterEvent_t *pEvent);
void StartTask(Task_t *pTask);
BOOL CheckMeleeAttack1(float flDot, float flDist);
BOOL CheckMeleeAttack2(float flDot, float flDist);
BOOL CheckRangeAttack1(float flDot, float flDist);
void RunAI(void);
Schedule_t *GetSchedule();
Schedule_t *GetScheduleOfType( int Type );
int TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType);
//void SetActivity( Activity NewActivity );
void PainSound( void );
void DeathSound( void );
void IdleSound( void );
int Save(CSave &save);
int Restore(CRestore &restore);
CUSTOM_SCHEDULES
static TYPEDESCRIPTION m_SaveData[];
static const char* pPainSounds[];
static const char* pIdleSounds[];
static const char* pDeathSounds[];
protected:
//int GonomeLookupActivity( void *pmodel, int activity );
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 gonome used the spit attack.
bool gonnaAttack1;
};
LINK_ENTITY_TO_CLASS(monster_gonome, CGonome)
const char* CGonome::pPainSounds[] = {
"gonome/gonome_pain1.wav",
"gonome/gonome_pain2.wav",
"gonome/gonome_pain3.wav",
"gonome/gonome_pain4.wav"
};
const char* CGonome::pIdleSounds[] = {
"gonome/gonome_idle1.wav",
"gonome/gonome_idle2.wav",
"gonome/gonome_idle3.wav"
};
const char* CGonome::pDeathSounds[] = {
"gonome/gonome_death2.wav",
"gonome/gonome_death3.wav",
"gonome/gonome_death4.wav"
};
TYPEDESCRIPTION CGonome::m_SaveData[] =
{
DEFINE_FIELD( CGonome, m_flLastHurtTime, FIELD_TIME ),
DEFINE_FIELD( CGonome, m_flNextSpitTime, FIELD_TIME ),
};
IMPLEMENT_SAVERESTORE( CGonome, CBaseMonster )
void CGonome::PainSound( void )
{
int pitch = 95 + RANDOM_LONG( 0, 9 );
if( RANDOM_LONG( 0, 5 ) < 2 )
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pPainSounds[RANDOM_LONG( 0, ARRAYSIZE( pPainSounds ) - 1 )], 1.0, ATTN_NORM, 0, pitch );
}
void CGonome::DeathSound( void )
{
int pitch = 95 + RANDOM_LONG( 0, 9 );
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAlertSounds[ RANDOM_LONG( 0, ARRAYSIZE( pDeathSounds ) - 1 )], 1.0, ATTN_NORM, 0, pitch );
}
void CGonome::IdleSound( void )
{
int pitch = 95 + RANDOM_LONG( 0, 9 );
// Play a random idle sound
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pIdleSounds[RANDOM_LONG( 0, ARRAYSIZE( pIdleSounds ) -1 )], 1.0, ATTN_NORM, 0, pitch );
}
/*
* Hack to ignore activity weights when choosing melee attack animation
*/
/*
int CGonome::GonomeLookupActivity( void *pmodel, int activity )
{
studiohdr_t *pstudiohdr;
pstudiohdr = (studiohdr_t *)pmodel;
if( !pstudiohdr )
return 0;
mstudioseqdesc_t *pseqdesc;
pseqdesc = (mstudioseqdesc_t *)( (byte *)pstudiohdr + pstudiohdr->seqindex );
int sameActivityNum = 0;
for( int i = 0; i < pstudiohdr->numseq && sameActivityNum < 2; i++ )
{
if( pseqdesc[i].activity == activity )
{
sameActivityNum++;
if (sameActivityNum == 1 && gonnaAttack1) {
return i;
} else if (sameActivityNum == 2) {
return i;
}
}
}
return ACTIVITY_NOT_AVAILABLE;
}
void CGonome::SetActivity( Activity NewActivity )
{
if (NewActivity != ACT_MELEE_ATTACK1) {
CBaseMonster::SetActivity(NewActivity);
} else {
ASSERT( NewActivity != 0 );
void *pmodel = GET_MODEL_PTR( ENT( pev ) );
int iSequence = GonomeLookupActivity( pmodel, NewActivity );
// Set to the desired anim, or default anim if the desired is not present
if( iSequence > ACTIVITY_NOT_AVAILABLE )
{
if( pev->sequence != iSequence || !m_fSequenceLoops )
{
// don't reset frame between walk and run
if( !( m_Activity == ACT_WALK || m_Activity == ACT_RUN ) || !( NewActivity == ACT_WALK || NewActivity == ACT_RUN ) )
pev->frame = 0;
}
pev->sequence = iSequence; // Set to the reset anim (if it's there)
ResetSequenceInfo();
SetYawSpeed();
}
else
{
// Not available try to get default anim
ALERT( at_aiconsole, "%s has no sequence for act:%d\n", STRING( pev->classname ), NewActivity );
pev->sequence = 0; // Set to the reset anim (if it's there)
}
m_Activity = NewActivity; // Go ahead and set this so it doesn't keep trying when the anim is not present
// In case someone calls this with something other than the ideal activity
m_IdealActivity = m_Activity;
}
}
*/
//=========================================================
// TakeDamage - overridden for gonome so we can keep track
// of how much time has passed since it was last injured
//=========================================================
int CGonome::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType)
{
// Take 15% damage from bullets
if( bitsDamageType == DMG_BULLET )
{
Vector vecDir = pev->origin - (pevInflictor->absmin + pevInflictor->absmax) * 0.5;
vecDir = vecDir.Normalize();
float flForce = DamageForce( flDamage );
pev->velocity = pev->velocity + vecDir * flForce;
flDamage *= 0.15;
}
// HACK HACK -- until we fix this.
if( IsAlive() )
PainSound();
return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType );
}
//=========================================================
// CheckRangeAttack1
//=========================================================
BOOL CGonome::CheckRangeAttack1(float flDot, float flDist)
{
if (IsMoving() && flDist >= 512)
{
// squid will far too far behind if he stops running to spit at this distance from the enemy.
return FALSE;
}
if (flDist > 64 && flDist <= 784 && flDot >= 0.5f && gpGlobals->time >= m_flNextSpitTime)
{
if (m_hEnemy != 0)
{
if (fabs(pev->origin.z - m_hEnemy->pev->origin.z) > 256)
{
// don't try to spit at someone up really high or down really low.
return FALSE;
}
}
if (IsMoving())
{
// don't spit again for a long time, resume chasing enemy.
m_flNextSpitTime = gpGlobals->time + 5.0f;
}
else
{
// not moving, so spit again pretty soon.
m_flNextSpitTime = gpGlobals->time + 0.5f;
}
return TRUE;
}
return FALSE;
}
//=========================================================
// CheckMeleeAttack1 - gonome is a big guy, so has a longer
// melee range than most monsters.
//=========================================================
BOOL CGonome::CheckMeleeAttack1(float flDot, float flDist)
{
if( m_hEnemy->pev->health <= gSkillData.gonomeDmgOneSlash && flDist <= 85 && flDot >= 0.7f )
{
return TRUE;
}
return FALSE;
}
//=========================================================
// CheckMeleeAttack2 - both gonome's melee attacks are ACT_MELEE_ATTACK1
//=========================================================
BOOL CGonome::CheckMeleeAttack2(float flDot, float flDist)
{
if( flDist <= 85 && flDot >= 0.7f && !HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) // The player & bullsquid can be as much as their bboxes
{ // apart (48 * sqrt(3)) and he can still attack (85 is a little more than 48*sqrt(3))
return TRUE;
}
return FALSE;
}
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//=========================================================
void CGonome::HandleAnimEvent(MonsterEvent_t *pEvent)
{
switch (pEvent->event)
{
case 1011:
// This may play sound twice
//EMIT_SOUND(ENT(pev), CHAN_VOICE, pEvent->options, 1, ATTN_NORM);
break;
case GONOME_AE_SPIT:
{
Vector vecSpitOffset;
Vector vecSpitDir;
UTIL_MakeVectors(pev->angles);
Vector vecArmPos, vecArmAng;
GetAttachment(0, vecArmPos, vecArmAng);
vecSpitOffset = pev->origin + pev->view_ofs - Vector( 0, 0, 16 );
UTIL_BloodDrips( vecSpitOffset, UTIL_RandomBloodVector(), BLOOD_COLOR_RED, 35 );
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);
// 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( iGonomeSpitSprite ); // model
WRITE_BYTE( 15 ); // count
WRITE_BYTE( 210 ); // speed
WRITE_BYTE( 25 ); // noise ( client will divide by 100 )
MESSAGE_END();
CGonomeGuts::Shoot(pev, vecSpitOffset, vecSpitDir * 1200); // Default: 900
}
break;
case GONOME_AE_BITE:
{
CBaseEntity *pHurt = CheckTraceHullAttack(GONOME_MELEE_ATTACK_RADIUS, gSkillData.gonomeDmgOneBite, DMG_SLASH);
if (pHurt)
{
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_forward * 100;
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_up * 100;
}
}
break;
case GONOME_AE_SLASH:
{
int iPitch;
CBaseEntity *pHurt = CheckTraceHullAttack(GONOME_TOLERANCE_MELEE2_RANGE, gSkillData.gonomeDmgOneSlash, DMG_CLUB | DMG_ALWAYSGIB);
if (pHurt)
{
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_forward * 200;
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_up * 200;
}
}
break;
case GONOME_AE_THROW:
{
CBaseEntity *pHurt = CheckTraceHullAttack( 70, DAMAGE_NO, DMG_GENERIC );
if( pHurt )
{
// croonchy bite sound
const int iPitch = RANDOM_FLOAT( 110, 120 );
switch( RANDOM_LONG( 0, 1 ) )
{
case 0:
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_bite2.wav", 0.7, ATTN_NORM, 0, iPitch );
break;
case 1:
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "bullchicken/bc_bite3.wav", 0.7, ATTN_NORM, 0, iPitch );
break;
}
// 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 );
// In Opposing Force enemies just go up, but not forward
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_forward * 200;
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_up * 200;
}
//else
//EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, pAttackMissSounds[RANDOM_LONG(0, ARRAYSIZE(pAttackMissSounds) - 1)], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG(-5, 5));
}
break;
default:
CBaseMonster::HandleAnimEvent(pEvent);
break;
}
}
//=========================================================
// Spawn
//=========================================================
void CGonome::Spawn()
{
Precache();
SET_MODEL(ENT(pev), "models/gonome.mdl");
UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX);
pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_STEP;
m_bloodColor = BLOOD_COLOR_GREEN;
pev->effects = 0;
pev->health = gSkillData.gonomeHealth;
m_flFieldOfView = 0.2;// indicates the width of this monster's forward view cone ( as a dotproduct result )
m_MonsterState = MONSTERSTATE_NONE;
m_flNextSpitTime = gpGlobals->time;
MonsterInit();
}
//=========================================================
// Precache - precaches all resources this monster needs
//=========================================================
void CGonome::Precache()
{
PRECACHE_MODEL("models/gonome.mdl");
PRECACHE_MODEL("sprites/blood_chnk.spr");// spit projectile.
iGonomeSpitSprite = PRECACHE_MODEL("sprites/tinyspit.spr");// client side spittle.
PRECACHE_SOUND("zombie/claw_miss2.wav");// because we use the basemonster SWIPE animation event
PRECACHE_SOUND("gonome/gonome_eat.wav");
PRECACHE_SOUND("gonome/gonome_jumpattack.wav");
PRECACHE_SOUND("gonome/gonome_melee1.wav");
PRECACHE_SOUND("gonome/gonome_melee2.wav");
PRECACHE_SOUND_ARRAY(pIdleSounds);
PRECACHE_SOUND_ARRAY(pPainSounds);
PRECACHE_SOUND_ARRAY(pDeathSounds);
PRECACHE_SOUND("gonome/gonome_run.wav");
PRECACHE_SOUND("bullchicken/bc_acid1.wav");
PRECACHE_SOUND("bullchicken/bc_bite2.wav");
PRECACHE_SOUND("bullchicken/bc_bite3.wav");
PRECACHE_SOUND("bullchicken/bc_spithit1.wav");
PRECACHE_SOUND("bullchicken/bc_spithit2.wav");
}
//========================================================
// RunAI - overridden for gonome because there are things
// that need to be checked every think.
//========================================================
void CGonome::RunAI(void)
{
// first, do base class stuff
CBaseMonster::RunAI();
if (m_hEnemy != 0 && m_Activity == ACT_RUN)
{
// chasing enemy. Sprint for last bit
if ((pev->origin - m_hEnemy->pev->origin).Length2D() < GONOME_SPRINT_DIST)
{
pev->framerate = 1.25;
}
}
}
//=========================================================
// GetSchedule
//=========================================================
Schedule_t *CGonome::GetSchedule( void )
{
switch( m_MonsterState )
{
case MONSTERSTATE_COMBAT:
{
// dead enemy
if( HasConditions( bits_COND_ENEMY_DEAD ) )
{
// call base class, all code to handle dead enemies is centralized there.
return CBaseMonster::GetSchedule();
}
if( HasConditions( bits_COND_NEW_ENEMY ) )
{
return GetScheduleOfType( SCHED_WAKE_ANGRY );
}
if( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) )
{
return GetScheduleOfType( SCHED_RANGE_ATTACK1 );
}
if( HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) )
{
return GetScheduleOfType( SCHED_MELEE_ATTACK1 );
}
if( HasConditions( bits_COND_CAN_MELEE_ATTACK2 ) )
{
return GetScheduleOfType( SCHED_MELEE_ATTACK2 );
}
return GetScheduleOfType( SCHED_CHASE_ENEMY );
break;
}
default:
break;
}
return CBaseMonster::GetSchedule();
}
// primary range attack
Task_t tlGonomeRangeAttack1[] =
{
{ TASK_STOP_MOVING, 0 },
{ TASK_FACE_IDEAL, (float)0 },
{ TASK_RANGE_ATTACK1, (float)0 },
{ TASK_SET_ACTIVITY, (float)ACT_IDLE },
};
Schedule_t slGonomeRangeAttack1[] =
{
{
tlGonomeRangeAttack1,
ARRAYSIZE( tlGonomeRangeAttack1 ),
bits_COND_NEW_ENEMY |
bits_COND_ENEMY_DEAD |
bits_COND_HEAVY_DAMAGE |
bits_COND_ENEMY_OCCLUDED |
bits_COND_NO_AMMO_LOADED,
0,
"Gonome Range Attack1"
},
};
// Chase enemy schedule
Task_t tlGonomeChaseEnemy1[] =
{
{ 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 },
};
Schedule_t slGonomeChaseEnemy[] =
{
{
tlGonomeChaseEnemy1,
ARRAYSIZE( tlGonomeChaseEnemy1 ),
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,
0,
"Gonome Chase Enemy"
},
};
// victory dance (eating body)
Task_t tlGonomeVictoryDance[] =
{
{ TASK_STOP_MOVING, (float)0 },
{ TASK_WAIT, (float)0.1 },
{ TASK_GONOME_GET_PATH_TO_ENEMY_CORPSE, (float)0 },
{ TASK_WALK_PATH, (float)0 },
{ TASK_WAIT_FOR_MOVEMENT, (float)0 },
{ TASK_FACE_ENEMY, (float)0 },
{ TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE },
{ TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE },
{ TASK_PLAY_SEQUENCE, (float)ACT_VICTORY_DANCE }
};
Schedule_t slGonomeVictoryDance[] =
{
{
tlGonomeVictoryDance,
ARRAYSIZE( tlGonomeVictoryDance ),
bits_COND_NEW_ENEMY |
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE,
0,
"GonomeVictoryDance"
},
};
DEFINE_CUSTOM_SCHEDULES( CGonome )
{
slGonomeRangeAttack1,
slGonomeChaseEnemy,
slGonomeVictoryDance,
};
IMPLEMENT_CUSTOM_SCHEDULES( CGonome, CBaseMonster )
Schedule_t* CGonome::GetScheduleOfType(int Type)
{
switch ( Type )
{
case SCHED_RANGE_ATTACK1:
return &slGonomeRangeAttack1[0];
break;
case SCHED_CHASE_ENEMY:
return &slGonomeChaseEnemy[0];
break;
case SCHED_VICTORY_DANCE:
return &slGonomeVictoryDance[0];
break;
default:
break;
}
return CBaseMonster::GetScheduleOfType(Type);
}
//=========================================================
// Start task - selects the correct activity and performs
// any necessary calculations to start the next task on the
// schedule.
//=========================================================
void CGonome::StartTask(Task_t *pTask)
{
m_iTaskStatus = TASKSTATUS_RUNNING;
switch (pTask->iTask)
{
case TASK_MELEE_ATTACK1:
{
EMIT_SOUND(ENT(pev), CHAN_VOICE, "gonome/gonome_melee1.wav", 1, ATTN_NORM);
CBaseMonster::StartTask(pTask);
}
break;
case TASK_MELEE_ATTACK2:
{
EMIT_SOUND(ENT(pev), CHAN_VOICE, "gonome/gonome_melee2.wav", 1, ATTN_NORM);
CBaseMonster::StartTask(pTask);
}
break;
case TASK_GONOME_GET_PATH_TO_ENEMY_CORPSE:
{
UTIL_MakeVectors( pev->angles );
if( BuildRoute( m_vecEnemyLKP - gpGlobals->v_forward * 40, bits_MF_TO_LOCATION, NULL ) )
{
TaskComplete();
}
else
{
ALERT( at_aiconsole, "GonomeGetPathToEnemyCorpse failed!!\n" );
TaskFail();
}
}
break;
default:
CBaseMonster::StartTask(pTask);
break;
}
}
//=========================================================
// DEAD GONOME PROP
//=========================================================
class CDeadGonome : public CBaseMonster
{
public:
void Spawn(void);
int Classify(void) { return CLASS_ALIEN_MONSTER; }
void KeyValue( KeyValueData *pkvd );
int m_iPose;
static const char *m_szPoses[3];
};
const char *CDeadGonome::m_szPoses[] = { "dead_on_stomach1", "dead_on_back", "dead_on_side" };
void CDeadGonome::KeyValue( KeyValueData *pkvd )
{
if( FStrEq( pkvd->szKeyName, "pose" ) )
{
m_iPose = atoi( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else
CBaseMonster::KeyValue( pkvd );
}
LINK_ENTITY_TO_CLASS(monster_gonome_dead, CDeadGonome)
//=========================================================
// ********** DeadGonome SPAWN **********
//=========================================================
void CDeadGonome::Spawn(void)
{
PRECACHE_MODEL("models/gonome.mdl");
SET_MODEL(ENT(pev), "models/gonome.mdl");
pev->effects = 0;
pev->yaw_speed = 8;
pev->sequence = 0;
m_bloodColor = BLOOD_COLOR_GREEN;
pev->sequence = LookupSequence( m_szPoses[m_iPose] );
if( pev->sequence == -1 )
{
ALERT( at_console, "Dead gonome with bad pose\n" );
}
// Corpses have less health
pev->health = 8;
MonsterInitDead();
}