Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
Doggler

Sound heard in certain radius?

Recommended Posts

I am trying to make it so that a sound can be heard in a certain radius. My case, I am trying to make a custom voice activate when either the unit has been shot or sees the player. Is this possible?

1. Trigger Activate on hit

2. Sound heard in radius

Thanks

EDIT: Is there also a way to change the name of a weapon? Like from M4A1 to CAR15?

Edited by Doggler

Share this post


Link to post
Share on other sites

Here is a real quick answer(May contain errors)!

The first part is easy(1. Trigger Activate on hit). Do you want to use "hit detection" or "unit sees player"?

HIT DETECTION:

You can use an Event Handler to detect if the unit has been hit or if the unit has taken damage. Use one of the following:

Hit: Example Below

_index = unitName addMPEventHandler ["Hit", {Null = _this execVM "playCustomVoice.sqf";}];

OR...

Damaged: Example Below

_index = unitName addMPEventHandler ["Dammaged", {Null = _this execVM "playCustomVoice.sqf";}];

FYI: It seems that the "Hit" Event Handler doesn't always trigger if the unit is killed from "the hit"(ex: single bullet), try and see which works best for you. You will have to tweak the above code to get it to work properly with your mission, but this is a good start. Place either of the above codes into your "Init.sqf" file to integrate the event handlers into your mission.

UNIT SEES PLAYER:

If you want to use this approach, then look into the "knowsabout" command.

Your second question(activating a custom voice heard only in a certain radius) is trickier.

If I remember correctly, you can adjust the volume of the sound file and it will increase/decrease the range that the sound will be heard. This is of course assuming you are using a sound file(.ogg, .wav. etc.). Not too sure about this one.

Here is a nice little tutorial I stumbled upon, not sure when it was written, hopefully it is still relevant.

Good Luck!

Share this post


Link to post
Share on other sites
Sign in to follow this  

×