OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: THobson on 28 Dec 2004, 20:31:55

Title: Get out and stay out!
Post by: THobson on 28 Dec 2004, 20:31:55
I want the crew of certain vehicles to abandon the vehicle and walk.  I  have the following code in a script:

Code: [Select]
if ((canMove _veh) and (fuel _veh > 0.05) and (side driver _veh == west)) then {goto"VehOkay_1"}
_crew = crew _veh
{unassignVehicle _x} forEach _crew
_crew orderGetIn false
#VehOkay_1

I tested it with a vehicle that had  setFuel 0

The result was the Gunner and the Driver got out and the Gunner then got back in!

How do I get them all out and keep them out?
Title: Re:Get out and stay out!
Post by: Planck on 28 Dec 2004, 20:34:28
Remove his ammo maybe?


Planck
Title: Re:Get out and stay out!
Post by: GrimMonkey on 28 Dec 2004, 20:46:40
Did you try locking the vehicle?

Code: [Select]
if ((canMove _veh) and (fuel _veh > 0.05) and (side driver _veh == west)) then {goto"VehOkay_1"}
_crew = crew _veh
{unassignVehicle _x} forEach _crew
_crew orderGetIn false
_veh Lock True
#VehOkay_1
Title: Re:Get out and stay out!
Post by: Triggerhappy on 28 Dec 2004, 21:45:53
locking only works on players, it has no affect on AI att all
Title: Re:Get out and stay out!
Post by: penguinman on 28 Dec 2004, 22:35:39
try using veh remove all magaziens/ammo(dont know which,
Title: Re:Get out and stay out!
Post by: THobson on 28 Dec 2004, 23:24:07
Cracked it.  It seems that telling the crew of a vehicle to unassignVehicle does not work on its own.  Somehow the crew are uniquely linked to the vehicle.  The code that solves my problem is:

Code: [Select]
if ((canMove _veh) and (fuel _veh > 0.05) and (side driver _veh == west)) then {goto"VehOkay_1"}
_crew = crew _veh
[_crew select 0] join grpNull
{unassignVehicle _x} forEach _crew
{[_x] join (_crew select 0)} forEach _crew
#VehOkay_1
It seems that it is necessary to assign the crew members to a group that is in noway associated with the vehicle - otherwise they just keep trying to get beck in.

I did not get chance to try the ammo/magzines bit - but anyway that would have spoiled what I was trying to achieve.
Title: Re:Get out and stay out!
Post by: Planck on 28 Dec 2004, 23:34:46
Was this a vehicle placed via the editor fully crewed?


Planck
Title: Re:Get out and stay out!
Post by: THobson on 28 Dec 2004, 23:40:59
Yes.  Is this a known issue?
Title: Re:Get out and stay out!
Post by: Planck on 28 Dec 2004, 23:43:20
Sort of

They do the same thing if you issue:

fredc action ["getout", fred]
fredd action ["getout", fred]
fredg action ["getout", fred]

fred being the vehicle.


Planck
Title: Re:Get out and stay out!
Post by: THobson on 28 Dec 2004, 23:45:55
I used action "eject" but they still kept getting back in.

Giving them a new group seem to have solved it though
Title: Re:Get out and stay out!
Post by: macguba on 24 Jan 2005, 16:51:17
I had this problem.   I solved it with

"unAssignVehicle _x" forEach units _group
units _group orderGetIn false
units _group allowGetIn false

I don't know which of these commands does the trick, or if its the combination of the two.... having eventually got it to work I couldn't face figuring out why, although it seems allowGetIn might be the crucial one.
Title: Re:Get out and stay out!
Post by: THobson on 24 Jan 2005, 19:34:57
I remember that code.  I didn't understand it, but at least it works.  If I had remembered I would have saved myself some trouble, anyway, giving the guys a new group to belong to works as well.
Title: Re:Get out and stay out!
Post by: macguba on 24 Jan 2005, 19:39:00
It's classic ofp code - tell a loon to do something, then bang him on the head with something else to make sure he does it.    
Title: Re:Get out and stay out!
Post by: THobson on 24 Jan 2005, 21:50:04
Lol ;D