Results 1 to 8 of 8

Thread: How to intercept projectiles?

  1. #1

    How to intercept projectiles?

    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:
    Code:
    {_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:
    Code:
    {_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

  2. #2
    Master Gunnery Sergeant twirly's Avatar
    Join Date
    Sep 13 2010
    Location
    Gods Own (NZ)
    Posts
    1,302
    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
    PHP Code:
    _obj _this select 0;
    _dis _this select 1;

    _reset false;
    _incoming objnull;

    while {
    not _reset} do {
        
    _list = (position _objnearObjects ["MissileBase",_dis];
        
    _list _list + ((position _objnearObjects ["RocketBase",_dis]);
        if (
    count _list >=1then {
            
    _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,_disexecVM "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

    PHP Code:
    nul = [this,50execVM "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!
    Last edited by twirly; Apr 26 2012 at 04:28. Reason: Changes

    "Learn by doing!" - Quoted from a post by Imutep

    OUTERRA - OUTERRA - OUTERRA - OUTERRA - BLOWMIND!

  3. #3
    I shall not insult moderators
    Join Date
    Nov 25 2010
    Posts
    1,576
    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/showthrea...=1#post1974823
    Guided RPG
    http://forums.bistudio.com/showthrea...e-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.

  4. #4
    Master Gunnery Sergeant twirly's Avatar
    Join Date
    Sep 13 2010
    Location
    Gods Own (NZ)
    Posts
    1,302
    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.

    http://www.youtube.com/watch?v=tRhd8Bqnd7g

    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.

  5. #5
    I shall not insult moderators
    Join Date
    Nov 25 2010
    Posts
    1,576
    Quote Originally Posted by twirly View Post
    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:

    http://www.youtube.com/watch?v=5PUusycx3Xc

  6. #6
    Master Gunnery Sergeant twirly's Avatar
    Join Date
    Sep 13 2010
    Location
    Gods Own (NZ)
    Posts
    1,302
    Nice one. Actually it does look pretty damn close to the vid!

  7. #7
    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.

  8. #8
    Master Gunnery Sergeant twirly's Avatar
    Join Date
    Sep 13 2010
    Location
    Gods Own (NZ)
    Posts
    1,302
    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
    Code:
    _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"!
    Last edited by twirly; Apr 26 2012 at 04:26.

Similar Threads

  1. Intercept and destroy mission?
    By AirSuperiority in forum ARMA 2 & OA - USER MISSIONS
    Replies: 1
    Last Post: Jan 20 2012, 04:28
  2. Spawning projectiles
    By tryteyker in forum ARMA 2 & OA : MISSIONS - Editing & Scripting
    Replies: 1
    Last Post: Oct 26 2011, 21:56
  3. Editing Projectiles
    By ProPilot in forum ARMA - ADDONS & MODS: DISCUSSION
    Replies: 17
    Last Post: Aug 30 2007, 02:21
  4. Bas ch-47 demo mission intercept
    By Javito1986 in forum USER MISSIONS
    Replies: 1
    Last Post: Feb 15 2004, 23:56
  5. Projectiles!
    By DodgeME in forum GENERAL
    Replies: 9
    Last Post: Apr 3 2002, 20:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •