OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Resources Beta Testing & Submission => Topic started by: Semedar on 25 Apr 2011, 05:36:51
-
So I have this script for when I kill an opfor dude a sound plays:
?!local _this: exit
playSound "GotHim"
Question is: How do I make it play a random one of two. So:
?!local _this: exit
playSound "GotHim"
or
playSound "GotHim2"
I'm assuming you will use the "Random" argument but I wouldn't know how to implement it. :(
Thanks for any help. ;)
Hah! I found out with a ton of research. :D Here's how I did it:
"KillSound.sqs"
; ****************************************************************
; Random Kill Sound Script
; Created by: Semedar
; ****************************************************************
?!local _this: exit
_random = random 5
_a = _random - (_random mod 1)
~(random 3)
?(_a == 1) : goto "1"
?(_a == 2) : goto "2"
?(_a == 3) : goto "3"
?(_a == 4) : goto "4"
?(_a == 5) : goto "5"
#1
playSound "GotHim"
exit
#2
playSound "Contact"
exit
#3
playSound "TangoDown"
exit
#4
playSound "BingoBingo"
exit
#5
playSound "ThreatNeutralized"
exit
And if you want to know how I implemented this in-game, just add a trigger like this:
(http://i51.tinypic.com/6f829y.jpg)
Axis a: 99999
Axis b: 99999
Activation: OPFOR (Once)
Present
Text: Kill Sound
Condition: true
On Act.:
{_x addEventHandler ["killed", "(_this select 1) exec ""KillSound.sqs"""]} forEach thisList
-
If you want to use slightly less scripts something like this would work just as well
_random = random 100
? _random <= 50 : playsound "GotHim"
? _random > 50 : playsound "GotHim2"
That would work just as well, doesn't really make any difference but just thought I'd mention it
-
The best way to do it in ARMA 2 is using BIS' function. Saves a lot of space:
waitUntil {!(isNil "bis_fnc_init")};
_sound = ["Sound1","Sound2","Sound3"] call bis_fnc_selectRandom;
playSound _sound;
Obviously you'll need to place the Functions Module in the mission. Anyways, this thread was made in April so I guess there isn't much benefit to us telling him better ways to find it. :P
-
Haha thanks for the update :) I now switched from my version to yours, Zipper5. :D Can always appreciate cutting down the file size. ;)
-
I have another thing I would like to add to this:
How would I add a sideChat feature to it so every time I kill someone, it plays a random sound AND the person who killed the enemy would say something like: "Tango Down" along with a sound file I have that says exactly that. I thought it would be simple to just put something like this:
waitUntil {!(isNil "bis_fnc_init")};
_responses = [["GotHim","Got Him!"],["Contact","Contact!"],["TangoDown","Tango Down!"],["BingoBingo","Bingo Bingo!"],["ThreatNeutralized","Threat Neutralized!"]];
_indx = floor random 3;
playsound ((_responses select _indx) select 0);
player sidechat ((_responses select _indx) select 1);
But everyone says the response (assuming they're an actual player). And if an AI kills an enemy, it will make me say the response. I just want the killer to say the response.
tl:dr: How would I be able to make the killer say the response but everyone else be able to hear the sound file?