webbie. 3 Posted June 24, 2017 On 5/5/2017 at 4:06 PM, sarogahtyp said: Thanks for ur suggestions. I thought about those negative score thing and I ll turn the civilian to enemy side to fix this. Are u sure that _dist_target becomes undefined? I ve an alive check in the while loop for it. And in the condition this alive check is at first position. The loop should simply break before _dist_target gets checked if the civilian is dead. But if it truly throws an error then I ll fix it. But I be no time for it within the next few days. sent from mobile using Tapatalk Im also experiencing this, they are actually running at me when this occurs. Im also using BI revive. Im using it in on COS as well and everything works fine but it does throw that error up. Share this post Link to post Share on other sites
anfo 118 Posted July 7, 2017 Hey @sarogahtyp, where could one fit into your script a say3D? Share this post Link to post Share on other sites
sarogahtyp 1108 Posted July 7, 2017 (edited) Okay. I think this question will be repeated if I don't do it. therefore here is the script with YOUR sound integration. Happy Alah u Ak'bar! /* SSSB - Sarogahtyps Simple Suicide Bomber Description: Function can be called wherever u want even in init line. It waits for player who is in range and follows him until reached and then BOOOOM! The bomber is walking if player can see the bomber. If there is no line of sight to player then the bomber will run. Works even if the bomber is driving a vehicle. If player is out of range before bomber can reach him then the bomber will just wait for the next player in range. You can pass a chance to get a bomber to the function. This is useful for implementing the script into COS - Civilian Occupation System. You can apply the script to all civilians and if u pass e.g. 1 % as chance then only every 100th civ will become a bomber and wait for near players. Enjoy the boom. :-) Cheers Saro. Paramameters: object - the object of your unit which should become a bomber number (optional) - range to seek for players (default is 300 m) number (optional) - chance to turn the unit into a bomber. (default is 100 %) Return values: number - handle of spawned script if someone likes to check if bombers script has ended (scriptDone) will return -1 if script ends without spawning code (in case no civ was turned into bomber) */ params [["_civ", objNull,[objNull]], ["_act_range", 300, [0]], ["_chance", 100, [0]]]; if ((random 100 > _chance) || !(alive _civ)) exitWith {-1}; _handle = [_civ, _act_range] spawn { params ["_bomber", "_act_range"]; private _melee_dist = 15; private _boom_dist = 5; private _dist_target = _act_range; private _lost_range = round (_act_range * 1.2); private _act_range_sqr = _act_range ^ 2; private _melee_dist_sqr = _melee_dist ^ 2; private _boom_dist_sqr = _boom_dist ^ 2; private _dist_target_sqr = _act_range ^ 2; private _lost_range_sqr = _lost_range ^ 2; private _grp_bomber = group _bomber; private _is_vec = if (isNull objectParent _bomber) then {false} else {true}; private _target_players = []; private _wp =[]; while {(alive _bomber) && (_dist_target_sqr > _boom_dist_sqr)} do { private _shouted = false; // wait until players are in range waitUntil { sleep (2 + random 1); _target_players = (allPlayers - entities "HeadlessClient_F") select {(alive _x) && ((_x distanceSqr _bomber) < _act_range_sqr)}; ((count _target_players > 0) || !(alive _bomber)) }; // end everything if suicide bomber is already dead if !(alive _bomber) exitWith {}; // follow nearest player as long as bomber lives, target is in range and target is not close enough to boom while {alive _bomber && (_dist_target_sqr < _lost_range_sqr) && (_dist_target_sqr > _boom_dist_sqr)} do { _target_players = (allPlayers - entities "HeadlessClient_F") select {(alive _x) && ((_x distanceSqr _bomber) < _act_range_sqr)}; // get nearest player _target_players = _target_players apply {[(_x distanceSqr _bomber), _x]}; _target_players sort true; _target_plyr = _target_players select 0 select 1; // check distance and visibility _dist_target_sqr = if(count _target_players > 0) then {_target_players select 0 select 0} else {_lost_range_sqr}; _can_see = [_target_plyr, "VIEW", _bomber] checkVisibility [(eyePos _target_plyr), (eyePos _bomber)]; // add waypoint and set bombers behavior if (count _wp > 0) then {_grp_bomber setCurrentWaypoint _wp;} else {_wp = _grp_bomber addWaypoint [position _target_plyr, 0];}; _wp setWaypointPosition [position _target_plyr, 0]; _wp setWaypointBehaviour "CARELESS"; _wp setWaypointCombatMode "BLUE"; _wp setWaypointCompletionRadius 0; _grp_bomber setBehaviour "CARELESS"; _grp_bomber setCombatMode "BLUE"; if ( !_shouted && (((_dist_target < _melee_dist) && !_is_vec) || ((_dist_target < (2 * _melee_dist)) && _is_vec)) ) then { _shouted = true; [_bomber, ["YOURSOUNDNAME", 150]] remoteExec ["say3D", -2]; // << ADJUST SOUNDNAME HERE (has to be defined in CfgSounds, see link below)!! // https://community.bistudio.com/wiki/Description.ext#CfgSounds }; //run if close enough or if target cant see bomber if ( (_can_see < 0.3) || ((_dist_target_sqr < _melee_dist_sqr) && !_is_vec) || ((_dist_target_sqr < (2 * _melee_dist_sqr)) && _is_vec) ) then { _wp setWaypointSpeed "FULL"; } else { _wp setWaypointSpeed "LIMITED"; }; sleep (0.5 + random 0.5); }; // end follow while _wp = []; }; // main while end if (_is_vec) then { _boom = createVehicle ["Bo_GBU12_LGB", getPos _bomber, [], 0, "CAN_COLLIDE"]; } else { _boom = createVehicle ["R_60mm_HE", getPos _bomber, [], 0, "CAN_COLLIDE"]; }; deleteVehicle _bomber; }; //spawn end _handle Maybe you have to adjust _melee_dist to get the sound played properly. // the distance in meters from which bomber begins to move fast and shout private _melee_dist = 15; Edited July 18, 2017 by sarogahtyp updated to V 1.0 3 Share this post Link to post Share on other sites
anfo 118 Posted July 7, 2017 42 minutes ago, sarogahtyp said: Okay. I think this question will be repeated if I don't do it. therefore here is the script with YOUR sound integration. Happy Alah u Ak'bar! Haha, thanks Saro! Share this post Link to post Share on other sites
Tankbuster 1747 Posted July 7, 2017 Here's what I do - functionaly the same. { _wp setWaypointSpeed "LIMITED"; }; sleep (0.5 + random 0.5); }; // end follow while _wp = []; }; // main while end _playsound = mission_root + "client\sounds\allahu.ogg"; playsound3d [_playsound, _bomber,false, getposasl _bomber,10,1,50]; sleep 1.7; if (_is_vec) then { _boom = createVehicle ["Bo_GBU12_LGB", getPos _bomber, [], 0, "CAN_COLLIDE"]; } else { _boom = createVehicle ["R_80mm_HE", getPos _bomber, [], 0, "CAN_COLLIDE"]; }; deleteVehicle _bomber; }; //spawn end \\\\ true 1 Share this post Link to post Share on other sites
anfo 118 Posted July 10, 2017 On 07/07/2017 at 3:49 PM, sarogahtyp said: Maybe you have to adjust _melee_dist to get the sound played properly. // the distance in meters from which bomber begins to move fast and shout private _melee_dist = 15; Hi Saro Not sure if related to melee distance, but I get an error and no sound played when civilian AI is about to explode: 1 Share this post Link to post Share on other sites
C.Hall 3 Posted July 14, 2017 Hello, and thank you for the script. I have followed the instructions to the letter, but the civ I put the code into the init line for just stands there, and when player walks up to him, nothing happens. Not sure what I am doing wrong. Share this post Link to post Share on other sites
anfo 118 Posted July 15, 2017 11 hours ago, C.Hall said: Hello, and thank you for the script. I have followed the instructions to the letter, but the civ I put the code into the init line for just stands there, and when player walks up to him, nothing happens. Not sure what I am doing wrong. Walk through in steps what you have Share this post Link to post Share on other sites
anfo 118 Posted July 15, 2017 On 07/07/2017 at 6:07 PM, Tankbuster said: Here's what I do - functionaly the same. _playsound = mission_root + "client\sounds\allahu.ogg"; I have tried both sound inclusion edits from Saro and Tankbuster's and my "alluha" sound won't play (bomber blows up beautifully, if not a bit delayed). I've even tried using a different ogg sound that I've proved works in a separate say3D task and even that doesn't work. @Tankbuster Do I assume if my ogg is in root\sound\alluha.ogg, then the line above would be: _playsound = mission_root + "sound\alluha.ogg"; Share this post Link to post Share on other sites
Tankbuster 1747 Posted July 15, 2017 oh yes, that wasn't clear... apologies. I define mission_root earlier in the scripts mission_root = str missionConfigFile; mission_root = [mission_root, 0, -15] call BIS_fnc_trimString; My sound file. https://www.dropbox.com/s/m58tfd1jq4evo5h/allahu.ogg?dl=0 1 Share this post Link to post Share on other sites
C.Hall 3 Posted July 15, 2017 10 hours ago, anfo said: Walk through in steps what you have Thank you for the response, I got it working. Now trying to get the sound to play. Same as others, I am getting an error and no sound. I replaced "YOURSOUNDNAME" with the name of the sound file "allahu.ogg" which is in my mission folder, but I am guessing that is not how you do it. if ( !_shouted && (((_dist_target < _melee_dist) && !_is_vec) || ((_dist_target < (2 * _melee_dist)) && _is_vec)) ) then { _shouted = true; [_civ, ["YOURSOUNDNAME", 150]] remoteExec ["say3D", -2]; // << ADJUST SOUNDNAME HERE !! }; How does one define mission_root? I am sorry, I am not a coder, but I really want to make this work. Thanks. Share this post Link to post Share on other sites
C.Hall 3 Posted July 16, 2017 I am having bombers blow themselves up when they are nowhere near a player. Just beforehand, this error pops up: while {alive _bomber && (_dist_target < _lost_range) && (_dist_ta> 21:08:37 Error position: <_dist_target < _lost_range) && (_dist_ta> 21:08:37 Error Undefined variable in expression: _dist_target 21:08:37 File C:\Users\Chris\Documents\Arma 3 - Other Profiles\C%2eHall\missions\R34P3RS_FRAMEWORK.Zargabad\SSSB.sqf, line 71 21:08:37 Error in expression <lse {true}; 1 Share this post Link to post Share on other sites
C.Hall 3 Posted July 16, 2017 Is it possible to deactivate the explosive when the bomber is killed? As it stands, when I shoot the bomber, he explodes. Share this post Link to post Share on other sites
sarogahtyp 1108 Posted July 17, 2017 On 10.07.2017 at 11:41 AM, anfo said: Hi Saro Not sure if related to melee distance, but I get an error and no sound played when civilian AI is about to explode: I think u fixed it meanwhile... I did a mistake with _civ/_bomber variable names. I updated my post with the corrected version. it's not related to melee distance. Melee distance is the distance where the civ begins to run and shout. If u adjust it to a larger value than the civ will run and shout earlier. Share this post Link to post Share on other sites
sarogahtyp 1108 Posted July 17, 2017 On 15.07.2017 at 1:57 AM, C.Hall said: Hello, and thank you for the script. I have followed the instructions to the letter, but the civ I put the code into the init line for just stands there, and when player walks up to him, nothing happens. Not sure what I am doing wrong. post what u inserted in units init line! Also post what ur SSSB.sqf file looks like. Share this post Link to post Share on other sites
sarogahtyp 1108 Posted July 17, 2017 12 hours ago, C.Hall said: Is it possible to deactivate the explosive when the bomber is killed? As it stands, when I shoot the bomber, he explodes. If u want the bomber to not explode if he died the add this line: if(!alive _bomber) exitWith {deleteVehicle _bomber;}; right below this line: }; // main while end 1 Share this post Link to post Share on other sites
C.Hall 3 Posted July 17, 2017 1 hour ago, sarogahtyp said: post what u inserted in units init line! Also post what ur SSSB.sqf file looks like. 1 Hello Saro, Here is what I have (with the delete bomb if bomber dies line included) /* SSSB - Sarogahtyps Simple Suicide Bomber Description: Function can be called wherever u want even in init line. It waits for player who is in range and follows him until reached and then BOOOOM! The bomber is walking if player can see the bomber. If there is no line of sight to player then the bomber will run. Works even if the bomber is driving a vehicle. If player is out of range before bomber can reach him then the bomber will just wait for the next player in range. You can pass a chance to get a bomber to the function. This is useful for implementing the script into COS - Civilian Occupation System. You can apply the script to all civilians and if u pass e.g. 1 % as chance then only every 100th civ will become a bomber and wait for near players. Enjoy the boom. :-) Cheers Saro. Paramameters: object - the object of your unit which should become a bomber number (optional) - range to seek for players (default is 300 m) number (optional) - chance to turn the unit into a bomber. (default is 100 %) Return values: true if script has ended. */ params [["_civ", objNull,[objNull]], ["_act_range", 300, [0]], ["_chance", 100, [0]]]; if ((random 100 > _chance) || !(alive _civ)) exitWith {true}; [_civ, _act_range] spawn { params ["_bomber", "_act_range"]; private _melee_dist = 15; private _boom_dist = 5; private _target_players = []; private _grp_bomber = group _bomber; private _wp =[]; private _dist_target = _act_range; private _lost_range = round (_act_range * 1.2); private _is_vec = if (isNull objectParent _bomber) then {false} else {true}; while {(alive _bomber) && !(isNull _bomber) && (_dist_target > _boom_dist)} do { // wait until players are in range waitUntil { sleep (2 + random 1); _target_players = (allPlayers - entities "HeadlessClient_F") select {(alive _x) && ((_x distance _bomber) < _act_range)}; ((count _target_players > 0) || !(alive _bomber)) }; // end everything if suicide bomber is already dead if !(alive _bomber) exitWith {}; // follow nearest player as long as bomber lives, target is in range and target is not close enough to boom while {alive _bomber && (_dist_target < _lost_range) && (_dist_target > _boom_dist)} do { _target_players = (allPlayers - entities "HeadlessClient_F") select {(alive _x) && ((_x distance _bomber) < _act_range)}; // get nearest player _target_players = _target_players apply {[(_x distance _bomber), _x]}; _target_players sort true; _target_plyr = _target_players select 0 select 1; // check distance and visibility _dist_target = _target_players select 0 select 0; _can_see = [_target_plyr, "VIEW", _bomber] checkVisibility [(eyePos _target_plyr), (eyePos _bomber)]; // add waypoint and set bombers behavior if (count _wp > 0) then {_grp_bomber setCurrentWaypoint _wp;} else {_wp = _grp_bomber addWaypoint [position _target_plyr, 0];}; _wp setWaypointPosition [position _target_plyr, 0]; _wp setWaypointBehaviour "CARELESS"; _wp setWaypointCombatMode "BLUE"; _wp setWaypointCompletionRadius 0; _grp_bomber setBehaviour "CARELESS"; _grp_bomber setCombatMode "BLUE"; //run if close enough or if target cant see bomber if ( (_can_see < 0.3) || ((_dist_target < _melee_dist) && !_is_vec) || ((_dist_target < (2 * _melee_dist)) && _is_vec) ) then { _wp setWaypointSpeed "FULL"; } else { _wp setWaypointSpeed "LIMITED"; }; sleep (0.5 + random 0.5); }; // end follow while _wp = []; }; // main while end //Delete Bomb if Bomber dies if(!alive _bomber) exitWith {deleteVehicle _bomber;}; if (_is_vec) then { _boom = createVehicle ["Bo_GBU12_LGB", getPos _bomber, [], 0, "CAN_COLLIDE"]; } else { _boom = createVehicle ["R_60mm_HE", getPos _bomber, [], 0, "CAN_COLLIDE"]; }; deleteVehicle _bomber; }; //spawn end true And the init line d = [this, 250, 50] execVM "SSSB.sqf"; Thanks Share this post Link to post Share on other sites
Tankbuster 1747 Posted July 17, 2017 On 15/07/2017 at 0:31 PM, anfo said: @Tankbuster Do I assume if my ogg is in root\sound\alluha.ogg, then the line above would be: _playsound = mission_root + "sound\alluha.ogg"; 1 Yes, that's right 1 Share this post Link to post Share on other sites
sarogahtyp 1108 Posted July 18, 2017 (edited) On 16.07.2017 at 7:52 PM, C.Hall said: I am having bombers blow themselves up when they are nowhere near a player. Just beforehand, this error pops up: while {alive _bomber && (_dist_target < _lost_range) && (_dist_ta> 21:08:37 Error position: <_dist_target < _lost_range) && (_dist_ta> 21:08:37 Error Undefined variable in expression: _dist_target 21:08:37 File C:\Users\Chris\Documents\Arma 3 - Other Profiles\C%2eHall\missions\R34P3RS_FRAMEWORK.Zargabad\SSSB.sqf, line 71 21:08:37 Error in expression <lse {true}; Updated first post (soundless version). Error should be fixed. Changelog SSSB 1.0 -changed from distance to distanceSqr for performance reasons -fixed bug with targets distance (variable not defined) -changed return value from true to script handle to make scriptDone check available SSSB 0.9 (initial version) -just created it because of so much requests for something like this seen in forum EDIT: Updated Sound version to 1.0 as well Edited July 18, 2017 by sarogahtyp 2 Share this post Link to post Share on other sites
C.Hall 3 Posted July 27, 2017 EDIT: I GOT IT!!! The sound file was missing the "a" at the end. Can you believe it? A fricking week of research and that is what it was. LOL Thanks again. The code below works! So grateful for the response. I have everything working perfectly now except for the sound. I've spent over a week trying to figure it out from this thread, reading other threads, and, well nothing. I tried to implement TankBusters code, and the error went away but the sound still does not play. I have a folder named "sound" in the mission folder (where init.sqf lives) with the sound file inside of the folder and my SSSB.sqf is this: /* SSSB - Sarogahtyps Simple Suicide Bomber Description: Function can be called wherever u want even in init line. It waits for player who is in range and follows him until reached and then BOOOOM! The bomber is walking if player can see the bomber. If there is no line of sight to player then the bomber will run. Works even if the bomber is driving a vehicle. If player is out of range before bomber can reach him then the bomber will just wait for the next player in range. You can pass a chance to get a bomber to the function. This is useful for implementing the script into COS - Civilian Occupation System. You can apply the script to all civilians and if u pass e.g. 1 % as chance then only every 100th civ will become a bomber and wait for near players. Enjoy the boom. :-) Cheers Saro. Paramameters: object - the object of your unit which should become a bomber number (optional) - range to seek for players (default is 300 m) number (optional) - chance to turn the unit into a bomber. (default is 100 %) Return values: number - handle of spawned script if someone likes to check if bombers script has ended (scriptDone) will return -1 if script ends without spawning code (in case no civ was turned into bomber) */ mission_root = str missionConfigFile; mission_root = [mission_root, 0, -15] call BIS_fnc_trimString; params [["_civ", objNull,[objNull]], ["_act_range", 300, [0]], ["_chance", 100, [0]]]; if ((random 100 > _chance) || !(alive _civ)) exitWith {-1}; _handle = [_civ, _act_range] spawn { params ["_bomber", "_act_range"]; private _melee_dist = 15; private _boom_dist = 5; private _dist_target = _act_range; private _lost_range = round (_act_range * 1.2); private _act_range_sqr = _act_range ^ 2; private _melee_dist_sqr = _melee_dist ^ 2; private _boom_dist_sqr = _boom_dist ^ 2; private _dist_target_sqr = _act_range ^ 2; private _lost_range_sqr = _lost_range ^ 2; private _grp_bomber = group _bomber; private _is_vec = if (isNull objectParent _bomber) then {false} else {true}; private _target_players = []; private _wp =[]; while {(alive _bomber) && (_dist_target_sqr > _boom_dist_sqr)} do { // wait until players are in range waitUntil { sleep (2 + random 1); _target_players = (allPlayers - entities "HeadlessClient_F") select {(alive _x) && ((_x distanceSqr _bomber) < _act_range_sqr)}; ((count _target_players > 0) || !(alive _bomber)) }; // end everything if suicide bomber is already dead if !(alive _bomber) exitWith {}; // follow nearest player as long as bomber lives, target is in range and target is not close enough to boom while {alive _bomber && (_dist_target_sqr < _lost_range_sqr) && (_dist_target_sqr > _boom_dist_sqr)} do { _target_players = (allPlayers - entities "HeadlessClient_F") select {(alive _x) && ((_x distanceSqr _bomber) < _act_range_sqr)}; // get nearest player _target_players = _target_players apply {[(_x distanceSqr _bomber), _x]}; _target_players sort true; _target_plyr = _target_players select 0 select 1; // check distance and visibility _dist_target_sqr = if(count _target_players > 0) then {_target_players select 0 select 0} else {_lost_range_sqr}; _can_see = [_target_plyr, "VIEW", _bomber] checkVisibility [(eyePos _target_plyr), (eyePos _bomber)]; // add waypoint and set bombers behavior if (count _wp > 0) then {_grp_bomber setCurrentWaypoint _wp;} else {_wp = _grp_bomber addWaypoint [position _target_plyr, 0];}; _wp setWaypointPosition [position _target_plyr, 0]; _wp setWaypointBehaviour "CARELESS"; _wp setWaypointCombatMode "BLUE"; _wp setWaypointCompletionRadius 0; _grp_bomber setBehaviour "CARELESS"; _grp_bomber setCombatMode "BLUE"; //run if close enough or if target cant see bomber if ( (_can_see < 0.3) || ((_dist_target_sqr < _melee_dist_sqr) && !_is_vec) || ((_dist_target_sqr < (2 * _melee_dist_sqr)) && _is_vec) ) then { _wp setWaypointSpeed "FULL"; } else { _wp setWaypointSpeed "LIMITED"; }; sleep (0.5 + random 0.5); }; // end follow while _wp = []; }; // main while end _playsound = mission_root + "sound\alluha.ogg"; playsound3d [_playsound, _bomber,false, getposasl _bomber,10,1,50]; sleep 1.7; if (_is_vec) then { _boom = createVehicle ["Bo_GBU12_LGB", getPos _bomber, [], 0, "CAN_COLLIDE"]; } else { _boom = createVehicle ["R_80mm_HE", getPos _bomber, [], 0, "CAN_COLLIDE"]; }; deleteVehicle _bomber; }; //spawn end \\\\ true Any assistance in getting the sound to play would be greatly appreciated. Share this post Link to post Share on other sites
Blackheart_Six 283 Posted November 16, 2017 Hi sarogahtyp, Any chance of a solution for integration with Engima Civilian Script? It runs a little smoother than COS, due to age of COS. I'm poking around, but get a undefined variable error no matter where I place insert the 2 lines of code for COS. Additionally, so I am clear, is C. HALL code the correct code for the sound? Thanks in advance, BH6 SOLUTION: Edit Line 20: ["ON_UNIT_SPAWNED_CALLBACK", {params["_unit"];[_unit, 300,25] call Saro_fnc_bomber;}], Located in the ConfigAndStart.sqf file. Still try to get sound to work. Share this post Link to post Share on other sites
MrAkyet 0 Posted September 1, 2021 Anyone know how I would go about adding this to KPLiberation civilians? Share this post Link to post Share on other sites
civiciam 12 Posted May 25, 2022 Brilliant script. Thank you! 1 Share this post Link to post Share on other sites
Gunter Severloh 4067 Posted June 23 Here is an updated fixed version of the script of the first post. When i originally used the script on the first post i got an error which was this: Error in expression < 0} else {_lost_range_sqr}; _can_see = [_target_plyr, "VIEW", _bomber] checkVisi> Error position: <_target_plyr, "VIEW", _bomber] checkVisi> Error Undefined variable in expression: _target_plyr This is line 73 - 75 of the script: // check distance and visibility _dist_target_sqr = if(count _target_players > 0) then {_target_players select 0 select 0} else {_lost_range_sqr}; _can_see = [_target_plyr, "VIEW", _bomber] checkVisibility [(eyePos _target_plyr), (eyePos _bomber)]; ================== I went to my good friend Rydygier and we sorted out the error and fixed the script, script will no longer show any errors. Credits: Rydygier Below is the updated fixed version: SSSB - Sarogahtyps Simple Suicide Bomber /* SSSB - Sarogahtyps Simple Suicide Bomber Description: Function can be called wherever u want even in init line. It waits for player who is in range and follows him until reached and then BOOOOM! The bomber is walking if player can see the bomber. If there is no line of sight to player then the bomber will run. Works even if the bomber is driving a vehicle. If player is out of range before bomber can reach him then the bomber will just wait for the next player in range. You can pass a chance to get a bomber to the function. This is useful for implementing the script into COS - Civilian Occupation System. You can apply the script to all civilians and if u pass e.g. 1 % as chance then only every 100th civ will become a bomber and wait for near players. Enjoy the boom. :-) Cheers Saro. How to use: Put the following in the init box of the unit, or the driver of the vehicle to be a bomber. [this] execVM "SSSB.sqf"; Paramameters: object - the object of your unit which should become a bomber number (optional) - range to seek for players (default is 300 m) number (optional) - chance to turn the unit into a bomber. (default is 100 %) Return values: number - handle of spawned script if someone likes to check if bombers script has ended (scriptDone) will return -1 if script ends without spawning code (in case no civ was turned into bomber) */ params [["_civ", objNull,[objNull]], ["_act_range", 300, [0]], ["_chance", 100, [0]]]; if ((random 100 > _chance) || !(alive _civ)) exitWith {-1}; _handle = [_civ, _act_range] spawn { params ["_bomber", "_act_range"]; private _melee_dist = 15; private _boom_dist = 5; private _dist_target = _act_range; private _lost_range = round (_act_range * 1.2); private _act_range_sqr = _act_range ^ 2; private _melee_dist_sqr = _melee_dist ^ 2; private _boom_dist_sqr = _boom_dist ^ 2; private _dist_target_sqr = _act_range ^ 2; private _lost_range_sqr = _lost_range ^ 2; private _grp_bomber = group _bomber; private _is_vec = if (isNull objectParent _bomber) then {false} else {true}; private _target_players = []; private _wp =[]; while {(alive _bomber) && (_dist_target_sqr > _boom_dist_sqr)} do { // wait until players are in range waitUntil { sleep (2 + random 1); _target_players = (allPlayers - entities "HeadlessClient_F") select {(alive _x) && ((_x distanceSqr _bomber) < _act_range_sqr)}; ((count _target_players > 0) || !(alive _bomber)) }; // end everything if suicide bomber is already dead if !(alive _bomber) exitWith {}; // follow nearest player as long as bomber lives, target is in range and target is not close enough to boom while {alive _bomber && (_dist_target_sqr < _lost_range_sqr) && (_dist_target_sqr > _boom_dist_sqr)} do { _target_players = (allPlayers - entities "HeadlessClient_F") select {(alive _x) && ((_x distanceSqr _bomber) < _act_range_sqr)}; // get nearest player _target_players = _target_players apply {[(_x distanceSqr _bomber), _x]}; _target_players sort true; if ((count _target_players)== 0) exitWith {_dist_target_sqr = _lost_range_sqr}; _target_plyr = _target_players select 0 select 1; // check distance and visibility _dist_target_sqr = if(count _target_players > 0) then {_target_players select 0 select 0} else {_lost_range_sqr}; _can_see = [_target_plyr, "VIEW", _bomber] checkVisibility [(eyePos _target_plyr), (eyePos _bomber)]; // add waypoint and set bombers behavior if (count _wp > 0) then {_grp_bomber setCurrentWaypoint _wp;} else {_wp = _grp_bomber addWaypoint [position _target_plyr, 0];}; _wp setWaypointPosition [position _target_plyr, 0]; _wp setWaypointBehaviour "CARELESS"; _wp setWaypointCombatMode "BLUE"; _wp setWaypointCompletionRadius 0; _grp_bomber setBehaviour "CARELESS"; _grp_bomber setCombatMode "BLUE"; //run if close enough or if target cant see bomber if ( (_can_see < 0.3) || ((_dist_target_sqr < _melee_dist_sqr) && !_is_vec) || ((_dist_target_sqr < (2 * _melee_dist_sqr)) && _is_vec) ) then { _wp setWaypointSpeed "FULL"; } else { _wp setWaypointSpeed "LIMITED"; }; sleep (0.5 + random 0.5); }; // end follow while _wp = []; }; // main while end if (_is_vec) then { _boom = createVehicle ["Bo_GBU12_LGB", getPos _bomber, [], 0, "CAN_COLLIDE"]; } else { _boom = createVehicle ["R_60mm_HE", getPos _bomber, [], 0, "CAN_COLLIDE"]; }; deleteVehicle _bomber; }; //spawn end _handle Create Suicide Bombers with Units or Vehicles that will Hunt You with this Script! 1 Share this post Link to post Share on other sites
Komodo-1 13 Posted June 24 20 hours ago, Gunter Severloh said: Here is an updated fixed version of the script of the first post. When i originally used the script on the first post i got an error which was this: Error in expression < 0} else {_lost_range_sqr}; _can_see = [_target_plyr, "VIEW", _bomber] checkVisi> Error position: <_target_plyr, "VIEW", _bomber] checkVisi> Error Undefined variable in expression: _target_plyr This is line 73 - 75 of the script: // check distance and visibility _dist_target_sqr = if(count _target_players > 0) then {_target_players select 0 select 0} else {_lost_range_sqr}; _can_see = [_target_plyr, "VIEW", _bomber] checkVisibility [(eyePos _target_plyr), (eyePos _bomber)]; ================== I went to my good friend Rydygier and we sorted out the error and fixed the script, script will no longer show any errors. Credits: Rydygier Below is the updated fixed version: SSSB - Sarogahtyps Simple Suicide Bomber /* SSSB - Sarogahtyps Simple Suicide Bomber Description: Function can be called wherever u want even in init line. It waits for player who is in range and follows him until reached and then BOOOOM! The bomber is walking if player can see the bomber. If there is no line of sight to player then the bomber will run. Works even if the bomber is driving a vehicle. If player is out of range before bomber can reach him then the bomber will just wait for the next player in range. You can pass a chance to get a bomber to the function. This is useful for implementing the script into COS - Civilian Occupation System. You can apply the script to all civilians and if u pass e.g. 1 % as chance then only every 100th civ will become a bomber and wait for near players. Enjoy the boom. :-) Cheers Saro. How to use: Put the following in the init box of the unit, or the driver of the vehicle to be a bomber. [this] execVM "SSSB.sqf"; Paramameters: object - the object of your unit which should become a bomber number (optional) - range to seek for players (default is 300 m) number (optional) - chance to turn the unit into a bomber. (default is 100 %) Return values: number - handle of spawned script if someone likes to check if bombers script has ended (scriptDone) will return -1 if script ends without spawning code (in case no civ was turned into bomber) */ params [["_civ", objNull,[objNull]], ["_act_range", 300, [0]], ["_chance", 100, [0]]]; if ((random 100 > _chance) || !(alive _civ)) exitWith {-1}; _handle = [_civ, _act_range] spawn { params ["_bomber", "_act_range"]; private _melee_dist = 15; private _boom_dist = 5; private _dist_target = _act_range; private _lost_range = round (_act_range * 1.2); private _act_range_sqr = _act_range ^ 2; private _melee_dist_sqr = _melee_dist ^ 2; private _boom_dist_sqr = _boom_dist ^ 2; private _dist_target_sqr = _act_range ^ 2; private _lost_range_sqr = _lost_range ^ 2; private _grp_bomber = group _bomber; private _is_vec = if (isNull objectParent _bomber) then {false} else {true}; private _target_players = []; private _wp =[]; while {(alive _bomber) && (_dist_target_sqr > _boom_dist_sqr)} do { // wait until players are in range waitUntil { sleep (2 + random 1); _target_players = (allPlayers - entities "HeadlessClient_F") select {(alive _x) && ((_x distanceSqr _bomber) < _act_range_sqr)}; ((count _target_players > 0) || !(alive _bomber)) }; // end everything if suicide bomber is already dead if !(alive _bomber) exitWith {}; // follow nearest player as long as bomber lives, target is in range and target is not close enough to boom while {alive _bomber && (_dist_target_sqr < _lost_range_sqr) && (_dist_target_sqr > _boom_dist_sqr)} do { _target_players = (allPlayers - entities "HeadlessClient_F") select {(alive _x) && ((_x distanceSqr _bomber) < _act_range_sqr)}; // get nearest player _target_players = _target_players apply {[(_x distanceSqr _bomber), _x]}; _target_players sort true; if ((count _target_players)== 0) exitWith {_dist_target_sqr = _lost_range_sqr}; _target_plyr = _target_players select 0 select 1; // check distance and visibility _dist_target_sqr = if(count _target_players > 0) then {_target_players select 0 select 0} else {_lost_range_sqr}; _can_see = [_target_plyr, "VIEW", _bomber] checkVisibility [(eyePos _target_plyr), (eyePos _bomber)]; // add waypoint and set bombers behavior if (count _wp > 0) then {_grp_bomber setCurrentWaypoint _wp;} else {_wp = _grp_bomber addWaypoint [position _target_plyr, 0];}; _wp setWaypointPosition [position _target_plyr, 0]; _wp setWaypointBehaviour "CARELESS"; _wp setWaypointCombatMode "BLUE"; _wp setWaypointCompletionRadius 0; _grp_bomber setBehaviour "CARELESS"; _grp_bomber setCombatMode "BLUE"; //run if close enough or if target cant see bomber if ( (_can_see < 0.3) || ((_dist_target_sqr < _melee_dist_sqr) && !_is_vec) || ((_dist_target_sqr < (2 * _melee_dist_sqr)) && _is_vec) ) then { _wp setWaypointSpeed "FULL"; } else { _wp setWaypointSpeed "LIMITED"; }; sleep (0.5 + random 0.5); }; // end follow while _wp = []; }; // main while end if (_is_vec) then { _boom = createVehicle ["Bo_GBU12_LGB", getPos _bomber, [], 0, "CAN_COLLIDE"]; } else { _boom = createVehicle ["R_60mm_HE", getPos _bomber, [], 0, "CAN_COLLIDE"]; }; deleteVehicle _bomber; }; //spawn end _handle Create Suicide Bombers with Units or Vehicles that will Hunt You with this Script! thnx GS for this, dope script 1 Share this post Link to post Share on other sites