![]() |
Hearing sounds
I am quite curious how you guys code your hearing of a bot. I know several methods, but i am not sure which one is the best. Like for players you can scan them, check if they are in distance and try to see if that person runs (and thus can be heared). However, i still am not quite satisfied with that, there is also another way of intercepting sounds, like firing weapons and such right?
|
Re: Hearing sounds
hmm I do it like Count Floyd did it... I just store the sound in a array for clients when pfnEmitSound gets called. Elsewhere I check if this sound is heareble by looking how far it is and if the player who made the sound is visible
|
Re: Hearing sounds
I think I can boast to have the most complicated sound code in my bot - ever :D
In fact, sounds are of 2 types: - "important" sounds are played by the server, which orders then some or all of its client to play it at the same time, through a network message. - most of the other sounds are emulated by the client DLL, which interprets the game and decides if a sound must be played or not. This is done to save a whole lot of network bandwidth. Only a few sounds are hookable through server-side functions, actually. All the rest is client-side stuff only. Since bots have no client DLL, they need to emulate all the other sounds themselves. Movement sounds AND weapon sounds. Movement sounds can be evaluated each frame, while weapon sounds can be hooked by catching "ammo decrease" network messages. Here's how I do it (here for emulating a Counter-Strike client DLL). Code:
void PlayClientSoundsForBots (edict_t *pPlayer) Code:
void PlayBulletSoundsForBots (edict_t *pPlayer) |
Re: Hearing sounds
Hi all, it's been some time :-)
So here's my first question: What's the advantage of using DispatchSound() ? You'll have to hook to this function again to let the bots react to the sounds, and you'll need a lot of branching for the different cases there again. Why not do it in one go? Apart from that, nice code: I had the texture switch, too, but not the water sounds :-) |
Re: Hearing sounds
Haha, you forgot what were the engine functions don't you :D
DispatchSound is a function I wrote myself ;) I call this for every sound emitted in the game, to dispatch the sound with the right attenuation in one slot of the bot's ears, for the specified duration of the sound (yep, because in my bot, the sounds LAST in the bot's ears :D) Code:
void DispatchSound (const char *sample, Vector v_origin, float volume, float attenuation) Code:
void BotFeedEar (bot_t *pBot, sound_t *sound, Vector v_origin, float volume) |
Re: Hearing sounds
Uhm, yeah, I forgot the engine function names - partly ;-)
Now I see your system: Neat! - Although I doubt players will be able to appreciate these details... But knowing that you are programming the bot for your own pleasure: who cares, just do it! :-) |
Re: Hearing sounds
Don't forget to randomize the location of the sound - the farther away, the more random error. Otherwise, your bots will seem to be able to see through walls if they aim right for the sound source.
Human players, even with headphones, can't pinpoint the exact position of a sound, unless it is very close and they know the map layout very well. |
Re: Hearing sounds
No problem, Michael, this is exactly what I am doing:
Code:
pBotEar->noises[selected_index].direction = BotEstimateDirection (pBot, v_origin); - rather in front of the bot - rather ahead on the left - rather on the left - rather behind on the left - rather behind it - rather behind on the right - rather on the right - rather in front on the right Code:
// relative directions Distance is not taken in account, it's only the angle at which the sound comes to the bot. I believe it's more natural that way than to inflict (yet another) arbitrary randomization, what do you think ? |
Re: Hearing sounds
I think estimating the sounds relative position like you have done is a clever idea. It prevents "perfect hearing" and is computationally efficient.
However, I often store the estimated sound position and have the bot move there when hunting for enemies. If you only have a relative direction, you can't easily do that. |
Re: Hearing sounds
Right.
My bot's AI is not that far yet, hence I never faced really the problem. But it certainly will arise sooner or later. I believe I can tackle it out easily, though... lemme see: - The "direction" will encompass a certain group of walkfaces in the navmesh, which I can pop out quickly thanks to the topology hashtable - The "distance" will be expressed in function of the sound's LOUDNESS, taking in account whether there is a direct LOS or not (a wall in between, for example). Direction & distance => position. I believe that's the most human-like way of doing things. However, this was just a 5 minute thought. I might be able to do better ;) |
Re: Hearing sounds
i like the way you do this pierre, it is not so 'abstract' as mike said.
However, of course such a lazy dutchmen as i am would just grab the enemy vector, do some randomization (taking velocity, distance and bot skill into account) and you would have the same position. Btw, i think your 5 minute thought aint that bad afterall ;) |
Re: Hearing sounds
what ? the finishing touch of God, a lazy dutchman ? it's so... disappointing :D
|
Re: Hearing sounds
hmm.
for the direction, You could just alter the angle of the sounds position by a random amount depending on the bots skill. I'm not sure how to calculate the loudness though.. might need to find some sort of correlation ratio with a quiet sound and certain distance etc. :) But yea, angle and distance is the way to go :P |
Re: Hearing sounds
rhaaa, random amounts, random amounts, random amounts... you guys seem to think that AI should be driven by randomness or what ? :)
|
Re: Hearing sounds
its the lazy way :)
|
Re: Hearing sounds
it should probably be based on experience and what you know of your surroundings and such..
random is just not right... |
Re: Hearing sounds
Quote:
|
All times are GMT +2. The time now is 18:31. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.