mirror of
https://github.com/YGGverse/hlsdk-portable.git
synced 2025-01-25 22:24:16 +00:00
Add monster_helmet implementation. Fix monster_otis and monster_gonome.
This commit is contained in:
parent
3ebd7536db
commit
f3966a31fe
@ -27,11 +27,12 @@
|
||||
#include "decals.h"
|
||||
#include "animation.h"
|
||||
#include "studio.h"
|
||||
#include "zombie.h"
|
||||
|
||||
#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 65
|
||||
#define GONOME_TOLERANCE_MELEE2_RANGE 48
|
||||
|
||||
#define GONOME_TOLERANCE_MELEE1_DOT 0.7
|
||||
#define GONOME_TOLERANCE_MELEE2_DOT 0.7
|
||||
@ -49,7 +50,8 @@ enum
|
||||
|
||||
#define GONOME_AE_SLASH_RIGHT ( 1 )
|
||||
#define GONOME_AE_SLASH_LEFT ( 2 )
|
||||
#define GONOME_AE_THROW ( 4 )
|
||||
#define GONOME_AE_SPIT ( 3 )
|
||||
#define GONOME_AE_THROW ( 4 )
|
||||
|
||||
#define GONOME_AE_BITE1 ( 19 )
|
||||
#define GONOME_AE_BITE2 ( 20 )
|
||||
@ -122,7 +124,8 @@ void CGonomeGuts::Touch( CBaseEntity *pOther )
|
||||
{
|
||||
// make a splat on the wall
|
||||
UTIL_TraceLine( pev->origin, pev->origin + pev->velocity * 10, dont_ignore_monsters, ENT( pev ), &tr );
|
||||
UTIL_DecalTrace( &tr, DECAL_BLOOD1 + RANDOM_LONG( 0, 5 ) );
|
||||
UTIL_BloodDecalTrace( &tr, BLOOD_COLOR_RED );
|
||||
UTIL_BloodDrips( tr.vecEndPos, UTIL_RandomBloodVector(), BLOOD_COLOR_RED, 35 );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -136,20 +139,14 @@ void CGonomeGuts::Touch( CBaseEntity *pOther )
|
||||
//=========================================================
|
||||
// CGonome
|
||||
//=========================================================
|
||||
class CGonome : public CBaseMonster
|
||||
class CGonome : public CZombie
|
||||
{
|
||||
public:
|
||||
|
||||
void Spawn(void);
|
||||
void Precache(void);
|
||||
|
||||
int Classify(void);
|
||||
void SetYawSpeed();
|
||||
void HandleAnimEvent(MonsterEvent_t *pEvent);
|
||||
void IdleSound(void);
|
||||
void PainSound(void);
|
||||
void DeathSound(void);
|
||||
void AlertSound(void);
|
||||
void StartTask(Task_t *pTask);
|
||||
|
||||
BOOL CheckMeleeAttack1(float flDot, float flDist);
|
||||
@ -158,11 +155,14 @@ public:
|
||||
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);
|
||||
|
||||
@ -208,6 +208,29 @@ TYPEDESCRIPTION CGonome::m_SaveData[] =
|
||||
|
||||
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
|
||||
*/
|
||||
@ -277,42 +300,26 @@ void CGonome::SetActivity( Activity NewActivity )
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// Classify - indicates this monster's place in the
|
||||
// relationship table.
|
||||
//=========================================================
|
||||
int CGonome::Classify(void)
|
||||
{
|
||||
return CLASS_ALIEN_MONSTER;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// 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)
|
||||
{
|
||||
float flDist;
|
||||
Vector vecApex;
|
||||
|
||||
// if the gonome 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 != NULL && IsMoving() && pevAttacker == m_hEnemy->pev)
|
||||
// Take 15% damage from bullets
|
||||
if( bitsDamageType == DMG_BULLET )
|
||||
{
|
||||
flDist = (pev->origin - m_hEnemy->pev->origin).Length2D();
|
||||
|
||||
if (flDist > GONOME_SPRINT_DIST)
|
||||
{
|
||||
flDist = (pev->origin - m_Route[m_iRouteIndex].vecLocation).Length2D();// reusing flDist.
|
||||
|
||||
if (FTriangulate(pev->origin, m_Route[m_iRouteIndex].vecLocation, flDist * 0.5, m_hEnemy, &vecApex))
|
||||
{
|
||||
InsertWaypoint(vecApex, bits_MF_TO_DETOUR | bits_MF_DONT_SIMPLIFY);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
return CBaseMonster::TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType);
|
||||
// HACK HACK -- until we fix this.
|
||||
if( IsAlive() )
|
||||
PainSound();
|
||||
return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType );
|
||||
}
|
||||
|
||||
|
||||
@ -346,7 +353,7 @@ BOOL CGonome::CheckRangeAttack1(float flDot, float flDist)
|
||||
else
|
||||
{
|
||||
// not moving, so spit again pretty soon.
|
||||
m_flNextSpitTime = gpGlobals->time + 3;
|
||||
m_flNextSpitTime = gpGlobals->time + 0.5;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -381,65 +388,6 @@ BOOL CGonome::CheckMeleeAttack2(float flDot, float flDist)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
//=========================================================
|
||||
// IdleSound
|
||||
//=========================================================
|
||||
#define GONOME_ATTN_IDLE (float)1.5
|
||||
void CGonome::IdleSound(void)
|
||||
{
|
||||
EMIT_SOUND(ENT(pev), CHAN_VOICE, RANDOM_SOUND_ARRAY(pIdleSounds), 1, GONOME_ATTN_IDLE);
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// PainSound
|
||||
//=========================================================
|
||||
void CGonome::PainSound(void)
|
||||
{
|
||||
const int iPitch = RANDOM_LONG(85, 120);
|
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, RANDOM_SOUND_ARRAY(pPainSounds), 1, ATTN_NORM, 0, iPitch);
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// AlertSound
|
||||
//=========================================================
|
||||
void CGonome::AlertSound(void)
|
||||
{
|
||||
int iPitch = RANDOM_LONG(140, 160);
|
||||
EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, RANDOM_SOUND_ARRAY(pIdleSounds), 1, ATTN_NORM, 0, iPitch);
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// SetYawSpeed - allows each sequence to have a different
|
||||
// turn rate associated with it.
|
||||
//=========================================================
|
||||
void CGonome::SetYawSpeed( void )
|
||||
{
|
||||
int ys;
|
||||
|
||||
ys = 0;
|
||||
|
||||
switch ( m_Activity )
|
||||
{
|
||||
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;
|
||||
default:
|
||||
ys = 90;
|
||||
break;
|
||||
}
|
||||
|
||||
pev->yaw_speed = ys;
|
||||
}
|
||||
//=========================================================
|
||||
// HandleAnimEvent - catches the monster-specific messages
|
||||
// that occur when tagged animation frames are played.
|
||||
@ -452,6 +400,7 @@ void CGonome::HandleAnimEvent(MonsterEvent_t *pEvent)
|
||||
// This may play sound twice
|
||||
//EMIT_SOUND(ENT(pev), CHAN_VOICE, pEvent->options, 1, ATTN_NORM);
|
||||
break;
|
||||
case GONOME_AE_SPIT:
|
||||
case GONOME_AE_THROW:
|
||||
{
|
||||
Vector vecSpitOffset;
|
||||
@ -462,13 +411,16 @@ void CGonome::HandleAnimEvent(MonsterEvent_t *pEvent)
|
||||
GetAttachment(0, vecArmPos, vecArmAng);
|
||||
|
||||
vecSpitOffset = vecArmPos;
|
||||
vecSpitDir = ((m_hEnemy->pev->origin + m_hEnemy->pev->view_ofs) - vecSpitOffset).Normalize();
|
||||
UTIL_BloodDrips( vecSpitOffset, UTIL_RandomBloodVector(), BLOOD_COLOR_RED, 35 );
|
||||
if( pEvent->event == GONOME_AE_THROW )
|
||||
{
|
||||
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);
|
||||
|
||||
CGonomeGuts::Shoot(pev, vecSpitOffset, vecSpitDir * 1200); // Default: 900
|
||||
vecSpitDir.x += RANDOM_FLOAT(-0.05, 0.05);
|
||||
vecSpitDir.y += RANDOM_FLOAT(-0.05, 0.05);
|
||||
vecSpitDir.z += RANDOM_FLOAT(-0.05, 0);
|
||||
CGonomeGuts::Shoot(pev, vecSpitOffset, vecSpitDir * 1200); // Default: 900
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -477,10 +429,9 @@ void CGonome::HandleAnimEvent(MonsterEvent_t *pEvent)
|
||||
CBaseEntity *pHurt = CheckTraceHullAttack(GONOME_MELEE_ATTACK_RADIUS, gSkillData.bullsquidDmgWhip, DMG_SLASH);
|
||||
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;
|
||||
pHurt->pev->punchangle.z = 9;
|
||||
pHurt->pev->punchangle.x = 5;
|
||||
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_right * 25;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -490,10 +441,9 @@ void CGonome::HandleAnimEvent(MonsterEvent_t *pEvent)
|
||||
CBaseEntity *pHurt = CheckTraceHullAttack(GONOME_MELEE_ATTACK_RADIUS, gSkillData.bullsquidDmgWhip, DMG_SLASH);
|
||||
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;
|
||||
pHurt->pev->punchangle.z = -9;
|
||||
pHurt->pev->punchangle.x = 5;
|
||||
pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_right * 25;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -502,14 +452,14 @@ void CGonome::HandleAnimEvent(MonsterEvent_t *pEvent)
|
||||
case GONOME_AE_BITE2:
|
||||
case GONOME_AE_BITE3:
|
||||
case GONOME_AE_BITE4:
|
||||
{
|
||||
{
|
||||
int iPitch;
|
||||
CBaseEntity *pHurt = CheckTraceHullAttack(GONOME_TOLERANCE_MELEE2_RANGE, gSkillData.bullsquidDmgBite, DMG_SLASH);
|
||||
|
||||
if (pHurt)
|
||||
{
|
||||
// croonchy bite sound
|
||||
iPitch = RANDOM_FLOAT(90, 110);
|
||||
iPitch = PITCH_NORM + RANDOM_FLOAT(-5, 5);
|
||||
switch (RANDOM_LONG(0, 1))
|
||||
{
|
||||
case 0:
|
||||
@ -520,16 +470,19 @@ void CGonome::HandleAnimEvent(MonsterEvent_t *pEvent)
|
||||
break;
|
||||
}
|
||||
|
||||
pHurt->pev->punchangle.z = RANDOM_LONG(-10, 10);
|
||||
pHurt->pev->punchangle.x = RANDOM_LONG(-35, -45);
|
||||
pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_forward * 50;
|
||||
pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_up * 50;
|
||||
if( pEvent->event == GONOME_AE_BITE4 )
|
||||
{
|
||||
pHurt->pev->punchangle.x = 15;
|
||||
pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_forward * 75;
|
||||
}
|
||||
else
|
||||
{
|
||||
pHurt->pev->punchangle.x = 9;
|
||||
pHurt->pev->velocity = pHurt->pev->velocity - gpGlobals->v_forward * 25;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
default:
|
||||
CBaseMonster::HandleAnimEvent(pEvent);
|
||||
}
|
||||
@ -549,7 +502,7 @@ void CGonome::Spawn()
|
||||
pev->movetype = MOVETYPE_STEP;
|
||||
m_bloodColor = BLOOD_COLOR_GREEN;
|
||||
pev->effects = 0;
|
||||
pev->health = gSkillData.bullsquidHealth;
|
||||
pev->health = gSkillData.bullsquidHealth * 2;
|
||||
m_flFieldOfView = 0.2;// indicates the width of this monster's forward view cone ( as a dotproduct result )
|
||||
m_MonsterState = MONSTERSTATE_NONE;
|
||||
|
||||
@ -589,14 +542,6 @@ void CGonome::Precache()
|
||||
PRECACHE_SOUND("bullchicken/bc_spithit2.wav");
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// DeathSound
|
||||
//=========================================================
|
||||
void CGonome::DeathSound(void)
|
||||
{
|
||||
EMIT_SOUND(ENT(pev), CHAN_VOICE, RANDOM_SOUND_ARRAY(pDeathSounds), 1, ATTN_NORM);
|
||||
}
|
||||
|
||||
//========================================================
|
||||
// RunAI - overridden for gonome because there are things
|
||||
// that need to be checked every think.
|
||||
|
665
dlls/CAd/helmet.cpp
Normal file
665
dlls/CAd/helmet.cpp
Normal file
@ -0,0 +1,665 @@
|
||||
/***
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****/
|
||||
//=========================================================
|
||||
// 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"
|
||||
|
||||
//=========================================================
|
||||
// Monster's Anim Events Go Here
|
||||
//=========================================================
|
||||
// first flag is barney dying for scripted sequences?
|
||||
#define HELMET_AE_DRAW ( 2 )
|
||||
#define HELMET_AE_SHOOT ( 3 )
|
||||
#define HELMET_AE_HOLSTER ( 4 )
|
||||
|
||||
#define HELMET_BODY_GUNHOLSTERED 0
|
||||
#define HELMET_BODY_GUNDRAWN 1
|
||||
#define HELMET_BODY_GUNGONE 2
|
||||
|
||||
class CHelmet : public CBarney
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
void HelmetFireShotgun( void );
|
||||
void AlertSound( void );
|
||||
void HandleAnimEvent( MonsterEvent_t *pEvent );
|
||||
|
||||
virtual int ObjectCaps( void ) { return CTalkMonster :: ObjectCaps() | FCAP_IMPULSE_USE; }
|
||||
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 DeathSound( void );
|
||||
void PainSound( void );
|
||||
|
||||
void TalkInit( void );
|
||||
|
||||
void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType);
|
||||
void Killed( entvars_t *pevAttacker, int iGib );
|
||||
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
CUSTOM_SCHEDULES
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( monster_helmet, CHelmet )
|
||||
|
||||
TYPEDESCRIPTION CHelmet::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CHelmet, m_fGunDrawn, FIELD_BOOLEAN ),
|
||||
DEFINE_FIELD( CHelmet, m_painTime, FIELD_TIME ),
|
||||
DEFINE_FIELD( CHelmet, m_checkAttackTime, FIELD_TIME ),
|
||||
DEFINE_FIELD( CHelmet, m_lastAttackCheck, FIELD_BOOLEAN ),
|
||||
DEFINE_FIELD( CHelmet, m_flPlayerDamage, FIELD_FLOAT ),
|
||||
};
|
||||
|
||||
IMPLEMENT_SAVERESTORE( CHelmet, CTalkMonster )
|
||||
/*
|
||||
//=========================================================
|
||||
// AI Schedules Specific to this monster
|
||||
//=========================================================
|
||||
Task_t tlBaFollow[] =
|
||||
{
|
||||
{ TASK_MOVE_TO_TARGET_RANGE, (float)128 }, // Move within 128 of target ent (client)
|
||||
{ TASK_SET_SCHEDULE, (float)SCHED_TARGET_FACE },
|
||||
};
|
||||
|
||||
Schedule_t slBaFollow[] =
|
||||
{
|
||||
{
|
||||
tlBaFollow,
|
||||
ARRAYSIZE( tlBaFollow ),
|
||||
bits_COND_NEW_ENEMY |
|
||||
bits_COND_LIGHT_DAMAGE |
|
||||
bits_COND_HEAVY_DAMAGE |
|
||||
bits_COND_HEAR_SOUND |
|
||||
bits_COND_PROVOKED,
|
||||
bits_SOUND_DANGER,
|
||||
"Follow"
|
||||
},
|
||||
};
|
||||
|
||||
//=========================================================
|
||||
// BarneyDraw - much better looking draw schedule for when
|
||||
// barney knows who he's gonna attack.
|
||||
//=========================================================
|
||||
Task_t tlBarneyEnemyDraw[] =
|
||||
{
|
||||
{ TASK_STOP_MOVING, 0 },
|
||||
{ TASK_FACE_ENEMY, 0 },
|
||||
{ TASK_PLAY_SEQUENCE_FACE_ENEMY, (float) ACT_ARM },
|
||||
};
|
||||
|
||||
Schedule_t slBarneyEnemyDraw[] =
|
||||
{
|
||||
{
|
||||
tlBarneyEnemyDraw,
|
||||
ARRAYSIZE( tlBarneyEnemyDraw ),
|
||||
0,
|
||||
0,
|
||||
"Barney Enemy Draw"
|
||||
}
|
||||
};
|
||||
|
||||
Task_t tlBaFaceTarget[] =
|
||||
{
|
||||
{ TASK_SET_ACTIVITY, (float)ACT_IDLE },
|
||||
{ TASK_FACE_TARGET, (float)0 },
|
||||
{ TASK_SET_ACTIVITY, (float)ACT_IDLE },
|
||||
{ TASK_SET_SCHEDULE, (float)SCHED_TARGET_CHASE },
|
||||
};
|
||||
|
||||
Schedule_t slBaFaceTarget[] =
|
||||
{
|
||||
{
|
||||
tlBaFaceTarget,
|
||||
ARRAYSIZE( tlBaFaceTarget ),
|
||||
bits_COND_CLIENT_PUSH |
|
||||
bits_COND_NEW_ENEMY |
|
||||
bits_COND_LIGHT_DAMAGE |
|
||||
bits_COND_HEAVY_DAMAGE |
|
||||
bits_COND_HEAR_SOUND |
|
||||
bits_COND_PROVOKED,
|
||||
bits_SOUND_DANGER,
|
||||
"FaceTarget"
|
||||
},
|
||||
};
|
||||
|
||||
Task_t tlIdleBaStand[] =
|
||||
{
|
||||
{ TASK_STOP_MOVING, 0 },
|
||||
{ TASK_SET_ACTIVITY, (float)ACT_IDLE },
|
||||
{ TASK_WAIT, (float)2 }, // repick IDLESTAND every two seconds.
|
||||
{ TASK_TLK_HEADRESET, (float)0 }, // reset head position
|
||||
};
|
||||
|
||||
Schedule_t slIdleBaStand[] =
|
||||
{
|
||||
{
|
||||
tlIdleBaStand,
|
||||
ARRAYSIZE( tlIdleBaStand ),
|
||||
bits_COND_NEW_ENEMY |
|
||||
bits_COND_LIGHT_DAMAGE |
|
||||
bits_COND_HEAVY_DAMAGE |
|
||||
bits_COND_HEAR_SOUND |
|
||||
bits_COND_SMELL |
|
||||
bits_COND_PROVOKED,
|
||||
bits_SOUND_COMBAT |// sound flags - change these, and you'll break the talking code.
|
||||
//bits_SOUND_PLAYER |
|
||||
//bits_SOUND_WORLD |
|
||||
bits_SOUND_DANGER |
|
||||
bits_SOUND_MEAT |// scents
|
||||
bits_SOUND_CARCASS |
|
||||
bits_SOUND_GARBAGE,
|
||||
"IdleStand"
|
||||
},
|
||||
};
|
||||
*/
|
||||
|
||||
extern Schedule_t slBaFollow[];
|
||||
extern Schedule_t slBarneyEnemyDraw[];
|
||||
extern Schedule_t slBaFaceTarget[];
|
||||
extern Schedule_t slIdleBaStand[];
|
||||
|
||||
DEFINE_CUSTOM_SCHEDULES( CHelmet )
|
||||
{
|
||||
slBaFollow,
|
||||
slBarneyEnemyDraw,
|
||||
slBaFaceTarget,
|
||||
slIdleBaStand,
|
||||
};
|
||||
|
||||
IMPLEMENT_CUSTOM_SCHEDULES( CHelmet, CTalkMonster )
|
||||
|
||||
//=========================================================
|
||||
// ALertSound - barney says "Freeze!"
|
||||
//=========================================================
|
||||
void CHelmet::AlertSound( void )
|
||||
{
|
||||
if( m_hEnemy != 0 )
|
||||
{
|
||||
if( FOkToSpeak() )
|
||||
{
|
||||
PlaySentence( "HM_ATTACK", RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// BarneyFirePistol - shoots one round from the pistol at
|
||||
// the enemy barney is facing.
|
||||
//=========================================================
|
||||
void CHelmet::HelmetFireShotgun( 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( 2, vecShootOrigin, vecShootDir, VECTOR_CONE_2DEGREES, 1024, BULLET_MONSTER_12MM );
|
||||
|
||||
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, "helmet/ba_attack2.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 CHelmet::HandleAnimEvent( MonsterEvent_t *pEvent )
|
||||
{
|
||||
switch( pEvent->event )
|
||||
{
|
||||
case HELMET_AE_SHOOT:
|
||||
HelmetFireShotgun();
|
||||
break;
|
||||
case HELMET_AE_DRAW:
|
||||
// barney's bodygroup switches here so he can pull gun from holster
|
||||
pev->body = HELMET_BODY_GUNDRAWN;
|
||||
m_fGunDrawn = TRUE;
|
||||
break;
|
||||
case HELMET_AE_HOLSTER:
|
||||
// change bodygroup to replace gun in holster
|
||||
pev->body = HELMET_BODY_GUNHOLSTERED;
|
||||
m_fGunDrawn = FALSE;
|
||||
break;
|
||||
default:
|
||||
CTalkMonster::HandleAnimEvent( pEvent );
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// Spawn
|
||||
//=========================================================
|
||||
void CHelmet::Spawn()
|
||||
{
|
||||
Precache();
|
||||
|
||||
SET_MODEL( ENT( pev ), "models/helmet.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.barneyHealth;
|
||||
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;
|
||||
|
||||
MonsterInit();
|
||||
SetUse( &CTalkMonster::FollowerUse );
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// Precache - precaches all resources this monster needs
|
||||
//=========================================================
|
||||
void CHelmet::Precache()
|
||||
{
|
||||
PRECACHE_MODEL( "models/helmet.mdl" );
|
||||
|
||||
PRECACHE_SOUND( "helmet/ba_attack1.wav" );
|
||||
PRECACHE_SOUND( "helmet/ba_attack2.wav" );
|
||||
|
||||
PRECACHE_SOUND( "helmet/ba_pain1.wav" );
|
||||
PRECACHE_SOUND( "helmet/ba_pain2.wav" );
|
||||
PRECACHE_SOUND( "helmet/ba_pain3.wav" );
|
||||
|
||||
PRECACHE_SOUND( "helmet/ba_die1.wav" );
|
||||
PRECACHE_SOUND( "helmet/ba_die2.wav" );
|
||||
PRECACHE_SOUND( "helmet/ba_die3.wav" );
|
||||
|
||||
// every new barney must call this, otherwise
|
||||
// when a level is loaded, nobody will talk (time is reset to 0)
|
||||
TalkInit();
|
||||
CTalkMonster::Precache();
|
||||
}
|
||||
|
||||
// Init talk data
|
||||
void CHelmet::TalkInit()
|
||||
{
|
||||
CTalkMonster::TalkInit();
|
||||
|
||||
// scientists speach group names (group names are in sentences.txt)
|
||||
m_szGrp[TLK_ANSWER] = "HM_ANSWER";
|
||||
m_szGrp[TLK_QUESTION] = "HM_QUESTION";
|
||||
m_szGrp[TLK_IDLE] = "HM_IDLE";
|
||||
m_szGrp[TLK_STARE] = "HM_STARE";
|
||||
m_szGrp[TLK_USE] = "HM_OK";
|
||||
m_szGrp[TLK_UNUSE] = "HM_WAIT";
|
||||
m_szGrp[TLK_STOP] = "HM_STOP";
|
||||
|
||||
m_szGrp[TLK_NOSHOOT] = "HM_SCARED";
|
||||
m_szGrp[TLK_HELLO] = "HM_HELLO";
|
||||
|
||||
m_szGrp[TLK_PLHURT1] = "!HM_CUREA";
|
||||
m_szGrp[TLK_PLHURT2] = "!HM_CUREB";
|
||||
m_szGrp[TLK_PLHURT3] = "!HM_CUREC";
|
||||
|
||||
m_szGrp[TLK_PHELLO] = NULL; //"HM_PHELLO"; // UNDONE
|
||||
m_szGrp[TLK_PIDLE] = NULL; //"HM_PIDLE"; // UNDONE
|
||||
m_szGrp[TLK_PQUESTION] = "HM_PQUEST"; // UNDONE
|
||||
|
||||
m_szGrp[TLK_SMELL] = "HM_SMELL";
|
||||
|
||||
m_szGrp[TLK_WOUND] = "HM_WOUND";
|
||||
m_szGrp[TLK_MORTAL] = "HM_MORTAL";
|
||||
|
||||
// get voice for head - just one barney 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 CHelmet::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 == 0 )
|
||||
{
|
||||
// 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( "HM_MAD", 4, VOL_NORM, ATTN_NORM );
|
||||
|
||||
Remember( bits_MEMORY_PROVOKED );
|
||||
StopFollowing( TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Hey, be careful with that
|
||||
PlaySentence( "HM_SHOT", 4, VOL_NORM, ATTN_NORM );
|
||||
Remember( bits_MEMORY_SUSPICIOUS );
|
||||
}
|
||||
}
|
||||
else if( !( m_hEnemy->IsPlayer()) && pev->deadflag == DEAD_NO )
|
||||
{
|
||||
PlaySentence( "HM_SHOT", 4, VOL_NORM, ATTN_NORM );
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// PainSound
|
||||
//=========================================================
|
||||
void CHelmet::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, "helmet/ba_pain1.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
|
||||
break;
|
||||
case 1:
|
||||
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "helmet/ba_pain2.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
|
||||
break;
|
||||
case 2:
|
||||
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "helmet/ba_pain3.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// DeathSound
|
||||
//=========================================================
|
||||
void CHelmet::DeathSound( void )
|
||||
{
|
||||
switch( RANDOM_LONG( 0, 2 ) )
|
||||
{
|
||||
case 0:
|
||||
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "helmet/ba_die1.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
|
||||
break;
|
||||
case 1:
|
||||
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "helmet/ba_die2.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
|
||||
break;
|
||||
case 2:
|
||||
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "helmet/ba_die3.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CHelmet::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:
|
||||
if( bitsDamageType & ( DMG_BULLET | DMG_SLASH | DMG_CLUB ) )
|
||||
{
|
||||
flDamage -= 20;
|
||||
if( flDamage <= 0 )
|
||||
{
|
||||
UTIL_Ricochet( ptr->vecEndPos, 1.0 );
|
||||
flDamage = 0.01;
|
||||
}
|
||||
}
|
||||
|
||||
// always a head shot
|
||||
ptr->iHitgroup = HITGROUP_HEAD;
|
||||
break;
|
||||
}
|
||||
|
||||
CTalkMonster::TraceAttack( pevAttacker, flDamage, vecDir, ptr, bitsDamageType );
|
||||
}
|
||||
|
||||
void CHelmet::Killed( entvars_t *pevAttacker, int iGib )
|
||||
{
|
||||
if( pev->body < HELMET_BODY_GUNGONE )
|
||||
{
|
||||
// drop the gun!
|
||||
Vector vecGunPos;
|
||||
Vector vecGunAngles;
|
||||
|
||||
pev->body = HELMET_BODY_GUNGONE;
|
||||
|
||||
GetAttachment( 0, vecGunPos, vecGunAngles );
|
||||
|
||||
DropItem( "weapon_shotgun", vecGunPos, vecGunAngles );
|
||||
}
|
||||
|
||||
SetUse( NULL );
|
||||
CTalkMonster::Killed( pevAttacker, iGib );
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// 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 *CHelmet::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( "HM_KILL", 4, VOL_NORM, ATTN_NORM );
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
// always act surprized with a new enemy
|
||||
if( HasConditions( bits_COND_NEW_ENEMY ) && HasConditions( bits_COND_LIGHT_DAMAGE ) )
|
||||
return GetScheduleOfType( SCHED_SMALL_FLINCH );
|
||||
|
||||
// wait for one schedule to draw gun
|
||||
if( !m_fGunDrawn )
|
||||
return GetScheduleOfType( SCHED_ARM_WEAPON );
|
||||
|
||||
if( HasConditions( bits_COND_HEAVY_DAMAGE ) )
|
||||
return GetScheduleOfType( SCHED_TAKE_COVER_FROM_ENEMY );
|
||||
}
|
||||
break;
|
||||
case MONSTERSTATE_ALERT:
|
||||
case MONSTERSTATE_IDLE:
|
||||
if( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) )
|
||||
{
|
||||
// flinch if hurt
|
||||
return GetScheduleOfType( SCHED_SMALL_FLINCH );
|
||||
}
|
||||
|
||||
if( m_hEnemy == 0 && IsFollowing() )
|
||||
{
|
||||
if( !m_hTargetEnt->IsAlive() )
|
||||
{
|
||||
// UNDONE: Comment about the recently dead player here?
|
||||
StopFollowing( FALSE );
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( HasConditions( bits_COND_CLIENT_PUSH ) )
|
||||
{
|
||||
return GetScheduleOfType( SCHED_MOVE_AWAY_FOLLOW );
|
||||
}
|
||||
return GetScheduleOfType( SCHED_TARGET_FACE );
|
||||
}
|
||||
}
|
||||
|
||||
if( HasConditions( bits_COND_CLIENT_PUSH ) )
|
||||
{
|
||||
return GetScheduleOfType( SCHED_MOVE_AWAY );
|
||||
}
|
||||
|
||||
// try to say something about smells
|
||||
TrySmellTalk();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return CTalkMonster::GetSchedule();
|
||||
}
|
||||
|
||||
void CHelmet::DeclineFollowing( void )
|
||||
{
|
||||
PlaySentence( "HM_POK", 2, VOL_NORM, ATTN_NORM );
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// DEAD BARNEY 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 CDeadHelmet : 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 const char *m_szPoses[3];
|
||||
};
|
||||
|
||||
const char *CDeadHelmet::m_szPoses[] = { "lying_on_back", "lying_on_side", "lying_on_stomach" };
|
||||
|
||||
void CDeadHelmet::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_helmet_dead, CDeadHelmet )
|
||||
|
||||
//=========================================================
|
||||
// ********** DeadBarney SPAWN **********
|
||||
//=========================================================
|
||||
void CDeadHelmet::Spawn()
|
||||
{
|
||||
PRECACHE_MODEL( "models/helmet.mdl" );
|
||||
SET_MODEL( ENT( pev ), "models/helmet.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 helmet with bad pose\n" );
|
||||
}
|
||||
// Corpses have less health
|
||||
pev->health = 8;//gSkillData.barneyHealth;
|
||||
|
||||
MonsterInitDead();
|
||||
}
|
@ -73,6 +73,9 @@ public:
|
||||
// Override these to set behavior
|
||||
Schedule_t *GetSchedule(void);
|
||||
|
||||
void DeathSound( void );
|
||||
void PainSound( void );
|
||||
|
||||
void TalkInit(void);
|
||||
void TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType);
|
||||
void Killed(entvars_t *pevAttacker, int iGib);
|
||||
@ -217,15 +220,15 @@ void COtis::Precache()
|
||||
{
|
||||
PRECACHE_MODEL("models/otis.mdl");
|
||||
|
||||
PRECACHE_SOUND("barney/desert_eagle_fire.wav");
|
||||
PRECACHE_SOUND("weapons/desert_eagle_fire.wav");
|
||||
|
||||
PRECACHE_SOUND("barney/ba_pain1.wav");
|
||||
PRECACHE_SOUND("barney/ba_pain2.wav");
|
||||
PRECACHE_SOUND("barney/ba_pain3.wav");
|
||||
PRECACHE_SOUND("otis/ba_pain1.wav");
|
||||
PRECACHE_SOUND("otis/ba_pain2.wav");
|
||||
PRECACHE_SOUND("otis/ba_pain3.wav");
|
||||
|
||||
PRECACHE_SOUND("barney/ba_die1.wav");
|
||||
PRECACHE_SOUND("barney/ba_die2.wav");
|
||||
PRECACHE_SOUND("barney/ba_die3.wav");
|
||||
PRECACHE_SOUND("otis/ba_die1.wav");
|
||||
PRECACHE_SOUND("otis/ba_die2.wav");
|
||||
PRECACHE_SOUND("otis/ba_die3.wav");
|
||||
|
||||
// every new otis must call this, otherwise
|
||||
// when a level is loaded, nobody will talk (time is reset to 0)
|
||||
@ -348,6 +351,48 @@ void COtis::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, T
|
||||
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/ba_pain1.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
|
||||
break;
|
||||
case 1:
|
||||
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "otis/ba_pain2.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
|
||||
break;
|
||||
case 2:
|
||||
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "otis/ba_pain3.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================
|
||||
// DeathSound
|
||||
//=========================================================
|
||||
void COtis::DeathSound( void )
|
||||
{
|
||||
switch( RANDOM_LONG( 0, 2 ) )
|
||||
{
|
||||
case 0:
|
||||
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "otis/ba_die1.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
|
||||
break;
|
||||
case 1:
|
||||
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "otis/ba_die2.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
|
||||
break;
|
||||
case 2:
|
||||
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "otis/ba_die3.wav", 1, ATTN_NORM, 0, GetVoicePitch() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void COtis::Killed(entvars_t *pevAttacker, int iGib)
|
||||
{
|
||||
|
@ -129,7 +129,8 @@ set (SVDLL_SOURCES
|
||||
zombie.cpp
|
||||
CAd/displacer.cpp
|
||||
CAd/eagle.cpp
|
||||
CAd/gonome
|
||||
CAd/helmet.cpp
|
||||
CAd/gonome.cpp
|
||||
CAd/otis.cpp
|
||||
../pm_shared/pm_debug.c
|
||||
../pm_shared/pm_math.c
|
||||
|
@ -24,14 +24,14 @@
|
||||
class CBarney : public CTalkMonster
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
virtual void Spawn( void );
|
||||
virtual void Precache( void );
|
||||
void SetYawSpeed( void );
|
||||
int ISoundMask( void );
|
||||
void BarneyFirePistol( void );
|
||||
void AlertSound( void );
|
||||
virtual void BarneyFirePistol( void );
|
||||
virtual void AlertSound( void );
|
||||
int Classify( void );
|
||||
void HandleAnimEvent( MonsterEvent_t *pEvent );
|
||||
virtual void HandleAnimEvent( MonsterEvent_t *pEvent );
|
||||
|
||||
void RunTask( Task_t *pTask );
|
||||
void StartTask( Task_t *pTask );
|
||||
@ -39,20 +39,20 @@ public:
|
||||
int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType);
|
||||
BOOL CheckRangeAttack1( float flDot, float flDist );
|
||||
|
||||
void DeclineFollowing( void );
|
||||
virtual void DeclineFollowing( void );
|
||||
|
||||
// Override these to set behavior
|
||||
Schedule_t *GetScheduleOfType( int Type );
|
||||
Schedule_t *GetSchedule( void );
|
||||
virtual Schedule_t *GetSchedule( void );
|
||||
MONSTERSTATE GetIdealState( void );
|
||||
|
||||
void DeathSound( void );
|
||||
void PainSound( void );
|
||||
virtual void DeathSound( void );
|
||||
virtual void PainSound( void );
|
||||
|
||||
void TalkInit( void );
|
||||
virtual void TalkInit( void );
|
||||
|
||||
void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType);
|
||||
void Killed( entvars_t *pevAttacker, int iGib );
|
||||
virtual void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType);
|
||||
virtual void Killed( entvars_t *pevAttacker, int iGib );
|
||||
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
|
@ -43,33 +43,33 @@ public:
|
||||
class CBullsquid : public CBaseMonster
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
void SetYawSpeed( void );
|
||||
virtual void Spawn( void );
|
||||
virtual void Precache( void );
|
||||
virtual void SetYawSpeed( void );
|
||||
int ISoundMask( void );
|
||||
int Classify( void );
|
||||
void HandleAnimEvent( MonsterEvent_t *pEvent );
|
||||
void IdleSound( void );
|
||||
void PainSound( void );
|
||||
void DeathSound( void );
|
||||
void AlertSound( void );
|
||||
virtual int Classify( void );
|
||||
virtual void HandleAnimEvent( MonsterEvent_t *pEvent );
|
||||
virtual void IdleSound( void );
|
||||
virtual void PainSound( void );
|
||||
virtual void DeathSound( void );
|
||||
virtual void AlertSound( void );
|
||||
void AttackSound( void );
|
||||
void StartTask( Task_t *pTask );
|
||||
virtual void StartTask( Task_t *pTask );
|
||||
void RunTask( Task_t *pTask );
|
||||
BOOL CheckMeleeAttack1( float flDot, float flDist );
|
||||
BOOL CheckMeleeAttack2( float flDot, float flDist );
|
||||
BOOL CheckRangeAttack1( float flDot, float flDist );
|
||||
void RunAI( void );
|
||||
virtual BOOL CheckMeleeAttack1( float flDot, float flDist );
|
||||
virtual BOOL CheckMeleeAttack2( float flDot, float flDist );
|
||||
virtual BOOL CheckRangeAttack1( float flDot, float flDist );
|
||||
virtual void RunAI( void );
|
||||
BOOL FValidateHintType( short sHint );
|
||||
Schedule_t *GetSchedule( void );
|
||||
Schedule_t *GetScheduleOfType( int Type );
|
||||
int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
|
||||
virtual Schedule_t *GetSchedule( void );
|
||||
virtual Schedule_t *GetScheduleOfType( int Type );
|
||||
virtual int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
|
||||
int IRelationship( CBaseEntity *pTarget );
|
||||
int IgnoreConditions( void );
|
||||
MONSTERSTATE GetIdealState( void );
|
||||
|
||||
int Save( CSave &save );
|
||||
int Restore( CRestore &restore );
|
||||
virtual int Save( CSave &save );
|
||||
virtual int Restore( CRestore &restore );
|
||||
|
||||
CUSTOM_SCHEDULES
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "cbase.h"
|
||||
#include "monsters.h"
|
||||
#include "schedule.h"
|
||||
#include "zombie.h"
|
||||
|
||||
//=========================================================
|
||||
// Monster's Anim Events Go Here
|
||||
@ -33,36 +34,6 @@
|
||||
|
||||
#define ZOMBIE_FLINCH_DELAY 2 // at most one flinch every n secs
|
||||
|
||||
class CZombie : public CBaseMonster
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
void Precache( void );
|
||||
void SetYawSpeed( void );
|
||||
int Classify( void );
|
||||
void HandleAnimEvent( MonsterEvent_t *pEvent );
|
||||
int IgnoreConditions( void );
|
||||
|
||||
float m_flNextFlinch;
|
||||
|
||||
void PainSound( void );
|
||||
void AlertSound( void );
|
||||
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
|
||||
BOOL CheckRangeAttack1( float flDot, float flDist ) { return FALSE; }
|
||||
BOOL CheckRangeAttack2( float flDot, float flDist ) { return FALSE; }
|
||||
int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS( monster_zombie, CZombie )
|
||||
LINK_ENTITY_TO_CLASS( monster_zombie_barney, CZombie )
|
||||
|
||||
|
47
dlls/zombie.h
Normal file
47
dlls/zombie.h
Normal file
@ -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…
x
Reference in New Issue
Block a user