Jump to content
davidoss

[RELEASE] Vehicle autoflip

Recommended Posts

HI.

Maybe someone can find this usable.

This script add possibility to automatically turn back vehicle on wheels once flipped.
To event take place vehicle needs to be side/up flipped and empty and no units in 10m around.

 

/*
file: autoflip.sqf
by DaVidoSS
add possibility to automatically turn back vehicle on wheels once flipped
to event take place vehicle needs to be side/up flipped and empty and no units in 10m around

parameters:
0: OBJECT
return VOID
usage:

if (isServer) then {
	0 = [_vehicle] execVM "autoflip.sqf";
};

*/

params [["_vehicle",objNull,[objNull]]];

if (!isServer) exitWith {};
if (!((getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "hasDriver")) isEqualTo 1)) exitWith {};

_vehicle addEventHandler ["GetOut", {
	private _vehicle = param [0, objNull, [objNull]];
	if !((crew _vehicle) isEqualTo []) exitWith {}; 
	(_vehicle call BIS_fnc_getPitchBank) params ["_vx","_vy"];
	if (([_vx,_vy] findIf {_x > 80 || _x < -80}) != -1) then {	
		0 = [_vehicle] spawn {
			private _vehicle = param [0, objNull, [objNull]];
			waitUntil {(_vehicle nearEntities ["Man", 10]) isEqualTo [] || !alive _vehicle};
			if (!alive _vehicle) exitWith {};
			_vehicle allowDamage false;
			_vehicle setVectorUp [0,0,1];
			_vehicle setPosATL [(getPosATL _vehicle) select 0, (getPosATL _vehicle) select 1, 0];
			_vehicle allowDamage true;
		};
	};
}];

 

  • Like 1
  • Thanks 3

Share this post


Link to post
Share on other sites

All of your scripts are brilliant. Could you release them in mini mod format too? 

Share this post


Link to post
Share on other sites

Oh come on its not brilliant i am sure them all could be better.

I have a big archive with scripts/functions and now i improving them and release.

Maybe at end of this process i gather them into mod, we will see.

  • Like 1

Share this post


Link to post
Share on other sites

can be called  for every vehicle ,ai, player, crew empty.

Basically i always use this using  init/initpost XEH for every vehicle

Share this post


Link to post
Share on other sites

@davidoss  or anyone else does this still work. I made a autoflip.sqf put code into it and dropped the autoflip.sqf into mission. its not working. Do I need to call it other way. Looking for a script to unflip AI  vehicle in a mission. Thanks AVIBIRD

Share this post


Link to post
Share on other sites

Can't get this to work. How would incall the script. Do I just need the code in code in a Autoflip.sqf in my mission folder or do I need to call it in another way. Thanks avibird. The is for AI vehicles 

Share this post


Link to post
Share on other sites

As davidoss doesn't seem to be on line since 2020, base on his "getout approach", you could try something like that:

 

MGI_fnc_unFlip = compileFinal "
  params [['_veh',objNull,[objNull]]];
  _veh allowCrewInImmobile[isAllowedCrewInImmobile _veh,FALSE];
  _veh addEventHandler ['GetOut', {
    params ['_veh'];
    if ((vectorUp _veh) vectorCos (surfaceNormal getPos _veh) <0.5) then {
      _veh allowDamage false;
      _veh setVectorUp [0,0,1];
      _veh setPosATL [(getPosATL _veh) select 0, (getPosATL _veh) select 1, 0];
      _veh allowDamage true;
    };
  }];
";

{_x call MGI_fnc_unFlip} forEach (vehicles select {_x isKindOf "landVehicle"});

addMissionEventHandler ["entityCreated", {
  params ["_obj"];
  if (_obj isKindOf "landVehicle") then {
    _obj call MGI_fnc_unFlip
  };
}];

 

different from my unflip module, based on addAction for player(s), and simplified.

  • Thanks 1

Share this post


Link to post
Share on other sites

Thank you brother for the assist works great for AI flipped vehicles. 

 

I called the script in a gamelogic module and using a unflip.sqf calling the script via my mission.init  execVM "unflipvehicle.sqf";

 

To see if there is any performance difference with the script or lag both work great no real difference. 

 

Flip on the side does not unflip all the time I guess it's based on the angle the vehicle is on. 

Share this post


Link to post
Share on other sites

Maybe I'll get a golden shovel, but... Pierremgi, the script works fine, only the stupid AI commander doesn't give the order to get back in. Is there a chance to fix this?

Share this post


Link to post
Share on other sites

@piter306 it's works fine for me. The only issues that I see if the vehicle is on its side or angled straight up like after falling off a bridge the script does not work. But if the vehicle is on its back 100% of the time it works in seconds.

 

There is a liability mod on steam workshop that works great. It does not allow  infantry units on patrol to get killed by poor AI driving.  If you are going to design a mission with vehicle patrols and vehicle patrols these two scripts/mods are need or you will have a bunch of vehicle crew members running around and a bunch of infantry patrol units with have of the units already dead on the ground from being run over. 

 

Hopefully these issues will be addressed in armA4  for it's certainly has never been addressed for arma3 with updates. Avibird 

Share this post


Link to post
Share on other sites

Script working good, my point is that the crew gets off after the vehicle capsizes and is not ordered to get back on when it is already on its wheels 🙂

I won't buy a new Arma unless I see a rebuilt AI that works better

Share this post


Link to post
Share on other sites

@piter306 the script works as intended for me. The only time the script does not work perfectly if the vehicle does not flip completely on its back or on its side. If the vehicle is vertically straight up like falling off the bridge any angle is not completely on its side or its back then the crew members sometimes will not jump out or if they do they won't get back in. This happens for a really only when it's really wood falls off a bridge and like I said it's not on its back or completely on its side. 

 

I don't know what you're talking about this was never in the vanilla game this is modification to improve some of the vanilla shortcomings of the game. 

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

×