Skip to content

Commit e9af8c6

Browse files
authored
Merge pull request #192 from steadyfield/tankfix
Fixed Mounted Gun Anims and Effects When Spawned by Users
2 parents 0fda062 + 474df72 commit e9af8c6

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

game/server/hl2/func_tank.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,65 @@ void CFuncTank::Spawn( void )
868868
void CFuncTank::Activate( void )
869869
{
870870
BaseClass::Activate();
871+
872+
CBaseEntity *pParent = gEntList.FindEntityByName( NULL, m_iParent );
873+
874+
if ((pParent != NULL) && (pParent->edict() != NULL))
875+
{
876+
SetParent( pParent );
877+
}
878+
879+
if ( GetParent() && GetParent()->GetBaseAnimating() )
880+
{
881+
CBaseAnimating *pAnim = GetParent()->GetBaseAnimating();
882+
if ( m_iszBaseAttachment != NULL_STRING )
883+
{
884+
int nAttachment = pAnim->LookupAttachment( STRING( m_iszBaseAttachment ) );
885+
if ( nAttachment != 0 )
886+
{
887+
SetParent( pAnim, nAttachment );
888+
SetLocalOrigin( vec3_origin );
889+
SetLocalAngles( vec3_angle );
890+
}
891+
}
871892

893+
m_bUsePoseParameters = (m_iszYawPoseParam != NULL_STRING) && (m_iszPitchPoseParam != NULL_STRING);
894+
895+
if ( m_iszBarrelAttachment != NULL_STRING )
896+
{
897+
if ( m_bUsePoseParameters )
898+
{
899+
pAnim->SetPoseParameter( STRING( m_iszYawPoseParam ), 0 );
900+
pAnim->SetPoseParameter( STRING( m_iszPitchPoseParam ), 0 );
901+
pAnim->InvalidateBoneCache();
902+
}
903+
904+
m_nBarrelAttachment = pAnim->LookupAttachment( STRING(m_iszBarrelAttachment) );
905+
906+
Vector vecWorldBarrelPos;
907+
QAngle worldBarrelAngle;
908+
pAnim->GetAttachment( m_nBarrelAttachment, vecWorldBarrelPos, worldBarrelAngle );
909+
VectorITransform( vecWorldBarrelPos, EntityToWorldTransform( ), m_barrelPos );
910+
}
911+
912+
if ( m_bUsePoseParameters )
913+
{
914+
// In this case, we're relying on the parent to have the gun model
915+
AddEffects( EF_NODRAW );
916+
QAngle localAngles( m_flPitchPoseCenter, m_flYawPoseCenter, 0 );
917+
SetLocalAngles( localAngles );
918+
SetSolid( SOLID_NONE );
919+
SetMoveType( MOVETYPE_NOCLIP );
920+
921+
// If our parent is a prop_dynamic, make it use hitboxes for renderbox
922+
CDynamicProp *pProp = dynamic_cast<CDynamicProp*>(GetParent());
923+
if ( pProp )
924+
{
925+
pProp->m_bUseHitboxesForRenderBox = true;
926+
}
927+
}
928+
}
929+
872930
// Necessary for save/load
873931
if ( (m_iszBarrelAttachment != NULL_STRING) && (m_nBarrelAttachment == 0) )
874932
{

0 commit comments

Comments
 (0)