Jump to content
cpt.ghost

Cruise Missile problem

Recommended Posts

hello 

 

well im a SP/only guy and wanted to add some charm to my mission so i tried the amazing mod HAFM submarines in altis and it rocks but the mission i play set in takistan so 

i searched almost all of BI forums and armaholic for a onmapclick cruise missile script that works in arma 3 but no luck , i've found a script in arma2oa section that simulate a cruise missile launch via mapclick but i got a problem the missile wont travel to target and hit , it launch nicely and all but when it reach about 200m up in the sky the missile fly away and hit the ground about 400m away from launch position .... im very n00b in SQF so tried my best to get it to work properly but sadly i failed please i need your help here if anyone can get this to work

 

launch.sqf

Spoiler

private ["_Launcher", "_dropPosition", "_path", "_pathS","_misL", "_misFlare","_pos", "_vel", "_dir","_mis", "_pilot"];
///////////////////////////////////////////////////////////////////
//Launcher & target position  setup
hint "Single click on Map!!";
openMap true;
onMapSingleClick "CMTarget setPos _pos;launch_count = false;";
waitUntil {not (launch_count)};
_Launcher = getPos launch;
_dropPosition = getPos CMTarget;
sleep 0.5;
"dropPosMarker" setmarkerpos getPos CMTarget;
openMap false;

//ca path shortcut
_path = "\ca\air2\cruisemissile\"; //"
_pathS = _path + "data\scripts\"; //"

//Spawn the launch variant of the cruise missile and its flare.
_misL = "CruiseMissile1" createVehicle [(_Launcher select 0), (_Launcher select 1), -1];
_misFlare = "CruiseMissileFlare1" createVehicle [(_Launcher select 0), (_Launcher select 1), -1];
_misFlare inflame true;

//Start the launch.
_misL setVelocity [0, 0, 20];
_dirLaunch = GetDir launch;
_misL setdir _dirLaunch;
[_misL] execVM (_pathS + "watersplash.sqf");

//Unhide animated parts.
_misL setObjectTexture [0, "#(argb,8,8,3)color(0.501961,0.501961,0.501961,1.0,CO)"];
_misL setObjectTexture [1, "#(argb,8,8,3)color(0.501961,0.501961,0.501961,1.0,CO)"];
_misL setObjectTexture [2, "#(argb,8,8,3)color(0.501961,0.501961,0.501961,1.0,CO)"];
_misL setObjectTexture [3, "#(argb,8,8,3)color(0,0,0,1.0,co)"];
_misL setVariable ["cruisemissile_level", false];

[_misL, _misFlare] execVM (_pathS + "cruisemissileflare.sqf");
_misL setObjectTexture [4, _path + "data\exhaust_flame_ca"];
_misFlare say "CruiseMissileLaunch";
[_misL] execVM (_pathS + "exhaust1.sqf");
[_misL] execVM (_pathS + "exhaust3.sqf");

sleep 0.3;
[_misL] execVM "tomahawk\booster.sqf";
[_misL] execVM "tomahawk\vector_control.sqf";
sleep 1;

_misL setObjectTexture [0, ""];
_misL animate ["Cover1", 1];
_misL animate ["Cover2", 1];
_misL animate ["Fin1", 1];
_misL animate ["Fin2", 1];
_misL animate ["Fin3", 1];
_misL animate ["Fin4", 1];
_misL animate ["Wing1", 1];
_misL animate ["Wing2", 1];
_misL animate ["Intake1", 1];
sleep 0.5;

_misL setObjectTexture [1, ""];
_misL setObjectTexture [2, ""];

drop [_path + "cl_cover1", "", "SpaceObject", 1, 40, [-3, -3, -0.5], [-5, 0, 50], 2, 10.0, 1.0, 0, [1], [[1, 1, 1, 1]], [0, 1], 0, 0, "", "", _misL];
drop [_path + "cl_cover1", "", "SpaceObject", 1, 40, [3, 3, -0.5], [5, 0, 50], 2, 10.0, 1.0, 0, [1], [[1, 1, 1, 1]], [0, 1], 0, 0, "", "", _misL];

//higher & higher waiting
waitUntil {((Getpos _misL) select 2) >= 250};

_misL setVariable ["cruisemissile_level", true];
_misL setObjectTexture [4, ""];

_pos = position _misL;
_vel = velocity _misL;
_dir = direction _misL;
deleteVehicle _misL;

//Spawn the actual cruising missile.
_mis = "CruiseMissile2" createVehicle _pos;
_pilot = (group player) createUnit ["USMC_soldier", _pos, [], 0, "NONE"];
[_pilot] join grpNull;

_mis setDamage 0;
_mis setPos _pos;
_pilot moveInDriver _mis;
_mis engineOn true;
_mis setDir _dir;
_pilot move [_pos select 0, (_pos select 1) - 100];
_mis flyInHeight (position _mis select 2);
_mis setVelocity [100 * sin _dir,100 * cos _dir, 30];
[_mis] execVM (_pathS + "exhaust3.sqf");
drop [_path + "cl_booster1", "", "SpaceObject", 1, 40, [0, -5, 0], [0, 40, 0], 2, 3.0, 1.0, 0, [1], [[1, 1, 1, 1]], [0, 1], 0, 0, "", "", _mis];
[_mis] execVM "tomahawk\cruising.sqf";
 

 

 

 

cruising.sqf

Spoiler

private ["_mis", "_dropPos","_path", "_pathS","_dropPos"];
_mis = _this select 0;
_dropPosition = getPos CMTarget;

_path = "\ca\air2\cruisemissile\"; //"
_pathS = _path + "data\scripts\"; //"

_mis setCombatMode "BLUE";
_mis setBehaviour "CARELESS";
_mis disableAI "AUTOTARGET";
_mis reveal _target;
_mis flyInHeight 200;
//_mis doMove _dropPosition;
_mis move _dropPosition;
//_wp = _mis addWaypoint [_dropPosition _mis,50];
[_mis] execVM "tomahawk\marker.sqf";

private ["_dropposX","_dropposY","_misposX","_misposY"];
_dropposX = _dropPosition select 0;
_dropposY = _dropPosition select 1;
_misposX = getpos _mis select 0;
_misposY = getpos _mis select 1;

private ["_difX","_difY"];

while {alive _mis}do
{
    
    _misposX = getpos _mis select 0;
    _misposY = getpos _mis select 1;
        //_mis doMove _dropPosition;

    
    sleep 0.1;
    _difX = _dropposX - _misposX;
    _difY = _dropposY - _misposY;
    
    if( abs _difX < 1500 && abs _difY < 1500 )then
    {
    _mis flyInHeight 100;
    //_mis doMove _dropPosition;

        if( abs _difX < 1000 && abs _difY < 1000 )then
        {
            _mis flyInHeight 80;
            //_mis doMove _dropPosition;
                        
//hit rate 90~100%?
//    if( abs _difX < 150 && abs _difY < 150 )then    //most establishment

//hit rate 80~90%?    
//    if( abs _difX < 130 && abs _difY < 130 )then

//hit rate 70~80%?
//    if( abs _difX < 100 && abs _difY < 100 )then

//hit rate 10~70%?
    if( abs _difX < 50 && abs _difY < 50 )then    //recommends it! (Reality)
            {    
                
                
                private ["_det0","_det1","_det2","_det3","_det4","_det5","_det6","_det7","_det8","_det9","_det10","_det11","_det12"];    
                
                _det0 = "BO_GBU12_LGB" createvehicle [( _dropPosition  select 0),    (_dropPosition  select 1), 0];
                _det1 = "BO_GBU12_LGB" createvehicle [( _dropPosition  select 0) +   5,    (_dropPosition  select 1) +  5, 0];
                _det2 = "BO_GBU12_LGB" createvehicle [( _dropPosition  select 0) +  10,    (_dropPosition  select 1) + 10, 0];
                _det3 = "BO_GBU12_LGB" createvehicle [( _dropPosition  select 0) +  15,    (_dropPosition  select 1) + 15, 0];
                _det4 = "BO_GBU12_LGB" createvehicle [( _dropPosition  select 0) -   5,    (_dropPosition  select 1) -  5, 0];
                _det5 = "BO_GBU12_LGB" createvehicle [( _dropPosition  select 0) -  10,    (_dropPosition  select 1) - 10, 0];
                _det6 = "BO_GBU12_LGB" createvehicle [( _dropPosition  select 0) -  15,    (_dropPosition  select 1) - 15, 0];
                _det7 = "BO_GBU12_LGB" createvehicle [( _dropPosition  select 0) +   5,    (_dropPosition  select 1) +  5, 0];
                _det8 = "BO_GBU12_LGB" createvehicle [( _dropPosition  select 0) +  10,    (_dropPosition  select 1) + 10, 0];
                _det9 = "BO_GBU12_LGB" createvehicle [( _dropPosition  select 0) +  15,    (_dropPosition  select 1) + 15, 0];
                _det10 = "BO_GBU12_LGB" createvehicle [( _dropPosition  select 0) -  5,    (_dropPosition  select 1) -  5, 0];
                _det11 = "BO_GBU12_LGB" createvehicle [( _dropPosition  select 0) - 10,    (_dropPosition  select 1) - 10, 0];
                _det12 = "BO_GBU12_LGB" createvehicle [( _dropPosition  select 0) - 15,    (_dropPosition  select 1) - 15, 0];
                
                deleteVehicle (driver _mis);
                deleteVehicle _mis;

            };
        };
    };
};
launch_count = true;

 

 

booster.sqf

Spoiler

private ["_mis","_dirMis"];
_mis = _this select 0;
_dirMis = Getdir _mis;


while {!(_mis getVariable "cruisemissile_level")} do 
{
    _mis setvelocity [30 * sin _dirMis,30 * cos _dirMis,40];
};

 

 

vector_control.sqf

Spoiler

private ["_mis", "_climb", "_dir"];
_mis = _this select 0;

_climb = -30;//boosting missile vector
_dir = Getdir _mis;

_vz = (sin _climb);
_vh = (cos _climb);
_vx = (sin _dir)* _vh;
_vy = (cos _dir)* _vh;

_uz = sin(_climb+90); // 0.940
_ur = cos(_climb+90); // -0.342
_ux = sin(_dir)* _ur;
_uy = cos(_dir)* _ur;

while {!(_mis getVariable "cruisemissile_level")} do 
{
    _mis setVectorDir[_vx, _vy, _vz];
    _mis setVectorUp[_ux, _uy, _uz];
    sleep 0.01;
    _climb = _climb - 3 ;    
};

 

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

×