madmedic 0 Posted December 1, 2005 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
pazuzu 21 Posted December 1, 2005 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
madmedic 0 Posted December 1, 2005 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
pazuzu 21 Posted December 1, 2005 Just name all the paratroopers too and use the deletevehicle command... Share this post Link to post Share on other sites
[aps]gnat 28 Posted December 1, 2005 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
LoTekK 0 Posted December 1, 2005 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
madmedic 0 Posted December 1, 2005 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
Chris Death 0 Posted December 1, 2005 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
thobson 38 Posted December 1, 2005 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
Chris Death 0 Posted December 1, 2005 hehe - 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
thobson 38 Posted December 1, 2005 Quite right - I should read more slowly. I only hope I am better at my job than I am at some of this 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
madmedic 0 Posted December 2, 2005 Quite right - I should read more slowly.  I only hope I am better at my job than I am at some of this   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? By the way, Your script line is PERFECT for what I need. Thanks Share this post Link to post Share on other sites
Garcia 0 Posted December 2, 2005 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
thobson 38 Posted December 2, 2005 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