Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions game/server/hl2/func_tank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,65 @@ void CFuncTank::Spawn( void )
void CFuncTank::Activate( void )
{
BaseClass::Activate();

CBaseEntity *pParent = gEntList.FindEntityByName( NULL, m_iParent );

if ((pParent != NULL) && (pParent->edict() != NULL))
{
SetParent( pParent );
}

if ( GetParent() && GetParent()->GetBaseAnimating() )
{
CBaseAnimating *pAnim = GetParent()->GetBaseAnimating();
if ( m_iszBaseAttachment != NULL_STRING )
{
int nAttachment = pAnim->LookupAttachment( STRING( m_iszBaseAttachment ) );
if ( nAttachment != 0 )
{
SetParent( pAnim, nAttachment );
SetLocalOrigin( vec3_origin );
SetLocalAngles( vec3_angle );
}
}

m_bUsePoseParameters = (m_iszYawPoseParam != NULL_STRING) && (m_iszPitchPoseParam != NULL_STRING);

if ( m_iszBarrelAttachment != NULL_STRING )
{
if ( m_bUsePoseParameters )
{
pAnim->SetPoseParameter( STRING( m_iszYawPoseParam ), 0 );
pAnim->SetPoseParameter( STRING( m_iszPitchPoseParam ), 0 );
pAnim->InvalidateBoneCache();
}

m_nBarrelAttachment = pAnim->LookupAttachment( STRING(m_iszBarrelAttachment) );

Vector vecWorldBarrelPos;
QAngle worldBarrelAngle;
pAnim->GetAttachment( m_nBarrelAttachment, vecWorldBarrelPos, worldBarrelAngle );
VectorITransform( vecWorldBarrelPos, EntityToWorldTransform( ), m_barrelPos );
}

if ( m_bUsePoseParameters )
{
// In this case, we're relying on the parent to have the gun model
AddEffects( EF_NODRAW );
QAngle localAngles( m_flPitchPoseCenter, m_flYawPoseCenter, 0 );
SetLocalAngles( localAngles );
SetSolid( SOLID_NONE );
SetMoveType( MOVETYPE_NOCLIP );

// If our parent is a prop_dynamic, make it use hitboxes for renderbox
CDynamicProp *pProp = dynamic_cast<CDynamicProp*>(GetParent());
if ( pProp )
{
pProp->m_bUseHitboxesForRenderBox = true;
}
}
}

// Necessary for save/load
if ( (m_iszBarrelAttachment != NULL_STRING) && (m_nBarrelAttachment == 0) )
{
Expand Down