Jump to content

Recommended Posts

DETONATING CORD

 

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.


Parameters:  UNITS   /  PROJECTILE  /  SAFETY DISTANCE  /  CORD LENGTH

Spoiler

[  <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 3
  • Thanks 4

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

Lovely script for APOBS. Any idea why the cord legth does not go beyond about 50 meters no matter what parameters are set?

Share this post


Link to post
Share on other sites
17 hours ago, FenixDK said:

Lovely script for APOBS. Any idea why the cord legth does not go beyond about 50 meters no matter what parameters are set?

 

I don't have the full explanation but ropes are limited to 63 segments.

ropeCreate

And Arma's cabinet of curiosities : Arma_3:_Ropes

 

Btw, this script works for smoke hand grenades, throwing a specific one (here orange) during game.

In MGI advanced modules, things are little bit different. In "Blast and Fire" module,  if you tick the "demine with det cord" option, the player(s) can throw rope when firing any smoke grenade (from GL) if holding ALT (left). If not, the smoke grenade is not replaced by rope.

  • Like 2

Share this post


Link to post
Share on other sites

I was fiddling with this earlier (it's neat!) and was able to "throw" det cord using GL and even bullets. I could not achieve a rope longer than 90 meters, however, which I assumed was a limitation of the rope system.

  • Like 1

Share this post


Link to post
Share on other sites

How does one make this work? I added the code to my init.sqf, equipped myself with orange smoke, but nothing happend.

 

 

 

 

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

×