Jump to content
Sign in to follow this  
-ami- mofo

How to despawn a spawned AI on a marker

Recommended Posts

Hi all,

I have a script that spawns an aircraft on a marker (via a trigger) and then the aircraft cycles back and forth between the two markers waypoint1 and waypoint2. Works a treat :)

_array = [[(getMarkerPos "spawnfly") select 0,(getMarkerPos "spawnfly") select 1,150], 180, "I_Plane_Fighter_03_CAS_F", INDEPENDENT] call bis_fnc_spawnvehicle;

_fly1 = _array select 0;	
_flycrew = _array select 1;	
_flygroup = _array select 2;	

_flygroup flyInHeight 150;

_wp1 = _flygroup addWaypoint [getMarkerPos "waypoint1", 0];	
_wp2 = _flygroup addWaypoint [getMarkerPos "waypoint2", 0];	
_wp1 = _flygroup addWaypoint [getMarkerPos "waypoint1", 0];	
_wp1 setwaypointtype "CYCLE";

But say if I wanted the aircraft to despawn at marker waypoint2 how (besides removing the 3rd and 4th lines just above) would I get that to happen?

Thanks.

Share this post


Link to post
Share on other sites

{deleteVehicle _x} forEach (crew AIRCRAFTNAME)+[AIRCRAFTNAME]

Will delete the Plane and it's crew. :)

Share this post


Link to post
Share on other sites

For example this would delete all units of type "I_Plane_Fighter_03_CAS_F" within 15m of the marker:

{ deleteVehicle _x; } forEach nearestObjects [getMarkerPos "waypoint2",["I_Plane_Fighter_03_CAS_F"],15];

Or you could set up a trigger at the marker running a clean up script with something along the lines of:

_veh = _this select 0;
_obj = nearestObject [_veh, "I_Plane_Fighter_03_CAS_F"];
delete _obj;

Share this post


Link to post
Share on other sites

I like the idea of deleting it when it gets close to the waypoint2 marker so I did this...

_array = [[(getMarkerPos "spawnfly") select 0,(getMarkerPos "spawnfly") select 1,100], 180, "I_Plane_Fighter_03_CAS_F", INDEPENDENT] call bis_fnc_spawnvehicle;// 150 is flying 

height (change flyinheight line if you change this).

_fly1 = _array select 0;	//the aircraft
_flycrew = _array select 1;	//the units that make up the crew
_flygroup = _array select 2;	//the group

_flygroup flyInHeight 100;

_wp1 = _flygroup addWaypoint [getMarkerPos "waypoint1", 0];
_wp2 = _flygroup addWaypoint [getMarkerPos "waypoint2", 0];	
{ deleteVehicle _x; } forEach nearestObjects [getMarkerPos "waypoint2",["I_Plane_Fighter_03_CAS_F"],200];

It definitely flew well within 200m of the waypoint2 marker but it didn't disappear. :confused:

Was I supposed to put it in the script another way?

Share this post


Link to post
Share on other sites

Something has to trigger the script to make it delete the vehicle, it isn't running constantly. You could add a trigger with a 200m radius which executes the script to delete them (which i recommend seperating from the rest of the script if you choose this option) i.e.

nul = [] execVM "script.sqf";

or simply adding

{ deleteVehicle _x; } forEach nearestObjects [getMarkerPos "waypoint2",["I_Plane_Fighter_03_CAS_F"],200];

in the trigger ACT. should work too, i recommend this for ease of editing and neatness :)

Edited by Blasturbator

Share this post


Link to post
Share on other sites

Hi mate tried both of those ways you've suggested and neither worked. Maybe they'd work on editor placed stuff but maybe because it's a spawned object it's different?

Still searching for a solution.....

Share this post


Link to post
Share on other sites

Both work on objects spawned during the mission by scripts or anything for that matter, chances are you have implemented it wrong somehow. Does the jet even set off the trigger? I don't work with aircraft much so i don't know how right this is, but if it's too high up (over 200m altitude basically) it could still be outside the trigger range. Could be wrong though, i'm not sure if trigger ranges are spherical or cylindrical.

Share this post


Link to post
Share on other sites

It's probably me mate, I don't know much about scripting. :o

Anyway we're only talking about a couple of aircraft so I've just placed them in the editor and have them doing what I want them to do through waypoints.

Cheers

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  

×