I was curious what would it be like to make the sliding doors in Arma 3 hospital building to open and close automatically. After a few lines of really bad code it actually didn’t look too bad:

But then you guys who watched the video started asking for this bad code, so I’ve decided to do a proper job this time. The function I’ve constructed will first assemble the hospital building from 3 available hospital parts. You only need to supply function with direction you want the hospital facing and position. Then the function will add 3 triggers, one for each sliding door (can’t seem to stop using triggers now).

The triggers should react to anyone (even zombies) and open doors. I’ve specifically constructed this function to be run on a dedicated server. The reason for this is that only server will operate the doors to avoid potential client code clashes when several people are in proximity. Also the building should be built only once, and this is again could be easily done if function is executed on dedicated server. You can however just paste the code in Arma 3 debug console in editor to test it, it will also work. Mind you, you will need a very large flat surface. And here is the code:

KK_fnc_buildHospital = { private ["_hs","_var"]; _hs = createVehicle ["Land_Hospital_main_F", [0,0,0], [], 0, "NONE"]; _hs setDir (_this select 0); _hs setPosATL (_this select 1); _var = createVehicle ["Land_Hospital_side1_F", [0,0,0], [], 0, "NONE"]; _var attachTo [_hs, [4.69775,32.6045,-0.1125]]; detach _var; _var = createVehicle ["Land_Hospital_side2_F", [0,0,0], [], 0, "NONE"]; _var attachTo [_hs, [-28.0336,-10.0317,0.0889387]]; detach _var; { _var = createTrigger [ "EmptyDetector", _hs modelToWorld _x ]; _var setVariable ["parent", _hs]; _var setTriggerArea [5, 5, 0, false]; _var setTriggerActivation ["ANY", "PRESENT", true]; _var setTriggerStatements [ "this", format [ " (thisTrigger getVariable 'parent') animate ['Door_%1A_move', 1]; (thisTrigger getVariable 'parent') animate ['Door_%1B_move', 1]; ", _forEachIndex + 2 ], format [ " (thisTrigger getVariable 'parent') animate ['Door_%1A_move', 0]; (thisTrigger getVariable 'parent') animate ['Door_%1B_move', 0]; ", _forEachIndex + 2 ] ]; _hs setVariable [format [ "bis_disabled_Door_%1", _forEachIndex + 2 ], 1, true]; } forEach [ [2.80469,15.7993,-8.47323], [2.78027,7.52686,-8.4725], [-4.17358,-7.89453,-8.4725] ]; };

The array you need to pass to the function is [dir, pos]. And here is some sample code:

[45, player modelToWorld [0, 50, 0.25]] call KK_fnc_buildHospital;

Enjoy,
KK

EDIT: And just in case you would like to add automation to the existing hospital in Kavala on Altis, use this code on the server:

call { if (!isDedicated || worldName != "Altis") exitWith {}; private ["_hs","_var"]; _hs = [3760,12990,0] nearestObject "Land_Hospital_main_F"; { _var = createTrigger [ "EmptyDetector", _hs modelToWorld _x ]; _var setVariable ["parent", _hs]; _var setTriggerArea [5, 5, 0, false]; _var setTriggerActivation ["ANY", "PRESENT", true]; _var setTriggerStatements [ "this", format [ " (thisTrigger getVariable 'parent') animate ['Door_%1A_move', 1]; (thisTrigger getVariable 'parent') animate ['Door_%1B_move', 1]; ", _forEachIndex + 2 ], format [ " (thisTrigger getVariable 'parent') animate ['Door_%1A_move', 0]; (thisTrigger getVariable 'parent') animate ['Door_%1B_move', 0]; ", _forEachIndex + 2 ] ]; _hs setVariable [format [ "bis_disabled_Door_%1", _forEachIndex + 2 ], 1, true]; } forEach [ [2.80469,15.7993,-8.47323], [2.78027,7.52686,-8.4725], [-4.17358,-7.89453,-8.4725] ]; };

EDIT2: Replaced attachTo offset used in KK_fnc_buildHospital with more precise one, obtained via automatic object positioning.

More: Airport Terminal