Jump to content

Call airstrike with radio for $50k script need help!


theshadope69

Recommended Posts

Ok so I'm writing my first script to put into my epoch server because no one else seems to have done it (at least how i want to do it). I've written petty much all the way up to where the AI pilot has to target the way point (a map click position). All I want the pilot to do (A10 is the jet btw), is fly towards the location, on approach drop a couple of bombs and then leave! Essentially I just need help figuring how to get the pilot to target the location (there is a red smoke marker made also at the location)  and just fire bombs before flying off to a reasonable degree of accuracy.

Here is my script:

private ["_unit","_cashMoney","_costStrike","_flyHeight","_notEnough","_jetPos","_dir","pPos","_jet","_oid","_jetType","_target","_mark","_group","wp","_x1","_x2","_y1","_y2","_disTarget"];
disableserialization;
_unit = _this select 0;
_costStrike = 50000;

if (unit == player) then {
_cashMoney = player getVariable["cashMoney",0];    //Get the amount of money in players wallet
    if (_cashMoney < _costStrike) then {
        _notEnough = _costStrike - _cashMoney;	//Find how much money short the player is to call the strike
        [format["<t>You need %1 more coins to call the aistrike!</t>",(_notEnough)],0,0,2,2] spawn BIS_fnc_dynamicText;
	} else {
		_cashMoney = _cashMoney - _costStrike;
		player setVariable["cashMoney", _cashMoney,true];
		[format["<t>The airstrike is inbound!</t>"],0,0,2,2] spawn BIS_fnc_dynamicText;
		
		
		//AIRSTRIKE
		clicked = 0; hint "Click on the map where you require the drop."
		openmap true;
		onMapSingleClick {
			onmapsingelclick{};
			_target setPos [_pos select 0,_pos select 1, 0];
			clicked = 1;
			openmap false;
		};
		waitUntil {(clicked == 1)};
		_jetType = "A10_US_EP1";
		_flyHeight = 1000;
		//Create the AI Jet on the edge of the map
		_pPos = getPosASL _target;
		_jetPos = [(_this select 0)+1000,(_this select 1)+1000,1000];
		_oid = str(ceil(random 999999));
		_jet = _jetType createVehicleLocal _jetPos;
		_jet engineOn true;
		_jet setPosATL _jetPos;
		_jet setVariable ["ObjectID",_oid,true];
		_jet setVariable ["ObjectUID",_oid,true];
		_jet setVehicleLock "UNLOCKED";
		_jet flyInHeight _flyHeight;
		_dir = [_pPos,this] call BIS_fnc_dirTo;
		_jet setDir (90 - _dir);
		_jet setVelocity [(50*(sin _dir)+100),(50*(cos _dir)+100),0]
		_group = createGroup west;
		_unit = _group createAgent ["US_Soldier_Pilot_EP1",_this,[],0,"CAN_COLLIDE"];
		_unit assignAsDriver _jet;
		_unit moveInDriver _jet;
		_unit setRank "COLONEL";
		_jet removeWeapon "MaverickLauncher";
		_jet removeWeapon "SidewinderLaucher_AH1Z";
		_jet removeWeapon "FFARLauncher_14";

		//Mark the location
		_mark = "SmokeShellRed" createVehicle [(getPos _target select 0),(getPos _target select 1),(getPos _target select 2)+2];
		
		/*
		Essentially this is what should now happen:
			+ The AI jet has been created.
			+ As the jet approaches the target it will slow down to a reasonable speed to drop
			+ the jet lowers to 70m when it is within 1000m of the target and slows to 150km/hr
			+ 30 seconds after flying away it will be deleted
		*/
		_x1 = (getPos _jet) select 0;  
		_y1 = (getPos _jet) select 1;
		_x2 = (getPos _target) select 0;
		_y2 = (getPos _target) select 1;
		_disTarget = (sqrt((_x2-_x1)*(_x2-_x1))+((_y2-_y1)*(_y2-_y1)));
		if _disTarget > 1000 then {
			_jet flyInHeight 1000;
			_jet setVelocity 200;
		} else {
			_flyHeight = 70;
			_jet flyInHeight _flyHeight;
			_jet setVelocity 150;
		};
		_wp = _group addWaypoint [position _target, 0];
		[_group, 1] setWaypointType "SAD";
		[_group, 1] setWaypointSpeed "FULL";
		[_group, 1] setWaypointBehaviour "RED";
		[_group, 1] setWapointStatements ["true","_jet flyInHeight _flyHeight;"];
		
		//From here the code shall be to drop bombs when in 50m range of the map click location, i just dont know how to do so.
	};
};
    



 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...