2017-12-18 00:39:44 +01: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.
|
|
|
|
*
|
|
|
|
****/
|
|
|
|
/*
|
|
|
|
|
|
|
|
===== h_cycler.cpp ========================================================
|
|
|
|
|
|
|
|
The Halflife Cycler Monsters
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "extdll.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "cbase.h"
|
|
|
|
#include "monsters.h"
|
|
|
|
#include "animation.h"
|
|
|
|
#include "weapons.h"
|
|
|
|
#include "player.h"
|
|
|
|
|
|
|
|
#define TEMP_FOR_SCREEN_SHOTS
|
|
|
|
#ifdef TEMP_FOR_SCREEN_SHOTS //===================================================
|
|
|
|
|
|
|
|
class CCycler : public CBaseMonster
|
|
|
|
{
|
|
|
|
public:
|
2017-06-29 15:56:03 +02:00
|
|
|
void GenericCyclerSpawn( const char *szModel, Vector vecMin, Vector vecMax );
|
2016-07-31 15:48:50 +02:00
|
|
|
virtual int ObjectCaps( void ) { return ( CBaseEntity::ObjectCaps() | FCAP_IMPULSE_USE ); }
|
2017-12-18 00:39:44 +01:00
|
|
|
int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType );
|
|
|
|
void Spawn( void );
|
|
|
|
void Think( void );
|
|
|
|
//void Pain( float flDamage );
|
|
|
|
void Use ( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
|
|
|
|
|
|
|
// Don't treat as a live target
|
|
|
|
virtual BOOL IsAlive( void ) { return FALSE; }
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
virtual int Save( CSave &save );
|
|
|
|
virtual int Restore( CRestore &restore );
|
|
|
|
static TYPEDESCRIPTION m_SaveData[];
|
2017-12-18 00:39:44 +01:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
int m_animate;
|
2017-12-18 00:39:44 +01:00
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
TYPEDESCRIPTION CCycler::m_SaveData[] =
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
|
|
|
DEFINE_FIELD( CCycler, m_animate, FIELD_INTEGER ),
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
IMPLEMENT_SAVERESTORE( CCycler, CBaseMonster )
|
2017-12-18 00:39:44 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// we should get rid of all the other cyclers and replace them with this.
|
|
|
|
//
|
|
|
|
class CGenericCycler : public CCycler
|
|
|
|
{
|
|
|
|
public:
|
2016-07-31 15:48:50 +02:00
|
|
|
void Spawn( void )
|
|
|
|
{
|
2017-07-23 23:24:55 +02:00
|
|
|
GenericCyclerSpawn( STRING( pev->model ), Vector( -16, -16, 0 ), Vector( 16, 16, 72 ) );
|
2016-07-31 15:48:50 +02:00
|
|
|
}
|
2017-12-18 00:39:44 +01:00
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
LINK_ENTITY_TO_CLASS( cycler, CGenericCycler )
|
2017-12-18 00:39:44 +01:00
|
|
|
|
|
|
|
// Probe droid imported for tech demo compatibility
|
|
|
|
//
|
|
|
|
// PROBE DROID
|
|
|
|
//
|
|
|
|
class CCyclerProbe : public CCycler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void Spawn( void );
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
LINK_ENTITY_TO_CLASS( cycler_prdroid, CCyclerProbe )
|
2017-12-18 00:39:44 +01:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CCyclerProbe::Spawn( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->origin = pev->origin + Vector( 0, 0, 16 );
|
|
|
|
GenericCyclerSpawn( "models/prdroid.mdl", Vector( -16, -16, -16 ), Vector( 16, 16, 16 ) );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2017-12-18 00:39:44 +01:00
|
|
|
|
|
|
|
// Cycler member functions
|
2017-06-29 15:56:03 +02:00
|
|
|
void CCycler::GenericCyclerSpawn( const char *szModel, Vector vecMin, Vector vecMax )
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !szModel || !*szModel )
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
ALERT( at_error, "cycler at %.0f %.0f %0.f missing modelname", pev->origin.x, pev->origin.y, pev->origin.z );
|
|
|
|
REMOVE_ENTITY( ENT( pev ) );
|
2017-12-18 00:39:44 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->classname = MAKE_STRING( "cycler" );
|
2017-12-18 00:39:44 +01:00
|
|
|
PRECACHE_MODEL( szModel );
|
2016-07-31 15:48:50 +02:00
|
|
|
SET_MODEL( ENT( pev ), szModel );
|
2017-12-18 00:39:44 +01:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
CCycler::Spawn();
|
2017-12-18 00:39:44 +01:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
UTIL_SetSize( pev, vecMin, vecMax );
|
2017-12-18 00:39:44 +01:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CCycler::Spawn()
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
|
|
|
InitBoneControllers();
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->solid = SOLID_SLIDEBOX;
|
2017-12-18 00:39:44 +01:00
|
|
|
pev->movetype = MOVETYPE_NONE;
|
|
|
|
pev->takedamage = DAMAGE_YES;
|
|
|
|
pev->effects = 0;
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->health = 80000;// no cycler should die
|
2017-12-18 00:39:44 +01:00
|
|
|
pev->yaw_speed = 5;
|
|
|
|
pev->ideal_yaw = pev->angles.y;
|
|
|
|
ChangeYaw( 360 );
|
2016-07-31 15:48:50 +02:00
|
|
|
|
2017-12-18 00:39:44 +01:00
|
|
|
m_flFrameRate = 75;
|
|
|
|
m_flGroundSpeed = 0;
|
|
|
|
|
|
|
|
AbsoluteNextThink( m_fNextThink + 1.0 );
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
ResetSequenceInfo();
|
2017-12-18 00:39:44 +01:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->sequence != 0 || pev->frame != 0 )
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
|
|
|
m_animate = 0;
|
|
|
|
pev->framerate = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_animate = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// cycler think
|
|
|
|
//
|
2016-07-31 15:48:50 +02:00
|
|
|
void CCycler::Think( void )
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
|
|
|
SetNextThink( 0.1 );
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_animate )
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
StudioFrameAdvance();
|
2017-12-18 00:39:44 +01:00
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_fSequenceFinished && !m_fSequenceLoops )
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
|
|
|
// ResetSequenceInfo();
|
|
|
|
// hack to avoid reloading model every frame
|
|
|
|
pev->animtime = gpGlobals->time;
|
|
|
|
pev->framerate = 1.0;
|
|
|
|
m_fSequenceFinished = FALSE;
|
|
|
|
m_flLastEventCheck = gpGlobals->time;
|
|
|
|
pev->frame = 0;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !m_animate )
|
2017-12-18 00:39:44 +01:00
|
|
|
pev->framerate = 0.0; // FIX: don't reset framerate
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// CyclerUse - starts a rotation trend
|
|
|
|
//
|
2016-07-31 15:48:50 +02:00
|
|
|
void CCycler::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
|
|
|
m_animate = !m_animate;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_animate )
|
2017-12-18 00:39:44 +01:00
|
|
|
pev->framerate = 1.0;
|
|
|
|
else
|
|
|
|
pev->framerate = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// CyclerPain , changes sequences when shot
|
|
|
|
//
|
2016-07-31 15:48:50 +02:00
|
|
|
//void CCycler::Pain( float flDamage )
|
|
|
|
int CCycler::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_animate )
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
|
|
|
pev->sequence++;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
ResetSequenceInfo();
|
2017-12-18 00:39:44 +01:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_flFrameRate == 0.0 )
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
|
|
|
pev->sequence = 0;
|
2016-07-31 15:48:50 +02:00
|
|
|
ResetSequenceInfo();
|
2017-12-18 00:39:44 +01:00
|
|
|
}
|
|
|
|
pev->frame = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pev->framerate = 1.0;
|
2016-07-31 15:48:50 +02:00
|
|
|
StudioFrameAdvance( 0.1 );
|
2017-12-18 00:39:44 +01:00
|
|
|
pev->framerate = 0;
|
2016-06-04 15:24:23 +02:00
|
|
|
ALERT( at_console, "sequence: %d, frame %.0f\n", pev->sequence, pev->frame );
|
2017-12-18 00:39:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class CCyclerSprite : public CBaseEntity
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void Spawn( void );
|
|
|
|
void Think( void );
|
|
|
|
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
|
2016-07-31 15:48:50 +02:00
|
|
|
virtual int ObjectCaps( void ) { return ( CBaseEntity :: ObjectCaps() | FCAP_DONT_SAVE | FCAP_IMPULSE_USE ); }
|
|
|
|
virtual int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );
|
|
|
|
void Animate( float frames );
|
|
|
|
|
|
|
|
virtual int Save( CSave &save );
|
|
|
|
virtual int Restore( CRestore &restore );
|
|
|
|
static TYPEDESCRIPTION m_SaveData[];
|
|
|
|
|
|
|
|
inline int ShouldAnimate( void )
|
|
|
|
{
|
|
|
|
return m_animate && m_maxFrame > 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int m_animate;
|
|
|
|
float m_lastTime;
|
|
|
|
float m_maxFrame;
|
2017-12-18 00:39:44 +01:00
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
LINK_ENTITY_TO_CLASS( cycler_sprite, CCyclerSprite )
|
2017-12-18 00:39:44 +01:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
TYPEDESCRIPTION CCyclerSprite::m_SaveData[] =
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
|
|
|
DEFINE_FIELD( CCyclerSprite, m_animate, FIELD_INTEGER ),
|
|
|
|
DEFINE_FIELD( CCyclerSprite, m_lastTime, FIELD_TIME ),
|
|
|
|
DEFINE_FIELD( CCyclerSprite, m_maxFrame, FIELD_FLOAT ),
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
IMPLEMENT_SAVERESTORE( CCyclerSprite, CBaseEntity )
|
2017-12-18 00:39:44 +01:00
|
|
|
|
|
|
|
void CCyclerSprite::Spawn( void )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->solid = SOLID_SLIDEBOX;
|
2017-12-18 00:39:44 +01:00
|
|
|
pev->movetype = MOVETYPE_NONE;
|
|
|
|
pev->takedamage = DAMAGE_YES;
|
|
|
|
pev->effects = 0;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->frame = 0;
|
2017-12-18 00:39:44 +01:00
|
|
|
SetNextThink( 0.1 );
|
2016-07-31 15:48:50 +02:00
|
|
|
m_animate = 1;
|
|
|
|
m_lastTime = gpGlobals->time;
|
2017-12-18 00:39:44 +01:00
|
|
|
|
2017-07-23 23:24:55 +02:00
|
|
|
PRECACHE_MODEL( STRING( pev->model ) );
|
2016-07-31 15:48:50 +02:00
|
|
|
SET_MODEL( ENT( pev ), STRING( pev->model ) );
|
2017-12-18 00:39:44 +01:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
m_maxFrame = (float)MODEL_FRAMES( pev->modelindex ) - 1;
|
2017-12-18 00:39:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCyclerSprite::Think( void )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( ShouldAnimate() )
|
|
|
|
Animate( pev->framerate * ( gpGlobals->time - m_lastTime ) );
|
2017-12-18 00:39:44 +01:00
|
|
|
|
|
|
|
SetNextThink( 0.1 );
|
|
|
|
m_lastTime = gpGlobals->time;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCyclerSprite::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
|
|
|
|
{
|
|
|
|
m_animate = !m_animate;
|
2016-07-31 15:48:50 +02:00
|
|
|
ALERT( at_console, "Sprite: %s\n", STRING( pev->model ) );
|
2017-12-18 00:39:44 +01:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
int CCyclerSprite::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_maxFrame > 1.0 )
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
|
|
|
Animate( 1.0 );
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCyclerSprite::Animate( float frames )
|
|
|
|
{
|
|
|
|
pev->frame += frames;
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_maxFrame > 0 )
|
2017-12-18 00:39:44 +01:00
|
|
|
pev->frame = fmod( pev->frame, m_maxFrame );
|
|
|
|
}
|
|
|
|
|
|
|
|
class CWeaponCycler : public CBasePlayerWeapon
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void Spawn( void );
|
|
|
|
int iItemSlot( void ) { return 1; }
|
|
|
|
int GetItemInfo(ItemInfo *p) {return 0; }
|
|
|
|
|
|
|
|
void PrimaryAttack( void );
|
|
|
|
void SecondaryAttack( void );
|
|
|
|
BOOL Deploy( void );
|
|
|
|
void Holster( int skiplocal = 0 );
|
|
|
|
int m_iszModel;
|
|
|
|
int m_iModel;
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
LINK_ENTITY_TO_CLASS( cycler_weapon, CWeaponCycler )
|
2017-12-18 00:39:44 +01:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CWeaponCycler::Spawn()
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->solid = SOLID_SLIDEBOX;
|
|
|
|
pev->movetype = MOVETYPE_NONE;
|
2017-12-18 00:39:44 +01:00
|
|
|
|
2017-07-23 23:24:55 +02:00
|
|
|
PRECACHE_MODEL( STRING( pev->model ) );
|
2016-07-31 15:48:50 +02:00
|
|
|
SET_MODEL( ENT( pev ), STRING( pev->model ) );
|
2017-12-18 00:39:44 +01:00
|
|
|
m_iszModel = pev->model;
|
|
|
|
m_iModel = pev->modelindex;
|
|
|
|
|
|
|
|
UTIL_SetOrigin( this, pev->origin );
|
2016-07-31 15:48:50 +02:00
|
|
|
UTIL_SetSize( pev, Vector( -16, -16, 0 ), Vector( 16, 16, 16 ) );
|
2017-12-18 00:39:44 +01:00
|
|
|
SetTouch(&CWeaponCycler:: DefaultTouch );
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
BOOL CWeaponCycler::Deploy()
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
|
|
|
m_pPlayer->pev->viewmodel = m_iszModel;
|
|
|
|
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0;
|
|
|
|
SendWeaponAnim( 0 );
|
|
|
|
m_iClip = 0;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWeaponCycler::Holster( int skiplocal /* = 0 */ )
|
|
|
|
{
|
|
|
|
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWeaponCycler::PrimaryAttack()
|
|
|
|
{
|
|
|
|
SendWeaponAnim( pev->sequence );
|
|
|
|
|
|
|
|
m_flNextPrimaryAttack = gpGlobals->time + 0.3;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWeaponCycler::SecondaryAttack( void )
|
|
|
|
{
|
|
|
|
float flFrameRate, flGroundSpeed;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->sequence = ( pev->sequence + 1 ) % 8;
|
2017-12-18 00:39:44 +01:00
|
|
|
|
|
|
|
pev->modelindex = m_iModel;
|
2016-07-31 15:48:50 +02:00
|
|
|
void *pmodel = GET_MODEL_PTR( ENT( pev ) );
|
2017-12-18 00:39:44 +01:00
|
|
|
GetSequenceInfo( pmodel, pev, &flFrameRate, &flGroundSpeed );
|
|
|
|
pev->modelindex = 0;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( flFrameRate == 0.0 )
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
|
|
|
pev->sequence = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SendWeaponAnim( pev->sequence );
|
|
|
|
|
|
|
|
m_flNextSecondaryAttack = gpGlobals->time + 0.3;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Flaming Wreakage
|
|
|
|
class CWreckage : public CBaseMonster
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
int Save( CSave &save );
|
|
|
|
int Restore( CRestore &restore );
|
|
|
|
static TYPEDESCRIPTION m_SaveData[];
|
2017-12-18 00:39:44 +01:00
|
|
|
|
|
|
|
void Spawn( void );
|
|
|
|
void Precache( void );
|
|
|
|
void Think( void );
|
|
|
|
|
|
|
|
int m_flStartTime;
|
|
|
|
};
|
2016-06-25 18:33:39 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
TYPEDESCRIPTION CWreckage::m_SaveData[] =
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
|
|
|
DEFINE_FIELD( CWreckage, m_flStartTime, FIELD_TIME ),
|
|
|
|
};
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
IMPLEMENT_SAVERESTORE( CWreckage, CBaseMonster )
|
2017-12-18 00:39:44 +01:00
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
LINK_ENTITY_TO_CLASS( cycler_wreckage, CWreckage )
|
2017-12-18 00:39:44 +01:00
|
|
|
|
|
|
|
void CWreckage::Spawn( void )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->solid = SOLID_NOT;
|
|
|
|
pev->movetype = MOVETYPE_NONE;
|
|
|
|
pev->takedamage = 0;
|
|
|
|
pev->effects = 0;
|
2017-12-18 00:39:44 +01:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
pev->frame = 0;
|
2017-12-18 00:39:44 +01:00
|
|
|
SetNextThink( 0.1 );
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->model )
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
2017-07-23 23:24:55 +02:00
|
|
|
PRECACHE_MODEL( STRING( pev->model ) );
|
2016-07-31 15:48:50 +02:00
|
|
|
SET_MODEL( ENT( pev ), STRING( pev->model ) );
|
2017-12-18 00:39:44 +01:00
|
|
|
}
|
|
|
|
// pev->scale = 5.0;
|
|
|
|
|
2017-06-29 15:56:03 +02:00
|
|
|
m_flStartTime = (int)gpGlobals->time;
|
2017-12-18 00:39:44 +01:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CWreckage::Precache()
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->model )
|
2017-07-23 23:24:55 +02:00
|
|
|
PRECACHE_MODEL( STRING( pev->model ) );
|
2017-12-18 00:39:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CWreckage::Think( void )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
StudioFrameAdvance();
|
2017-12-18 00:39:44 +01:00
|
|
|
SetNextThink( 0.2 );
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->dmgtime )
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->dmgtime < gpGlobals->time )
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
|
|
|
UTIL_Remove( this );
|
|
|
|
return;
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( RANDOM_FLOAT( 0, pev->dmgtime - m_flStartTime ) > pev->dmgtime - gpGlobals->time )
|
2017-12-18 00:39:44 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
|
2017-12-18 00:39:44 +01:00
|
|
|
Vector VecSrc;
|
2016-07-31 15:48:50 +02:00
|
|
|
|
2017-12-18 00:39:44 +01:00
|
|
|
VecSrc.x = RANDOM_FLOAT( pev->absmin.x, pev->absmax.x );
|
|
|
|
VecSrc.y = RANDOM_FLOAT( pev->absmin.y, pev->absmax.y );
|
|
|
|
VecSrc.z = RANDOM_FLOAT( pev->absmin.z, pev->absmax.z );
|
|
|
|
|
|
|
|
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 );
|
2016-07-31 15:48:50 +02:00
|
|
|
WRITE_BYTE( RANDOM_LONG( 0,49 ) + 50 ); // scale * 10
|
|
|
|
WRITE_BYTE( RANDOM_LONG( 0, 3 ) + 8 ); // framerate
|
2017-12-18 00:39:44 +01:00
|
|
|
MESSAGE_END();
|
|
|
|
}
|