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.

798 lines
20 KiB

7 years ago
/***
*
9 years ago
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
7 years ago
*
* 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.
*
****/
7 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"
typedef struct
{
int isValid;
EHANDLE hGrunt;
Vector vecOrigin;
Vector vecAngles;
} t_ospreygrunt;
#define SF_WAITFORTRIGGER 0x40
#define MAX_CARRY 24
class COsprey : public CBaseMonster
{
public:
8 years ago
int Save( CSave &save );
int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
int ObjectCaps( void ) { return CBaseMonster::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }
7 years ago
void Spawn( void );
void Precache( void );
int Classify( void ) { return CLASS_MACHINE; }
8 years ago
int BloodColor( void ) { return DONT_BLEED; }
7 years ago
void Killed( entvars_t *pevAttacker, int iGib );
void UpdateGoal( void );
BOOL HasDead( void );
void EXPORT FlyThink( void );
void EXPORT DeployThink( void );
void Flight( void );
void EXPORT HitTouch( CBaseEntity *pOther );
void EXPORT FindAllThink( void );
void EXPORT HoverThink( void );
CBaseMonster *MakeGrunt( Vector vecSrc );
void EXPORT CrashTouch( CBaseEntity *pOther );
void EXPORT DyingThink( void );
void EXPORT CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
8 years ago
// int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType );
7 years ago
void ShowDamage( void );
CBaseEntity *m_pGoalEnt;
Vector m_vel1;
Vector m_vel2;
Vector m_pos1;
Vector m_pos2;
Vector m_ang1;
Vector m_ang2;
float m_startTime;
float m_dTime;
Vector m_velocity;
float m_flIdealtilt;
float m_flRotortilt;
float m_flRightHealth;
float m_flLeftHealth;
8 years ago
int m_iUnits;
7 years ago
EHANDLE m_hGrunt[MAX_CARRY];
Vector m_vecOrigin[MAX_CARRY];
EHANDLE m_hRepel[4];
int m_iSoundState;
int m_iSpriteTexture;
int m_iPitch;
int m_iExplode;
8 years ago
int m_iTailGibs;
int m_iBodyGibs;
int m_iEngineGibs;
7 years ago
int m_iDoLeftSmokePuff;
int m_iDoRightSmokePuff;
};
LINK_ENTITY_TO_CLASS( monster_osprey, COsprey )
7 years ago
TYPEDESCRIPTION COsprey::m_SaveData[] =
7 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, MAX_CARRY ),
DEFINE_ARRAY( COsprey, m_vecOrigin, FIELD_POSITION_VECTOR, MAX_CARRY ),
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
8 years ago
void COsprey::Spawn( void )
7 years ago
{
8 years ago
Precache();
7 years ago
// motor
pev->movetype = MOVETYPE_FLY;
pev->solid = SOLID_BBOX;
if (pev->model)
SET_MODEL(ENT(pev), STRING(pev->model)); //LRC
else
SET_MODEL( ENT( pev ), "models/osprey.mdl" );
8 years ago
UTIL_SetSize( pev, Vector( -400, -400, -100 ), Vector( 400, 400, 32 ) );
7 years ago
UTIL_SetOrigin( this, pev->origin );
//ALERT(at_console, "Osprey origin %f %f %f\n", pev->origin.x, pev->origin.y, pev->origin.z);
pev->flags |= FL_MONSTER;
8 years ago
pev->takedamage = DAMAGE_YES;
m_flRightHealth = 200;
m_flLeftHealth = 200;
pev->health = 400;
7 years ago
pev->speed = 80; //LRC - default speed, in case path corners don't give a speed.
m_flFieldOfView = 0; // 180 degrees
pev->sequence = 0;
8 years ago
ResetSequenceInfo();
pev->frame = RANDOM_LONG( 0, 0xFF );
7 years ago
InitBoneControllers();
9 years ago
SetThink( &COsprey::FindAllThink );
SetUse( &COsprey::CommandUse );
7 years ago
8 years ago
if( !( pev->spawnflags & SF_WAITFORTRIGGER ) )
7 years ago
{
SetNextThink( 1.0 );
}
m_pos2 = pev->origin;
m_ang2 = pev->angles;
m_vel2 = pev->velocity;
}
void COsprey::Precache( void )
{
UTIL_PrecacheOther( "monster_human_grunt" );
if (pev->model)
PRECACHE_MODEL(STRING(pev->model)); //LRC
7 years ago
else
PRECACHE_MODEL( "models/osprey.mdl" );
8 years ago
PRECACHE_MODEL( "models/HVR.mdl" );
7 years ago
8 years ago
PRECACHE_SOUND( "apache/ap_rotor4.wav" );
PRECACHE_SOUND( "weapons/mortarhit.wav" );
7 years ago
m_iSpriteTexture = PRECACHE_MODEL( "sprites/rope.spr" );
8 years ago
m_iExplode = PRECACHE_MODEL( "sprites/fexplo.spr" );
7 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 )
{
SetNextThink( 0.1 );
}
8 years ago
void COsprey::FindAllThink( void )
7 years ago
{
CBaseEntity *pEntity = NULL;
m_iUnits = 0;
8 years ago
while( m_iUnits < MAX_CARRY && ( pEntity = UTIL_FindEntityByClassname( pEntity, "monster_human_grunt" ) ) != NULL )
7 years ago
{
8 years ago
if( pEntity->IsAlive() )
7 years ago
{
8 years ago
m_hGrunt[m_iUnits] = pEntity;
m_vecOrigin[m_iUnits] = pEntity->pev->origin;
7 years ago
m_iUnits++;
}
}
8 years ago
if( m_iUnits == 0 )
7 years ago
{
m_iUnits = 4; //LRC - stop whining, just make the damn grunts...
// ALERT( at_console, "osprey error: no grunts to resupply\n");
// UTIL_Remove( this );
// return;
}
9 years ago
SetThink( &COsprey::FlyThink );
7 years ago
SetNextThink( 0.1 );
m_startTime = gpGlobals->time;
}
8 years ago
void COsprey::DeployThink( void )
7 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;
8 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 );
7 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 );
9 years ago
SetThink( &COsprey::HoverThink );
7 years ago
SetNextThink( 0.1 );
}
8 years ago
BOOL COsprey::HasDead()
7 years ago
{
8 years ago
for( int i = 0; i < m_iUnits; i++ )
7 years ago
{
if( m_hGrunt[i] == 0 || !m_hGrunt[i]->IsAlive() )
7 years ago
{
return TRUE;
}
else
{
m_vecOrigin[i] = m_hGrunt[i]->pev->origin; // send them to where they died
}
}
return FALSE;
}
8 years ago
CBaseMonster *COsprey::MakeGrunt( Vector vecSrc )
7 years ago
{
CBaseEntity *pEntity;
CBaseMonster *pGrunt;
TraceResult tr;
8 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 )
7 years ago
return NULL;
8 years ago
for( int i = 0; i < m_iUnits; i++ )
7 years ago
{
if( m_hGrunt[i] == 0 || !m_hGrunt[i]->IsAlive() )
7 years ago
{
if( m_hGrunt[i] != 0 && m_hGrunt[i]->pev->rendermode == kRenderNormal )
7 years ago
{
8 years ago
m_hGrunt[i]->SUB_StartFadeOut();
7 years ago
}
pEntity = Create( "monster_human_grunt", vecSrc, pev->angles );
8 years ago
pGrunt = pEntity->MyMonsterPointer();
7 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(&CBeam:: SUB_Remove );
pBeam->SetNextThink( -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;
}
8 years ago
void COsprey::HoverThink( void )
7 years ago
{
int i;
8 years ago
for( i = 0; i < 4; i++ )
7 years ago
{
if( m_hRepel[i] != 0 && m_hRepel[i]->pev->health > 0 && !( m_hRepel[i]->pev->flags & FL_ONGROUND ) )
7 years ago
{
break;
}
}
8 years ago
if( i == 4 )
7 years ago
{
m_startTime = gpGlobals->time;
9 years ago
SetThink( &COsprey::FlyThink );
7 years ago
}
SetNextThink( 0.1 );
UTIL_MakeAimVectors( pev->angles );
8 years ago
ShowDamage();
7 years ago
}
8 years ago
void COsprey::UpdateGoal()
7 years ago
{
8 years ago
if( m_pGoalEnt )
7 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 ) );
//LRC - ugh. we shouldn't require our path corners to specify a speed!
if (m_pGoalEnt->pev->speed)
pev->speed = m_pGoalEnt->pev->speed;
m_vel2 = gpGlobals->v_forward * pev->speed; //LRC
m_startTime = m_startTime + m_dTime;
m_dTime = 2.0 * (m_pos1 - m_pos2).Length() / (m_vel1.Length() + pev->speed);
//ALERT(at_console, "osprey m_dTime = %f / %f + %f\n", (m_pos1 - m_pos2).Length(), m_vel1.Length(), m_pGoalEnt->pev->speed);
8 years ago
if( m_ang1.y - m_ang2.y < -180 )
7 years ago
{
m_ang1.y += 360;
}
8 years ago
else if( m_ang1.y - m_ang2.y > 180 )
7 years ago
{
m_ang1.y -= 360;
}
if (pev->speed < 400)
m_flIdealtilt = 0;
else
m_flIdealtilt = -90;
}
else
{
8 years ago
ALERT( at_console, "osprey missing target" );
7 years ago
}
}
void COsprey::FlyThink( void )
{
8 years ago
StudioFrameAdvance();
7 years ago
SetNextThink( 0.1 );
8 years ago
if( m_pGoalEnt == NULL && !FStringNull( pev->target) )// this monster has a target
7 years ago
{
m_pGoalEnt = UTIL_FindEntityByTargetname( NULL, STRING( pev->target ) );
8 years ago
UpdateGoal();
7 years ago
}
8 years ago
if( gpGlobals->time > m_startTime + m_dTime )
7 years ago
{
8 years ago
if( m_pGoalEnt->pev->speed == 0 )
7 years ago
{
9 years ago
SetThink( &COsprey::DeployThink );
7 years ago
}
int loopbreaker = 100; //LRC - <slap> don't loop indefinitely!
8 years ago
do{
7 years ago
m_pGoalEnt = UTIL_FindEntityByTargetname( NULL, STRING( m_pGoalEnt->pev->target ) );
loopbreaker--; //LRC
} while (m_pGoalEnt->pev->speed < 400 && !HasDead() && loopbreaker > 0);
8 years ago
UpdateGoal();
7 years ago
}
8 years ago
Flight();
ShowDamage();
7 years ago
}
8 years ago
void COsprey::Flight()
7 years ago
{
8 years ago
float t = ( gpGlobals->time - m_startTime );
7 years ago
float scale = 1.0 / m_dTime;
9 years ago
float f = UTIL_SplineFraction( t * scale, 1.0 );
7 years ago
8 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;
7 years ago
UTIL_SetOrigin( this, pos );
pev->angles = ang;
UTIL_MakeAimVectors( pev->angles );
float flSpeed = DotProduct( gpGlobals->v_forward, m_velocity );
// float flSpeed = DotProduct( gpGlobals->v_forward, pev->velocity );
m_flIdealtilt = (160 - flSpeed) / 10.0;
// ALERT( at_console, "%f %f\n", flSpeed, flIdealtilt );
8 years ago
if( m_flRotortilt < m_flIdealtilt )
7 years ago
{
m_flRotortilt += 0.5;
8 years ago
if ( m_flRotortilt > 0 )
7 years ago
m_flRotortilt = 0;
}
8 years ago
if( m_flRotortilt > m_flIdealtilt )
7 years ago
{
m_flRotortilt -= 0.5;
8 years ago
if( m_flRotortilt < -90 )
7 years ago
m_flRotortilt = -90;
}
SetBoneController( 0, m_flRotortilt );
8 years ago
if( m_iSoundState == 0 )
7 years ago
{
8 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 );
7 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.
8 years ago
if( pPlayer )
7 years ago
{
8 years ago
float pitch = DotProduct( m_velocity - pPlayer->pev->velocity, ( pPlayer->pev->origin - pev->origin ).Normalize() );
7 years ago
8 years ago
pitch = (int)( 100 + pitch / 75.0 );
7 years ago
8 years ago
if( pitch > 250 )
7 years ago
pitch = 250;
8 years ago
if( pitch < 50 )
7 years ago
pitch = 50;
8 years ago
if( pitch == 100 )
7 years ago
pitch = 101;
8 years ago
if( pitch != m_iPitch )
7 years ago
{
m_iPitch = pitch;
8 years ago
EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_rotor4.wav", 1.0, 0.15, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch );
7 years ago
// ALERT( at_console, "%.0f\n", pitch );
}
}
8 years ago
// EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, "apache/ap_whine1.wav", flVol, 0.2, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch );
7 years ago
}
}
void COsprey::HitTouch( CBaseEntity *pOther )
{
SetNextThink( 2.0 );
}
/*
int COsprey::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{
8 years ago
if( m_flRotortilt <= -90 )
7 years ago
{
m_flRotortilt = 0;
}
else
{
m_flRotortilt -= 45;
}
SetBoneController( 0, m_flRotortilt );
return 0;
}
*/
8 years ago
void COsprey::Killed( entvars_t *pevAttacker, int iGib )
7 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 ) );
8 years ago
STOP_SOUND( ENT( pev ), CHAN_STATIC, "apache/ap_rotor4.wav" );
7 years ago
8 years ago
UTIL_SetSize( pev, Vector( -32, -32, -64 ), Vector( 32, 32, 0 ) );
9 years ago
SetThink( &COsprey::DyingThink );
SetTouch( &COsprey::CrashTouch );
7 years ago
SetNextThink( 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
8 years ago
if( pOther->pev->solid == SOLID_BSP )
7 years ago
{
SetTouch( NULL );
m_startTime = gpGlobals->time;
SetNextThink( 0 );
m_velocity = pev->velocity;
}
}
8 years ago
void COsprey::DyingThink( void )
7 years ago
{
8 years ago
StudioFrameAdvance();
7 years ago
SetNextThink( 0.1 );
pev->avelocity = pev->avelocity * 1.02;
// still falling?
8 years ago
if( m_startTime > gpGlobals->time )
7 years ago
{
UTIL_MakeAimVectors( pev->angles );
8 years ago
ShowDamage();
7 years ago
Vector vecSpot = pev->origin + pev->velocity * 0.2;
// random explosions
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot );
8 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 ) );
7 years ago
WRITE_SHORT( g_sModelIndexFireball );
8 years ago
WRITE_BYTE( RANDOM_LONG( 0, 29 ) + 30 ); // scale * 10
WRITE_BYTE( 12 ); // framerate
7 years ago
WRITE_BYTE( TE_EXPLFLAG_NONE );
MESSAGE_END();
// lots of smoke
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecSpot );
WRITE_BYTE( TE_SMOKE );
8 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 ) );
7 years ago
WRITE_SHORT( g_sModelIndexSmoke );
WRITE_BYTE( 100 ); // scale * 10
8 years ago
WRITE_BYTE( 10 ); // framerate
7 years ago
MESSAGE_END();
8 years ago
vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5;
7 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;
SetNextThink( 0.2 );
return;
}
else
{
8 years ago
Vector vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5;
7 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
8 years ago
WRITE_BYTE( 10 ); // framerate
7 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
8 years ago
WRITE_BYTE( 6 ); // framerate
7 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();
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_STATIC, "weapons/mortarhit.wav", 1.0, 0.3 );
7 years ago
RadiusDamage( pev->origin, pev, pev, 300, CLASS_NONE, DMG_BLAST );
// gibs
8 years ago
vecSpot = pev->origin + ( pev->mins + pev->maxs ) * 0.5;
7 years ago
MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, vecSpot );
WRITE_BYTE( TE_BREAKMODEL);
// position
WRITE_COORD( vecSpot.x );
WRITE_COORD( vecSpot.y );
8 years ago
WRITE_COORD( vecSpot.z + 64 );
7 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 );
}
}
8 years ago
void COsprey::ShowDamage( void )
7 years ago
{
8 years ago
if( m_iDoLeftSmokePuff > 0 || RANDOM_LONG( 0, 99 ) > m_flLeftHealth )
7 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 );
8 years ago
WRITE_BYTE( RANDOM_LONG( 0, 9 ) + 20 ); // scale * 10
7 years ago
WRITE_BYTE( 12 ); // framerate
MESSAGE_END();
8 years ago
if( m_iDoLeftSmokePuff > 0 )
7 years ago
m_iDoLeftSmokePuff--;
}
8 years ago
if( m_iDoRightSmokePuff > 0 || RANDOM_LONG( 0, 99 ) > m_flRightHealth )
7 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 );
8 years ago
WRITE_BYTE( RANDOM_LONG( 0, 9 ) + 20 ); // scale * 10
7 years ago
WRITE_BYTE( 12 ); // framerate
MESSAGE_END();
8 years ago
if( m_iDoRightSmokePuff > 0 )
7 years ago
m_iDoRightSmokePuff--;
}
}
8 years ago
void COsprey::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType )
7 years ago
{
// ALERT( at_console, "%d %.0f\n", ptr->iHitgroup, flDamage );
// only so much per engine
8 years ago
if( ptr->iHitgroup == 3 )
7 years ago
{
8 years ago
if( m_flRightHealth < 0 )
7 years ago
return;
else
m_flRightHealth -= flDamage;
8 years ago
m_iDoLeftSmokePuff = 3 + ( flDamage / 5.0 );
7 years ago
}
8 years ago
if( ptr->iHitgroup == 2 )
7 years ago
{
8 years ago
if( m_flLeftHealth < 0 )
7 years ago
return;
else
m_flLeftHealth -= flDamage;
8 years ago
m_iDoRightSmokePuff = 3 + ( flDamage / 5.0 );
7 years ago
}
// hit hard, hits cockpit, hits engines
8 years ago
if( flDamage > 50 || ptr->iHitgroup == 1 || ptr->iHitgroup == 2 || ptr->iHitgroup == 3 )
7 years ago
{
// ALERT( at_console, "%.0f\n", flDamage );
AddMultiDamage( pevAttacker, this, flDamage, bitsDamageType );
}
else
{
UTIL_Sparks( ptr->vecEndPos );
}
}