Jump to content
Sign in to follow this  
battleship

Cruise missile script

Recommended Posts

This is a underwater sub-launched onmapclick cruise missile script , for this you have to place on map the following objects & marker-

Place the objects & marker at the edge of map and name these as-

invisible helipad H - launcher
invisible helipad H - targetPos
destroy marker      - target

A functions module on map.

 

To simulate a warship firing a cruise missile place frigate on sea and attach invisible helipad H (launcher) to frigate using attachto command.

 

in 1st radio trigger-
cruiseMissile = [] execVM "launch1.sqf";   //HE warhead.

Click on target position with mapclick and missile will be launched towards mapclick position & will hit target position.Note that due to terrain elevation or slope sometimes the missile may miss its target.

 

in 2nd radio trigger-
cruiseMissileCL = [] execVM "launch2.sqf";   //HE Warhead + cluster munitions.

Click on target area with mapclick and missile will overfly target position & drop cluster munitions.You can change cluster munition type by changing the bomblet's classname in launch2.sqf.

 

Place launch1.sqf & launch2.sqf in mission folder.

 

launch1.sqf

//Cruise Missile Script.

player sidechat "Requesting cruise missile strike on target position!, over!";

sleep 1;
[West,"HQ"] sideChat "Specify target coordinates on map!";

sleep 1;
titleText ["Click on map position to mark position!","plain down"];
sleep 0.1;
mapclick = true;
onMapSingleClick "targetPos setPos _pos;""target"" setMarkerPos _pos;mapclick = false;
onMapSingleClick ''; true;";
waitUntil {!mapClick};

sleep 3;
Hintsilent "Launching missile!";

sleep 1;
private ["_path", "_pathS"];

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

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

//Start the launch.
_misL setVelocity [0, 0, 40];
[_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];

sleep 0.5;

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

//Missile Launch Sequence.
sleep 2;
[West,"HQ"] sideChat "Missile Launched!";
for "_i" from 0 to 1 do {
for "_i" from 0 to 80 do {sleep 0.01;
_misL setvelocity [0,0,70];_misl setvectorDir [0,0,0];
[_misL,-1, 0] call BIS_fnc_setPitchBank;
};
};

sleep 0.1;
for "_i" from 0 to 1 do {
for "_i" from 0 to 40 do {sleep 0.01;
_misL setvelocity [10,0,10];_misl setvectorDir [0,1,0];
[_misL,-1*3,0] call BIS_fnc_setPitchBank;
};
};

sleep 0.1;
for "_i" from 0 to 1 do {
for "_i" from 0 to 40 do {sleep 0.01;
_misL setvelocity [20,0,0];_misl setvectorDir [6,1,0];
[_misL,-2*3, 0] call BIS_fnc_setPitchBank;
};
};

sleep 0.1;
for "_i" from 0 to 1 do {
for "_i" from 0 to 40 do {sleep 0.01;
_misL setvelocity [30,0,0];_misl setvectorDir [8,1,0];
[_misL,-5*3, 0] call BIS_fnc_setPitchBank;
};
};

sleep 0.1;
for "_i" from 0 to 1 do {
for "_i" from 0 to 40 do {sleep 0.01;
_misL setvelocity [40,0,0];_misl setvectorDir [10,1,0];
[_misL,-8*3, 0] call BIS_fnc_setPitchBank;
};
};

sleep 0.1;
for "_i" from 0 to 1 do {
for "_i" from 0 to 40 do {sleep 0.01;
_misL setvelocity [40,0,0];_misl setvectorDir [15,1,0];
[_misL,-15*3, 0] call BIS_fnc_setPitchBank;
};
};

sleep 0.1;
for "_i" from 0 to 1 do {
for "_i" from 0 to 40 do {sleep 0.01;
_misL setvelocity [40,0,0];_misl setvectorDir [20,1,0];
[_misL,-50, 0] call BIS_fnc_setPitchBank;
};
};

sleep 0.1;
for "_i" from 0 to 1 do {
for "_i" from 0 to 40 do {sleep 0.01;
_misL setvelocity [40,0,0];_misl setvectorDir [20,1,0];
[_misL,-70, 0] call BIS_fnc_setPitchBank;
};
};

sleep 0.1;
for "_i" from 0 to 1 do {
for "_i" from 0 to 40 do {sleep 0.01;
_misL setvelocity [40,0,0];_misl setvectorDir [20,2,0];
[_misL,-100, 0] call BIS_fnc_setPitchBank;
};
};

sleep 0.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.01;
_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];

_misL setObjectTexture [4, ""];

private ["_pos", "_vel", "_dir"];
_pos = position _misL;
_vel = velocity _misL;
_dir = direction _misL;
deleteVehicle _misL;

//Moving marker for missile.
_marker1 = createMarker ["Mark1",[0,0,0]];
_marker1 setMarkerColor "ColorRED";
_marker1 setMarkerType "mil_dot";
_marker1 setMarkerShape "ICON";
_marker1 setMarkerSize [1,1];
_marker1 setMarkerText "cruise_missile";

//Spawn the actual cruising missile.
private ["_mis", "_pilot"];
missilegrp = createGroup west;
_mis = "CruiseMissile2" createVehicle _pos;

_pilot = missilegrp createUnit ["USMC_Soldier_Pilot", _pos, [], 0, "NONE"];
_pilot moveInDriver _mis;
	
//attach marker to missile.
[] spawn {
  while {not isnull leader missilegrp} do {"Mark1" setmarkerpos getpos leader missilegrp; sleep 0.5;
};
};

_mis setDamage 0;
_mis setPosASL _pos;
_mis engineOn true;
_mis flyInHeight (position _mis select 2);
_mis setVelocity [0,90,2];
_mis setvectorDir [20,2,0];
_mis forcespeed 120;

// Guiding missile to target.
sleep 10;
_mis setCombatMode "BLUE";
_mis setBehaviour "COMBAT";
_mis setSpeedMode "FULL";

sleep 1;
_mis domove getPos targetpos;
_mis dowatch targetPos;
_mis dotarget targetPos;
_mis lookat targetPos;

sleep 1;
_targetDir = [_mis,targetPos] call BIS_fnc_DirTo;
_mis setdir _targetDir;
_mis setvelocity [100,100,1];
	
sleep 1;
waitUntil {_mis distance targetPos < 2000};
  	_mis flyInHeight 60;
	_targetDir = [_mis,targetPos] call BIS_fnc_DirTo;
    _mis setdir _targetDir;        
        
waitUntil {_mis distance targetPos < 800};                                                         
    _targetDir = [_mis,targetPos] call BIS_fnc_DirTo;
    _mis setdir _targetDir;
       
waitUntil {_mis distance targetPos < 500};                                                    
    _targetDir = [_mis,targetPos] call BIS_fnc_DirTo;
    _mis setdir _targetDir;                                                                    

waitUntil {_mis distance targetPos < 290};   		
         {deleteVehicle _x} forEach (units missilegrp);
         [_mis,-13.99, 0] call BIS_fnc_setPitchBank;
         waitUntil {!alive _mis};
         deleteVehicle _mis;
         deleteMarker "Mark1";
	private ["_shell"];
         _shell = createVehicle ["Bo_GBU12_LGB",[(getpos _mis select 0),(getpos _mis select 1),0],[], 0,"NONE"];
         _shell = createVehicle ["Bo_GBU12_LGB",[(getpos _mis select 0),(getpos _mis select 1),0],[], 0,"NONE"];			
		
sleep 5;
targetPos setPos [0,0,0];
"target" setMarkerPos [0,0,0];

sleep 1;
hintsilent "cruise missile strike available again!";

exit;

 

launch2.sqf

//Cruise Missile Script.
//Cluster munitions.

player sidechat "Requesting cruise missile strike on target position!, over!";

sleep 1;
[West,"HQ"] sideChat "Specify target coordinates on map!";

sleep 1;
titleText ["Click on map position to mark position!","plain down"];
sleep 0.1;
mapclick = true;
onMapSingleClick "targetPos setPos _pos;""target"" setMarkerPos _pos;mapclick = false;
onMapSingleClick ''; true;";
waitUntil {!mapClick};

sleep 3;
Hintsilent "Launching missile!";

sleep 1;
private ["_path", "_pathS"];

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

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

//Start the launch.
_misL setVelocity [0, 0, 40];
[_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];

sleep 0.5;

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

//Missile Launch Sequence.
sleep 2;
[West,"HQ"] sideChat "Missile Launched!";
for "_i" from 0 to 1 do {
for "_i" from 0 to 80 do {sleep 0.01;
_misL setvelocity [0,0,70];_misl setvectorDir [0,0,0];
[_misL,-1, 0] call BIS_fnc_setPitchBank;
};
};

sleep 0.1;
for "_i" from 0 to 1 do {
for "_i" from 0 to 40 do {sleep 0.01;
_misL setvelocity [10,0,10];_misl setvectorDir [0,1,0];
[_misL,-1*3,0] call BIS_fnc_setPitchBank;
};
};

sleep 0.1;
for "_i" from 0 to 1 do {
for "_i" from 0 to 40 do {sleep 0.01;
_misL setvelocity [20,0,0];_misl setvectorDir [6,1,0];
[_misL,-2*3, 0] call BIS_fnc_setPitchBank;
};
};

sleep 0.1;
for "_i" from 0 to 1 do {
for "_i" from 0 to 40 do {sleep 0.01;
_misL setvelocity [30,0,0];_misl setvectorDir [8,1,0];
[_misL,-5*3, 0] call BIS_fnc_setPitchBank;
};
};

sleep 0.1;
for "_i" from 0 to 1 do {
for "_i" from 0 to 40 do {sleep 0.01;
_misL setvelocity [40,0,0];_misl setvectorDir [10,1,0];
[_misL,-8*3, 0] call BIS_fnc_setPitchBank;
};
};

sleep 0.1;
for "_i" from 0 to 1 do {
for "_i" from 0 to 40 do {sleep 0.01;
_misL setvelocity [40,0,0];_misl setvectorDir [15,1,0];
[_misL,-15*3, 0] call BIS_fnc_setPitchBank;
};
};

sleep 0.1;
for "_i" from 0 to 1 do {
for "_i" from 0 to 40 do {sleep 0.01;
_misL setvelocity [40,0,0];_misl setvectorDir [20,1,0];
[_misL,-50, 0] call BIS_fnc_setPitchBank;
};
};

sleep 0.1;
for "_i" from 0 to 1 do {
for "_i" from 0 to 40 do {sleep 0.01;
_misL setvelocity [40,0,0];_misl setvectorDir [20,1,0];
[_misL,-70, 0] call BIS_fnc_setPitchBank;
};
};

sleep 0.1;
for "_i" from 0 to 1 do {
for "_i" from 0 to 40 do {sleep 0.01;
_misL setvelocity [40,0,0];_misl setvectorDir [20,2,0];
[_misL,-100, 0] call BIS_fnc_setPitchBank;
};
};

sleep 0.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.01;
_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];

_misL setObjectTexture [4, ""];

private ["_pos", "_vel", "_dir"];
_pos = position _misL;
_vel = velocity _misL;
_dir = direction _misL;
deleteVehicle _misL;

//Moving marker for missile.
_marker1 = createMarker ["Mark1",[0,0,0]];
_marker1 setMarkerColor "ColorRED";
_marker1 setMarkerType "mil_dot";
_marker1 setMarkerShape "ICON";
_marker1 setMarkerSize [1,1];
_marker1 setMarkerText "cruise_missile";

//Spawn the actual cruising missile.
private ["_mis", "_pilot"];
missilegrp = createGroup west;
_mis = "CruiseMissile2" createVehicle _pos;

_pilot = missilegrp createUnit ["USMC_Soldier_Pilot", _pos, [], 0, "NONE"];
_pilot moveInDriver _mis;
	
//attach marker to missile.
[] spawn {
  while {not isnull leader missilegrp} do {"Mark1" setmarkerpos getpos leader missilegrp;sleep 0.5;
};
};

_mis setDamage 0;
_mis setPosASL _pos;
_mis engineOn true;
_mis flyInHeight (position _mis select 2);
_mis setVelocity [0,90,2];
_mis setvectorDir [20,2,0];
_mis forcespeed 120;

// Guiding missile to target.
sleep 10;
_mis setCombatMode "BLUE";
_mis setBehaviour "COMBAT";
_mis setSpeedMode "FULL";

sleep 1;
_mis domove getPos targetpos;
_mis dowatch targetPos;
_mis dotarget targetPos;
_mis lookat targetPos;

sleep 1;
_targetDir = [_mis,targetPos] call BIS_fnc_DirTo;
_mis setdir _targetDir;
_mis setvelocity [100,100,1];

sleep 1;
waitUntil {_mis distance targetPos < 2000};

	_mis flyInHeight 60;
	_targetDir = [_mis,targetPos] call BIS_fnc_DirTo;
    _mis setdir _targetDir;        
        

waitUntil {_mis distance targetPos < 800};                                                                    
_targetDir = [_mis,targetPos] call BIS_fnc_DirTo;
_mis setdir _targetDir;
       
         
waitUntil {_mis distance targetPos < 500};                                                    
        _targetDir = [_mis,targetPos] call BIS_fnc_DirTo;
        _mis setdir _targetDir;                                                                        

waitUntil {_mis distance targetPos < 300};                                                    
        _targetDir = [_mis,targetPos] call BIS_fnc_DirTo;
        _mis setdir _targetDir;       
        
waitUntil {_mis distance targetPos < 190}; 
// releasing Bomblets
        _B1 = "sh_85_he" createvehicle (getPosASL _mis);
        _B1 setVeLOCITY [1,0,-6];
sleep 0.1;
       _B2 = "sh_85_he" createvehicle (getPosASL _mis);   
       _B2 setVeLOCITY [-1,0,-6];
sleep 0.1;
        _B3 = "sh_85_he" createvehicle (getPosASL _mis);  
        _B3 setVeLOCITY [0,1,-6]; 
sleep 0.1;
      _B4 = "sh_85_he" createvehicle (getPosASL _mis);   
      _B4 setVeLOCITY [0,-1,-6];
sleep 0.1;
       _B5 = "sh_85_he" createvehicle (getPosASL _mis);   
       _B5 setVeLOCITY [0,1,-6]; 
sleep 0.1;
      _B6 = "sh_85_he" createvehicle (getPosASL _mis);   
      _B6 setVeLOCITY [0,1,-6];
sleep 0.2;
      _B7 = "sh_85_he" createvehicle (getPosASL _mis);   
      _B7 setVeLOCITY [0,1,-6];
sleep 0.1;
      _B8 = "sh_85_he" createvehicle (getPosASL _mis);   
      _B8 setVeLOCITY [0,1,-6];
sleep 0.1;
     _B9 = "sh_85_he" createvehicle (getPosASL _mis);   
     _B9 setVeLOCITY [0,1,-6];
sleep 0.1;
     _B10 = "sh_85_he" createvehicle (getPosASL _mis);   
     _B10 setVeLOCITY [0,1,-6];
sleep 0.1;
     _B11 = "sh_85_he" createvehicle (getPosASL _mis);   
     _B11 setVeLOCITY [0,1,-6];
sleep 0.1;
     _B12 = "sh_85_he" createvehicle (getPosASL _mis);   
     _B12 setVeLOCITY [0,1,-6];
sleep 0.1;
     _B13 = "sh_85_he" createvehicle (getPosASL _mis);   
     _B13 setVeLOCITY [0,1,-6];
sleep 0.1;
     _B14 = "sh_85_he" createvehicle (getPosASL _mis);   
     _B14 setVeLOCITY [0,1,-6];
sleep 0.1;
     _B15 = "sh_85_he" createvehicle (getPosASL _mis);   
     _B15 setVeLOCITY [0,1,-6];
sleep 0.1;
	waitUntil {_mis distance targetPos > 270};
        {deleteVehicle _x} forEach (units missilegrp);
        [_mis,-9.99, 0] call BIS_fnc_setPitchBank;
        waitUntil {!alive _mis};
        deleteVehicle _mis;
        deleteMarker "Mark1";
	private ["_shell"];
        _shell = createVehicle ["Bo_GBU12_LGB",[(getpos _mis select 0),(getpos _mis select 1), 0],[], 0,"NONE"];
        
sleep 5;
targetPos setPos [0,0,0];
"target" setMarkerPos [0,0,0];

sleep 1;
hintsilent "cruise missile strike available again!";

exit;

 

Edited by battleship
  • 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  

×