Jump to content
zephyrdark

How to intercept projectiles?

Recommended Posts

Recently I have been working on an active countermeasure script. The issue I have run into is that I cannot find a straight forward way to 'intercept' the incoming projectile.

My current attempts and their results have been so far:

Attempt 1: Use ProtectionZone_Ep1 to detonate the RPG.

Result: Works. Protection Zone is visible to all but the server despite setting its alpha to 0.

Attempt 2: Spawn another projectile to 'intercept' the other,

Result: Didn't work.

Attempt 3: Delete the incoming projectile, spawn another projectile to explode to simulate the detonation of the first.

Result: Partially worked. Created explosion at ground level, despite the altitude of the incoming projectile.

Now, is there any way to 'detonate' any projectile via a script, is my main question. I would also like to get some help figuring out why the ProtectionZone_Ep1 object doesn't like to set its alpha for everyone (even when the script is run on all clients. (cba_fnc_globalExecute doesn't work either, might be an issue on their part)

Here is a download for a test mission containing my current version of the scripts and etc. I don't know how much of a working condition it is in at the moment. I believe it is currently in Attempt 3's method of dealing with the threat. The script is currently running a isServer check to reduce issues with spawning of multiple objects, etc.

Here is the code-blocks that does all the fancy stuff with the projectile:

In-Range Distance Check:

{_rDistArray = _rDistArray + [((_x select 0) distance _unit)];} forEach vehArray;
   {if (_x <= _maxDetect) then {_rCheck = _rCheck + [1]} else {_rCheck = _rCheck + [0]};} forEach _rDistArray;
{ if (_rCheck select _x == 1) then 
       {
           _defVeh = _defVeh + [vehArray select _x];
       };
} forEach _vehCount;
_run = true;

/* (Ballistics Formula, not used currently)
_prH = (getPosATL _projectile select 0);
_gc = 9.8;
_vel = .2777 * (speed _projectile);
_theta = [(vectorDir _projectile select 0), (vectorDir _projectile select 1), (vectorDir _projectile select 2)] call CBA_fnc_vectElev;
_dist = ((_vel * cos _theta) / _gc) * ( (_vel * sin _theta) + sqrt( ( (_vel * sin _theta) ^ 2 ) + (2 * _gc * _prH) ));
_height = _prH + (_dist * tan _theta) - ((_gc * (_dist^2)) / (2 * ((_vel * cos _theta)^2)));
hintC format ["Theta = %1 : D = %2 : H = %3", _theta,_dist, _height];
*/

Tracking of Projectile's Distance:

{_projDist = _projDist + [[_projectile distance (_x select 0), _x]]} forEach _defVeh;
{

           if ((_x select 0) <= 35)  then 
           {
               if ((((_x select 1) select 1) > 0) && alive _projectile) then
               {
                   /*
			{_prZone = "ProtectionZone_Ep1" createVehicle [0,0,0];
                		_prZone setObjectTexture [0,"#(argb,8,8,3)color(0,0,0,0,ca)"]; 
			In dedicated, this appears to not work...? (Object still flashes in as a red cylinder)
		  */
                   _prDir = getDir _projectile;
                   _yC= 1.1 * (cos _prDir);
                   _xC= 1.1 * (sin _prDir);
                   _xF= _xC + (getpos _projectile select 0);
                   _yF= _yC + (getpos _projectile select 1);
	 	  /*
			_prZone setPosATL (getPosATL _projectile);
               		_prZone setPos [_xF, _yF];
		  */



                   {
                       if (isServer) then
                       {
                           _num = (((vehArray select _x) select 1) - 1);
                           vehArray select _x set [1, _num];
                           publicVariable "vehArray";
                       };
                   } forEach ((_x select 1) select 2);

               } else {_run = false;};
           };
} forEach _projDist;
_timeNow = time;

The test mission requires ACE, CBA, and Fallujah to my knowledge. Sorry!

Download Link: http://www.mediafire.com/?d7dt4apotku3khj

Share this post


Link to post
Share on other sites

Here's a pseudo missile intercept.... had fun doing this!

Run this script on an any object and try to destroy it with any kind of rocket.

intercept.sqf

_obj = _this select 0;
_dis = _this select 1;

_reset = false;
_incoming = objnull;

while {not _reset} do {
_list = (position _obj) nearObjects ["MissileBase",_dis];
   _list = _list + ((position _obj) nearObjects ["RocketBase",_dis]);
if (count _list >=1) then {
	_incoming = _list select 0;
	_boom = "HelicopterExploSmall" createvehicle [(getpos _incoming select 0),(getpos _incoming select 1),(getpos _incoming select 2)];
	deletevehicle _incoming;
	_reset = true;
};
sleep 0.05;
};
sleep 1;
nul = [_obj,_dis] execVM "intercept.sqf";

Put this in the objects init....

Where:-

this is the object you want to protect

50 is the distance to scan for incoming rockets or missiles

nul = [this,50] execVM "intercept.sqf";

Demo here... Anti-Rocket Crap House

EDIT: If I can figure out how to point a static 50 cal.... we could even shoot it down!

Edited by twirly
Changes

Share this post


Link to post
Share on other sites

What an interesting idea!

On the subject of getting 1 missile to track and hit another I was wondering if this could be adapted. I helped someone out with a guided RPG that hits a base ball, thought of an improvement but not done it yet - you can use _projectile = _this select 6; with a fired event handler to get the actual projectile instead of spawning one:

Bullet tracker

http://forums.bistudio.com/showthread.php?121828-Track-Morta-Rounds&p=1974823&viewfull=1#post1974823

Guided RPG

http://forums.bistudio.com/showthread.php?133275-RPG-man-fire-on-Blackhawk

example mission for RPG (script in spoiler post #6)

http://www.mediafire.com/?5b3dqk9pt11y1uq

The script that does the missile trajectory may have to run extra checks per second for accuracy. It's likely that they would not explode on contact so you may still have to do the distance check/delete/explosion effect thing.

Share this post


Link to post
Share on other sites

Was looking for an automatic weapon system addon that I had run into at some point and ended up with this Mando Missiles video on YouTube.... it seems Mando Missiles already has auto surface to air stuff.

It's not hard to do using this code from kylania's site which is great. I modify that to suit whatever situation and have used it a lot.

As you say Pelham.... would be a lot of checks though for a fast moving object.

Share this post


Link to post
Share on other sites
Here's a pseudo missile intercept.... had fun doing this!!

It looks like the real thing - nice job, saw this vid a few years ago:

Share this post


Link to post
Share on other sites

Nice one. Actually it does look pretty damn close to the vid!

Share this post


Link to post
Share on other sites

I believe I quite the working script now. Only thing is, is it possible to use the createVehicle command for the explosion classname "ATRocketExplosion"? Only reason I ask is that its possible with the Secondary one and the Helo Explosion ones, but so far I have been getting no result with ATRocketExplosion.

Share this post


Link to post
Share on other sites

Try this instead then mate.... however I think that other script is more reliable. I've been getting some weird results depending on what I use for the charge (_boom).

Also it won't work unless I set the charge at half the height of the incoming missile! This is quite bizarre and I don't understand why.

Call it the same way as above.

intercept.sqf

_obj = _this select 0;
_dis = _this select 1;

_reset = false;

while {not _reset} do {
_list = (position _obj) nearObjects ["MissileBase",_dis];
       _list = _list + ((position _obj) nearObjects ["RocketBase",_dis]);
if (count _list >=1) then {
	_incoming = _list select 0;
	//"Sh_85_HE" or "G_Camel_HE" or "B_30mm_HE" or "Bo_FAB_250" or "Bo_Mk82" etc....
	_boom = createVehicle ["G_Camel_HE",[(getpos _incoming) select 0,(getpos _incoming) select 1,((getpos _incoming) select 2)/2], [], 0, "CAN_COLLIDE"];
	_wh = createVehicle ["weaponHolder", [(getpos _incoming) select 0,(getpos _incoming) select 1,(getpos _incoming) select 2], [], 0, "CAN_COLLIDE"];
	_boom setDamage 1;
	deletevehicle _incoming;
	sleep 1;
	deleteVehicle _wh;  //if this is deleted too quickly you will get no explosion... but I think it should be deleted
	_reset = true;
};
sleep 0.05;
};
hint "resetting";
nul = [_obj,_dis] execVM "intercept.sqf";

EDIT: Sorry.... I should have added above that the only explosions that will work with the first script are ""HelicopterExploSmall", ""HelicopterExploBig" and "SecondaryExplosion"!

Edited by twirly

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

×