Jump to content
Sign in to follow this  
allamawitharifle

Man say random sound

Recommended Posts

I have a ton of different sounds which I've set up in the description.ext file and they all play fine.

Now I want to set up triggers so that when enemy walk into the trigger it activates a script with

nul = [thislist select 0] execVM "AIShout.sqf"

Now in AIShout.sqf I have the following...

_man = this select 0;

_sound = ["af_attack1","af_attack2","af_attack3"] call bis_fnc_selectRandom;
_man say _sound;

Which for some reason doesn't seem to work. When I change the say command to playsound then the sound plays except the sound is heard no matter where you are. I want the man that activated the trigger to say the sound so that it's only heard loudly when up close and it's quiet/unhearable when far away.

Share this post


Link to post
Share on other sites

_man = _this select 0;

_sounds = ["af_attack1","af_attack2","af_attack3"];

_sound = _sounds select floor random count _sounds;

_man say _sound;

Edited by Celery

Share this post


Link to post
Share on other sites

Thanks a lot, that works perfectly...

Only problem is that even using say the sound can be heard over stupidly long distances. The player needs to be a good 1000 metres before the sound is relatively quiet and nearly double that before the sound can't be heard at all.

Is there a way to make it slightly more realistic volume wise? Or should I just alter the volume of the sounds?

Share this post


Link to post
Share on other sites

Change the volume in description.ext to like 0.1.

Share this post


Link to post
Share on other sites

_man say [_sound, 2];

This will limit the say to 2 "titles" from the source. Not entirely sure how large a "tile" is, but you can play around with it.

Share this post


Link to post
Share on other sites

Alernatively... dunno if this works in sqf, you can do:

_ce = ceil (random 3)

_man say format["af_attack%1",(_ce)]

Share this post


Link to post
Share on other sites

I went with Celery's suggestion, works perfectly. I tried the whole titles thing but seemed more trouble then it's worth so I just changed the sound in the description.ext and that's worked perfectly.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×