Jump to content
Sign in to follow this  
mons00n

prevent AI cargo from leaving vehicle

Recommended Posts

Is there any way to prevent AI from disembarking from a cargo spot when it gets damaged? I know allowCrewInImmobile works for "crew", but unfortunately does not work for "cargo" =/. I'm trying to setup a sort of escort mission where the unit never leaves a vehicle, but it is proving rather difficult when a few shots to the tire makes him jump out and lay on the ground. I have tried disableAI for FSM & MOVE, neither of which seem to do the trick. Any ideas? Thanks!

---------- Post added at 11:55 ---------- Previous post was at 11:38 ----------

I just figured out a pretty poor way of handling this:

_unit = _this select 0;
_veh  = _this select 1;

_unit assignAsCargoIndex [_veh,1];

while{true} do{
waitUntil{vehicle _unit != _veh};
_unit moveInCargo [_veh,1];
sleep 1;
};

which seems to work, but I'd be curious to hear any other approaches.

Share this post


Link to post
Share on other sites

allowCrewInImmobile should work for all occupants, not just turret seats (driver,gunner,commander,turrets). The key for using that function is to call it while the vehicle is empty. If you call it while the vehicle has occupants, it may not work correctly, at least that was my experience.

I would also assign him to the seat you want him to sit in, or at least to cargo.

using the 'assignAsCargo / assignAsCargoIndex' functions. (EDIT: see you've already used it) Can even try the 'addVehicle' function although I doubt that's necessary. I don't believe 'moveInCargo' will assign him a seat, meaning he'll get out at first opportunity or whenever his group leader issues a 'getout' command.

Edited by MDCCLXXVI

Share this post


Link to post
Share on other sites
allowCrewInImmobile should work for all occupants, not just turret seats (driver,gunner,commander,turrets). The key for using that function is to call it while the vehicle is empty. If you call it while the vehicle has occupants, it may not work correctly, at least that was my experience.

I've tried calling this while it was empty, or occupied, either way makes no difference for me. I slap down a transport vehicle, add "this allowCrewInImmobile true" to the init, tell the AI to hop in, shoot the tire and the AI hops out. If I follow the same procedure with a driver he stays in the vehicle as expected.

I would also assign him to the seat you want him to sit in, or at least to cargo.

using the 'assignAsCargo / assignAsCargoIndex' functions.

oh yea I'm already doing that

(EDIT: see you've already used it) Can even try the 'addVehicle' function although I doubt that's necessary. I don't believe 'moveInCargo' will assign him a seat, meaning he'll get out at first opportunity or whenever his group leader issues a 'getout' command.

Yea I think the AI is just pre-programed to get out when the vehicle is damaged. The while loop I posted above seems to be working well enough for me.

Share this post


Link to post
Share on other sites

You can use the "GetOut" eventHandler to put the unit back into cargo, which is basically the same as your loop, but is perhaps better for performance.

Although I just tried allowCrewInImmobile on a Zamak with an AAF fireteam in cargo, and they stay in the vehicle even if I shoot out all the tyres, whereas they would normally eject after I damaged 3 of the wheels. What vehicle are you using?

Edited by 2nd Ranger

Share this post


Link to post
Share on other sites

i'm pretty sure bailing out of the vehicle is part of the danger fsm, so disableai "FSM" might work?

Share this post


Link to post
Share on other sites
You can use the "GetOut" eventHandler to put the unit back into cargo, which is basically the same as your loop, but is perhaps better for performance.

Although I just tried allowCrewInImmobile on a Zamak with an AAF fireteam in cargo, and they stay in the vehicle even if I shoot out all the tyres, whereas they would normally eject after I damaged 3 of the wheels. What vehicle are you using?

Hrm, I'm using a Zamack transport (open). Maybe the behavior is different when a driver is present? I've only tested this with an empty vehicle and putting the AI in the passenger seat.

i'm pretty sure bailing out of the vehicle is part of the danger fsm, so disableai "FSM" might work?

That's the first thing I tried! Unfortunately the AI still has some sort of brain when the FSM is disabled.

Share this post


Link to post
Share on other sites

The results are the same for me whether the truck has a driver or not.

Scratch that - the AI in the vehicle were friendly to me. When I make them hostile they do actually disembark. I'd go with the getOut eventhandler.

Edited by 2nd Ranger

Share this post


Link to post
Share on other sites

Try this:

[color="#FF8040"]KK_fnc_allowCrewInImmobile [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
[color="#000000"]_this[/color] [color="#191970"][b]allowCrewInImmobile[/b][/color] [color="#000000"]true[/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]{[/b][/color]
	[color="#000000"]_x[/color] [color="#191970"][b]disableAI[/b][/color] [color="#7A7A7A"]"FSM"[/color][color="#8B3E2F"][b];[/b][/color]
	[color="#000000"]_x[/color] [color="#191970"][b]setBehaviour[/b][/color] [color="#7A7A7A"]"CARELESS"[/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color] [color="#191970"][b]forEach[/b][/color] [color="#191970"][b]crew[/b][/color] [color="#000000"]_this[/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color]

[color="#006400"][i]//example[/i][/color]
car [color="#191970"][b]call[/b][/color] KK_fnc_allowCrewInImmobile[color="#8B3E2F"][b];[/b][/color][/color]

Made with KK's SQF to BBCode Converter

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  

×