clock_x 2 Posted April 16, 2019 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. So I'm looking for something like: 'If script is already running for group X, then don't run it again!' And all the origin scripts needs to recognize it. 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: 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"];};}; }; }; } (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.) Help is much appreciated! Cheers. Share this post Link to post Share on other sites
f2k sel 164 Posted April 16, 2019 You could try stetting up a variable in init.sqf endscript=true; then at the beginning of your code add if (!endscript) exitwith {}; endscript = false; rest of your code goes here then right at the end where it finishes flip it back to true so it can run again. endscript = true; you could also add a delay before the endcript =true; so it can't be called immediately Share this post Link to post Share on other sites
clock_x 2 Posted April 17, 2019 Hey, thanks for the reply! That might work, there is one problem with it though, as far as I can see. During the duration of the script, no other group can execute it. For example.. The BLUFOR stealth team takes down a OPFOR unit from a pat of 2. The other OPFOR unit finds the body and executes the script -> starts sending radio messages. A different OPFOR squad in the near proximity could hear/see the whole thing and fire a flare(tries to execute the script), thus the script would not be executed. But this is pretty much what I want. A bad example would be: A OPFOR unit finds a body AND fires a flare and the script gets fired twice for the same group. (w/o the solution). By the way, there is actually a meaning behind the shouting. When a unit finds a body/fires a flare/realizes nearby bullet hits, a countdown starts in which the player has time to kill it, if not all units get alarmed and reinforcements are coming. So the shouting is basically an indicator that the situation must be dealt with. I was thinking about something in the shower... I could give all units a global value like unit_x=1; unit_y=1;[...] And in the script I do something similiar like you wrote. if (_unit = 1) then {_unit = 2; RESTOFTHESCRIPT; _unit = 1;} else {exitwith {};}; Could that work? Seems like a lot of hustle tho. Cheers Share this post Link to post Share on other sites
f2k sel 164 Posted April 17, 2019 Sorry don't have much time right now but you could use setvariable, that can be used to store the group name and other info in an array, so basically you look to see if that units group has been used and then exit the script for that group only https://community.bistudio.com/wiki/setVariable you will also need to look at https://community.bistudio.com/wiki/getVariable so you can retrieve the info I'm not saying your Idea won't work it just looks a little confusing and I'm not really clear what your trying to do. Share this post Link to post Share on other sites
clock_x 2 Posted April 17, 2019 Oh well that seems to do pretty much something like what I was trying to do. I'm going to give it a try. If I get this right I need to do something like this: At mission start, for all groups, in a script or logic or something: group1 setVariable [var1, false]; group2 setVariable [var2, false]; group3 setVariable [var3, false]; [...] And in my shout script: if (_unit_group getVariable var1) then { group1 setVariable [var1, true]; RESTOFTHESCRIPT; group1 setVariable [var1, false]; } else {exitwith {};}; Or maybe something like this(dunno if the above actually returns true): _var = _unit_group getVariable var1; if (_var = true) then { group1 setVariable [var1, true]; RESTOFTHESCRIPT; group1 setVariable [var1, false]; } else {exitwith {};}; //Edit: I'm thinking that I should use 1 and 2 instead of true and false in this case. group1 setVariable [var1, 1]; if (_var = 1) then { group1 setVariable [var1, 2]; RESTOFTHESCRIPT; group1 setVariable [var1, 1]; } else {exitwith {};}; But this would only work for group1 because it's the only one whose variable is named var1. Can I maybe name all of them just var like this: group1 setVariable [var, false]; group2 setVariable [var, false]; group3 setVariable [var, false]; So that I can simply use this line: _unit_group getVariable var I can imagine that each group needs it's own variable name. If yes, is there a way to get the names from my execution line.. _shout1 = [leader (group finder), _killer, VARIABLE] execVM "scripts\ShoutSound.sqf"; So I can do: _this select 3; to get the name? Man this is complicated. 😀 Share this post Link to post Share on other sites
f2k sel 164 Posted April 17, 2019 Your on the right track with naming the groups. It shouldn't be that difficult your just looking for a variable set against the groups name to see if it's true or false. Example below //_shout1 = [_unit, _target] execVM "scripts\ShoutSound.sqf"; // // init.sqf ; // set up your group variables // mygroup1 setVariable ["endscript",true]; // mygroup2 setVariable ["endscript",true];//ect // mygroup will be the original group name whatever your using change to match // _unit = _this select 0; _target = _this select 1; _unit_group = group _unit; if (!_unit_group getvariable "endscript") exitwith {};// it looks at the group name and if variable is false it should exit _unit_group setVariable ["endscript",false];// set to false to prevent it starting again; // main code // endof script sets it back to true so can run again _unit_group setVariable ["endscript",true]; make sure you set up the groups names and set the default variable at mission start. Share this post Link to post Share on other sites
clock_x 2 Posted April 17, 2019 Sounds good! I'm going to implement it tomorrow, shouldn't be a problem. Thanks for your help, really appreciate it! I may just group them and try to have the same effect with disableAI commands, but not sure this is gonna work out. Share this post Link to post Share on other sites
clock_x 2 Posted April 18, 2019 It's ok if I assign the variables to groups and single units, right? I got a few ungrouped units for animations and stuff, they get grouped after contact, but it's not always happening in time. Share this post Link to post Share on other sites
f2k sel 164 Posted April 18, 2019 A single unit can be a group on it's own so that should be fine, after they're group ed they should fall under original group variable and their own variable ignored (I think). Just see if any of it works and build on that. 1 Share this post Link to post Share on other sites
clock_x 2 Posted April 22, 2019 Hey, I managed to get it to work after some small changes. Here the finished scripts: Script executed via init.sqf: groupinit.sqf Spoiler //group variables //init.sqf: [] execVM "scripts\groupinit.sqf"; N1_G setVariable ["endscript",true]; //radio1 pat N2_G setVariable ["endscript",true]; //radio2 pat N3_G setVariable ["endscript",true]; //radio pat N4_G setVariable ["endscript",true]; //hind camp pat N5_G setVariable ["endscript",true]; //east camp pat N6_G setVariable ["endscript",true]; //kord pat N7_G setVariable ["endscript",true]; //AA pat N8_G setVariable ["endscript",true]; //west camp pat pat1_G setVariable ["endscript",true]; //south pat pat2_G setVariable ["endscript",true]; //south pat pat3_G setVariable ["endscript",true]; //hills pat pat4_G setVariable ["endscript",true]; //hills pat pat5_G setVariable ["endscript",true]; //hills pat pat6_G setVariable ["endscript",true]; //hills pat pat7_G setVariable ["endscript",true]; //hills pat pat8_G setVariable ["endscript",true]; //hills dog pat 50% pat_s_G setVariable ["endscript",true]; //sniper pat 50% R0_G setVariable ["endscript",true]; //outpost pat R1_G setVariable ["endscript",true]; //east dog pat R2_G setVariable ["endscript",true]; //west dog pat (group N1_1) setVariable ["endscript",true]; //radio1 camp (group N1_2) setVariable ["endscript",true]; // (group N2_2) setVariable ["endscript",true]; //radio2 camp (group N2_3) setVariable ["endscript",true]; // (group N4_1) setVariable ["endscript",true]; //hind camp (group sleeper_1) setVariable ["endscript",true]; // (group N5_2) setVariable ["endscript",true]; // east camp (group N5_3) setVariable ["endscript",true]; // (group N6_2) setVariable ["endscript",true]; // kord camp (group N6_3) setVariable ["endscript",true]; // (group N6_4) setVariable ["endscript",true]; // (group N6_5) setVariable ["endscript",true]; // (group sitting_2) setVariable ["endscript",true]; // AA camp (group sleeper_2) setVariable ["endscript",true]; // (group N7_2) setVariable ["endscript",true]; // (group N7_3) setVariable ["endscript",true]; // (group N7_4) setVariable ["endscript",true]; // (group N8) setVariable ["endscript",true]; //west camp (group N8_1) setVariable ["endscript",true]; // ShoutSound.sqf Spoiler //_shout1 = [_unit, _target] execVM "scripts\ShoutSound.sqf"; // // init.sqf ; // set up your group variables // mygroup1 setVariable ["endscript",true]; // mygroup2 setVariable ["endscript",true];//ect // mygroup will be the original group name whatever your using change to match _unit = _this select 0; _target = _this select 1; _unit_group = group _unit; _variable = _unit_group getVariable "endscript"; if (!_variable) exitwith {if (mein_debug>0) then {player globalChat format ["ShoutSound.sqf - END group: %1 already executing", _unit_group];};};// it looks at the group name and if variable is false it should exit _unit_group setVariable ["endscript", false];// set to false to prevent it starting again; while { ({alive _x} count units (_unit_group) > 0) && ((leader (_unit_group) distance _target < 100) OR (leader (_unit_group) distance player < 100)) } 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 //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 < 100) OR (leader (_unit_group) distance player < 100))) 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 < 100) OR (leader (_unit_group) distance player < 100))) 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 < 100) OR (leader (_unit_group) distance player < 10))) 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 < 100) OR (leader (_unit_group) distance player < 100))) 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 < 100) OR (leader (_unit_group) distance player < 100))) exitWith {if (mein_debug>0) then {player globalChat format ["ShoutSound.sqf - end"];};}; }; }; }; // endof script sets it back to true so can run again _unit_group setVariable ["endscript",true]; if (mein_debug>0) then {player globalChat format ["ShoutSound.sqf - END"];}; Thanks again for your help! Cheers. Share this post Link to post Share on other sites
f2k sel 164 Posted April 23, 2019 Glad you got it sorted. 1 Share this post Link to post Share on other sites