Jump to content
madmedic

Delete all crew and cargo of an aircraft

Recommended Posts

Can someone please tell me what is the proper way to write a scripting line that will delete all of the units inside a vehicle.

(I am trying to write a script that will prevent any AI from bailing out of a plane that is going down)

I have the script set to activate when the plane reaches a certain damage level.

The units will all be deleted, instead of automatically bailing out.

Share this post


Link to post
Share on other sites

If you have vehicles with crew already inside then you just Name the vehicle and for the crew you use the same name as vehicle but add D for driver, G for gunner or C for commander.

Example: deletevehicle tank_1; deletevehicle tank_1D; deletevehicle tank_1G; deletevehicle tank_1C

This will delete the tank and the crew.

Share this post


Link to post
Share on other sites

What about the cargo?

I really need to delete the cargo.

(I am using it with a transport plane, full of paratroopers)

Share this post


Link to post
Share on other sites

Just name all the paratroopers too and use the deletevehicle command...

Share this post


Link to post
Share on other sites
Quote[/b] ]"deletevehicle _x" foreach (crew ThePlane)

But just noticed for the first time that this results in an empty vehicle that no one can get into.

Share this post


Link to post
Share on other sites
Gnat @ Dec. 01 2005,18:41)]
Quote[/b] ]"deletevehicle _x" foreach (crew ThePlane)

But just noticed for the first time that this results in an empty vehicle that no one can get into.

Why not just kill them, then? That way if the player happens to come across one of the downed birds, they won't encounter a ghost plane.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"_x setdammage 1" forEach (crew ThePlane)

Share this post


Link to post
Share on other sites
Gnat @ Dec. 01 2005,11:41)]
Quote[/b] ]"deletevehicle _x" foreach (crew ThePlane)

But just noticed for the first time that this results in an empty vehicle that no one can get into.

Thank you...that is exactly what I was looking for.

It does not matter if the plane is locked, because it will be crashed anyway.

Share this post


Link to post
Share on other sites
If you have vehicles with crew already inside then you just Name the vehicle and for the crew you use the same name as vehicle but add D for driver, G for gunner or C for commander.

Example: deletevehicle tank_1; deletevehicle tank_1D; deletevehicle tank_1G; deletevehicle tank_1C

This will delete the tank and the crew.

Just one thing here pazuzu:

If you would do it in that order - first the vehicle itself, followed by it's D/G/C would not work me thinks.

Why?

Because: deletevehicle tank_1 will delete tank_1

and then tank_1D/G/C would have not tank_1 referback

as it got deleted before.

Solution: delete tank_1 at last and the crew first

~S~ CD

Share this post


Link to post
Share on other sites

There is a problem with OFP. You cannot fully delete a unit that is in a vehicle - residual bits remain. Instead try:

{_x setPos [0,0,0];deleteVehicle _x} forEach crew vehiclename

This will move all the crew (and cargo) units to 0,0,0 and then delete them. To keep it clean you might want to put an unassignVehicle instruction in there as well incase the now empty vehicle gets confused.

Something like:

{_x setPos [0,0,0];unassignVehicle _x;deleteVehicle _x} forEach crew vehiclename

EDIT: I just read that you plan for the plane to crash anyway - so why not just kill the pilot?

Share this post


Link to post
Share on other sites

hehe smile_o.gif - Thobson - you should have re-re-read as madmedic

wants to:

Quote[/b] ]when the plane reaches a certain damage level.

The units will all be deleted, instead of automatically bailing out

However i'm not sure if killing the pilot will prevent them

others from leaving the plane by chute, but it could be

maybe happen upon ofp bug in case crew select 0 (the pilot)

is dead and then there might be a chance that the eject

process gets terminated upon that.

Only a quick try will give an exact result (except you or somebody else already know that it's like that).

~S~ CD

Share this post


Link to post
Share on other sites

smile_o.gif Quite right - I should read more slowly. I only hope I am better at my job than I am at some of this smile_o.gif

Why not then just kill the lot of them with a:

{_x setDammage 1} forEach crew aircraftname

Then if the player happens on the wreck there will be bodies realistically inside it.

Share this post


Link to post
Share on other sites
smile_o.gif Quite right - I should read more slowly.  I only hope I am better at my job than I am at some of this  smile_o.gif  

Why not then just kill the lot of them with a:

{_x setDammage 1} forEach crew aircraftname

Then if the player happens on the wreck there will be bodies realistically inside it.

well ...I chose to delete them because the dead bodies sitting in the default "dead cargo" position, with their heads sticking through the top of the plane...just doesnt look very good IMHO.

I was thinking it might free up a little memory with the unused units deleted as well? huh.gif

By the way, Your script line is PERFECT for what I need.

Thanks

Share this post


Link to post
Share on other sites

I wonder, what if a unit is killed, and then deleted...should I still move them to [0,0,0]?

Share this post


Link to post
Share on other sites

I have never tested that.  I have in the past tried to delete units that were in vehicles (while alive) and some very strange things happened.  Hence the need to move them out and unassign them and then delete them.  My preference without testing it would be give the ofp engine all the help you can to get it right so I would still do the setpos.

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

×