Night Owl
7 years ago
5 changed files with 3087 additions and 30 deletions
@ -0,0 +1,815 @@
@@ -0,0 +1,815 @@
|
||||
/***
|
||||
* |
||||
* 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.1; |
||||
} |
||||
|
||||
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.5 && 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; |
||||
} |
||||
else |
||||
{ |
||||
// not moving, so spit again pretty soon.
|
||||
m_flNextSpitTime = gpGlobals->time + 0.5; |
||||
} |
||||
|
||||
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.7 ) |
||||
{ |
||||
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.7 && !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(); |
||||
} |
@ -0,0 +1,520 @@
@@ -0,0 +1,520 @@
|
||||
/***
|
||||
* |
||||
* 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. |
||||
* |
||||
* 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. |
||||
* |
||||
****/ |
||||
//=========================================================
|
||||
// monster template
|
||||
//=========================================================
|
||||
// UNDONE: Holster weapon?
|
||||
|
||||
#include "extdll.h" |
||||
#include "util.h" |
||||
#include "cbase.h" |
||||
#include "monsters.h" |
||||
#include "talkmonster.h" |
||||
#include "schedule.h" |
||||
#include "defaultai.h" |
||||
#include "scripted.h" |
||||
#include "weapons.h" |
||||
#include "soundent.h" |
||||
#include "barney.h" |
||||
|
||||
#define NUM_OTIS_HEADS 2 // heads available for otis model
|
||||
|
||||
#define GUN_GROUP 1 |
||||
#define HEAD_GROUP 2 |
||||
|
||||
#define HEAD_HAIR 0 |
||||
#define HEAD_BALD 1 |
||||
|
||||
#define GUN_NONE 0 |
||||
#define GUN_EAGLE 1 |
||||
#define GUN_DONUT 2 |
||||
|
||||
//=========================================================
|
||||
// Monster's Anim Events Go Here
|
||||
//=========================================================
|
||||
// first flag is Otis dying for scripted sequences?
|
||||
#define OTIS_AE_DRAW ( 2 ) |
||||
#define OTIS_AE_SHOOT ( 3 ) |
||||
#define OTIS_AE_HOLSTER ( 4 ) |
||||
|
||||
#define OTIS_BODY_GUNHOLSTERED 0 |
||||
#define OTIS_BODY_GUNDRAWN 1 |
||||
#define OTIS_BODY_DONUT 2 |
||||
|
||||
class COtis : public CBarney |
||||
{ |
||||
public: |
||||
#if 1 |
||||
void KeyValue(KeyValueData *pkvd); |
||||
#endif |
||||
|
||||
void Spawn(void); |
||||
void Precache(void); |
||||
void BarneyFirePistol(void); |
||||
void AlertSound(void); |
||||
void HandleAnimEvent(MonsterEvent_t *pEvent); |
||||
|
||||
int TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType); |
||||
|
||||
void DeclineFollowing(void); |
||||
|
||||
// Override these to set behavior
|
||||
Schedule_t *GetSchedule(void); |
||||
|
||||
void TalkInit(void); |
||||
void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); |
||||
void Killed(entvars_t *pevAttacker, int iGib); |
||||
|
||||
void PainSound( void ); |
||||
void DeathSound( void ); |
||||
|
||||
int head; |
||||
int bodystate; |
||||
}; |
||||
|
||||
LINK_ENTITY_TO_CLASS(monster_otis, COtis); |
||||
|
||||
//=========================================================
|
||||
// ALertSound - otis says "Freeze!"
|
||||
//=========================================================
|
||||
void COtis::AlertSound(void) |
||||
{ |
||||
if (m_hEnemy != NULL) |
||||
{ |
||||
if (FOkToSpeak()) |
||||
{ |
||||
PlaySentence("OT_ATTACK", RANDOM_FLOAT(2.8, 3.2), VOL_NORM, ATTN_IDLE); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
//=========================================================
|
||||
// BarneyFirePistol - shoots one round from the pistol at
|
||||
// the enemy otis is facing.
|
||||
//=========================================================
|
||||
void COtis::BarneyFirePistol(void) |
||||
{ |
||||
Vector vecShootOrigin; |
||||
|
||||
UTIL_MakeVectors(pev->angles); |
||||
vecShootOrigin = pev->origin + Vector(0, 0, 55); |
||||
Vector vecShootDir = ShootAtEnemy(vecShootOrigin); |
||||
|
||||
Vector angDir = UTIL_VecToAngles(vecShootDir); |
||||
SetBlending(0, angDir.x); |
||||
pev->effects = EF_MUZZLEFLASH; |
||||
|
||||
FireBullets(1, vecShootOrigin, vecShootDir, VECTOR_CONE_2DEGREES, 1024, BULLET_MONSTER_357); |
||||
|
||||
int pitchShift = RANDOM_LONG(0, 20); |
||||
|
||||
// Only shift about half the time
|
||||
if (pitchShift > 10) |
||||
pitchShift = 0; |
||||
else |
||||
pitchShift -= 5; |
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, "weapons/desert_eagle_fire.wav", 1, ATTN_NORM, 0, 100 + pitchShift); |
||||
|
||||
CSoundEnt::InsertSound(bits_SOUND_COMBAT, pev->origin, 384, 0.3); |
||||
|
||||
// UNDONE: Reload?
|
||||
m_cAmmoLoaded--;// take away a bullet!
|
||||
} |
||||
|
||||
//=========================================================
|
||||
// HandleAnimEvent - catches the monster-specific messages
|
||||
// that occur when tagged animation frames are played.
|
||||
//
|
||||
// Returns number of events handled, 0 if none.
|
||||
//=========================================================
|
||||
void COtis::HandleAnimEvent(MonsterEvent_t *pEvent) |
||||
{ |
||||
switch (pEvent->event) |
||||
{ |
||||
case OTIS_AE_DRAW: |
||||
// otis' bodygroup switches here so he can pull gun from holster
|
||||
// pev->body = OTIS_BODY_GUNDRAWN;
|
||||
SetBodygroup( GUN_GROUP, GUN_EAGLE ); |
||||
m_fGunDrawn = TRUE; |
||||
break; |
||||
|
||||
case OTIS_AE_HOLSTER: |
||||
// change bodygroup to replace gun in holster
|
||||
// pev->body = OTIS_BODY_GUNHOLSTERED;
|
||||
SetBodygroup( GUN_GROUP, GUN_NONE ); |
||||
m_fGunDrawn = FALSE; |
||||
break; |
||||
|
||||
default: |
||||
CBarney::HandleAnimEvent(pEvent); |
||||
} |
||||
} |
||||
|
||||
//=========================================================
|
||||
// Spawn
|
||||
//=========================================================
|
||||
void COtis::Spawn() |
||||
{ |
||||
Precache(); |
||||
|
||||
SET_MODEL(ENT(pev), "models/otis.mdl"); |
||||
UTIL_SetSize(pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX); |
||||
|
||||
pev->solid = SOLID_SLIDEBOX; |
||||
pev->movetype = MOVETYPE_STEP; |
||||
m_bloodColor = BLOOD_COLOR_RED; |
||||
pev->health = gSkillData.otisHealth; |
||||
pev->view_ofs = Vector(0, 0, 50);// position of the eyes relative to monster's origin.
|
||||
m_flFieldOfView = VIEW_FIELD_WIDE; // NOTE: we need a wide field of view so npc will notice player and say hello
|
||||
m_MonsterState = MONSTERSTATE_NONE; |
||||
|
||||
pev->body = 0; // gun in holster
|
||||
m_fGunDrawn = FALSE; |
||||
|
||||
m_afCapability = bits_CAP_HEAR | bits_CAP_TURN_HEAD | bits_CAP_DOORS_GROUP; |
||||
|
||||
// Make sure hands are white.
|
||||
pev->skin = 0; |
||||
|
||||
// Select a random head.
|
||||
if (head == -1) |
||||
{ |
||||
SetBodygroup(HEAD_GROUP, RANDOM_LONG(0, NUM_OTIS_HEADS - 1)); |
||||
} |
||||
else |
||||
{ |
||||
SetBodygroup(HEAD_GROUP, head); |
||||
} |
||||
|
||||
if (bodystate == -1) |
||||
{ |
||||
SetBodygroup(GUN_GROUP, RANDOM_LONG(OTIS_BODY_GUNHOLSTERED, OTIS_BODY_GUNDRAWN)); // don't random donut
|
||||
} |
||||
else |
||||
{ |
||||
SetBodygroup(GUN_GROUP, bodystate); |
||||
} |
||||
|
||||
MonsterInit(); |
||||
SetUse(&COtis::FollowerUse); |
||||
} |
||||
|
||||
//=========================================================
|
||||
// Precache - precaches all resources this monster needs
|
||||
//=========================================================
|
||||
void COtis::Precache() |
||||
{ |
||||
PRECACHE_MODEL("models/otis.mdl"); |
||||
|
||||
PRECACHE_SOUND("weapons/desert_eagle_fire.wav"); |
||||
|
||||
PRECACHE_SOUND("otis/ot_pain1.wav"); |
||||
PRECACHE_SOUND("otis/ot_pain2.wav"); |
||||
PRECACHE_SOUND("otis/ot_pain3.wav"); |
||||
|
||||
PRECACHE_SOUND("otis/ot_die1.wav"); |
||||
PRECACHE_SOUND("otis/ot_die2.wav"); |
||||
|
||||
// every new otis must call this, otherwise
|
||||
// when a level is loaded, nobody will talk (time is reset to 0)
|
||||
TalkInit(); |
||||
CTalkMonster::Precache(); |
||||
} |
||||
|
||||
// Init talk data
|
||||
void COtis::TalkInit() |
||||
{ |
||||
CTalkMonster::TalkInit(); |
||||
|
||||
// scientists speach group names (group names are in sentences.txt)
|
||||
|
||||
m_szGrp[TLK_ANSWER] = "OT_ANSWER"; |
||||
m_szGrp[TLK_QUESTION] = "OT_QUESTION"; |
||||
m_szGrp[TLK_IDLE] = "OT_IDLE"; |
||||
m_szGrp[TLK_STARE] = "OT_STARE"; |
||||
m_szGrp[TLK_USE] = "OT_OK"; |
||||
m_szGrp[TLK_UNUSE] = "OT_WAIT"; |
||||
m_szGrp[TLK_STOP] = "OT_STOP"; |
||||
|
||||
m_szGrp[TLK_NOSHOOT] = "OT_SCARED"; |
||||
m_szGrp[TLK_HELLO] = "OT_HELLO"; |
||||
|
||||
m_szGrp[TLK_PLHURT1] = "!OT_CUREA"; |
||||
m_szGrp[TLK_PLHURT2] = "!OT_CUREB"; |
||||
m_szGrp[TLK_PLHURT3] = "!OT_CUREC"; |
||||
|
||||
m_szGrp[TLK_PHELLO] = NULL; |
||||
m_szGrp[TLK_PIDLE] = NULL; |
||||
m_szGrp[TLK_PQUESTION] = NULL; |
||||
|
||||
m_szGrp[TLK_SMELL] = "OT_SMELL"; |
||||
|
||||
m_szGrp[TLK_WOUND] = "OT_WOUND"; |
||||
m_szGrp[TLK_MORTAL] = "OT_MORTAL"; |
||||
|
||||
// get voice for head - just one otis voice for now
|
||||
m_voicePitch = 100; |
||||
} |
||||
|
||||
|
||||
static BOOL IsFacing(entvars_t *pevTest, const Vector &reference) |
||||
{ |
||||
Vector vecDir = (reference - pevTest->origin); |
||||
vecDir.z = 0; |
||||
vecDir = vecDir.Normalize(); |
||||
Vector forward, angle; |
||||
angle = pevTest->v_angle; |
||||
angle.x = 0; |
||||
UTIL_MakeVectorsPrivate(angle, forward, NULL, NULL); |
||||
// He's facing me, he meant it
|
||||
if (DotProduct(forward, vecDir) > 0.96) // +/- 15 degrees or so
|
||||
{ |
||||
return TRUE; |
||||
} |
||||
return FALSE; |
||||
} |
||||
|
||||
|
||||
int COtis::TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType) |
||||
{ |
||||
// make sure friends talk about it if player hurts talkmonsters...
|
||||
int ret = CTalkMonster::TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType); |
||||
if (!IsAlive() || pev->deadflag == DEAD_DYING) |
||||
return ret; |
||||
|
||||
if (m_MonsterState != MONSTERSTATE_PRONE && (pevAttacker->flags & FL_CLIENT)) |
||||
{ |
||||
m_flPlayerDamage += flDamage; |
||||
|
||||
// This is a heurstic to determine if the player intended to harm me
|
||||
// If I have an enemy, we can't establish intent (may just be crossfire)
|
||||
if (m_hEnemy == NULL) |
||||
{ |
||||
// If the player was facing directly at me, or I'm already suspicious, get mad
|
||||
if ((m_afMemory & bits_MEMORY_SUSPICIOUS) || IsFacing(pevAttacker, pev->origin)) |
||||
{ |
||||
// Alright, now I'm pissed!
|
||||
PlaySentence("OT_MAD", 4, VOL_NORM, ATTN_NORM); |
||||
|
||||
Remember(bits_MEMORY_PROVOKED); |
||||
StopFollowing(TRUE); |
||||
} |
||||
else |
||||
{ |
||||
// Hey, be careful with that
|
||||
PlaySentence("OT_SHOT", 4, VOL_NORM, ATTN_NORM); |
||||
Remember(bits_MEMORY_SUSPICIOUS); |
||||
} |
||||
} |
||||
else if (!(m_hEnemy->IsPlayer()) && pev->deadflag == DEAD_NO) |
||||
{ |
||||
PlaySentence("OT_SHOT", 4, VOL_NORM, ATTN_NORM); |
||||
} |
||||
} |
||||
|
||||
return ret; |
||||
} |
||||
|
||||
void COtis::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) |
||||
{ |
||||
switch (ptr->iHitgroup) |
||||
{ |
||||
case HITGROUP_CHEST: |
||||
case HITGROUP_STOMACH: |
||||
if (bitsDamageType & (DMG_BULLET | DMG_SLASH | DMG_BLAST)) |
||||
{ |
||||
flDamage = flDamage / 2; |
||||
} |
||||
break; |
||||
case 10: // Otis wears no helmet, so do not prevent taking headshot damage.
|
||||
// always a head shot
|
||||
ptr->iHitgroup = HITGROUP_HEAD; |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
CTalkMonster::TraceAttack(pevAttacker, flDamage, vecDir, ptr, bitsDamageType); |
||||
} |
||||
|
||||
//=========================================================
|
||||
// PainSound
|
||||
//=========================================================
|
||||
void COtis::PainSound( void ) |
||||
{ |
||||
if( gpGlobals->time < m_painTime ) |
||||
return; |
||||
|
||||
m_painTime = gpGlobals->time + RANDOM_FLOAT( 0.5, 0.75 ); |
||||
|
||||
switch( RANDOM_LONG( 0, 2 ) ) |
||||
{ |
||||
case 0: |
||||
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "otis/ot_pain1.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); |
||||
break; |
||||
case 1: |
||||
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "otis/ot_pain2.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); |
||||
break; |
||||
case 2: |
||||
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "otis/ot_pain3.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
//=========================================================
|
||||
// DeathSound
|
||||
//=========================================================
|
||||
void COtis::DeathSound( void ) |
||||
{ |
||||
switch( RANDOM_LONG( 0, 1 ) ) |
||||
{ |
||||
case 0: |
||||
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "otis/ot_die1.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); |
||||
break; |
||||
case 1: |
||||
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "otis/ot_die2.wav", 1, ATTN_NORM, 0, GetVoicePitch() ); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
void COtis::Killed(entvars_t *pevAttacker, int iGib) |
||||
{ |
||||
if (GetBodygroup(GUN_GROUP) != OTIS_BODY_GUNHOLSTERED) |
||||
{// drop the gun!
|
||||
Vector vecGunPos; |
||||
Vector vecGunAngles; |
||||
|
||||
SetBodygroup(GUN_GROUP, OTIS_BODY_GUNHOLSTERED); |
||||
|
||||
GetAttachment(0, vecGunPos, vecGunAngles); |
||||
|
||||
CBaseEntity *pGun = DropItem("weapon_glock", vecGunPos, vecGunAngles); |
||||
} |
||||
|
||||
SetUse(NULL); |
||||
CTalkMonster::Killed(pevAttacker, iGib); |
||||
} |
||||
|
||||
//=========================================================
|
||||
// AI Schedules Specific to this monster
|
||||
//=========================================================
|
||||
|
||||
//=========================================================
|
||||
// GetSchedule - Decides which type of schedule best suits
|
||||
// the monster's current state and conditions. Then calls
|
||||
// monster's member function to get a pointer to a schedule
|
||||
// of the proper type.
|
||||
//=========================================================
|
||||
Schedule_t *COtis::GetSchedule(void) |
||||
{ |
||||
if (HasConditions(bits_COND_HEAR_SOUND)) |
||||
{ |
||||
CSound *pSound; |
||||
pSound = PBestSound(); |
||||
|
||||
ASSERT(pSound != NULL); |
||||
if (pSound && (pSound->m_iType & bits_SOUND_DANGER)) |
||||
return GetScheduleOfType(SCHED_TAKE_COVER_FROM_BEST_SOUND); |
||||
} |
||||
|
||||
if (HasConditions(bits_COND_ENEMY_DEAD) && FOkToSpeak()) |
||||
{ |
||||
PlaySentence("OT_KILL", 4, VOL_NORM, ATTN_NORM); |
||||
} |
||||
|
||||
return CBarney::GetSchedule(); |
||||
} |
||||
|
||||
|
||||
void COtis::DeclineFollowing(void) |
||||
{ |
||||
PlaySentence("OT_POK", 2, VOL_NORM, ATTN_NORM); |
||||
} |
||||
|
||||
void COtis::KeyValue(KeyValueData *pkvd) |
||||
{ |
||||
if (FStrEq(pkvd->szKeyName, "head")) |
||||
{ |
||||
head = atoi(pkvd->szValue); |
||||
pkvd->fHandled = TRUE; |
||||
} |
||||
else |
||||
CBarney::KeyValue(pkvd); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
//=========================================================
|
||||
// DEAD OTIS PROP
|
||||
//
|
||||
// Designer selects a pose in worldcraft, 0 through num_poses-1
|
||||
// this value is added to what is selected as the 'first dead pose'
|
||||
// among the monster's normal animations. All dead poses must
|
||||
// appear sequentially in the model file. Be sure and set
|
||||
// the m_iFirstPose properly!
|
||||
//
|
||||
//=========================================================
|
||||
class CDeadOtis : public CBaseMonster |
||||
{ |
||||
public: |
||||
void Spawn(void); |
||||
int Classify(void) { return CLASS_PLAYER_ALLY; } |
||||
|
||||
void KeyValue(KeyValueData *pkvd); |
||||
|
||||
int m_iPose;// which sequence to display -- temporary, don't need to save
|
||||
static char *m_szPoses[5]; |
||||
}; |
||||
|
||||
char *CDeadOtis::m_szPoses[] = { "lying_on_back", "lying_on_side", "lying_on_stomach", "stuffed_in_vent", "dead_sitting" }; |
||||
|
||||
void CDeadOtis::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_otis_dead, CDeadOtis); |
||||
|
||||
//=========================================================
|
||||
// ********** DeadOtis SPAWN **********
|
||||
//=========================================================
|
||||
void CDeadOtis::Spawn() |
||||
{ |
||||
PRECACHE_MODEL("models/otis.mdl"); |
||||
SET_MODEL(ENT(pev), "models/otis.mdl"); |
||||
|
||||
pev->effects = 0; |
||||
pev->yaw_speed = 8; |
||||
pev->sequence = 0; |
||||
m_bloodColor = BLOOD_COLOR_RED; |
||||
|
||||
pev->sequence = LookupSequence(m_szPoses[m_iPose]); |
||||
if (pev->sequence == -1) |
||||
{ |
||||
ALERT(at_console, "Dead otis with bad pose\n"); |
||||
} |
||||
// Corpses have less health
|
||||
pev->health = 8;//gSkillData.otisHealth;
|
||||
|
||||
MonsterInitDead(); |
||||
} |
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
/***
|
||||
* |
||||
* 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. |
||||
* |
||||
****/ |
||||
//=========================================================
|
||||
// Zombie
|
||||
//=========================================================
|
||||
|
||||
class CZombie : public CBaseMonster |
||||
{ |
||||
public: |
||||
virtual void Spawn( void ); |
||||
virtual void Precache( void ); |
||||
void SetYawSpeed( void ); |
||||
int Classify( void ); |
||||
virtual void HandleAnimEvent( MonsterEvent_t *pEvent ); |
||||
int IgnoreConditions( void ); |
||||
|
||||
float m_flNextFlinch; |
||||
|
||||
virtual void PainSound( void ); |
||||
void AlertSound( void ); |
||||
virtual void IdleSound( void ); |
||||
void AttackSound( void ); |
||||
|
||||
static const char *pAttackSounds[]; |
||||
static const char *pIdleSounds[]; |
||||
static const char *pAlertSounds[]; |
||||
static const char *pPainSounds[]; |
||||
static const char *pAttackHitSounds[]; |
||||
static const char *pAttackMissSounds[]; |
||||
|
||||
// No range attacks
|
||||
virtual BOOL CheckRangeAttack1( float flDot, float flDist ) { return FALSE; } |
||||
virtual BOOL CheckRangeAttack2( float flDot, float flDist ) { return FALSE; } |
||||
virtual int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); |
||||
}; |
Loading…
Reference in new issue