Example #1
0
void CBeam::OnDataChanged( DataUpdateType_t updateType )
{
    MarkMessageReceived();

    // Make sure that the correct model is referenced for this entity
    SetModelPointer( modelinfo->GetModel( GetModelIndex() ) );

    // Convert weapon world models to viewmodels if they're weapons being carried by the local player
    for (int i=0;i<MAX_BEAM_ENTS;i++)
    {
        C_BaseEntity *pEnt = m_hAttachEntity[i].Get();
        if ( pEnt )
        {
            C_BaseCombatWeapon *pWpn = dynamic_cast<C_BaseCombatWeapon *>(pEnt);
            if ( pWpn && pWpn->ShouldDrawUsingViewModel() )
            {
                C_BasePlayer *player = ToBasePlayer( pWpn->GetOwner() );

                // Use GetRenderedWeaponModel() instead?
                C_BaseViewModel *pViewModel = player ? player->GetViewModel( 0 ) : NULL;
                if ( pViewModel )
                {
                    // Get the viewmodel and use it instead
                    m_hAttachEntity.Set( i, pViewModel );
                }
            }
        }
    }

    // Compute the bounds here...
    Vector mins, maxs;
    ComputeBounds( mins, maxs );
    SetCollisionBounds( mins, maxs );
}
Example #2
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
Vector GetTracerOrigin( const CEffectData &data )
{
	Vector vecStart = data.m_vStart;
	QAngle vecAngles;

	int iAttachment = data.m_nAttachmentIndex;;

	// Attachment?
	if ( data.m_fFlags & TRACER_FLAG_USEATTACHMENT )
	{
		C_BaseViewModel *pViewModel = NULL;

		// If the entity specified is a weapon being carried by this player, use the viewmodel instead
		IClientRenderable *pRenderable = data.GetRenderable();
		if ( !pRenderable )
			return vecStart;

		C_BaseEntity *pEnt = data.GetEntity();

// This check should probably be for all multiplayer games, investigate later
#if defined( HL2MP ) || defined( TF_CLIENT_DLL ) || defined( TF_CLASSIC_CLIENT )
		if ( pEnt && pEnt->IsDormant() )
			return vecStart;
#endif

		C_BaseCombatWeapon *pWpn = dynamic_cast<C_BaseCombatWeapon *>( pEnt );
		if ( pWpn && pWpn->ShouldDrawUsingViewModel() )
		{
			C_BasePlayer *player = ToBasePlayer( pWpn->GetOwner() );

			// Use GetRenderedWeaponModel() instead?
			pViewModel = player ? player->GetViewModel( 0 ) : NULL;
			if ( pViewModel )
			{
				// Get the viewmodel and use it instead
				pRenderable = pViewModel;
			}
		}

		// Get the attachment origin
		if ( !pRenderable->GetAttachment( iAttachment, vecStart, vecAngles ) )
		{
			DevMsg( "GetTracerOrigin: Couldn't find attachment %d on model %s\n", iAttachment, 
				modelinfo->GetModelName( pRenderable->GetModel() ) );
		}
	}

	return vecStart;
}