Jump to content
Sign in to follow this  
BlueB52

Having an enemy attack a certain unit when triggered

Recommended Posts

I have a group of helos that will be flying past a trigger. I want this trigger to tell an enemy jet to attack specifically one unit of my choice. How would I go about doing this? Is there a command I can give the jet to attack the named helicopter only? Or even better, can I make the jet spawn when the helicopter trigger it to? If this is the wrong place to put this I'm sorry, a point in the right direction would be helpful. I'm trying to learn the mission editor so any information retaining to it is very helpful. :)

Share this post


Link to post
Share on other sites

Place a gamelogic where you want the plane to spawn and call it start and place the following line in the init box

null = ["vehname","Su34",start,180,130,east] execvm "Veh_Spawn.sqf";

Also place a function module on the map as well as a unit of the same side as the vehicle your spawning or they won't attack anything.

save script as Veh_Spawn.sqf"

//null = ["vehname","Su34",start,180,130,east] execvm "Veh_Spawn.sqf";

_name   = _this select 0;// name of vehicle 
_type   = _this select 1;// type of vehicle
_pos    = _this select 2;// starting x,y,z position of vehicle 
_dir    = _this select 3;// Direction vehicle will face
_height = _this select 4;// optional height added to z value. 0 is default.
_side   = _this select 5;// side the unit will be on

createcenter _side;

_createdVehicle = [[getpos _pos select 0,getpos _pos select 1,_height],_dir,_type,_side] call bis_fnc_spawnvehicle;
_theVehicleItSelf = _createdVehicle select 0;
_theGroupOfTheCrew = _createdVehicle select 2;

_theVehicleItSelf setVehicleVarName _name;
call compile format["%1 = _theVehicleItSelf", _name];

About the only way to get the plane to target one specific Chopper maybe to set the others as captive

you can do that by placing this in each choppers init that you don't want attacked.

this setcaptive true;

Share this post


Link to post
Share on other sites

Thank you for your help!

If I may ask for future reference, in

["vehname","Su34",start,180,130,east] execvm "Veh_Spawn.sqf";

what do each of the values stand for?

Edited by BlueB52

Share this post


Link to post
Share on other sites
["vehname","Su34",start,180,130,east] execvm "Veh_Spawn.sqf";[/code] what do each of the values stand for?

Its all there:

//null = ["vehname","Su34",start,180,130,east] execvm "Veh_Spawn.sqf";

_name = _this select 0;// name of vehicle

_type = _this select 1;// type of vehicle

_pos = _this select 2;// starting x,y,z position of vehicle

_dir = _this select 3;// Direction vehicle will face

_height = _this select 4;// optional height added to z value. 0 is default.

_side = _this select 5;// side the unit will be on

Anyway, if you want to be sure the chopper actually gets hit, you could try this:

_type = "Priest"; // Class of the Pilot (yeah, the priest kicks ass)
mygroup = creategroup resistance; // Defines which side the plane is on
_airtype = "F35B"; // Type of plane spawned
_launcher = "SidewinderLaucher";
_rocket = "M_Sidewinder_AA";


_target = _this select 0; // The target of the attack
_vdir = _this select 1; // The angle of approach

_pos = getpos _target;
_apos = getposasl _target;


_npos = [(_pos select 0) + (_vdir select 0) * -2000, (_pos select 1) + (_vdir select 1) * -2000, 400];

_vehicle = createVehicle  [_airtype,_npos, [], 0, "FLY"];
_vehicle setpos _npos;
_vehicle setDir (direction player);


_vehicle setvelocity [(_vdir select 0)*50,(_vdir select 1)*50, 0];

_type createUnit [_npos, mygroup,"pilot=this;"];
_pilot = pilot;
_pilot moveindriver _vehicle;
_pilot reveal _target;
_pilot doMove getpos _target;
_pilot dofollow _target;
_pilot dotarget _target;
_pilot FlyInHeight 360;


while {_vehicle distance _target > 800} do {
sleep 0.5;
if(_vehicle distance _target < 1000) then {
	_pilot FlyInHeight ((getpos _target) select 2);
};
};

_aiming = {_source = _this select 0;_class = _this select 1;_aim = _this select 2;_shot = nearestObject [_source,_class];_shot setvectorup [0.1,1000,0.1];while {_aim distance _shot > 10} do {_asl1 = getposasl _aim;_asl2 = getposasl _shot;_trim = velocity _aim;_vdir = [(_asl1 select 0)+(_trim select 0)-(_asl2 select 0),(_asl1 select 1)+(_trim select 1)-(_asl2 select 1),(_asl1 select 2)+(_trim select 2)-(_asl2 select 2)+ 1 + random 3];_shot setvectordir _vdir;sleep 0.01;};};

sleep 0.5;

_vehicle fire [_launcher, "", _rocket];
[_vehicle,_rocket,_target] spawn _aiming;

sleep 1;

_vehicle fire [_launcher, "", _rocket];
[_vehicle,_rocket,_target] spawn _aiming;

sleep 1;

_vehicle fire [_launcher, "", _rocket];
[_vehicle,_rocket,_target] spawn _aiming;

sleep 1;

_vehicle fire [_launcher, "", _rocket];
[_vehicle,_rocket,_target] spawn _aiming;

_vehicle FlyInHeight 75;


sleep 1;
_vehicle FlyInHeight 250;
_pilot doMove [(_pos select 0) + (_vdir select 0) * 800, (_pos select 1) + (_vdir select 1) * 800, 500];

sleep 35;

deletevehicle _vehicle;
deletevehicle _pilot;

Can be called like this:

nul=[yourtargevehicle,90] execvm "airsupport.sqf";

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  

×