Jump to content
Sign in to follow this  
JIMMI DEE BILLY BOB

Delete specific vehicles in radius from Named object/vehicle

Recommended Posts

Im trying to make a simple electronic warfare vehicle to jam drones, i have a script that works for markers, but i dont know to make it work with vehicles, I imagine it's pretty simple, but I can't figure it out.

 

The idea is that all drones that come within a range of 3.5 km of vehicle will get destroyed, now here in this case deleted, a simple way to defend against drones.

 

this works for markers in the INIT.sqf file

// Clean Drones

nul = [] spawn
{
  private _pos = markerPos "EWvehicle";
  while {true} do
  {
    sleep 15;
    {deleteVehicle _x} forEach nearestObjects [_pos, ["O_UAV_01_F","O_Static_Designator_02_F","O_UAV_06_medical_F","O_UAV_06_F"], 3500];
  };
};
 

Share this post


Link to post
Share on other sites

I don't know how much a permanent/infinite "searching" for menaces around vehicle could impact performance - and I haven't exactly tried a way to do it, but you will probably need to add such code in the init.sqs just like the markers' stuff you have already figured out.

But, as an idea, you could try and use an addAction to the vehicle, and so run a "searcher.sqf" external file.

this addAction ["<t color='#f0cc0f'>Clear Threats!</t>",
{
        [] spawn {
            execVM "searcher.sqf";
        };
}];



Such file could contain something like the code below, adapted from a "searcher" script I run for my creations:

// searcher.sqf

_droneStuffClasses =  ["O_UAV_01_F","O_Static_Designator_02_F","O_UAV_06_medical_F","O_UAV_06_F"];
_flyingMenaceClasses = _droneStuffClasses;
_nearbyFlyingMenaces = nearestObjects [player, _flyingMenaceClasses, 3500, false, false];

	{
	_menaceClass = typeOf _x;
	if (_menaceClass in _droneStuffClasses) then {
		deleteVehicle _x;
		};
	} forEach _nearbyFlyingMenaces;


As guys here have taught me, it might be much more efficient if you create an array with the vehicles'  classes you want to destroy, so you could easily edit it in future, just by adding or removing from such list, without needing to search for them in the entire code.

In the script above, firstly we create an array. But such is not accepted for searching in "nearby", so we create a "simple" variable (_flyingMenaceClasses) containing everything in the previous array.

Then we say what we want to search and delete in case it matches what we (don't) want. You can even go crazy and add some visual stuff like, instead of "delete", use "setDamage 1;" and also create some grenades or explosions around eliminated threats 😁

Edited by JCataclisma

Share this post


Link to post
Share on other sites
6 hours ago, JCataclisma said:

I don't know how much a permanent/infinite "searching" for menaces around vehicle could impact performance - and I haven't exactly tried a way to do it, but you will probably need to add such code in the init.sqs just like the markers' stuff you have already figured out.

But, as an idea, you could try and use an addAction to the vehicle, and so run a "searcher.sqf" external file.


this addAction ["<t color='#f0cc0f'>Clear Threats!</t>",
{
        [] spawn {
            execVM "searcher.sqf";
        };
}];



Such file could contain something like the code below, adapted from a "searcher" script I run for my creations:


// searcher.sqf

_droneStuffClasses =  ["O_UAV_01_F","O_Static_Designator_02_F","O_UAV_06_medical_F","O_UAV_06_F"];
_flyingMenaceClasses = _droneStuffClasses;
_nearbyFlyingMenaces = nearestObjects [player, _flyingMenaceClasses, 3500, false, false];

	{
	_menaceClass = typeOf _x;
	if (_menaceClass in _droneStuffClasses) then {
		deleteVehicle _x;
		};
	} forEach _nearbyFlyingMenaces;


As guys here have taught me, it might be much more efficient if you create an array with the vehicles'  classes you want to destroy, so you could easily edit it in future, just by adding or removing from such list, without needing to search for them in the entire code.

In the script above, firstly we create an array. But such is not accepted for searching in "nearby", so we create a "simple" variable (_flyingMenaceClasses) containing everything in the previous array.

Then we say what we want to search and delete in case it matches what we (don't) want. You can even go crazy and add some visual stuff like, instead of "delete", use "setDamage 1;" and also create some grenades or explosions around eliminated threats 😁

 

It dont work, I have done as you showed me.

 

 

regarding the impact on performance, I have noticed that when you just make the time between searches longer, you can't notice anything.

 

I have the script i shared running 4 x every 15 sek, I dont feel it

 

 

 

 

Share this post


Link to post
Share on other sites

//// EW Nato
    nul = [] spawn
    {
    while {true} do
    {
    sleep 15;
    {deleteVehicle _x} forEach nearestObjects [NatoEW, ["O_UAV_01_F","O_Static_Designator_02_F","O_UAV_06_medical_F","O_UAV_06_F"], 3000];
    };
    };
 

 

 

I got it ❤️ 

 

 

 

Share this post


Link to post
Share on other sites

I've made the Jamming vehicle (NatoEW)a bit better, with more depth, not perfect, but still fun.

 

3800m from EW will setAutonomous FALSE; drone wil stop flying, just hover. 

2500m from EW will setDamage 1; it will destroy the drone.

 

Init.sqf

------------

 

//// EW Nato

 

    nul = [] spawn
    {
    while {true} do
    {
    sleep 15;
    {_x setAutonomous FALSE;} forEach (nearestObjects  [NatoEW, ["O_UAV_01_F","O_Static_Designator_02_F","O_UAV_06_medical_F","O_UAV_06_F"], 3800]);
    };
    };
   nul = [] spawn
    {
    while {true} do
    {
    sleep 15;
    {_x setDamage 1;} forEach (nearestObjects  [NatoEW, ["O_UAV_01_F","O_Static_Designator_02_F","O_UAV_06_medical_F","O_UAV_06_F"], 2500]);
    };
    };


 

  • Like 1

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
Sign in to follow this  

×