fn_Quiksilver 1633 Posted July 2, 2021 Have this code block sitting un-used on my PC , might as well publish. Mainly for scenarios with player-driven armored vehicles where flying tanks is an issue. Problem: - Tracked vehicles can go flying with unfortunate collision with other objects Solution: - Periodically save the tanks position - Detect when tank is flying - Restore tank to saved position Things to improve upon: - Detect if the previously saved position is still safe. If not , place nearby instead. // initPlayerLocal.sqf // Execute on client machine QS_tankFix_enabled = TRUE; QS_tankFix_safeScript = scriptNull; QS_tankFix_safeOrientation = [[0,[0,0,0],[[0,0,0],[0,0,0]]],[0,[0,0,0],[[0,0,0],[0,0,0]]]]; QS_tankFix_EH_EachFrame = -1; QS_tankFix_EH_GetInMan = player addEventHandler [ 'GetInMan', { params ['','','_enteredVehicle']; if (_enteredVehicle isKindOf 'Tank') then { QS_tankFix_EH_EachFrame = addMissionEventHandler [ 'EachFrame', { if (QS_tankFix_enabled) then { _vehicle = objectParent player; if ( (alive _vehicle) && {(local _vehicle)} && {(isNull (attachedTo _vehicle))} && {(isNull (ropeAttachedTo _vehicle))} && {(isNull (isVehicleCargo _vehicle))} ) then { if (((velocity _vehicle) # 2) > 10) then { if (!isTouchingGround _vehicle) then { if (scriptDone QS_tankFix_safeScript) then { QS_tankFix_safeScript = [_vehicle,QS_tankFix_safeOrientation # 0] spawn { uiSleep 1; params ['_vehicle','_safeOrientation']; private _safePos = _safeOrientation # 1; _safePos set [2,((_safePos # 2) + 7.5)]; _vehicle setPosWorld _safePos; _vehicle setVectorDirAndUp (_safeOrientation # 2); }; }; }; } else { if (diag_tickTime > ((QS_tankFix_safeOrientation # 1) # 0)) then { QS_tankFix_safeOrientation deleteAt 0; QS_tankFix_safeOrientation pushBack [diag_tickTime + 1,getPosWorld _vehicle,[vectorDir _vehicle,vectorUp _vehicle]]; }; }; }; }; } ]; }; } ]; QS_tankFix_EH_GetOutMan = player addEventHandler [ 'GetOutMan', { params ['','','_exitedVehicle']; if (QS_tankFix_EH_EachFrame isNotEqualTo -1) then { removeMissionEventHandler ['EachFrame',QS_tankFix_EH_EachFrame]; QS_tankFix_EH_EachFrame = -1; }; } ]; QS_tankFix_EH_Killed = player addEventHandler [ 'Killed', { if (QS_tankFix_EH_EachFrame isNotEqualTo -1) then { removeMissionEventHandler ['EachFrame',QS_tankFix_EH_EachFrame]; QS_tankFix_EH_EachFrame = -1; }; } ]; 3 2 Share this post Link to post Share on other sites
LSValmont 789 Posted July 2, 2021 3 hours ago, fn_Quiksilver said: Have this code block sitting un-used on my PC , might as well publish. Mainly for scenarios with player-driven armored vehicles where flying tanks is an issue. Problem: - Tracked vehicles can go flying with unfortunate collision with other objects Solution: - Periodically save the tanks position - Detect when tank is flying - Restore tank to saved position Things to improve upon: - Detect if the previously saved position is still safe. If not , place nearby instead. Very nice and much need contribution. Quick question: Wouldn't this https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#EpeContactEnd do the work as well instead of addMissionEventHandler 'EachFrame',? Share this post Link to post Share on other sites
fn_Quiksilver 1633 Posted July 4, 2021 On 7/2/2021 at 3:54 PM, LSValmont said: Very nice and much need contribution. Quick question: Wouldn't this https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#EpeContactEnd do the work as well instead of addMissionEventHandler 'EachFrame',? you need a saved position to restore the vehicle to. so you need to monitor the vehicle and poll its position every few seconds (in this case the rewind is 2 seconds). I have not run tests with epecontact events as its rather hard to reproduce the flying tank issue in many of the ways it manifests ... you would have to spawn a thread to check the velocities for a number of frames after each event triggering. I've edited it slightly to optimize it, so that it only runs the EachFrame component when actually in a tank. 1 Share this post Link to post Share on other sites