View Full Version : Ai senses and Volume
Sateth
06-05-2007, 04:58 PM
Hi,
I'm trying to detect where and when m_SoundPool[i] value change. Because i set player walk sound volume to 0, it works (EmitSound contains a volume wich is at 0). But when I walk m_SoundPool[i] return a positive value.
I do not understand where and when this change occurs.
Thanks for your help.
Sateth
06-09-2007, 10:26 AM
hum, you're maybe needing more informations.
My goal is to have a better understanding of all the AI detection/senses system.
I realised that i need to concentrate myself on a unique sense before continuing. That's why I choose the Sound System.
I thought that the only sound which is emmited is the Player Walk Sound (when NPC is at IDLE State). But when I'm displaying the Volume in CAI_Senses::Listen i saw that changing the Player Walk Volume to 0 in CBasePlayer::PlayStepSound does not change anything. A positive volume is returned.
My problem is that I cannot found where did this mysterious sound come from.
Any Help appreciated.
Sateth
06-17-2007, 04:22 PM
I checked where m_SoundPool exists and it appears that this var is only in Soundent.cpp. I checked functions calls ingame in order to know how can this value (m_SoundPool) be changed. And the only one called is "Think" (everytime ... normal ...).
But the m_SoundPool value is changed before entering in "Think".
How can it be possible ???? this is incredible ! Is there a piece of code hidden somewhere ??? Please i need to understand !
Please help me ! I cannot think i'm the only one who's ever tried to understand AI senses System.
Sateth, I just had a quick look in soundent.cpp/.h. m_SoundPool is declared as private, which means that finding it used only within soundent.cpp is to be expected.
Looking within soundent.h, I noticed the following functions.
static void InsertSound ( int iType, const Vector &vecOrigin, int iVolume, float flDuration, CBaseEntity *pOwner = NULL, int soundChannelIndex = SOUNDENT_CHANNEL_UNSPECIFIED, CBaseEntity *pSoundTarget = NULL );
static void FreeSound ( int iSound, int iPrevious );
It looks like FreeSound/InsertSound is what you're looking for. Notice this code within InsertSound to create a new sound:
CSound *pSound;
pSound = &g_pSoundEnt->m_SoundPool[ iThisSound ];
pSound->SetSoundOrigin( vecOrigin );
pSound->m_iType = iType;
pSound->m_iVolume = iVolume;
pSound->m_flOcclusionScale = 0.5;
pSound->m_flExpireTime = gpGlobals->curtime + flDuration;
pSound->m_bNoExpirationTime = false;
pSound->m_hOwner.Set( pOwner );
pSound->m_hTarget.Set( pSoundTarget );
pSound->m_ownerChannelIndex = soundChannelIndex;
Sateth
06-19-2007, 10:31 AM
Yes, I already noticed that, but i was wondering when one of this functions is called. Cause I put DevMsg in this functions to know if they're called and it never appears ingame :/. They're maybe called before map loading, or maybe just before I finished writing "developer 1" ? But how can I know is this is the case ? And I just don't understand how can a volume decrease with time without called theses functions ?
However Thanks for your answer :)
Edit :
Below is the call in CWorld::Precache
CSoundEnt::InitSoundEnt();
and here is what is done :
g_pSoundEnt = (CSoundEnt*)CBaseEntity::Create( "soundent", vec3_origin, vec3_angle, GetWorldEntity() );
But I cannot find any CSound Added :/
But I cannot find any CSound Added
I showed you where CSound was added in my previous post. As explained in soundent.h:
//================================================== =======
// CSound - an instance of a sound in the world.
//================================================== =======
//================================================== =======
// CSoundEnt - a single instance of this entity spawns when
// the world spawns. The SoundEnt's job is to update the
// world's Free and Active sound lists.
//================================================== =======
After a little digging with regards to footsteps, I found this function in c_baseanimating.cpp:
void MaterialFootstepSound( C_BaseAnimating *pEnt, bool bLeftFoot, float flVolume )
Specifically:
if( tr.fraction < 1.0 && tr.m_pEnt )
{
surfacedata_t *psurf = physprops->GetSurfaceData( tr.surface.surfaceProps );
if( psurf )
{
EmitSound_t params;
if( bLeftFoot )
{
params.m_pSoundName = physprops->GetString(psurf->sounds.stepleft);
}
else
{
params.m_pSoundName = physprops->GetString(psurf->sounds.stepright);
}
CPASAttenuationFilter filter( pEnt, params.m_pSoundName );
params.m_bWarnOnDirectWaveReference = true;
params.m_flVolume = flVolume;
pEnt->EmitSound( filter, pEnt->entindex(), params );
}
}
Sateth
06-20-2007, 04:43 AM
whoa, I should have continued looking for footsteps informations.
Thanks very much !
EDIT : well, it seems that i don't have this function :/.
I'm working on SP Sdk, are you ?
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.