2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-05-09 02:47:15 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
2015-09-28 15:11:53 +00:00
|
|
|
* Open door.
|
2015-05-09 02:47:15 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: House <OBJECT>
|
|
|
|
* 1: Door <STRING>
|
|
|
|
*
|
2015-09-28 16:06:25 +00:00
|
|
|
* Return Value:
|
2015-05-09 02:47:15 +00:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [house, "door"] call ace_interaction_fnc_openDoor
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _info = [MACRO_DOOR_REACH_DISTANCE] call FUNC(getDoor);
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2015-09-28 15:11:53 +00:00
|
|
|
_info params ["_house", "_door"];
|
2017-07-08 18:23:28 +00:00
|
|
|
TRACE_2("openDoor",_house,_door);
|
2015-01-11 19:32:51 +00:00
|
|
|
|
|
|
|
if (isNull _house) exitWith {};
|
|
|
|
|
2021-02-18 18:58:08 +00:00
|
|
|
if ((configProperties [configOf _house >> "UserActions"]) isEqualTo []) exitWith {
|
2019-01-02 15:55:03 +00:00
|
|
|
TRACE_1("Ignore houses with no UserActions",typeOf _house); // Fix problem with Shoothouse Walls
|
|
|
|
};
|
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _getDoorAnimations = [_house, _door] call FUNC(getDoorAnimations);
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2017-07-08 18:23:28 +00:00
|
|
|
_getDoorAnimations params ["_animations"];
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2015-09-28 15:11:53 +00:00
|
|
|
if (_animations isEqualTo []) exitWith {};
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2017-07-08 18:23:28 +00:00
|
|
|
private _lockedVariable = format ["bis_disabled_%1", _door];
|
2023-04-30 21:56:39 +00:00
|
|
|
private _lockedVariableAlt = _lockedVariable; // GM Buildings may have door names like door_01 but locking expects door_1
|
|
|
|
if ((count _door == 7) && {(_door select [0, 6]) == "door_0"}) then {
|
|
|
|
_lockedVariableAlt = format ["bis_disabled_door_%1", _door select [6, 1]]; // stip off the leading zero then check both vars
|
|
|
|
};
|
2017-07-08 18:23:28 +00:00
|
|
|
|
2017-09-11 22:33:58 +00:00
|
|
|
// Check if the door can be locked aka have locked variable, otherwhise cant lock it
|
2023-04-30 21:56:39 +00:00
|
|
|
if ((_house animationPhase (_animations select 0) <= 0) &&
|
|
|
|
{(_house getVariable [_lockedVariable, 0] == 1) || {_house getVariable [_lockedVariableAlt, 0] == 1}}) exitWith {
|
2017-07-08 18:23:28 +00:00
|
|
|
private _lockedAnimation = format ["%1_locked_source", _door];
|
2021-02-18 18:58:08 +00:00
|
|
|
TRACE_3("locked",_house,_lockedAnimation,isClass (configOf _house >> "AnimationSources" >> _lockedAnimation));
|
|
|
|
if (isClass (configOf _house >> "AnimationSources" >> _lockedAnimation)) then {
|
2017-07-08 18:23:28 +00:00
|
|
|
// from: a3\structures_f\scripts\fn_door.sqf: - wiggles the door handle (A3 buildings)
|
|
|
|
_house animateSource [_lockedAnimation, (1 - (_house animationSourcePhase _lockedAnimation))];
|
2017-06-02 21:50:53 +00:00
|
|
|
};
|
2015-01-11 19:32:51 +00:00
|
|
|
};
|
|
|
|
|
2017-09-11 22:33:58 +00:00
|
|
|
// Add handle on carrier
|
|
|
|
if (typeOf _house == "Land_Carrier_01_island_01_F") then {
|
2022-05-13 04:24:41 +00:00
|
|
|
private _handle = format ["door_handle_%1_rotate_1", (_animations select 0) select [5, 1]];
|
2017-09-11 22:33:58 +00:00
|
|
|
TRACE_1("carrier handle",_handle);
|
|
|
|
_animations pushBack _handle;
|
|
|
|
};
|
|
|
|
|
2015-09-28 15:11:53 +00:00
|
|
|
playSound "ACE_Sound_Click"; // @todo replace with smth. more fitting
|
|
|
|
|
2015-09-28 18:07:01 +00:00
|
|
|
GVAR(doorTargetPhase) = _house animationPhase (_animations select 0);
|
|
|
|
GVAR(isOpeningDoor) = true;
|
|
|
|
GVAR(usedScrollWheel) = false;
|
2015-09-28 15:11:53 +00:00
|
|
|
|
2015-09-28 18:07:01 +00:00
|
|
|
[{
|
|
|
|
(_this select 0) params ["_house", "_animations", "_position", "_time", "_frame"];
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2015-09-28 18:07:01 +00:00
|
|
|
if !(GVAR(isOpeningDoor)) exitWith {
|
|
|
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2015-09-28 18:07:01 +00:00
|
|
|
// didn't use incremental opening. Just do animation normally.
|
|
|
|
if !(GVAR(usedScrollWheel)) then {
|
2016-09-04 14:44:22 +00:00
|
|
|
private _phase = [0, 1] select (_house animationPhase (_animations select 0) < 0.5);
|
2015-09-28 15:11:53 +00:00
|
|
|
|
2015-09-28 18:07:01 +00:00
|
|
|
{_house animate [_x, _phase]; false} count _animations;
|
2015-04-06 16:22:43 +00:00
|
|
|
};
|
|
|
|
};
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2015-09-28 18:07:01 +00:00
|
|
|
// check if player moved too far away
|
|
|
|
if (getPosASL ACE_player distance _position > 1) exitWith {
|
|
|
|
GVAR(isOpeningDoor) = false;
|
|
|
|
};
|
2015-01-11 19:32:51 +00:00
|
|
|
|
2015-09-28 18:07:01 +00:00
|
|
|
// this allows for holding the door in it's current state.
|
2016-03-02 10:01:39 +00:00
|
|
|
if (CBA_missionTime > _time && {diag_frameno > _frame}) then {
|
2015-09-28 18:07:01 +00:00
|
|
|
GVAR(usedScrollWheel) = true;
|
2015-04-06 16:22:43 +00:00
|
|
|
};
|
2015-09-28 18:07:01 +00:00
|
|
|
// do incremental door opening
|
|
|
|
{_house animate [_x, GVAR(doorTargetPhase)]; false} count _animations;
|
2016-03-02 10:01:39 +00:00
|
|
|
}, 0.1, [_house, _animations, getPosASL ACE_player, CBA_missionTime + 0.2, diag_frameno + 2]] call CBA_fnc_addPerFrameHandler;
|