2017-01-23 17:59:08 +03:00
|
|
|
//Allready fixed
|
2017-01-22 18:44:30 +03:00
|
|
|
/***
|
|
|
|
*
|
|
|
|
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
|
|
*
|
|
|
|
* This product contains software technology licensed from Id
|
|
|
|
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* This source code contains proprietary and confidential information of
|
|
|
|
* Valve LLC and its suppliers. Access to this code is restricted to
|
|
|
|
* persons who have executed a written SDK license with Valve. Any access,
|
|
|
|
* use or distribution of this code by or to any unlicensed person is illegal.
|
|
|
|
*
|
|
|
|
****/
|
|
|
|
#include "extdll.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "cbase.h"
|
|
|
|
#include "monsters.h"
|
|
|
|
#include "schedule.h"
|
2024-01-04 01:18:12 +05:00
|
|
|
#include "explode.h"
|
|
|
|
#include "weapons.h"
|
2017-01-22 18:44:30 +03:00
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Monster's Anim Events Go Here
|
|
|
|
//=========================================================
|
2024-01-04 01:18:12 +05:00
|
|
|
#define TERROR_AE_ATTACK_RIGHT 0x01
|
|
|
|
#define TERROR_AE_ATTACK_LEFT 0x02
|
|
|
|
#define TERROR_AE_ATTACK_BOTH 0x03
|
2017-01-22 18:44:30 +03:00
|
|
|
|
2024-01-04 01:18:12 +05:00
|
|
|
#define TERROR_FLINCH_DELAY 5 // at most one flinch every n secs
|
2017-01-22 18:44:30 +03:00
|
|
|
|
|
|
|
class CTerror : 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 IdleSound( void );
|
|
|
|
|
|
|
|
static const char *pIdleSounds[];
|
|
|
|
|
|
|
|
// 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_terror, CTerror )
|
|
|
|
|
|
|
|
const char *CTerror::pIdleSounds[] =
|
|
|
|
{
|
2017-01-23 17:59:08 +03:00
|
|
|
"terror/allahuakbar.wav",
|
2017-01-22 18:44:30 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Classify - indicates this monster's place in the
|
|
|
|
// relationship table.
|
|
|
|
//=========================================================
|
|
|
|
int CTerror::Classify( void )
|
|
|
|
{
|
2024-01-04 01:18:12 +05:00
|
|
|
return CLASS_ALIEN_MONSTER;
|
2017-01-22 18:44:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// SetYawSpeed - allows each sequence to have a different
|
|
|
|
// turn rate associated with it.
|
|
|
|
//=========================================================
|
|
|
|
void CTerror::SetYawSpeed( void )
|
|
|
|
{
|
|
|
|
int ys;
|
|
|
|
|
2024-01-04 01:18:12 +05:00
|
|
|
ys = 160;
|
2017-01-22 18:44:30 +03:00
|
|
|
#if 0
|
|
|
|
switch ( m_Activity )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
pev->yaw_speed = ys;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CTerror::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
|
|
|
|
{
|
|
|
|
// Take 30% damage from bullets
|
|
|
|
if( bitsDamageType == DMG_BULLET )
|
|
|
|
{
|
2024-01-04 01:18:12 +05:00
|
|
|
Vector vecDir = pev->origin - (pevInflictor->absmin + pevInflictor->absmax) * 0.5f;
|
2017-01-22 18:44:30 +03:00
|
|
|
vecDir = vecDir.Normalize();
|
|
|
|
float flForce = DamageForce( flDamage );
|
|
|
|
pev->velocity = pev->velocity + vecDir * flForce;
|
2024-01-04 01:18:12 +05:00
|
|
|
flDamage *= 0.3f;
|
2017-01-22 18:44:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CTerror::IdleSound( void )
|
|
|
|
{
|
|
|
|
int pitch = 95 + RANDOM_LONG( 0, 9 );
|
|
|
|
|
|
|
|
// Play a random idle sound
|
2024-01-04 01:18:12 +05:00
|
|
|
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pIdleSounds[RANDOM_LONG( 0, ARRAYSIZE( pIdleSounds ) - 1 )], 1.0, ATTN_NORM, 0, pitch );
|
2017-01-22 18:44:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CTerror::HandleAnimEvent( MonsterEvent_t *pEvent )
|
|
|
|
{
|
|
|
|
switch( pEvent->event )
|
|
|
|
{
|
2024-01-04 01:18:12 +05:00
|
|
|
case TERROR_AE_ATTACK_RIGHT:
|
|
|
|
case TERROR_AE_ATTACK_LEFT:
|
|
|
|
case TERROR_AE_ATTACK_BOTH:
|
|
|
|
{
|
|
|
|
for( int i = 0; i < 3; i++ )
|
|
|
|
CGrenade::ShootTimed( pev, pev->origin + gpGlobals->v_forward * 34 + Vector( 0, 0, 32 ), gpGlobals->v_forward, 0.0f );
|
|
|
|
}
|
|
|
|
break;
|
2017-01-22 18:44:30 +03:00
|
|
|
default:
|
|
|
|
CBaseMonster::HandleAnimEvent( pEvent );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CTerror::Spawn()
|
|
|
|
{
|
|
|
|
Precache();
|
|
|
|
|
|
|
|
SET_MODEL( ENT(pev), "models/terror.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;
|
2024-01-04 01:18:12 +05:00
|
|
|
pev->health = gSkillData.zombieHealth;
|
2017-01-22 18:44:30 +03:00
|
|
|
pev->view_ofs = VEC_VIEW;// position of the eyes relative to monster's origin.
|
2024-01-04 01:18:12 +05:00
|
|
|
m_flFieldOfView = 0.5f;// indicates the width of this monster's forward view cone ( as a dotproduct result )
|
2017-01-22 18:44:30 +03:00
|
|
|
m_MonsterState = MONSTERSTATE_NONE;
|
|
|
|
m_afCapability = bits_CAP_DOORS_GROUP;
|
|
|
|
|
|
|
|
MonsterInit();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Precache - precaches all resources this monster needs
|
|
|
|
//=========================================================
|
|
|
|
void CTerror::Precache()
|
|
|
|
{
|
|
|
|
|
|
|
|
PRECACHE_MODEL( "models/terror.mdl" );
|
2024-01-04 01:18:12 +05:00
|
|
|
PRECACHE_SOUND_ARRAY( pIdleSounds );
|
2017-01-22 18:44:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// AI Schedules Specific to this monster
|
|
|
|
//=========================================================
|
|
|
|
|
|
|
|
int CTerror::IgnoreConditions( void )
|
|
|
|
{
|
|
|
|
int iIgnore = CBaseMonster::IgnoreConditions();
|
|
|
|
|
|
|
|
if( ( m_Activity == ACT_MELEE_ATTACK1 ) || ( m_Activity == ACT_MELEE_ATTACK1 ) )
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
if( pev->health < 20 )
|
|
|
|
iIgnore |= ( bits_COND_LIGHT_DAMAGE| bits_COND_HEAVY_DAMAGE );
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if( m_flNextFlinch >= gpGlobals->time )
|
|
|
|
iIgnore |= ( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ( m_Activity == ACT_SMALL_FLINCH ) || ( m_Activity == ACT_BIG_FLINCH ) )
|
|
|
|
{
|
|
|
|
if( m_flNextFlinch < gpGlobals->time )
|
2024-01-04 01:18:12 +05:00
|
|
|
m_flNextFlinch = gpGlobals->time + TERROR_FLINCH_DELAY;
|
2017-01-22 18:44:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return iIgnore;
|
|
|
|
}
|