Skip to content

killSound

Back To Armed Assault Scripts

Play selected sound when enemy is killed.

You need to have your sounds defined in Description.ext under CfgSounds.

For the Armed Assault 3 solution, you don’t need any triggers. If you have init.sqf in the root folder of your mission/scenario, it runs each time the enemy is killed.


Armed Assault

Trigger Axis A & B: 99999

Activation: Enemy side / Once / Present

On Activation:

{_x addEventHandler ["killed", "(_this select 1) exec ""killSound.sqs"""]} forEach thisList

killSound.sqs

; *************************************
; Random Kill Sound Script
; Created by Semedar (Villa, Victor D.)
; *************************************

?!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 "Sound1"
exit

#2
playSound "Sound2"
exit 

#3
playSound "Sound3"
exit

#4
playSound "Sound4"
exit

#5
playSound "Sound5"
exit

Armed Assault 2

Trigger Axis A & B: 99999

Activation: Enemy side / Once / Present

On Activation:

{_x addEventHandler ["KILLED", "(_this) execVM ""killSound.sqf"""]} forEach thisList;

killSound.sqf

/*
Kill Sound Script
Semedar (Villa, Victor D.)
*/

waitUntil {!(isNil "bis_fnc_init")};
_sound = ["Sound1","Sound2","Sound3","Sound4","Sound5"] call bis_fnc_selectRandom;
playSound _sound;

Armed Assault 3

init.sqf

addMissionEventHandler ["entityKilled", {
	params ["_killed","_killer","_instigator"];
	if (local _instigator && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 0) then {
		private _killSoundArray = [
			"Sound1",
			"Sound2",
			"Sound3",
			"Sound4",
			"Sound5"
		];
		_killSoundVar = selectRandom _killSoundArray;
		playSound _killSoundVar;
	}
}];

Note: See https://community.bistudio.com/wiki/Side to view side numbers and change to your specific side on line 3.

Opus@Monotonía | © Victor D. Villa, All rights reserved.