Sound Effect (Attacking) Not Working

Results 1 to 3 of 3
  1. #1
    Making a come back NickHough is offline
    MemberRank
    Nov 2009 Join Date
    United KingdomLocation
    397Posts

    Sound Effect (Attacking) Not Working

    Hello All,

    As the title insists I'm having a problem with DXSound, or something based around that.

    It seems that for some unknown reason (To me anyways) that all sound in-game works absolutely fine, that is until you hit someone and it won't make the normal weapon sound (Or any attacking sound).

    Has anyone come across this and found a fix.

    P.S. I have checked my files against Eflyff's ones and they are more of less similar (nothing that would cause this bug), and I have also copied across mssmp3.asi and mssogg.msi files to ensure they work as intended too (sometimes get mssogg.asi crashing).

    Source: Virtuous V19 (Mostly fixed if you can believe that aha).
    Upgraded Source to VS2013

    - - - Updated - - -

    Ignore that, for anyone having the same problem.

    In dsutil.cpp, under the CSoundManager::Play method, look for
    Code:
    D3DXVECTOR3 vPos = *pvPosition - m_vPosListener;
    		FLOAT fRadian = sqrt( 
    			fabs ( vPos.x ) * fabs ( vPos.x ) +	fabs ( vPos.z ) * fabs ( vPos.z ) );
    Replace everything underneath (to the next curly brace) with the following
    Code:
    if( fRadian > 100.0f )
    			return FALSE; 
    		else if (fRadian <= 0.0)
    		{
    			D3DVECTOR vec;
    			m_pDSListener->GetPosition(&vec);
    			pSound->m_pBufferParams[dwIndex].vPosition.x = vec.x;
    			pSound->m_pBufferParams[dwIndex].vPosition.y = vec.y;
    			pSound->m_pBufferParams[dwIndex].vPosition.z = vec.z;
    		}
    		else if (fRadian < 1.0){
    			D3DXVECTOR3 Line1 = D3DXVECTOR3(0.0f, 0.0f, -1.0f);
    			D3DXVECTOR3 Line2 = -vPos;
    			//Line2 = m_world.m_vCenter - Line2;
    			// Nomralize Vectors
    			FLOAT vlength = static_cast<FLOAT>(sqrt((Line2.x * Line2.x) + (Line2.z * Line2.z)));
    			Line2 = Line2 / vlength;
    			// ¶óµð¾È ±¸Çϱâ 
    			FLOAT a = acos(D3DXVec3Dot(&Line1, &Line2));
    			//a = ( D3DX_PI * 2.0f ) - a;
    			if (vPos.x < 0)
    				a = (D3DX_PI * 2.0f) - a;
    			a += -m_fTheta;
    
    			vPos.x = (float)((int)(sin(a) * fRadian));	// ¿©±â (int)ij½ºÆÃ ¹Ù²ÙÁö ¸»°Í. (int)¾ÈÇϸé ÄÄÅÍ ¸®º×µÊ.
    			vPos.z = (float)((int)(cos(a) * fRadian));
    			vPos.y = (float)((int)vPos.y);
    
    			D3DVECTOR v;
    			v.x = vPos.x;	// Ȥ½Ã ¸ô¶ó ÀÌ·¸°Ô ÇØºÃ´Ù.
    			v.y = vPos.y;
    			v.z = vPos.z;
    			pSound->m_pBufferParams[dwIndex].vPosition = v;	// D3XVECTOR3¸¦ D3DVECTOR¿¡ ±×´ë·Î ³Ö¾îµµ µÇ³ª?
    		}
    		else{
    			D3DXVECTOR3 Line1 = D3DXVECTOR3(0.0f, 0.0f, -1.0f);
    			D3DXVECTOR3 Line2 = -vPos;
    			//Line2 = m_world.m_vCenter - Line2;
    			// Nomralize Vectors
    			FLOAT vlength = static_cast<FLOAT>(sqrt((Line2.x * Line2.x) + (Line2.z * Line2.z)));
    			Line2 = Line2 / vlength;
    			// ¶óµð¾È ±¸Çϱâ 
    			FLOAT a = acos(D3DXVec3Dot(&Line1, &Line2));
    			//a = ( D3DX_PI * 2.0f ) - a;
    			if (vPos.x < 0)
    				a = (D3DX_PI * 2.0f) - a;
    			a += -m_fTheta;
    
    			vPos.x = (float)((int)(sin(a) * fRadian));	// ¿©±â (int)ij½ºÆÃ ¹Ù²ÙÁö ¸»°Í. (int)¾ÈÇϸé ÄÄÅÍ ¸®º×µÊ.
    			vPos.z = (float)((int)(cos(a) * fRadian));
    			vPos.y = (float)((int)vPos.y);
    
    			D3DVECTOR v;
    			v.x = vPos.x;	// Ȥ½Ã ¸ô¶ó ÀÌ·¸°Ô ÇØºÃ´Ù.
    			v.y = vPos.y;
    			v.z = vPos.z;
    			pSound->m_pBufferParams[dwIndex].vPosition = v;	// D3XVECTOR3¸¦ D3DVECTOR¿¡ ±×´ë·Î ³Ö¾îµµ µÇ³ª?
    		}


  2. #2
    Novice Fenris is offline
    MemberRank
    Sep 2011 Join Date
    RE:ℓσα∂Location
    69Posts

    Re: Sound Effect (Attacking) Not Working

    I think I did this before finally switching over to a different sound handler.
    Spoiler:
    Code:
    BOOL CSoundManager::Play(LPTSTR pszFileName, D3DXVECTOR3* pvPosition, D3DXVECTOR3* pvVelocity, BOOL bIsAutoplay, BOOL bIsVoice)
    {
    	if (!m_bSuccess){ return false; }
    	if (m_nSoundVolume == -5000){ return false; }
    
    	float fVolume = 0.0f;
    	fVolume = (float)(m_nSoundVolume);
    
    	CSound* pSound = GetSound(pszFileName);
    	if (pSound == NULL){ return false; }
    
    	unsigned long dwIndex = pSound->GetFreeBufferIndex();;
    	if (pvPosition)
    	{
    		D3DXVECTOR3 vPos = *pvPosition - m_vPosListener; //sound - player?
    		float fRadian = sqrt(fabs(vPos.x) * fabs(vPos.x) + fabs(vPos.z) * fabs(vPos.z));
    
    		if (fRadian > 100.0f){ return false; }
    		else if (fRadian < 0.0){ m_pDSListener->GetPosition(&pSound->m_pBufferParams[dwIndex].vPosition); }
    
    		D3DXVECTOR3 Line1 = D3DXVECTOR3(0.0f, 0.0f, -1.0f);
    		D3DXVECTOR3 Line2 = -vPos;
    
    		float vlength = sqrt((Line2.x * Line2.x) + (Line2.z * Line2.z));
    		if (vlength > 1){ Line2 = Line2 / vlength; }
    
    		float a = acos(D3DXVec3Dot(&Line1, &Line2));
    		if (vPos.x < 0){ a = (D3DX_PI * 2.0f) - a; }
    		a += -m_fTheta;
    
    		vPos.x = (float)((int)(sin(a) * fRadian));
    		vPos.z = (float)((int)(cos(a) * fRadian));
    		vPos.y = (float)((int)vPos.y);
    
    		D3DVECTOR v;
    		v.x = vPos.x;
    		v.y = vPos.y;
    		v.z = vPos.z;
    		pSound->m_pBufferParams[dwIndex].vPosition = v;
    	}
    	else
    	{
    		D3DVECTOR vec;
    		m_pDSListener->GetPosition(&vec);
    		pSound->m_pBufferParams[dwIndex].vPosition.x = vec.x;
    		pSound->m_pBufferParams[dwIndex].vPosition.y = vec.y;
    		pSound->m_pBufferParams[dwIndex].vPosition.z = vec.z;
    	}
    
    	if (pvVelocity)
    	{
    		pSound->m_pBufferParams[dwIndex].vVelocity.x = pvVelocity->x;
    		pSound->m_pBufferParams[dwIndex].vVelocity.y = pvVelocity->y;
    		pSound->m_pBufferParams[dwIndex].vVelocity.z = pvVelocity->z;
    	}
    	else
    	{
    		D3DVECTOR vec;
    		m_pDSListener->GetPosition(&vec);
    		pSound->m_pBufferParams[dwIndex].vVelocity.x = vec.x;
    		pSound->m_pBufferParams[dwIndex].vVelocity.y = vec.y;
    		pSound->m_pBufferParams[dwIndex].vVelocity.z = vec.z;
    	}
    	pSound->m_pBufferParams[dwIndex].flMinDistance = 4.0f;
    	pSound->m_pBufferParams[dwIndex].flMaxDistance = 70.0f;
    
    	pSound->m_apDS3DBuffer[dwIndex]->SetAllParameters(&pSound->m_pBufferParams[dwIndex], DS3D_IMMEDIATE);
    
    	pSound->GetBuffer(pSound->GetFreeBufferIndex())->SetVolume((LONG)(fVolume));
    	if (bIsAutoplay)
    	{
    		if (FAILED(pSound->Play(0, 0, &dwIndex))){ return false; }
    	}
    	return true;
    }

  3. #3
    Making a come back NickHough is offline
    MemberRank
    Nov 2009 Join Date
    United KingdomLocation
    397Posts

    Re: Sound Effect (Attacking) Not Working

    Hmm i don't know.

    All i know is it works again and Flyff's sounds don't require that good a handler tbh, unless you wanted to add more compressed formats such as MP3 and such or higher quality such as AAC



Advertisement