Portable Half-Life SDK. GoldSource and Xash3D. Crossplatform.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

708 lines
18 KiB

9 years ago
/***
*
* 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.
*
****/
9 years ago
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "weapons.h"
#include "nodes.h"
#include "soundent.h"
#include "effects.h"
#include "customentity.h"
#include "osprey.h"
9 years ago
typedef struct
{
int isValid;
EHANDLE hGrunt;
Vector vecOrigin;
Vector vecAngles;
} t_ospreygrunt;
#define SF_WAITFORTRIGGER 0x40
LINK_ENTITY_TO_CLASS( monster_osprey, COsprey )
9 years ago
TYPEDESCRIPTION COsprey::m_SaveData[] =
9 years ago
{
DEFINE_FIELD( COsprey, m_pGoalEnt, FIELD_CLASSPTR ),
DEFINE_FIELD( COsprey, m_vel1, FIELD_VECTOR ),
DEFINE_FIELD( COsprey, m_vel2, FIELD_VECTOR ),
DEFINE_FIELD( COsprey, m_pos1, FIELD_POSITION_VECTOR ),
DEFINE_FIELD( COsprey, m_pos2, FIELD_POSITION_VECTOR ),
DEFINE_FIELD( COsprey, m_ang1, FIELD_VECTOR ),
DEFINE_FIELD( COsprey, m_ang2, FIELD_VECTOR ),
DEFINE_FIELD( COsprey, m_startTime, FIELD_TIME ),
DEFINE_FIELD( COsprey, m_dTime, FIELD_FLOAT ),
DEFINE_FIELD( COsprey, m_velocity, FIELD_VECTOR ),
DEFINE_FIELD( COsprey, m_flIdealtilt, FIELD_FLOAT ),
DEFINE_FIELD( COsprey, m_flRotortilt, FIELD_FLOAT ),
DEFINE_FIELD( COsprey, m_flRightHealth, FIELD_FLOAT ),
DEFINE_FIELD( COsprey, m_flLeftHealth, FIELD_FLOAT ),
DEFINE_FIELD( COsprey, m_iUnits, FIELD_INTEGER ),
DEFINE_ARRAY( COsprey, m_hGrunt, FIELD_EHANDLE, OSPREY_MAX_CARRY ),
DEFINE_ARRAY( COsprey, m_vecOrigin, FIELD_POSITION_VECTOR, OSPREY_MAX_CARRY ),
9 years ago
DEFINE_ARRAY( COsprey, m_hRepel, FIELD_EHANDLE, 4 ),
// DEFINE_FIELD( COsprey, m_iSoundState, FIELD_INTEGER ),
// DEFINE_FIELD( COsprey, m_iSpriteTexture, FIELD_INTEGER ),
// DEFINE_FIELD( COsprey, m_iPitch, FIELD_INTEGER ),
DEFINE_FIELD( COsprey, m_iDoLeftSmokePuff, FIELD_INTEGER ),
DEFINE_FIELD( COsprey, m_iDoRightSmokePuff, FIELD_INTEGER ),
};
IMPLEMENT_SAVERESTORE( COsprey, CBaseMonster )
9 years ago
9 years ago
void COsprey::Spawn( void )
9 years ago
{
9 years ago
Precache();
9 years ago
// motor
pev->movetype = MOVETYPE_FLY;
pev->solid = SOLID_BBOX;
9 years ago
SET_MODEL( ENT( pev ), "models/osprey.mdl" );
UTIL_SetSize( pev, Vector( -400, -400, -100 ), Vector( 400, 400, 32 ) );
9 years ago
UTIL_SetOrigin( pev, pev->origin );
pev->flags |= FL_MONSTER;
9 years ago
pev->takedamage = DAMAGE_YES;
m_flRightHealth = 200;
m_flLeftHealth = 200;
pev->health = 400;
9 years ago
m_flFieldOfView = 0; // 180 degrees
pev->sequence = 0;
9 years ago
ResetSequenceInfo();
pev->frame = RANDOM_LONG( 0, 0xFF );
9 years ago
InitBoneControllers();
SetThink( &COsprey::FindAllThink );
SetUse( &COsprey::CommandUse );
9 years ago
if( !( pev->spawnflags & SF_WAITFORTRIGGER ) )
9 years ago
{
pev->nextthink = gpGlobals->time + 1.0;
}
m_pos2 = pev->origin;
m_ang2 = pev->angles;
m_vel2 = pev->velocity;
}
void COsprey::Precache( void )
{
UTIL_PrecacheOther( "monster_human_grunt" );
9 years ago
PRECACHE_MODEL( "models/osprey.mdl" );
PRECACHE_MODEL( "models/HVR.mdl" );
9 years ago
9 years ago
PRECACHE_SOUND( "apache/ap_rotor4.wav" );
PRECACHE_SOUND( "weapons/mortarhit.wav" );
9 years ago
m_iSpriteTexture = PRECACHE_MODEL( "sprites/rope.spr" );
9 years ago
m_iExplode = PRECACHE_MODEL( "sprites/fexplo.spr" );
9 years ago
m_iTailGibs = PRECACHE_MODEL( "models/osprey_tailgibs.mdl" );
m_iBodyGibs = PRECACHE_MODEL( "models/osprey_bodygibs.mdl" );
m_iEngineGibs = PRECACHE_MODEL( "models/osprey_enginegibs.mdl" );
}
void COsprey::CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
pev->nextthink = gpGlobals->time + 0.1;
}
9 years ago
void COsprey::FindAllThink( void )
9 years ago
{
CBaseEntity *pEntity = NULL;
m_iUnits = 0;
while( m_iUnits < OSPREY_MAX_CARRY && ( pEntity = UTIL_FindEntityByClassname( pEntity, "monster_human_grunt" ) ) != NULL )
9 years ago
{
9 years ago
if( pEntity->IsAlive() )
9 years ago
{
9 years ago
m_hGrunt[m_iUnits] = pEntity;
m_vecOrigin[m_iUnits] = pEntity->pev->origin;
9 years ago
m_iUnits++;
}
}
9 years ago
if( m_iUnits == 0 )
9 years ago
{
9 years ago
ALERT( at_console, "osprey error: no grunts to resupply\n" );
9 years ago
UTIL_Remove( this );
return;
}
SetThink( &COsprey::FlyThink );
pev->nextthink = gpGlobals->time + 0.1;
m_startTime = gpGlobals->time;
}
9 years ago
void COsprey::DeployThink( void )
9 years ago
{
UTIL_MakeAimVectors( pev->angles );
Vector vecForward = gpGlobals->v_forward;
Vector vecRight = gpGlobals->v_right;
Vector vecUp = gpGlobals->v_up;
Vector vecSrc;
TraceResult tr;
9 years ago
UTIL_TraceLine( pev->origin, pev->origin + Vector( 0, 0, -4096.0 ), ignore_monsters, ENT( pev ), &tr );
CSoundEnt::InsertSound( bits_SOUND_DANGER, tr.vecEndPos, 400, 0.3 );
9 years ago
vecSrc = pev->origin + vecForward * 32 + vecRight * 100 + vecUp * -96;
m_hRepel[0] = MakeGrunt( vecSrc );
vecSrc = pev->origin + vecForward * -64 + vecRight * 100 + vecUp * -96;
m_hRepel[1] = MakeGrunt( vecSrc );
vecSrc = pev->origin + vecForward * 32 + vecRight * -100 + vecUp * -96;
m_hRepel[2] = MakeGrunt( vecSrc );
vecSrc = pev->origin + vecForward * -64 + vecRight * -100 + vecUp * -96;
m_hRepel[3] = MakeGrunt( vecSrc );
SetThink( &COsprey::HoverThink );
pev->nextthink = gpGlobals->time + 0.1;
}
9 years ago
BOOL COsprey::HasDead()
9 years ago
{
9 years ago
for( int i = 0; i < m_iUnits; i++ )
9 years ago
{
if( m_hGrunt[i] == 0 || !m_hGrunt[i]->IsAlive() )
9 years ago
{
return TRUE;
}
else
{
m_vecOrigin[i] = m_hGrunt[i]->pev->origin; // send them to where they died
}
}
return FALSE;
}
9 years ago
CBaseMonster *COsprey::MakeGrunt( Vector vecSrc )
9 years ago
{
CBaseEntity *pEntity;
CBaseMonster *pGrunt;
TraceResult tr;
9 years ago
UTIL_TraceLine( vecSrc, vecSrc + Vector( 0, 0, -4096.0 ), dont_ignore_monsters, ENT( pev ), &tr );
if( tr.pHit && Instance( tr.pHit )->pev->solid != SOLID_BSP )
9 years ago
return NULL;
9 years ago
for( int i = 0; i < m_iUnits; i++ )
9 years ago
{
if( m_hGrunt[i] == 0 || !m_hGrunt[i]->IsAlive() )
9 years ago
{
if( m_hGrunt[i] != 0 && m_hGrunt[i]->pev->rendermode == kRenderNormal )
9 years ago
{
9 years ago
m_hGrunt[i]->SUB_StartFadeOut();
9 years ago
}
pEntity = Create( "monster_human_grunt", vecSrc, pev->angles );
9 years ago
pGrunt = pEntity->MyMonsterPointer();
9 years ago
pGrunt->pev->movetype = MOVETYPE_FLY;
pGrunt->pev->velocity = Vector( 0, 0, RANDOM_FLOAT( -196, -128 ) );
pGrunt->SetActivity( ACT_GLIDE );
CBeam *pBeam = CBeam::BeamCreate( "sprites/rope.spr", 10 );
pBeam->PointEntInit( vecSrc + Vector(0,0,112), pGrunt->entindex() );
pBeam->SetFlags( BEAM_FSOLID );
pBeam->SetColor( 255, 255, 255 );
pBeam->SetThink( &CBaseEntity::SUB_Remove );
pBeam->pev->nextthink = gpGlobals->time + -4096.0 * tr.flFraction / pGrunt->pev->velocity.z + 0.5;
// ALERT( at_console, "%d at %.0f %.0f %.0f\n", i, m_vecOrigin[i].x, m_vecOrigin[i].y, m_vecOrigin[i].z );
pGrunt->m_vecLastPosition = m_vecOrigin[i];
m_hGrunt[i] = pGrunt;
return pGrunt;
}
}
// ALERT( at_console, "none dead\n");
return NULL;
}
9 years ago
void COsprey::HoverThink( void )
9 years ago
{
int i;
9 years ago
for( i = 0; i < 4; i++ )
9 years ago
{
if( m_hRepel[i] != 0 && m_hRepel[i]->pev->health > 0 && !( m_hRepel[i]->pev->flags & FL_ONGROUND ) )
9 years ago
{
break;
}
}
9 years ago
if( i == 4 )
9 years ago
{
m_startTime = gpGlobals->time;
SetThink( &COsprey::FlyThink );
}
pev->nextthink = gpGlobals->time + 0.1;
UTIL_MakeAimVectors( pev->angles );
9 years ago
ShowDamage();
9 years ago
}
9 years ago
void COsprey::UpdateGoal()
9 years ago
{
9 years ago
if( m_pGoalEnt )
9 years ago
{
m_pos1 = m_pos2;
m_ang1 = m_ang2;
m_vel1 = m_vel2;
m_pos2 = m_pGoalEnt->pev->origin;
m_ang2 = m_pGoalEnt->pev->angles;
UTIL_MakeAimVectors( Vector( 0, m_ang2.y, 0 ) );
m_vel2 = gpGlobals->v_forward * m_pGoalEnt->pev->speed;
m_startTime = m_startTime + m_dTime;
9 years ago
m_dTime = 2.0 * ( m_pos1 - m_pos2 ).Length() / ( m_vel1.Length() + m_pGoalEnt->pev->speed );
9 years ago
9 years ago
if( m_ang1.y - m_ang2.y < -180 )
9 years ago
{
m_ang1.y += 360;
}
9 years ago
else if( m_ang1.y - m_ang2.y > 180 )
9 years ago
{
m_ang1.y -= 360;
}
9 years ago
if( m_pGoalEnt->pev->speed < 400 )
9 years ago
m_flIdealtilt = 0;
else
m_flIdealtilt = -90;
}
else
{
9 years ago
ALERT( at_console, "osprey missing target" );
9 years ago
}
}
void COsprey::FlyThink( void )
{
9 years ago
StudioFrameAdvance();
9 years ago
pev->nextthink = gpGlobals->time + 0.1;
9 years ago
if( m_pGoalEnt == NULL && !FStringNull( pev->target) )// this monster has a target
9 years ago
{
9 years ago
m_pGoalEnt = CBaseEntity::Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->target ) ) );
UpdateGoal();
9 years ago
}
9 years ago
if( gpGlobals->time > m_startTime + m_dTime )
9 years ago
{
9 years ago
if( m_pGoalEnt->pev->speed == 0 )
9 years ago
{
SetThink( &COsprey::DeployThink );
}
9 years ago
do{
m_pGoalEnt = CBaseEntity::Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_pGoalEnt->pev->target ) ) );
} while( m_pGoalEnt->pev->speed < 400 && !HasDead() );
UpdateGoal();
9 years ago
}
9 years ago
Flight();
ShowDamage();
9 years ago
}
9 years ago
void COsprey::Flight()
9 years ago
{
9 years ago
float t = ( gpGlobals->time - m_startTime );
9 years ago
float scale = 1.0 / m_dTime;
9 years ago
9 years ago
float f = UTIL_SplineFraction( t * scale, 1.0 );
9 years ago
Vector pos = ( m_pos1 + m_vel1 * t ) * ( 1.0 - f ) + ( m_pos2 - m_vel2 * ( m_dTime - t ) ) * f;
Vector ang = ( m_ang1 ) * ( 1.0 - f ) + ( m_ang2 ) * f;
m_velocity = m_vel1 * ( 1.0 - f ) + m_vel2 * f;
9 years ago
UTIL_SetOrigin( pev, pos );
pev->angles = ang;
UTIL_MakeAimVectors( pev->angles );
float flSpeed = DotProduct( gpGlobals->v_forward, m_velocity );
// float flSpeed = DotProduct( gpGlobals->v_forward, pev->velocity );
9 years ago
float m_flIdealtilt = ( 160 - flSpeed ) / 10.0;
9 years ago
// ALERT( at_console, "%f %f\n", flSpeed, flIdealtilt );
9 years ago
if( m_flRotortilt < m_flIdealtilt )
9 years ago
{
m_flRotortilt += 0.5;
9 years ago
if ( m_flRotortilt > 0 )
9 years ago
m_flRotortilt = 0;
}
9 years ago
if( m_flRotortilt > m_flIdealtilt )
9 years ago
{
m_flRotortilt -= 0.5;
9 years ago
if( m_flRotortilt < -90 )
9 years ago
m_flRotortilt = -90;
}
SetBoneController( 0, m_flRotortilt );
9 years ago
if( m_iSoundState == 0 )
9 years ago
{
9 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_rotor4.wav", 1.0, 0.15, 0, 110 );
// EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_whine1.wav", 0.5, 0.2, 0, 110 );
9 years ago
m_iSoundState = SND_CHANGE_PITCH; // hack for going through level transitions
}
else
{
CBaseEntity *pPlayer = NULL;
pPlayer = UTIL_FindEntityByClassname( NULL, "player" );
// UNDONE: this needs to send different sounds to every player for multiplayer.
9 years ago
if( pPlayer )
9 years ago
{
9 years ago
float pitch = DotProduct( m_velocity - pPlayer->pev->velocity, ( pPlayer->pev->origin - pev->origin ).Normalize() );
9 years ago
9 years ago
pitch = (int)( 100 + pitch / 75.0 );
9 years ago
9 years ago
if( pitch > 250 )
9 years ago
pitch = 250;
9 years ago
if( pitch < 50 )
9 years ago
pitch = 50;
9 years ago
if( pitch == 100 )
9 years ago
pitch = 101;
9 years ago
if( pitch != m_iPitch )
9 years ago
{
m_iPitch = pitch;
9 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_rotor4.wav", 1.0, 0.15, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch );
9 years ago
// ALERT( at_console, "%.0f\n", pitch );
}
}
9 years ago
// EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_whine1.wav", flVol, 0.2, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch );
9 years ago
}
}
void COsprey::HitTouch( CBaseEntity *pOther )
{
pev->nextthink = gpGlobals->time + 2.0;
}
/*
int COsprey::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{
9 years ago
if( m_flRotortilt <= -90 )
9 years ago
{
m_flRotortilt = 0;
}
else
{
m_flRotortilt -= 45;
}
SetBoneController( 0, m_flRotortilt );
return 0;
}
*/
9 years ago
void COsprey::Killed( entvars_t *pevAttacker, int iGib )
9 years ago
{
pev->movetype = MOVETYPE_TOSS;
pev->gravity = 0.3;
pev->velocity = m_velocity;
pev->avelocity = Vector( RANDOM_FLOAT( -20, 20 ), 0, RANDOM_FLOAT( -50, 50 ) );
9 years ago
STOP_SOUND( ENT( pev ), CHAN_STATIC, "apache/ap_rotor4.wav" );
9 years ago
9 years ago
UTIL_SetSize( pev, Vector( -32, -32, -64 ), Vector( 32, 32, 0 ) );
9 years ago
SetThink( &COsprey::DyingThink );
SetTouch( &COsprey::CrashTouch );
pev->nextthink = gpGlobals->time + 0.1;
pev->health = 0;
pev->takedamage = DAMAGE_NO;
m_startTime = gpGlobals->time + 4.0;
}
void COsprey::CrashTouch( CBaseEntity *pOther )
{
// only crash if we hit something solid
9 years ago
if( pOther->pev->solid == SOLID_BSP )
9 years ago
{
SetTouch( NULL );
m_startTime = gpGlobals->time;
pev->nextthink = gpGlobals->time;
m_velocity = pev->velocity;
}
}
9 years ago
void COsprey::DyingThink( void )
9 years ago
{
9 years ago
StudioFrameAdvance();
9 years ago
pev->nextthink = gpGlobals->time + 0.1;
pev->avelocity = pev->avelocity * 1.02;
// still falling?
9 years ago
if( m_startTime > gpGlobals->time )
9 years ago
{
UTIL_MakeAimVectors( pev->angles );
9 years ago
ShowDamage();
9 years ago
Vector vecSpot = pev->origin + pev->velocity * 0.2;
// random explosions
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot );
9 years ago
WRITE_BYTE( TE_EXPLOSION ); // This just makes a dynamic light now
WRITE_COORD( vecSpot.x + RANDOM_FLOAT( -150, 150 ) );
WRITE_COORD( vecSpot.y + RANDOM_FLOAT( -150, 150 ) );
WRITE_COORD( vecSpot.z + RANDOM_FLOAT( -150, -50 ) );
9 years ago
WRITE_SHORT( g_sModelIndexFireball );
9 years ago
WRITE_BYTE( RANDOM_LONG( 0, 29 ) + 30 ); // scale * 10
WRITE_BYTE( 12 ); // framerate
9 years ago
WRITE_BYTE( TE_EXPLFLAG_NONE );
MESSAGE_END();
// lots of smoke
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot );
WRITE_BYTE( TE_SMOKE );
9 years ago
WRITE_COORD( vecSpot.x + RANDOM_FLOAT( -150, 150 ) );
WRITE_COORD( vecSpot.y + RANDOM_FLOAT( -150, 150 ) );
WRITE_COORD( vecSpot.z + RANDOM_FLOAT( -150, -50 ) );
9 years ago
WRITE_SHORT( g_sModelIndexSmoke );
WRITE_BYTE( 100 ); // scale * 10
9 years ago
WRITE_BYTE( 10 ); // framerate
9 years ago
MESSAGE_END();
9 years ago
vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5;
9 years ago
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot );
WRITE_BYTE( TE_BREAKMODEL);
// position
WRITE_COORD( vecSpot.x );
WRITE_COORD( vecSpot.y );
WRITE_COORD( vecSpot.z );
// size
WRITE_COORD( 800 );
WRITE_COORD( 800 );
WRITE_COORD( 132 );
// velocity
WRITE_COORD( pev->velocity.x );
WRITE_COORD( pev->velocity.y );
WRITE_COORD( pev->velocity.z );
// randomization
WRITE_BYTE( 50 );
// Model
WRITE_SHORT( m_iTailGibs ); //model id#
// # of shards
WRITE_BYTE( 8 ); // let client decide
// duration
WRITE_BYTE( 200 );// 10.0 seconds
// flags
WRITE_BYTE( BREAK_METAL );
MESSAGE_END();
// don't stop it we touch a entity
pev->flags &= ~FL_ONGROUND;
pev->nextthink = gpGlobals->time + 0.2;
return;
}
else
{
9 years ago
Vector vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5;
9 years ago
/*
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_EXPLOSION); // This just makes a dynamic light now
WRITE_COORD( vecSpot.x );
WRITE_COORD( vecSpot.y );
WRITE_COORD( vecSpot.z + 512 );
WRITE_SHORT( m_iExplode );
WRITE_BYTE( 250 ); // scale * 10
9 years ago
WRITE_BYTE( 10 ); // framerate
9 years ago
MESSAGE_END();
*/
// gibs
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot );
WRITE_BYTE( TE_SPRITE );
WRITE_COORD( vecSpot.x );
WRITE_COORD( vecSpot.y );
WRITE_COORD( vecSpot.z + 512 );
WRITE_SHORT( m_iExplode );
WRITE_BYTE( 250 ); // scale * 10
WRITE_BYTE( 255 ); // brightness
MESSAGE_END();
/*
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_SMOKE );
WRITE_COORD( vecSpot.x );
WRITE_COORD( vecSpot.y );
WRITE_COORD( vecSpot.z + 300 );
WRITE_SHORT( g_sModelIndexSmoke );
WRITE_BYTE( 250 ); // scale * 10
9 years ago
WRITE_BYTE( 6 ); // framerate
9 years ago
MESSAGE_END();
*/
// blast circle
MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin );
WRITE_BYTE( TE_BEAMCYLINDER );
WRITE_COORD( pev->origin.x);
WRITE_COORD( pev->origin.y);
WRITE_COORD( pev->origin.z);
WRITE_COORD( pev->origin.x);
WRITE_COORD( pev->origin.y);
WRITE_COORD( pev->origin.z + 2000 ); // reach damage radius over .2 seconds
WRITE_SHORT( m_iSpriteTexture );
WRITE_BYTE( 0 ); // startframe
WRITE_BYTE( 0 ); // framerate
WRITE_BYTE( 4 ); // life
WRITE_BYTE( 32 ); // width
WRITE_BYTE( 0 ); // noise
WRITE_BYTE( 255 ); // r, g, b
WRITE_BYTE( 255 ); // r, g, b
WRITE_BYTE( 192 ); // r, g, b
WRITE_BYTE( 128 ); // brightness
WRITE_BYTE( 0 ); // speed
MESSAGE_END();
9 years ago
EMIT_SOUND( ENT( pev ), CHAN_STATIC, "weapons/mortarhit.wav", 1.0, 0.3 );
9 years ago
RadiusDamage( pev->origin, pev, pev, 300, CLASS_NONE, DMG_BLAST );
// gibs
9 years ago
vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5;
9 years ago
MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, vecSpot );
WRITE_BYTE( TE_BREAKMODEL);
// position
WRITE_COORD( vecSpot.x );
WRITE_COORD( vecSpot.y );
9 years ago
WRITE_COORD( vecSpot.z + 64 );
9 years ago
// size
WRITE_COORD( 800 );
WRITE_COORD( 800 );
WRITE_COORD( 128 );
// velocity
WRITE_COORD( m_velocity.x );
WRITE_COORD( m_velocity.y );
WRITE_COORD( fabs( m_velocity.z ) * 0.25 );
// randomization
WRITE_BYTE( 40 );
// Model
WRITE_SHORT( m_iBodyGibs ); //model id#
// # of shards
WRITE_BYTE( 128 );
// duration
WRITE_BYTE( 200 );// 10.0 seconds
// flags
WRITE_BYTE( BREAK_METAL );
MESSAGE_END();
UTIL_Remove( this );
}
}
9 years ago
void COsprey::ShowDamage( void )
9 years ago
{
9 years ago
if( m_iDoLeftSmokePuff > 0 || RANDOM_LONG( 0, 99 ) > m_flLeftHealth )
9 years ago
{
Vector vecSrc = pev->origin + gpGlobals->v_right * -340;
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc );
WRITE_BYTE( TE_SMOKE );
WRITE_COORD( vecSrc.x );
WRITE_COORD( vecSrc.y );
WRITE_COORD( vecSrc.z );
WRITE_SHORT( g_sModelIndexSmoke );
9 years ago
WRITE_BYTE( RANDOM_LONG( 0, 9 ) + 20 ); // scale * 10
9 years ago
WRITE_BYTE( 12 ); // framerate
MESSAGE_END();
9 years ago
if( m_iDoLeftSmokePuff > 0 )
9 years ago
m_iDoLeftSmokePuff--;
}
9 years ago
if( m_iDoRightSmokePuff > 0 || RANDOM_LONG( 0, 99 ) > m_flRightHealth )
9 years ago
{
Vector vecSrc = pev->origin + gpGlobals->v_right * 340;
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSrc );
WRITE_BYTE( TE_SMOKE );
WRITE_COORD( vecSrc.x );
WRITE_COORD( vecSrc.y );
WRITE_COORD( vecSrc.z );
WRITE_SHORT( g_sModelIndexSmoke );
9 years ago
WRITE_BYTE( RANDOM_LONG( 0, 9 ) + 20 ); // scale * 10
9 years ago
WRITE_BYTE( 12 ); // framerate
MESSAGE_END();
9 years ago
if( m_iDoRightSmokePuff > 0 )
9 years ago
m_iDoRightSmokePuff--;
}
}
9 years ago
void COsprey::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType )
9 years ago
{
// ALERT( at_console, "%d %.0f\n", ptr->iHitgroup, flDamage );
// only so much per engine
9 years ago
if( ptr->iHitgroup == 3 )
9 years ago
{
9 years ago
if( m_flRightHealth < 0 )
9 years ago
return;
else
m_flRightHealth -= flDamage;
9 years ago
m_iDoLeftSmokePuff = 3 + ( flDamage / 5.0 );
9 years ago
}
9 years ago
if( ptr->iHitgroup == 2 )
9 years ago
{
9 years ago
if( m_flLeftHealth < 0 )
9 years ago
return;
else
m_flLeftHealth -= flDamage;
9 years ago
m_iDoRightSmokePuff = 3 + ( flDamage / 5.0 );
9 years ago
}
// hit hard, hits cockpit, hits engines
9 years ago
if( flDamage > 50 || ptr->iHitgroup == 1 || ptr->iHitgroup == 2 || ptr->iHitgroup == 3 )
9 years ago
{
// ALERT( at_console, "%.0f\n", flDamage );
AddMultiDamage( pevAttacker, this, flDamage, bitsDamageType );
}
else
{
UTIL_Sparks( ptr->vecEndPos );
}
}