upload "kind" alien swarm

This commit is contained in:
nillerusr
2023-10-03 17:23:56 +03:00
parent b7bd94c52e
commit 7d3c0d8b5a
4229 changed files with 462900 additions and 495155 deletions
+186 -138
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose: Flame entity to be attached to target entity. Serves two purposes:
//
@@ -7,53 +7,63 @@
//
// 2) An entity that can be created at runtime to ignite a target entity.
//
//=============================================================================//
//===========================================================================//
#include "cbase.h"
#include "EntityFlame.h"
#include "ai_basenpc.h"
#ifdef INFESTED_DLL
#include "asw_fire.h"
#else
#include "fire.h"
#endif
#include "shareddefs.h"
#include "ai_link.h"
#include "ai_node.h"
#include "ai_network.h"
#include "ai_localnavigator.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
BEGIN_DATADESC( CEntityFlame )
DEFINE_KEYFIELD( m_flLifetime, FIELD_FLOAT, "lifetime" ),
DEFINE_FIELD( m_flLifetime, FIELD_TIME ),
DEFINE_FIELD( m_flSize, FIELD_FLOAT ),
DEFINE_FIELD( m_hEntAttached, FIELD_EHANDLE ),
DEFINE_FIELD( m_bUseHitboxes, FIELD_BOOLEAN ),
DEFINE_FIELD( m_iNumHitboxFires, FIELD_INTEGER ),
DEFINE_FIELD( m_flHitboxFireScale, FIELD_FLOAT ),
DEFINE_FIELD( m_iDangerSound, FIELD_INTEGER ),
DEFINE_FIELD( m_bCheapEffect, FIELD_BOOLEAN ),
// DEFINE_FIELD( m_bPlayingSound, FIELD_BOOLEAN ),
// DEFINE_FIELD( m_DangerLinks, CUtlVector< CAI_Link* > ),
DEFINE_FUNCTION( FlameThink ),
DEFINE_INPUTFUNC( FIELD_VOID, "Ignite", InputIgnite ),
END_DATADESC()
IMPLEMENT_SERVERCLASS_ST( CEntityFlame, DT_EntityFlame )
SendPropEHandle( SENDINFO( m_hEntAttached ) ),
SendPropBool( SENDINFO( m_bCheapEffect ) ),
END_SEND_TABLE()
#ifndef INFESTED_DLL
LINK_ENTITY_TO_CLASS( entityflame, CEntityFlame );
LINK_ENTITY_TO_CLASS( env_entity_igniter, CEntityFlame );
#endif
PRECACHE_REGISTER(entityflame);
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CEntityFlame::CEntityFlame( void )
{
m_flSize = 0.0f;
m_iNumHitboxFires = 10;
m_flHitboxFireScale = 1.0f;
m_flLifetime = 0.0f;
m_flLifetime = gpGlobals->curtime;
m_bPlayingSound = false;
m_iDangerSound = SOUNDLIST_EMPTY;
m_bCheapEffect = false;
m_hObstacle = OBSTACLE_INVALID;
}
void CEntityFlame::UpdateOnRemove()
@@ -66,6 +76,26 @@ void CEntityFlame::UpdateOnRemove()
m_bPlayingSound = false;
}
if ( m_iDangerSound != SOUNDLIST_EMPTY )
{
CSoundEnt::FreeSound( m_iDangerSound );
m_iDangerSound = SOUNDLIST_EMPTY;
}
int nCount = m_DangerLinks.Count();
for ( int i = 0; i < nCount; ++i )
{
CAI_Link *pLink = m_DangerLinks[i];
--pLink->m_nDangerCount;
}
m_DangerLinks.RemoveAll();
if ( m_hObstacle != OBSTACLE_INVALID )
{
CAI_LocalNavigator::RemoveGlobalObstacle( m_hObstacle );
m_hObstacle = OBSTACLE_INVALID;
}
BaseClass::UpdateOnRemove();
}
@@ -73,40 +103,42 @@ void CEntityFlame::Precache()
{
BaseClass::Precache();
PrecacheParticleSystem( "burning_character" );
PrecacheParticleSystem( "burning_gib_01" );
PrecacheScriptSound( "General.StopBurning" );
PrecacheScriptSound( "General.BurningFlesh" );
PrecacheScriptSound( "General.BurningObject" );
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : inputdata -
//-----------------------------------------------------------------------------
void CEntityFlame::InputIgnite( inputdata_t &inputdata )
void CEntityFlame::Spawn()
{
if (m_target != NULL_STRING)
{
CBaseEntity *pTarget = NULL;
while ((pTarget = gEntList.FindEntityGeneric(pTarget, STRING(m_target), this, inputdata.pActivator)) != NULL)
{
// Combat characters know how to catch themselves on fire.
CBaseCombatCharacter *pBCC = pTarget->MyCombatCharacterPointer();
if (pBCC)
{
// DVS TODO: consider promoting Ignite to CBaseEntity and doing everything here
pBCC->Ignite(m_flLifetime);
}
// Everything else, we handle here.
else
{
CEntityFlame *pFlame = CEntityFlame::Create(pTarget);
if (pFlame)
{
pFlame->SetLifetime(m_flLifetime);
}
}
}
}
BaseClass::Spawn();
m_flLifetime = gpGlobals->curtime;
SetThink( &CEntityFlame::FlameThink );
SetNextThink( gpGlobals->curtime + 0.1f );
//Send to the client even though we don't have a model
AddEFlags( EFL_FORCE_CHECK_TRANSMIT );
}
//-----------------------------------------------------------------------------
// Since we don't save/load danger links, we need to reacquire them here
//-----------------------------------------------------------------------------
void CEntityFlame::Activate()
{
BaseClass::Activate();
}
void CEntityFlame::UseCheapEffect( bool bCheap )
{
m_bCheapEffect = bCheap;
}
@@ -114,36 +146,35 @@ void CEntityFlame::InputIgnite( inputdata_t &inputdata )
// Purpose: Creates a flame and attaches it to a target entity.
// Input : pTarget -
//-----------------------------------------------------------------------------
CEntityFlame *CEntityFlame::Create( CBaseEntity *pTarget, bool useHitboxes )
CEntityFlame *CEntityFlame::Create( CBaseEntity *pTarget, float flLifetime, float flSize /*= 0.0f*/, bool bUseHitboxes /*= true*/ )
{
CEntityFlame *pFlame = (CEntityFlame *) CreateEntityByName( "entityflame" );
CEntityFlame *pFlame = (CEntityFlame *)CreateEntityByName( "entityflame" );
if ( pFlame == NULL )
return NULL;
float xSize = pTarget->CollisionProp()->OBBMaxs().x - pTarget->CollisionProp()->OBBMins().x;
float ySize = pTarget->CollisionProp()->OBBMaxs().y - pTarget->CollisionProp()->OBBMins().y;
float size = ( xSize + ySize ) * 0.5f;
if ( size < 16.0f )
if ( flSize <= 0.0f )
{
size = 16.0f;
float xSize = pTarget->CollisionProp()->OBBMaxs().x - pTarget->CollisionProp()->OBBMins().x;
float ySize = pTarget->CollisionProp()->OBBMaxs().y - pTarget->CollisionProp()->OBBMins().y;
flSize = ( xSize + ySize ) * 0.5f;
if ( flSize < 16.0f )
{
flSize = 16.0f;
}
}
if ( flLifetime <= 0.0f )
{
flLifetime = 2.0f;
}
pFlame->m_flSize = flSize;
pFlame->Spawn();
UTIL_SetOrigin( pFlame, pTarget->GetAbsOrigin() );
pFlame->m_flSize = size;
pFlame->SetThink( &CEntityFlame::FlameThink );
pFlame->SetNextThink( gpGlobals->curtime + 0.1f );
pFlame->AttachToEntity( pTarget );
pFlame->SetLifetime( 2.0f );
//Send to the client even though we don't have a model
pFlame->AddEFlags( EFL_FORCE_CHECK_TRANSMIT );
pFlame->SetUseHitboxes( useHitboxes );
pFlame->SetLifetime( flLifetime );
pFlame->Activate();
return pFlame;
}
@@ -183,47 +214,11 @@ void CEntityFlame::SetLifetime( float lifetime )
m_flLifetime = gpGlobals->curtime + lifetime;
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : use -
//-----------------------------------------------------------------------------
void CEntityFlame::SetUseHitboxes( bool use )
{
m_bUseHitboxes = use;
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : iNumHitBoxFires -
//-----------------------------------------------------------------------------
void CEntityFlame::SetNumHitboxFires( int iNumHitboxFires )
{
m_iNumHitboxFires = iNumHitboxFires;
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : flHitboxFireScale -
//-----------------------------------------------------------------------------
void CEntityFlame::SetHitboxFireScale( float flHitboxFireScale )
{
m_flHitboxFireScale = flHitboxFireScale;
}
float CEntityFlame::GetRemainingLife( void )
float CEntityFlame::GetRemainingLife( void ) const
{
return m_flLifetime - gpGlobals->curtime;
}
int CEntityFlame::GetNumHitboxFires( void )
{
return m_iNumHitboxFires;
}
float CEntityFlame::GetHitboxFireScale( void )
{
return m_flHitboxFireScale;
}
//-----------------------------------------------------------------------------
// Purpose: Burn targets around us
@@ -233,47 +228,45 @@ void CEntityFlame::FlameThink( void )
// Assure that this function will be ticked again even if we early-out in the if below.
SetNextThink( gpGlobals->curtime + FLAME_DAMAGE_INTERVAL );
if ( m_hEntAttached )
{
if ( m_hEntAttached->GetFlags() & FL_TRANSRAGDOLL )
{
SetRenderColorA( 0 );
return;
}
CAI_BaseNPC *pNPC = m_hEntAttached->MyNPCPointer();
if ( pNPC && !pNPC->IsAlive() )
{
UTIL_Remove( this );
// Notify the NPC that it's no longer burning!
pNPC->Extinguish();
return;
}
if( m_hEntAttached->GetWaterLevel() > 0 )
{
Vector mins, maxs;
mins = m_hEntAttached->WorldSpaceCenter();
maxs = mins;
maxs.z = m_hEntAttached->WorldSpaceCenter().z;
maxs.x += 32;
maxs.y += 32;
mins.z -= 32;
mins.x -= 32;
mins.y -= 32;
UTIL_Bubbles( mins, maxs, 12 );
}
}
else
if ( !m_hEntAttached.Get() )
{
UTIL_Remove( this );
return;
}
if ( m_hEntAttached->GetFlags() & FL_TRANSRAGDOLL )
{
SetRenderAlpha( 0 );
return;
}
CAI_BaseNPC *pNPC = m_hEntAttached->MyNPCPointer();
if ( pNPC && !pNPC->IsAlive() )
{
UTIL_Remove( this );
// Notify the NPC that it's no longer burning!
pNPC->Extinguish();
return;
}
if ( m_hEntAttached->GetWaterLevel() > 0 )
{
Vector mins, maxs;
mins = m_hEntAttached->WorldSpaceCenter();
maxs = mins;
maxs.z = m_hEntAttached->WorldSpaceCenter().z;
maxs.x += 32;
maxs.y += 32;
mins.z -= 32;
mins.x -= 32;
mins.y -= 32;
UTIL_Bubbles( mins, maxs, 12 );
}
// See if we're done burning, or our attached ent has vanished
if ( m_flLifetime < gpGlobals->curtime || m_hEntAttached == NULL )
{
@@ -326,10 +319,65 @@ void CEntityFlame::FlameThink( void )
//-----------------------------------------------------------------------------
// Purpose:
// Input : pEnt -
// Igniter
//-----------------------------------------------------------------------------
void CreateEntityFlame(CBaseEntity *pEnt)
class CEnvEntityIgniter : public CBaseEntity
{
CEntityFlame::Create( pEnt );
public:
DECLARE_CLASS( CEnvEntityIgniter, CBaseEntity );
DECLARE_DATADESC();
virtual void Precache();
protected:
void InputIgnite( inputdata_t &inputdata );
float m_flLifetime;
};
BEGIN_DATADESC( CEnvEntityIgniter )
DEFINE_KEYFIELD( m_flLifetime, FIELD_FLOAT, "lifetime" ),
DEFINE_INPUTFUNC( FIELD_VOID, "Ignite", InputIgnite ),
END_DATADESC()
LINK_ENTITY_TO_CLASS( env_entity_igniter, CEnvEntityIgniter );
//-----------------------------------------------------------------------------
// Purpose: Ignites entities
//-----------------------------------------------------------------------------
void CEnvEntityIgniter::Precache()
{
BaseClass::Precache();
UTIL_PrecacheOther( "entityflame" );
}
//-----------------------------------------------------------------------------
// Purpose: Ignites entities
//-----------------------------------------------------------------------------
void CEnvEntityIgniter::InputIgnite( inputdata_t &inputdata )
{
if ( m_target == NULL_STRING )
return;
CBaseEntity *pTarget = NULL;
while ( (pTarget = gEntList.FindEntityGeneric(pTarget, STRING(m_target), this, inputdata.pActivator)) != NULL )
{
// Combat characters know how to catch themselves on fire.
CBaseCombatCharacter *pBCC = pTarget->MyCombatCharacterPointer();
if (pBCC)
{
// DVS TODO: consider promoting Ignite to CBaseEntity and doing everything here
pBCC->Ignite( m_flLifetime );
continue;
}
// Everything else, we handle here.
CEntityFlame::Create( pTarget, m_flLifetime );
}
}