2016-06-04 15:24:23 +02: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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
****/
|
|
|
|
//=========================================================
|
|
|
|
// Hornets
|
|
|
|
//=========================================================
|
|
|
|
|
|
|
|
#include "extdll.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "cbase.h"
|
|
|
|
#include "monsters.h"
|
|
|
|
#include "weapons.h"
|
|
|
|
#include "soundent.h"
|
|
|
|
#include "hornet.h"
|
|
|
|
#include "gamerules.h"
|
|
|
|
|
|
|
|
int iHornetTrail;
|
|
|
|
int iHornetPuff;
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
LINK_ENTITY_TO_CLASS( hornet, CHornet )
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Save/Restore
|
|
|
|
//=========================================================
|
2016-06-25 18:33:39 +02:00
|
|
|
TYPEDESCRIPTION CHornet::m_SaveData[] =
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
DEFINE_FIELD( CHornet, m_flStopAttack, FIELD_TIME ),
|
|
|
|
DEFINE_FIELD( CHornet, m_iHornetType, FIELD_INTEGER ),
|
|
|
|
DEFINE_FIELD( CHornet, m_flFlySpeed, FIELD_FLOAT ),
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
IMPLEMENT_SAVERESTORE( CHornet, CBaseMonster )
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// don't let hornets gib, ever.
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
int CHornet::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// filter these bits a little.
|
2016-07-31 15:48:50 +02:00
|
|
|
bitsDamageType &= ~( DMG_ALWAYSGIB );
|
2016-06-04 15:24:23 +02:00
|
|
|
bitsDamageType |= DMG_NEVERGIB;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
void CHornet::Spawn( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
Precache();
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->movetype = MOVETYPE_FLY;
|
|
|
|
pev->solid = SOLID_BBOX;
|
2016-06-04 15:24:23 +02:00
|
|
|
pev->takedamage = DAMAGE_YES;
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->flags |= FL_MONSTER;
|
|
|
|
pev->health = 1;// weak!
|
|
|
|
|
|
|
|
if( g_pGameRules->IsMultiplayer() )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// hornets don't live as long in multiplayer
|
2019-10-13 13:49:25 +02:00
|
|
|
m_flStopAttack = gpGlobals->time + 3.5f;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
m_flStopAttack = gpGlobals->time + 5.0f;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
m_flFieldOfView = 0.9f; // +- 25 degrees
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( RANDOM_LONG( 1, 5 ) <= 2 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_iHornetType = HORNET_TYPE_RED;
|
|
|
|
m_flFlySpeed = HORNET_RED_SPEED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_iHornetType = HORNET_TYPE_ORANGE;
|
|
|
|
m_flFlySpeed = HORNET_ORANGE_SPEED;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
SET_MODEL( ENT( pev ), "models/hornet.mdl" );
|
2016-06-04 15:24:23 +02:00
|
|
|
UTIL_SetSize( pev, Vector( -4, -4, -4 ), Vector( 4, 4, 4 ) );
|
|
|
|
|
|
|
|
SetTouch( &CHornet::DieTouch );
|
|
|
|
SetThink( &CHornet::StartTrack );
|
|
|
|
|
2019-11-16 09:54:30 +01:00
|
|
|
/*edict_t *pSoundEnt = pev->owner;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !pSoundEnt )
|
2019-11-16 09:54:30 +01:00
|
|
|
pSoundEnt = edict();*/
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !FNullEnt( pev->owner ) && ( pev->owner->v.flags & FL_CLIENT ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
pev->dmg = gSkillData.plrDmgHornet;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// no real owner, or owner isn't a client.
|
|
|
|
pev->dmg = gSkillData.monDmgHornet;
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->nextthink = gpGlobals->time + 0.1f;
|
2016-07-31 15:48:50 +02:00
|
|
|
ResetSequenceInfo();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CHornet::Precache()
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
PRECACHE_MODEL( "models/hornet.mdl" );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
PRECACHE_SOUND( "agrunt/ag_fire1.wav" );
|
|
|
|
PRECACHE_SOUND( "agrunt/ag_fire2.wav" );
|
|
|
|
PRECACHE_SOUND( "agrunt/ag_fire3.wav" );
|
|
|
|
|
|
|
|
PRECACHE_SOUND( "hornet/ag_buzz1.wav" );
|
|
|
|
PRECACHE_SOUND( "hornet/ag_buzz2.wav" );
|
|
|
|
PRECACHE_SOUND( "hornet/ag_buzz3.wav" );
|
|
|
|
|
|
|
|
PRECACHE_SOUND( "hornet/ag_hornethit1.wav" );
|
|
|
|
PRECACHE_SOUND( "hornet/ag_hornethit2.wav" );
|
|
|
|
PRECACHE_SOUND( "hornet/ag_hornethit3.wav" );
|
|
|
|
|
|
|
|
iHornetPuff = PRECACHE_MODEL( "sprites/muz1.spr" );
|
2016-07-31 15:48:50 +02:00
|
|
|
iHornetTrail = PRECACHE_MODEL( "sprites/laserbeam.spr" );
|
|
|
|
}
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// hornets will never get mad at each other, no matter who the owner is.
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
int CHornet::IRelationship( CBaseEntity *pTarget )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pTarget->pev->modelindex == pev->modelindex )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
return R_NO;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
return CBaseMonster::IRelationship( pTarget );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// ID's Hornet as their owner
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
int CHornet::Classify( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->owner && pev->owner->v.flags & FL_CLIENT )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
return CLASS_PLAYER_BIOWEAPON;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CLASS_ALIEN_BIOWEAPON;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// StartTrack - starts a hornet out tracking its target
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
void CHornet::StartTrack( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
IgniteTrail();
|
|
|
|
|
|
|
|
SetTouch( &CHornet::TrackTouch );
|
|
|
|
SetThink( &CHornet::TrackTarget );
|
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->nextthink = gpGlobals->time + 0.1f;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// StartDart - starts a hornet out just flying straight.
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
void CHornet::StartDart( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
IgniteTrail();
|
|
|
|
|
|
|
|
SetTouch( &CHornet::DartTouch );
|
|
|
|
|
|
|
|
SetThink( &CBaseEntity::SUB_Remove );
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->nextthink = gpGlobals->time + 4.0f;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CHornet::IgniteTrail( void )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
|
|
|
|
ted's suggested trail colors:
|
|
|
|
|
|
|
|
r161
|
|
|
|
g25
|
|
|
|
b97
|
|
|
|
|
|
|
|
r173
|
|
|
|
g39
|
|
|
|
b14
|
|
|
|
|
|
|
|
old colors
|
|
|
|
case HORNET_TYPE_RED:
|
|
|
|
WRITE_BYTE( 255 ); // r, g, b
|
|
|
|
WRITE_BYTE( 128 ); // r, g, b
|
|
|
|
WRITE_BYTE( 0 ); // r, g, b
|
|
|
|
break;
|
|
|
|
case HORNET_TYPE_ORANGE:
|
2016-07-31 15:48:50 +02:00
|
|
|
WRITE_BYTE( 0 ); // r, g, b
|
2016-06-04 15:24:23 +02:00
|
|
|
WRITE_BYTE( 100 ); // r, g, b
|
|
|
|
WRITE_BYTE( 255 ); // r, g, b
|
|
|
|
break;
|
2016-07-31 15:48:50 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
*/
|
|
|
|
// trail
|
|
|
|
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
|
2016-07-31 15:48:50 +02:00
|
|
|
WRITE_BYTE( TE_BEAMFOLLOW );
|
2016-06-04 15:24:23 +02:00
|
|
|
WRITE_SHORT( entindex() ); // entity
|
|
|
|
WRITE_SHORT( iHornetTrail ); // model
|
|
|
|
WRITE_BYTE( 10 ); // life
|
|
|
|
WRITE_BYTE( 2 ); // width
|
2016-07-31 15:48:50 +02:00
|
|
|
|
|
|
|
switch( m_iHornetType )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
case HORNET_TYPE_RED:
|
|
|
|
WRITE_BYTE( 179 ); // r, g, b
|
|
|
|
WRITE_BYTE( 39 ); // r, g, b
|
|
|
|
WRITE_BYTE( 14 ); // r, g, b
|
|
|
|
break;
|
|
|
|
case HORNET_TYPE_ORANGE:
|
|
|
|
WRITE_BYTE( 255 ); // r, g, b
|
|
|
|
WRITE_BYTE( 128 ); // r, g, b
|
|
|
|
WRITE_BYTE( 0 ); // r, g, b
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
WRITE_BYTE( 128 ); // brightness
|
|
|
|
MESSAGE_END();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Hornet is flying, gently tracking target
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
void CHornet::TrackTarget( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
Vector vecFlightDir;
|
|
|
|
Vector vecDirToEnemy;
|
|
|
|
float flDelta;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
StudioFrameAdvance();
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( gpGlobals->time > m_flStopAttack )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
SetTouch( NULL );
|
|
|
|
SetThink( &CBaseEntity::SUB_Remove );
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->nextthink = gpGlobals->time + 0.1f;
|
2016-06-04 15:24:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// UNDONE: The player pointer should come back after returning from another level
|
2017-06-29 15:56:03 +02:00
|
|
|
if( m_hEnemy == 0 )
|
2016-06-25 18:33:39 +02:00
|
|
|
{
|
|
|
|
// enemy is dead.
|
2016-06-04 15:24:23 +02:00
|
|
|
Look( 512 );
|
2016-07-31 15:48:50 +02:00
|
|
|
m_hEnemy = BestVisibleEnemy();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
|
2017-06-29 15:56:03 +02:00
|
|
|
if( m_hEnemy != 0 && FVisible( m_hEnemy ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_vecEnemyLKP = m_hEnemy->BodyTarget( pev->origin );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
m_vecEnemyLKP = m_vecEnemyLKP + pev->velocity * m_flFlySpeed * 0.1f;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
vecDirToEnemy = ( m_vecEnemyLKP - pev->origin ).Normalize();
|
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
if( pev->velocity.Length() < 0.1f )
|
2016-06-04 15:24:23 +02:00
|
|
|
vecFlightDir = vecDirToEnemy;
|
|
|
|
else
|
|
|
|
vecFlightDir = pev->velocity.Normalize();
|
|
|
|
|
|
|
|
// measure how far the turn is, the wider the turn, the slow we'll go this time.
|
2016-07-31 15:48:50 +02:00
|
|
|
flDelta = DotProduct( vecFlightDir, vecDirToEnemy );
|
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
if( flDelta < 0.5f )
|
2016-06-25 18:33:39 +02:00
|
|
|
{
|
|
|
|
// hafta turn wide again. play sound
|
2016-07-31 15:48:50 +02:00
|
|
|
switch( RANDOM_LONG( 0, 2 ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
case 0:
|
|
|
|
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_buzz1.wav", HORNET_BUZZ_VOLUME, ATTN_NORM );
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_buzz2.wav", HORNET_BUZZ_VOLUME, ATTN_NORM );
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_buzz3.wav", HORNET_BUZZ_VOLUME, ATTN_NORM );
|
|
|
|
break;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( flDelta <= 0 && m_iHornetType == HORNET_TYPE_RED )
|
2016-06-25 18:33:39 +02:00
|
|
|
{
|
|
|
|
// no flying backwards, but we don't want to invert this, cause we'd go fast when we have to turn REAL far.
|
2019-10-13 13:49:25 +02:00
|
|
|
flDelta = 0.25f;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->velocity = ( vecFlightDir + vecDirToEnemy ).Normalize();
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->owner && ( pev->owner->v.flags & FL_MONSTER ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// random pattern only applies to hornets fired by monsters, not players.
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->velocity.x += RANDOM_FLOAT( -0.10f, 0.10f );// scramble the flight dir a bit.
|
|
|
|
pev->velocity.y += RANDOM_FLOAT( -0.10f, 0.10f );
|
|
|
|
pev->velocity.z += RANDOM_FLOAT( -0.10f, 0.10f );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
|
|
|
|
switch( m_iHornetType )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
case HORNET_TYPE_RED:
|
|
|
|
pev->velocity = pev->velocity * ( m_flFlySpeed * flDelta );// scale the dir by the ( speed * width of turn )
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.1f, 0.3f );
|
2016-06-04 15:24:23 +02:00
|
|
|
break;
|
|
|
|
case HORNET_TYPE_ORANGE:
|
|
|
|
pev->velocity = pev->velocity * m_flFlySpeed;// do not have to slow down to turn.
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->nextthink = gpGlobals->time + 0.1f;// fixed think time
|
2016-06-04 15:24:23 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->angles = UTIL_VecToAngles( pev->velocity );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
pev->solid = SOLID_BBOX;
|
|
|
|
|
|
|
|
// if hornet is close to the enemy, jet in a straight line for a half second.
|
|
|
|
// (only in the single player game)
|
2017-06-29 15:56:03 +02:00
|
|
|
if( m_hEnemy != 0 && !g_pGameRules->IsMultiplayer() )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
if( flDelta >= 0.4f && ( pev->origin - m_vecEnemyLKP ).Length() <= 300 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin );
|
|
|
|
WRITE_BYTE( TE_SPRITE );
|
2016-07-31 15:48:50 +02:00
|
|
|
WRITE_COORD( pev->origin.x ); // pos
|
|
|
|
WRITE_COORD( pev->origin.y );
|
|
|
|
WRITE_COORD( pev->origin.z );
|
2016-06-04 15:24:23 +02:00
|
|
|
WRITE_SHORT( iHornetPuff ); // model
|
|
|
|
// WRITE_BYTE( 0 ); // life * 10
|
|
|
|
WRITE_BYTE( 2 ); // size * 10
|
|
|
|
WRITE_BYTE( 128 ); // brightness
|
|
|
|
MESSAGE_END();
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
switch( RANDOM_LONG( 0, 2 ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
case 0:
|
|
|
|
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_buzz1.wav", HORNET_BUZZ_VOLUME, ATTN_NORM );
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_buzz2.wav", HORNET_BUZZ_VOLUME, ATTN_NORM );
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_buzz3.wav", HORNET_BUZZ_VOLUME, ATTN_NORM );
|
|
|
|
break;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->velocity = pev->velocity * 2.0f;
|
|
|
|
pev->nextthink = gpGlobals->time + 1.0f;
|
2016-06-04 15:24:23 +02:00
|
|
|
// don't attack again
|
|
|
|
m_flStopAttack = gpGlobals->time;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Tracking Hornet hit something
|
|
|
|
//=========================================================
|
2016-07-31 15:48:50 +02:00
|
|
|
void CHornet::TrackTouch( CBaseEntity *pOther )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pOther->edict() == pev->owner || pOther->pev->modelindex == pev->modelindex )
|
2016-06-25 18:33:39 +02:00
|
|
|
{
|
|
|
|
// bumped into the guy that shot it.
|
2016-06-04 15:24:23 +02:00
|
|
|
pev->solid = SOLID_NOT;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( IRelationship( pOther ) <= R_NO )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// hit something we don't want to hurt, so turn around.
|
|
|
|
|
|
|
|
pev->velocity = pev->velocity.Normalize();
|
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->velocity.x *= -1.0f;
|
|
|
|
pev->velocity.y *= -1.0f;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->origin = pev->origin + pev->velocity * 4.0f; // bounce the hornet off a bit.
|
2016-06-04 15:24:23 +02:00
|
|
|
pev->velocity = pev->velocity * m_flFlySpeed;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DieTouch( pOther );
|
|
|
|
}
|
|
|
|
|
|
|
|
void CHornet::DartTouch( CBaseEntity *pOther )
|
|
|
|
{
|
|
|
|
DieTouch( pOther );
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CHornet::DieTouch( CBaseEntity *pOther )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2017-07-02 13:11:40 +02:00
|
|
|
if( pOther && pOther->pev->takedamage && pev->owner )
|
2016-06-25 18:33:39 +02:00
|
|
|
{
|
|
|
|
// do the damage
|
2016-07-31 15:48:50 +02:00
|
|
|
switch( RANDOM_LONG( 0, 2 ) )
|
2016-06-25 18:33:39 +02:00
|
|
|
{
|
|
|
|
// buzz when you plug someone
|
2016-07-31 15:48:50 +02:00
|
|
|
case 0:
|
|
|
|
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_hornethit1.wav", 1, ATTN_NORM );
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_hornethit2.wav", 1, ATTN_NORM );
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "hornet/ag_hornethit3.wav", 1, ATTN_NORM );
|
|
|
|
break;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
pOther->TakeDamage( pev, VARS( pev->owner ), pev->dmg, DMG_BULLET );
|
|
|
|
}
|
|
|
|
|
|
|
|
pev->modelindex = 0;// so will disappear for the 0.1 secs we wait until NEXTTHINK gets rid
|
|
|
|
pev->solid = SOLID_NOT;
|
|
|
|
|
|
|
|
SetThink( &CBaseEntity::SUB_Remove );
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->nextthink = gpGlobals->time + 1.0f;// stick around long enough for the sound to finish!
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|