//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// ! Load a 3D sound @param sSound filename of the sound @param nFlags flags :) [optional] @param nVolume [optional] @param nMinDistance [optional] @param nMaxDistance [optional] @return nil or sound ID in case of success */
| 198 | @return nil or sound ID in case of success |
| 199 | */ |
| 200 | int CScriptObjectSound::Load3DSound(IFunctionHandler *pH) |
| 201 | { |
| 202 | int nParamCount=pH->GetParamCount(); |
| 203 | if(nParamCount<1) |
| 204 | { |
| 205 | m_pScriptSystem->RaiseError("Sound.Load3DSound wrong number of arguments"); |
| 206 | return pH->EndFunctionNull(); |
| 207 | }; |
| 208 | |
| 209 | const char *sSound=0; |
| 210 | ISound *pSound; |
| 211 | int nFlags=0; |
| 212 | |
| 213 | if (!pH->GetParam(1, sSound)) |
| 214 | { |
| 215 | m_pScriptSystem->RaiseError("Load3dSound: First parameter not a string"); |
| 216 | return pH->EndFunction(-1); |
| 217 | } |
| 218 | |
| 219 | float fMin=1,fClipDistance=500,fMax=100000,fVolume=128; |
| 220 | int nPriority=0; |
| 221 | |
| 222 | if (nParamCount>1) |
| 223 | { |
| 224 | pH->GetParam(2, nFlags); |
| 225 | } |
| 226 | if (nParamCount>2) |
| 227 | { |
| 228 | pH->GetParam(3,fVolume); |
| 229 | } |
| 230 | |
| 231 | if (nParamCount>3) |
| 232 | { |
| 233 | pH->GetParam(4,fMin); |
| 234 | } |
| 235 | |
| 236 | if (nParamCount>4) |
| 237 | { |
| 238 | pH->GetParam(5,fClipDistance); |
| 239 | if (fClipDistance>1000) |
| 240 | fClipDistance=1000; |
| 241 | //fMax=fClipDistance; |
| 242 | } |
| 243 | |
| 244 | if (pH->GetParamCount()>5) |
| 245 | { |
| 246 | pH->GetParam(6, nPriority); |
| 247 | } |
| 248 | |
| 249 | if (m_pSoundSystem) |
| 250 | { |
| 251 | pSound=m_pSoundSystem->LoadSound(sSound, FLAG_SOUND_3D | nFlags); |
| 252 | |
| 253 | if (pSound) |
| 254 | { |
| 255 | pSound->SetVolume((int)fVolume); |
| 256 | pSound->SetMinMaxDistance(fMin,fClipDistance/2.0f); |
| 257 | // pSound->SetMaxSoundDistance(fClipDistance/2); // :) |
nothing calls this directly
no test coverage detected