clock_x 2 Posted April 16, 2019 PLEASE DELETE THIS - WRONG SECTION Spoiler Hey, I modified a playlist script to simulate AI speech when the player is detected in some way. It works fine, but I got one problem which sometimes breaks immersion. The script gets executed multiple times for a single group, which is ok in big groups, I guess. But if there is only one or two guys in a group (I got lots of small pats), it sounds strange. Especially if there is only one guy left in a squad and he speaks in multiple voices. I googled alot for this, but I can't really find a solution. It gets executed by various other scripts: - If the AI finds a body: _shout1 = [leader (group finder), _killer] execVM "scripts\ShoutSound.sqf"; - If the AI detects nearby bullets (bdetect): _shout2 = [leader (group _unit_1), player] execVM "scripts\ShoutSound.sqf"; - if the AI fires a flare: _shout3 = [leader (group _unit), player] execVM "scripts\ShoutSound.sqf"; (if anyone wants to see the whole scripts I can put them here too, if that matters in any way.) I did this a while ago, I think I named them 1, 2 and 3 to tackle this problem, but couldn't find a way to put it to use. Here is the shouting script: (to clarify the sound files, s1-s5 is one voice, s9-s13 is a different one, the other ones are extra voices and radio sounds.) Spoiler //_shout1 = [_unit, _target] execVM "scripts\ShoutSound.sqf"; _unit = _this select 0; _target = _this select 1; _unit_group = group _unit; while { ({alive _x} count units (_unit_group) > 0) && ((leader (_unit_group) distance _target < 120) OR (leader (_unit_group) distance player < 120)) } do //repeat cycles as long unitis not killed { sleep 1; _alivecount = ({alive _x} count units _unit_group); if (_alivecount == 1) then { if (50 > random 100) then { if (mein_debug>0) then { player globalChat format ["ShoutSound.sqf - group: %1 alive: %2 target: %3", _unit_group, _alivecount, _target]; }; _shouts = [ ["s1",10+(random 20)], ["s2",10+(random 20)], ["s3",10+(random 20)], ["s4",10+(random 20)], ["s5",10+(random 20)] ]; while {((count _shouts) > 0) && (_alivecount == 1)} do { _selection = floor (random (count _shouts));//random playlist position number _shout = _shouts select _selection;//pick random element from _shouts _sleep = _shout select 1;//length _shout = _shout select 0;//name _shouts set [_selection,"Delete"]; _shouts = _shouts - ["Delete"];//remove for now chosen shout from the playlist, so will be not repeated in this cycle _shouter = units _unit_group call BIS_fnc_selectRandom; if (mein_debug>0) then { player globalChat format ["ShoutSound.sqf - unit:%1 shout: %2 time: %3 shouter: %4 group: %5", _unit, _shout, _sleep, _shouter, _unit_group]; }; if ( ( _shouter == _unit ) && ( _unit hasWeapon "ItemRadio" ) && !(_shouter call ace_sys_wounds_fnc_isUncon)) then { _shouter say3d "s17"; _shouter say3d _shout; _shouter say3d "s16"; sleep _sleep; } else { if !(_shouter call ace_sys_wounds_fnc_isUncon) then { _shouter say3d _shout; sleep _sleep; } else { sleep 5; }; }; if (({alive _x} count units (_unit_group) < 1) && ((leader (_unit_group) distance _target < 120) OR (leader (_unit_group) distance player < 120))) exitWith {if (mein_debug>0) then {player globalChat format ["ShoutSound.sqf - end"];};}; }; } else { if (mein_debug>0) then { player globalChat format ["ShoutSound.sqf - group: %1 alive: %2 target: %3", _unit_group, _alivecount, _target]; }; _shouts = [ ["s9",5+(random 25)], ["s10",5+(random 25)], ["s11",5+(random 25)], ["s12",5+(random 25)], ["s13",5+(random 25)] ]; while {((count _shouts) > 0) && (_alivecount == 1)} do //internal loop - lasts as long as there is at least one not played yet shout in the playlist { _selection = floor (random (count _shouts));//random playlist position number _shout = _shouts select _selection;//pick random element from _shouts _sleep = _shout select 1;//length _shout = _shout select 0;//name _shouts set [_selection,"Delete"]; _shouts = _shouts - ["Delete"];//remove for now chosen shout from the playlist, so will be not repeated in this cycle _shouter = units _unit_group call BIS_fnc_selectRandom; if (mein_debug>0) then { player globalChat format ["ShoutSound.sqf - unit:%1 shout: %2 time: %3 shouter: %4 group: %5", _unit, _shout, _sleep, _shouter, _unit_group]; }; if ( ( _shouter == _unit ) && ( _unit hasWeapon "ItemRadio" ) && !(_shouter call ace_sys_wounds_fnc_isUncon) ) then { _shouter say3d "s17"; _shouter say3d _shout; _shouter say3d "s16"; sleep _sleep; } else { if !(_shouter call ace_sys_wounds_fnc_isUncon) then { _shouter say3d _shout; sleep _sleep; } else { sleep 5; }; }; if (({alive _x} count units (_unit_group) < 1) && ((leader (_unit_group) distance _target < 120) OR (leader (_unit_group) distance player < 120))) exitWith {if (mein_debug>0) then {player globalChat format ["ShoutSound.sqf - end"];};}; }; }; }; if (_alivecount == 2) then { if (50 > random 100) then { if (mein_debug>0) then { player globalChat format ["ShoutSound.sqf - group: %1 alive: %2 target: %3", _unit_group, _alivecount, _target]; }; _shouts = [ ["s1",2+(random 28)], ["s2",2+(random 28)], ["s3",2+(random 28)], ["s4",2+(random 28)], ["s5",2+(random 28)], ["s6",2+(random 28)], ["s14",2+(random 28)], ["s15",2+(random 28)] ]; while {((count _shouts) > 0) && (_alivecount == 2)} do //internal loop - lasts as long as there is at least one not played yet shout in the playlist { _selection = floor (random (count _shouts));//random playlist position number _shout = _shouts select _selection;//pick random element from _shouts _sleep = _shout select 1;//length _shout = _shout select 0;//name _shouts set [_selection,"Delete"]; _shouts = _shouts - ["Delete"];//remove for now chosen shout from the playlist, so will be not repeated in this cycle _shouter = units _unit_group call BIS_fnc_selectRandom; if (mein_debug>0) then { player globalChat format ["ShoutSound.sqf - unit:%1 shout: %2 time: %3 shouter: %4 group: %5", _unit, _shout, _sleep, _shouter, _unit_group]; }; if ( ( _shouter == _unit ) && ( _unit hasWeapon "ItemRadio" ) && !(_shouter call ace_sys_wounds_fnc_isUncon) ) then { _shouter say3d "s17"; _shouter say3d _shout; _shouter say3d "s16"; sleep _sleep; } else { if !(_shouter call ace_sys_wounds_fnc_isUncon) then { _shouter say3d _shout; sleep _sleep; } else { sleep 5; }; }; if (({alive _x} count units (_unit_group) < 1) && ((leader (_unit_group) distance _target < 120) OR (leader (_unit_group) distance player < 120))) exitWith {if (mein_debug>0) then {player globalChat format ["ShoutSound.sqf - end"];};}; }; } else { if (mein_debug>0) then { player globalChat format ["ShoutSound.sqf - group: %1 alive: %2 target: %3", _unit_group, _alivecount, _target]; }; _shouts = [ ["s9",2+(random 28)], ["s10",2+(random 28)], ["s11",2+(random 28)], ["s12",2+(random 28)], ["s13",2+(random 28)], ["s6",2+(random 28)], ["s14",2+(random 28)], ["s15",2+(random 28)] ]; while {((count _shouts) > 0) && (_alivecount == 2)} do //internal loop - lasts as long as there is at least one not played yet shout in the playlist { _selection = floor (random (count _shouts));//random playlist position number _shout = _shouts select _selection;//pick random element from _shouts _sleep = _shout select 1;//length _shout = _shout select 0;//name _shouts set [_selection,"Delete"]; _shouts = _shouts - ["Delete"]; //remove for now chosen shout from the playlist, so will be not repeated in this cycle _shouter = units _unit_group call BIS_fnc_selectRandom; if (mein_debug>0) then { player globalChat format ["ShoutSound.sqf - unit:%1 shout: %2 time: %3 shouter: %4 group: %5", _unit, _shout, _sleep, _shouter, _unit_group]; }; if ( ( _shouter == _unit ) && ( _unit hasWeapon "ItemRadio" ) && !(_shouter call ace_sys_wounds_fnc_isUncon) ) then { _shouter say3d "s17"; _shouter say3d _shout; _shouter say3d "s16"; sleep _sleep; } else { if !(_shouter call ace_sys_wounds_fnc_isUncon) then { _shouter say3d _shout; sleep _sleep; } else { sleep 5; }; }; if (({alive _x} count units (_unit_group) < 1) && ((leader (_unit_group) distance _target < 120) OR (leader (_unit_group) distance player < 120))) exitWith {if (mein_debug>0) then {player globalChat format ["ShoutSound.sqf - end"];};}; }; }; }; if (_alivecount > 2) then { if (mein_debug>0) then { player globalChat format ["ShoutSound.sqf - group: %1 alive: %2 target: %3", _unit_group, _alivecount, _target]; }; _shouts = [ ["s1",0+(random 30)], ["s2",0+(random 30)], ["s3",0+(random 30)], ["s4",0+(random 30)], ["s5",0+(random 30)], ["s6",0+(random 30)], ["s7",0+(random 30)], ["s8",0+(random 30)], ["s9",0+(random 30)], ["s10",0+(random 30)], ["s11",0+(random 30)], ["s12",0+(random 30)], ["s13",0+(random 30)], ["s14",0+(random 30)], ["s15",0+(random 30)] ]; while {((count _shouts) > 0) && (_alivecount > 2)} do //internal loop - lasts as long as there is at least one not played yet shout in the playlist { _selection = floor (random (count _shouts));//random playlist position number _shout = _shouts select _selection;//pick random element from _shouts _sleep = _shout select 1;//length _shout = _shout select 0;//name _shouts set [_selection,"Delete"]; _shouts = _shouts - ["Delete"];//remove for now chosen shout from the playlist, so will be not repeated in this cycle _shouter = units _unit_group call BIS_fnc_selectRandom; if (mein_debug>0) then { player globalChat format ["ShoutSound.sqf - unit:%1 shout: %2 time: %3 shouter: %4 group: %5", _unit, _shout, _sleep, _shouter, _unit_group]; }; if ( ( _shouter == _unit ) && ( _unit hasWeapon "ItemRadio" ) && !(_shouter call ace_sys_wounds_fnc_isUncon) ) then { _shouter say3d "s17"; _shouter say3d _shout; _shouter say3d "s16"; sleep _sleep; } else { if !(_shouter call ace_sys_wounds_fnc_isUncon) then { _shouter say3d _shout; sleep _sleep; } else { sleep 5; }; }; if (({alive _x} count units (_unit_group) < 1) && ((leader (_unit_group) distance _target < 120) OR (leader (_unit_group) distance player < 120))) exitWith {if (mein_debug>0) then {player globalChat format ["ShoutSound.sqf - end"];};}; }; }; } Help is much appreciated! Cheers. Share this post Link to post Share on other sites