Jump to content

Recommended Posts



Hi all,

This topic gave me the idea to script a little for a detonating cord.


So, you can add this code in init.sqf or else. Just be sure your unit(s) created before running the code.



[  <object (unit) or array of units - player, single unit or arrays of any units>,  // example: allPlayers     default: [], so nothing occurs. This parameter is mandatory.

   <string - specific type of thrown projectile by the unit(s) >  //  example: "SmokeShellYellow"  (optional)   default: "SmokeShellOrange"

   <number - minimal distance from the start of the cord to fire a detonation> (optional)   default: 15

   <number - cord length>  (optional)   default: 60





MGI_fnc_detCord = {
  params [["_units",[],[objNull,[]]],["_thrownEnd","SmokeShellOrange"],["_safetyDist",15],["_cordLength",60]];
  if (_units isEqualType objNull) then {_units = [_units]};
  MGI_passToEhCord = [_thrownEnd,_safetyDist,_cordLength];
    _x  addEventHandler ["firedMan", {
      params ["_unit", "", "", "", "", "_magazine", "_projectile"];
      MGI_passToEhCord params ["_thrownEnd","_safetyDist","_cordLength"];
      if (_magazine == _thrownEnd) then {
        [_unit,_projectile,_safetyDist,_cordLength] spawn {
          params ["_unit","_projectile","_safetyDist","_cordLength"];
          private _veh = if (isNull objectParent _unit) then [{"B_UAV_01_F" createVehicleLocal getpos _unit},{objectParent _unit}];
          if (_veh isKindOf "B_UAV_01_F") then {_veh hideObject true};
          private _rope = ropeCreate [_veh,[0,0,0],_projectile,[0,0,0],_cordLength,["",[0,0,10]]];
          uisleep 6;
          private _segs = (_veh nearObjects ["ropesegment",_cordLength]) select {_x distanceSqr _veh > _safetyDist^2};
          if !(_segs isEqualTo []) then {
            _unit addAction ["detonate cord",{
              params ["_target", "_caller", "_id", "_args","_exploEnd"];
              _args params ["_rope","_veh","_segs","_projectile"];
              _target removeAction _id;
              for "_i" from 0 to count _segs -1 do {
                _explo = createVehicle ["mini_grenade",getpos (_segs #_i),[],0,"CAN_COLLIDE"];
                _explo hideObjectGlobal true;
                if (_i == count _segs -1) then {_exploEnd = _explo};
              waitUntil {isNull _exploEnd};
              if (_veh isKindOf "B_UAV_01_F") then {deleteVehicle _veh};
              deleteVehicle _rope;
              deleteVehicle _projectile;
            },[_rope,_veh,_segs,_projectile],0,true,false,"","alive _target"];
  } forEach _units;

player call MGI_fnc_detCord;  // example

Have fun!

  • Like 2
  • Thanks 3

Share this post

Link to post
Share on other sites

Brilliant I love this. Think if you made a custom item config you could end up with a throwable detcord object.

  • Like 2

Share this post

Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now