Jump to content
tierdisogni1450

Helicopter Shoot Down with VLS

Recommended Posts

Good morning! I have been struggling for a couple of days with a particular task for a co-op mission. The end goal is to have a possibility that the players primary extraction vehicle is shot down. Right now I'm seeing errors kicked back at the reportRemoteTarget section of my code, but I feel that is has more to do with the helicopter variable being initialized as an array, but I have yet to find the proper method for initializing the heli, if there is one. Any advice would be much appreciated, and thank you in advance! 

_crew1 = [];
_airframe1 = [];

//If this is the server
if(isServer) then 
{

	//create crew and aircraft
	_crew1 = creategroup WEST; //create crew for heli
	_airframe1 = [getMarkerPos "marker_5", 140, "B_Heli_Light_01_F", _crew1] call BIS_fnc_spawnVehicle; //create heli at marker 5, add crew, set direction


	//create waypoints
	_wp0 = _crew1 addWaypoint [(getMarkerPos "exfil1"), 0]; //create new waypoint at Primary Exfil
	_wp0 setWaypointType "TR UNLOAD"; //Move to that waypoint
	_wp0 setWaypointSpeed "FULL"; //Haul ass
	_wp0 setWaypointTimeout[60,60,60];
	
	_wp1 = _crew1 addWaypoint [(getmarkerpos "marker_5"), 0];
	_wp1 setWaypointType "MOVE";
	_wp1 setWaypointSpeed "FULL";
		
		//Random percent chance of shootdown, set to 100 for testing. 
		if(random 100 <= 100.00) then
		{
            //VLS target aquisition and shootdown
			independent reportRemoteTarget [_airframe1, 3000];
			_airframe1 confirmSensorTarget [west, true];
			l1 fireAtTarget[_airframe1, "weapon_vls_o1"];
		}
	
	
}

 

Share this post


Link to post
Share on other sites

BIS_fnc_spawnVehicle returns an array and the vehicle you're interested in is the first element of that array. Try this:

 

private _spawnResult = [getMarkerPos "marker_5", 140, "B_Heli_Light_01_F", _crew1] call BIS_fnc_spawnVehicle;
_airframe1 = _spawnResult # 0;

 

Share this post


Link to post
Share on other sites

Back again. It seems that the missile is not tracking the target. Launch goes ballistic and straight up. When I run the code during runtime I'm still getting an error with report remote target [#] reportRemoteTarget, but it says a ";" is needed. looking at my code, I have no idea where. 

 

I have seen other topics on the forums but it appears they're using a trigger, and I'm trying to accomplish everything in script. 

		if(random 100 <= 100.00) then
		{
			//sleep 2;
			l1 doWatch _airframe1;
			independent reportRemoteTarget [_airframe1, 15];
			waitUntil {l1 confirmSensorTarget [west, true]; 
			l1 aimedAtTarget [_airframe1] > 0}; 
			l1 fireAtTarget [_airframe1];
		};

l1 is the VLS with independent AI mounted. 

Share this post


Link to post
Share on other sites

Hi i use this for a missil hit

 

call {west reportRemoteTarget [t1, 3000];
t1 confirmSensorTarget [west, true];
g1 fireAtTarget [t1, "weapon_vls_01"];}

T1 = target G1=VLS

 

maybe you can get something out of it.

I guess you have to make the helicopter friends with the Opfor side to make it work.

 

 

Share this post


Link to post
Share on other sites

I wasn't able to get the VLS to hit a helicopter no matter what I tried. 

Share this post


Link to post
Share on other sites
14 minutes ago, Play3r said:

Hi i use this for a missil hit

 

call {west reportRemoteTarget [t1, 3000]; //This reports target (t1) to all members of BLUFOR
t1 confirmSensorTarget [west, true]; //Set the target (t1) as Hostile to BLUFOR
g1 fireAtTarget [t1, "weapon_vls_01"];} //VLS Fire missile at target(t1)

T1 = target G1=VLS

 

maybe you can get something out of it.

I guess you have to make the helicopter friends with the Opfor side to make it work.

 

 

 

Will the call function work in a script? I thought that was a way of expanding code usage in editor triggers? In either case let me see if I'm understanding all of this correctly. See Bold text in quote.

 

That part all seems pretty straight forward. In my mission, the Independent side are the aggressors/enemy, and _airframe1 is the player/blufor extraction. At runtime the script kicks back no errors, but the launcher only fires it's missile straight up. When the if() statement reaches the right condition I get an error for each line that shows a # in front of each command (reportRemoteTarget, confirmSensorTarget, aimedAtTarget, fireAtTarget) and the error reads "Error type Any, expected Object"

 

Also, I did try a direct copy/paste of your code into my script and the same error remains. 

Share this post


Link to post
Share on other sites
2 minutes ago, stburr91 said:

I wasn't able to get the VLS to hit a helicopter no matter what I tried. 

 

That's what I'm starting to wonder, if it's even possible that is. I wanted something a little flashy for this part of the mission, but I may have to settle for a spawned AA unit or something. 

Share this post


Link to post
Share on other sites
On 2/6/2022 at 5:52 PM, tierdisogni1450 said:

 

That's what I'm starting to wonder, if it's even possible that is. I wanted something a little flashy for this part of the mission, but I may have to settle for a spawned AA unit or something. 

How about spawning a bomb, attach it to the  heli and make a setdamage 1 to it. like this

helibomb = "DemoCharge_Remote_Ammo_Scripted" createVehicle [0,0,0];

helibomb  attachTo [heli, [0, 0, -2]]; i belive it attaches it under the middle of the heli

helibomb setdamage 1;

look here in Exp 6.

https://community.bistudio.com/wiki/createVehicle

 

I found this to be the best solution.. 

 

helibomb  attachTo [heli, [-4, 0, -20]];

done on a chinok with the DemoCharge

Edited by Play3r
added new info

Share this post


Link to post
Share on other sites
On 2/7/2022 at 11:54 AM, Play3r said:

How about spawning a bomb, attach it to the  heli and make a setdamage 1 to it. like this

helibomb = "DemoCharge_Remote_Ammo_Scripted" createVehicle [0,0,0];

helibomb  attachTo [heli, [0, 0, -2]]; i belive it attaches it under the middle of the heli

helibomb setdamage 1;

look here in Exp 6.

https://community.bistudio.com/wiki/createVehicle

 

I found this to be the best solution.. 

 

helibomb  attachTo [heli, [-4, 0, -20]];

done on a chinok with the DemoCharge

Thanks for the suggestion. I decided to spawn an AA unit, delay it long enough to get the kill, then delete it. Seems to do the trick pretty well

Share this post


Link to post
Share on other sites
On 2/16/2022 at 9:28 PM, alpha993 said:

How about using BIS_fnc_EXP_camp_guidedProjectile? You could spawn the VLS rocket itself and have it home in on the helicopter.

 

Interesting, however, there is no example on the wiki page, does anyone have a working example of this? 

Share this post


Link to post
Share on other sites

i found this on a discord channel i'm using. 

 

https://discord.gg/E4N7ZB8r

maybe you can change it to work like you want?

 

Create a fake AA missile launch missing target By @TROALINISM, forged by @wogz187

A missing AA missile generator, its used when you want to fake an AA missile reaching target vehicle and then losing track of it and flying away.

/*=========================you_near_miss===================

spawn missile _start number negative to create missile behind target, positive to create missile in front default -300

_height number altitude to create missile default 5

_target object target object for near miss default player

_type string missile classname (must be steerable) default "M_Scalpel_AT"

========================================================================*/

 

you_near_miss= { params [ ["_start", -300], ["_height", 5], ["_target", (allPlayers select 0)], ["_type", "M_Scalpel_AT"]];

private _missile = createVehicle [ _type, [ (_target getRelPos [_start, (random 10)+10]) select 0, (_target getRelPos [_start, (random 10)+10]) select 1, _height ] ];

_missile setDir ([_missile, _target] call bis_fnc_dirTo);

_missile setMissileTargetPos [ (_target getRelPos [20, (random 10)+10]) select 0, (_target getRelPos [20, (random 10)+10]) select 1, (getPosATL _target) select 2 ]; _missile };

 

private _return= [500, 5, player] call you_near_miss;

 

systemChat str _return;

Share this post


Link to post
Share on other sites
4 hours ago, stburr91 said:

 

Interesting, however, there is no example on the wiki page, does anyone have a working example of this? 


Here's a working example and a video of the result:
 

[
	getPosASL ALP_missileStart, 	// ASL coordinates where missile should spawn
	"ammo_Missile_Cruise_01", 	// cruise missile classname
	ALP_targetHeli, 		// target object
	100, 				// missile speed
	true, 				// destroy target on impact
	[0,0,0], 			// target modelspace coordinates for impact
	0, 				// minimum distance to enter ballistic mode
	"", 				// code to run on missile
	true				// run globally
] spawn BIS_fnc_EXP_camp_guidedProjectile

 

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

That's awesome! I will give it a test today. Thanks Alpha993!

 

On another note. Is there a way to create a public variable to activate a trigger? I thought I had seen one before but all the code I've tried thus far is not activating the trigger. I'm looking to set task state on one task, and trigger creation of another task right afterwards via variable exfil2. I'm getting a generic expression error in the process. My code is.....

_crew1 = [];
_airframe1 = [];
exfil2 = 0;


//If this is the server
if(isServer) then 
{

//Pulled other code for cleanliness

		if(isNull _crew1) then
			{
				["ex1","CANCELED"] call BIS_fnc_taskSetState;
				exfil2 = 1;
				hint "it worked";
				
			};
	
	
}

Below is a screenshot of the trigger setup, it's synced to the create task module in editor. I know a lot of people say it's easier to write all the code out, but I'm still learning arma's api and I'm not quite as fluent as I'd like to be. 

Trigger Setup

 

Edit: Messed up code on my end for missile and fixed it, works now, thanks again!

  • Like 1

Share this post


Link to post
Share on other sites

I would really recommend using the functions directly in a script instead of modules. See this tutorial, and this page for more info.

waitUntil {exfil2 == 1};

[west, "ex2", ["Exfiltrate Task 2 Description", "Exfiltrate 2 Task Title", "Exfiltrate 2 Task Marker"], TAG_exfil2Heli, "ASSIGNED", 1, true, "takeoff"] call BIS_fnc_taskCreate;

 

If you want to use the trigger anyway, I've found you sometimes need to add some kind of condition to the "Activation" section. You could probably set it to activated by BLUFOR not present, set the trigger radius to 0, and put the following in the condition:

this && (exfil == 1);

 

  • Like 1

Share this post


Link to post
Share on other sites

Or you can just set exfil to True

 

like this :

Exfil2 = true

 

and on the ACT of Trigger you can just write:

 

exfil2

 

then the trigger will wait until the variable is True. 

Share this post


Link to post
Share on other sites
17 hours ago, alpha993 said:

I would really recommend using the functions directly in a script instead of modules. See this tutorial, and this page for more info.


waitUntil {exfil2 == 1};

[west, "ex2", ["Exfiltrate Task 2 Description", "Exfiltrate 2 Task Title", "Exfiltrate 2 Task Marker"], TAG_exfil2Heli, "ASSIGNED", 1, true, "takeoff"] call BIS_fnc_taskCreate;

 

If you want to use the trigger anyway, I've found you sometimes need to add some kind of condition to the "Activation" section. You could probably set it to activated by BLUFOR not present, set the trigger radius to 0, and put the following in the condition:


this && (exfil == 1);

 

To the rescue again! haha I did end up scripting the last couple events. For all intents and purposes the mission is in a playable state with a few minor bugs left to hash out. I think I'm just letting the code intimidate me since it's so far from what I normally work with. I learned c# and c++ in school, but most of my coding work has been in Unreal blueprints until now.  Thanks to all you guys that helped me out! 

  • Like 2

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

×