From f48636e63395a8cfa0150446ec522016b4554429 Mon Sep 17 00:00:00 2001 From: commy2 Date: Mon, 28 Sep 2015 17:11:53 +0200 Subject: [PATCH] more interaction cleanup, remove dead code --- addons/interaction/CfgVehicles.hpp | 2 +- addons/interaction/XEH_postInit.sqf | 26 +++++++ addons/interaction/XEH_preInit.sqf | 50 +++++++------- .../functions/fnc_addSelectableItem.sqf | 33 --------- .../functions/fnc_canTapShoulder.sqf | 6 +- addons/interaction/functions/fnc_getDoor.sqf | 10 +-- .../functions/fnc_getDoorAnimations.sqf | 6 +- addons/interaction/functions/fnc_getDown.sqf | 32 ++++----- .../functions/fnc_getSelectedButton.sqf | 38 ----------- addons/interaction/functions/fnc_hideMenu.sqf | 22 ------ .../interaction/functions/fnc_isInRange.sqf | 53 --------------- addons/interaction/functions/fnc_moveDown.sqf | 67 ------------------- .../interaction/functions/fnc_onButtonUp.sqf | 44 ------------ addons/interaction/functions/fnc_onClick.sqf | 57 ---------------- .../functions/fnc_onSelectMenuDblClick.sqf | 18 ----- addons/interaction/functions/fnc_openDoor.sqf | 26 +++---- .../functions/fnc_openMenuSelectUI.sqf | 57 ---------------- .../functions/fnc_openSelectMenu.sqf | 49 -------------- .../functions/fnc_prepareSelectMenu.sqf | 33 --------- addons/interaction/functions/fnc_sendAway.sqf | 39 +++++------ .../functions/fnc_sortOptionsByPriority.sqf | 35 ---------- .../interaction/functions/fnc_tapShoulder.sqf | 26 ++----- .../functions/fnc_updateTooltipPosition.sqf | 33 --------- 23 files changed, 115 insertions(+), 647 deletions(-) delete mode 100644 addons/interaction/functions/fnc_addSelectableItem.sqf delete mode 100644 addons/interaction/functions/fnc_getSelectedButton.sqf delete mode 100644 addons/interaction/functions/fnc_hideMenu.sqf delete mode 100644 addons/interaction/functions/fnc_isInRange.sqf delete mode 100644 addons/interaction/functions/fnc_moveDown.sqf delete mode 100644 addons/interaction/functions/fnc_onButtonUp.sqf delete mode 100644 addons/interaction/functions/fnc_onClick.sqf delete mode 100644 addons/interaction/functions/fnc_onSelectMenuDblClick.sqf delete mode 100644 addons/interaction/functions/fnc_openMenuSelectUI.sqf delete mode 100644 addons/interaction/functions/fnc_openSelectMenu.sqf delete mode 100644 addons/interaction/functions/fnc_prepareSelectMenu.sqf delete mode 100644 addons/interaction/functions/fnc_sortOptionsByPriority.sqf delete mode 100644 addons/interaction/functions/fnc_updateTooltipPosition.sqf diff --git a/addons/interaction/CfgVehicles.hpp b/addons/interaction/CfgVehicles.hpp index 9372d3410c..e844da9517 100644 --- a/addons/interaction/CfgVehicles.hpp +++ b/addons/interaction/CfgVehicles.hpp @@ -167,7 +167,7 @@ class CfgVehicles { }; class ACE_Weapon { displayName = CSTRING(Weapon); - position = QUOTE(call FUNC(getWeaponPos)); + position = QUOTE(call DFUNC(getWeaponPos)); distance = 1.50; condition = ""; statement = ""; diff --git a/addons/interaction/XEH_postInit.sqf b/addons/interaction/XEH_postInit.sqf index 7b264db3c9..aeee004e7d 100644 --- a/addons/interaction/XEH_postInit.sqf +++ b/addons/interaction/XEH_postInit.sqf @@ -3,8 +3,34 @@ ACE_Modifier = 0; +["getDown", { + params ["_target"]; + + _target setUnitPos "DOWN"; +}] call EFUNC(common,addEventHandler); + +["sendAway", { + params ["_unit", "_position"]; + + _unit setUnitPos "AUTO"; + _unit doMove _position; +}] call EFUNC(common,addEventHandler); + if (!hasInterface) exitWith {}; +["tapShoulder", { + params ["_unit", "_shoulderNum"]; + + if (_unit == ACE_player) then { + addCamShake [4, 0.5, 5]; + }; + + private "_message"; + _message = parseText format ([["%1 >", localize LSTRING(YouWereTappedRight)], ["< %1", localize LSTRING(YouWereTappedLeft)]] select (_shoulderNum == 0)); + + ["displayTextStructured", _message] call EFUNC(common,targetEvent); +}] call EFUNC(common,addEventHandler); + GVAR(isOpeningDoor) = false; // restore global fire teams for JIP diff --git a/addons/interaction/XEH_preInit.sqf b/addons/interaction/XEH_preInit.sqf index c2534b44b9..a460fdeadd 100644 --- a/addons/interaction/XEH_preInit.sqf +++ b/addons/interaction/XEH_preInit.sqf @@ -2,37 +2,35 @@ ADDON = false; -PREP(addPassengerActions); +// interaction menu +PREP(addPassengerActions) PREP(addPassengersActions); -PREP(addSelectableItem); -PREP(applyButtons); -PREP(canBecomeLeader); +PREP(getWeaponPos); +PREP(moduleInteraction); +PREP(removeTag); + +// scroll wheel hint +PREP(showMouseHint); +PREP(hideMouseHint); + +// interaction with units PREP(canInteractWithCivilian); +PREP(getDown); +PREP(sendAway); PREP(canJoinGroup); PREP(canJoinTeam); -PREP(canTapShoulder); -PREP(doBecomeLeader); -PREP(getDoor); -PREP(getDoorAnimations); -PREP(getDown); -PREP(getSelectedButton); -PREP(getWeaponPos); -PREP(hideMenu); -PREP(hideMouseHint); -PREP(isInRange); PREP(joinTeam); -PREP(moduleInteraction); -PREP(moveDown); -PREP(onSelectMenuDblClick); -PREP(openDoor); -PREP(openMenuSelectUI); -PREP(openSelectMenu); -PREP(prepareSelectMenu); -PREP(push); -PREP(removeTag); -PREP(sendAway); -PREP(showMouseHint); -PREP(sortOptionsByPriority); +PREP(canBecomeLeader); +PREP(doBecomeLeader); +PREP(canTapShoulder); PREP(tapShoulder); +// interaction with doors +PREP(getDoor); +PREP(getDoorAnimations); +PREP(openDoor); + +// interaction with boats +PREP(push); + ADDON = true; diff --git a/addons/interaction/functions/fnc_addSelectableItem.sqf b/addons/interaction/functions/fnc_addSelectableItem.sqf deleted file mode 100644 index 3a0607dc88..0000000000 --- a/addons/interaction/functions/fnc_addSelectableItem.sqf +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Author: Garth de Wet (LH) - * Adds an item to the select menu. - * - * Arguments: - * 0: List container - * 1: Display name - * 2: Picture - * 3: Data - * - * Return Value: - * Container - * - * Example: - * [actions, "Banana", "UI\dot_ca.paa", "bananaContents"] call ace_interaction_fnc_addSelectableItem - * - * Public: No - */ -#include "script_component.hpp" - -params ["_container", "_displayName", "_picture", "_data"]; - -if (toLower _picture in ["", "picturething"]) then { - _picture = QUOTE(PATHTOF(UI\dot_ca.paa)); -}; - -private "_index"; -_index = lbAdd [_container, _displayName]; - -lbSetData [_container, _index, str _data]; -lbSetPicture [_container, _index, _picture]; - -_container diff --git a/addons/interaction/functions/fnc_canTapShoulder.sqf b/addons/interaction/functions/fnc_canTapShoulder.sqf index bbeee51b4a..a2b70e4959 100644 --- a/addons/interaction/functions/fnc_canTapShoulder.sqf +++ b/addons/interaction/functions/fnc_canTapShoulder.sqf @@ -1,6 +1,6 @@ /* * Author: commy2 - * Checks if the player can tap a shoulder + * Checks if the player can tap a shoulder. * * Arguments: * 0: Player @@ -16,9 +16,9 @@ */ #include "script_component.hpp" -PARAMS_2(_unit,_target); +params ["_unit", "_target"]; _target isKindOf "CAManBase" && {alive _target} && {_unit distance _target < 4} && -{!(_target getVariable ["ACE_isUnconscious", false])} +{!(_target getVariable ["ACE_isUnconscious", false])} // return diff --git a/addons/interaction/functions/fnc_getDoor.sqf b/addons/interaction/functions/fnc_getDoor.sqf index a085c9a3b8..6b1134675d 100644 --- a/addons/interaction/functions/fnc_getDoor.sqf +++ b/addons/interaction/functions/fnc_getDoor.sqf @@ -1,11 +1,11 @@ /* * Author: commy2 - * Get door + * Find door. * * Arguments: * 0: Distance * - * Return value: + * Return Value: * House objects and door * 0: House * 1: Door Name @@ -17,16 +17,17 @@ */ #include "script_component.hpp" -PARAMS_1(_distance); +params ["_distance"]; private ["_position0", "_position1", "_intersections", "_count", "_house", "_door"]; _position0 = positionCameraToWorld [0, 0, 0]; _position1 = positionCameraToWorld [0, 0, _distance]; -_intersections = lineIntersectsWith [ATLToASL _position0, ATLToASL _position1, objNull, objNull, true]; +_intersections = lineIntersectsWith [AGLToASL _position0, AGLToASL _position1, objNull, objNull, true]; // @todo LIS _count = count _intersections; + if (_count == 0) exitWith {[objNull, ""]}; _house = _intersections select (_count - 1); @@ -37,6 +38,7 @@ if (typeOf _house == "") exitWith {[objNull, ""]}; _intersections = [_house, "GEOM"] intersect [_position0, _position1]; _door = _intersections select 0 select 0; + if (isNil "_door") exitWith {[_house, ""]}; [_house, _door] diff --git a/addons/interaction/functions/fnc_getDoorAnimations.sqf b/addons/interaction/functions/fnc_getDoorAnimations.sqf index 0de74e61ed..fac29c74a8 100644 --- a/addons/interaction/functions/fnc_getDoorAnimations.sqf +++ b/addons/interaction/functions/fnc_getDoorAnimations.sqf @@ -1,12 +1,12 @@ /* * Author: commy2 - * Get door animations + * Get door animations. @todo rewrite for better custom building support * * Arguments: * 0: House * 1: Door * - * Return value: + * Return Value: * Animation and Locked variable * 0: Animation * 1: Locked variable @@ -18,7 +18,7 @@ */ #include "script_component.hpp" -PARAMS_2(_house,_door); +params ["_house", "_door"]; private ["_index", "_animations", "_lockedVariable"]; diff --git a/addons/interaction/functions/fnc_getDown.sqf b/addons/interaction/functions/fnc_getDown.sqf index 09d651eadf..b380fe9c39 100644 --- a/addons/interaction/functions/fnc_getDown.sqf +++ b/addons/interaction/functions/fnc_getDown.sqf @@ -1,6 +1,6 @@ /* - * Author: KoffeinFlummi - * Forces a civilian to the ground (with a chance of failure) + * Author: KoffeinFlummi, commy2 + * Forces a civilian to the ground with a chance of failure. * * Arguments: * 0: Unit @@ -9,30 +9,24 @@ * None * * Example: - * [target] call ace_interaction_fnc_getDown + * [civillian] call ace_interaction_fnc_getDown * * Public: No */ #include "script_component.hpp" -#define RADIUS 10 +#define SEND_RADIUS 10 -PARAMS_1(_unit); +params ["_unit"]; -private ["_chance", "_x"]; +_unit playActionNow "GestureGo"; -ACE_player playActionNow "GestureGo"; // put something else here. - -if (count (weapons ACE_player) > 0) then { - _chance = 0.8; -} else { - _chance = 0.5; -}; +private "_chance"; +_chance = [0.5, 0.8] select (count weapons _unit > 0); { - if (count (weapons _unit) == 0 and random 1 < _chance) then { - [-2, { - _this setUnitPos "DOWN"; - }, _x] call CBA_fnc_globalExecute; - }; -} forEach (_unit nearEntities ["Civilian", RADIUS]); + if (count weapons _x == 0 && {random 1 < _chance}) then { + ["getDown", [_x], [_x]] call EFUNC(common,targetEvent); + }; + false +} count (_unit nearEntities ["Civilian", SEND_RADIUS]); diff --git a/addons/interaction/functions/fnc_getSelectedButton.sqf b/addons/interaction/functions/fnc_getSelectedButton.sqf deleted file mode 100644 index 92768b67f7..0000000000 --- a/addons/interaction/functions/fnc_getSelectedButton.sqf +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Author: commy2 - * Get selected button - * - * Arguments: - * None - * - * Return value: - * Angle - * - * Example: - * call ace_interaction_fnc_getSelectedButton - * - * Public: No - */ -#include "script_component.hpp" - -#define MIN_DISTANCE 0.0065 - -private ["_position", "_distance", "_angle"]; - -_position = uiNamespace getVariable [QGVAR(CursorPosition), [0.5, 0.5, 0]]; - -_position = [((_position select 1) - 0.5) / safezoneH, ((_position select 2) - 0.5) / safezoneW, 0]; - -_distance = [0, 0, 0] vectorDistanceSqr _position; - -// is in center -if (_distance < MIN_DISTANCE) exitWith {-1}; - -_angle = (_position select 0) atan2 (_position select 1); - -// rotate circle -_angle = 180 - _angle + 360 / 10 / 2; -if (_angle < 0) then {_angle = _angle + 360}; - -_angle = floor (_angle / 360 * 10); -if (_angle == 10) then {0} else {_angle} diff --git a/addons/interaction/functions/fnc_hideMenu.sqf b/addons/interaction/functions/fnc_hideMenu.sqf deleted file mode 100644 index 89dc49be40..0000000000 --- a/addons/interaction/functions/fnc_hideMenu.sqf +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Author: Garth de Wet (LH) - * Closes the Interaction menu - * - * Arguments: - * None - * - * Return value: - * None - * - * Example: - * call ace_interaction_fnc_hideMenu - * - * Public: No - */ -#include "script_component.hpp" - -closeDialog 0; -(findDisplay 1713999) closeDisplay 1; -(uiNameSpace getVariable QGVAR(Flow_Display)) closeDisplay 0; -GVAR(MainButton) = nil; -call FUNC(hideMouseHint); diff --git a/addons/interaction/functions/fnc_isInRange.sqf b/addons/interaction/functions/fnc_isInRange.sqf deleted file mode 100644 index 49ac391871..0000000000 --- a/addons/interaction/functions/fnc_isInRange.sqf +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Author: commy2 - * Check if the vehicle is in range of the player. - * - * Arguments: - * 0: Vehicle - * 1: Distance in meters - * - * Return value: - * Vehicle in range of player - * - * Example: - * [target, 5] call ace_interaction_fnc_isInRange - * - * Public: No - */ -#include "script_component.hpp" - -PARAMS_2(_vehicle,_distance); - -private ["_player", "_position0", "_position1"]; - -_player = ACE_player; - -if (_vehicle isKindOf "Man") exitWith {_player distance _vehicle < _distance}; - -private ["_position0", "_position1"];//, "_direction"]; - -_position0 = getPosASL _player; -_position1 = getPosASL _vehicle; - -/* -_direction = _position1 vectorDiff _position0; -_direction = _direction vectorMultiply (_distance / (vectorMagnitude _direction)); - -_position0 = eyePos _player; -_position1 = _position0 vectorAdd _direction; - -_vehicle in lineIntersectsWith [_position0, _position1] || {_player distance _vehicle < _distance} -*/ - -_position0 = ATLToASL positionCameraToWorld [0, 0, 0]; -_position0 set [2, (_position0 select 2) - (getTerrainHeightASL _position0 min 0)]; - -_position1 = ATLToASL positionCameraToWorld [0, 0, _distance]; -_position1 set [2, (_position1 select 2) - (getTerrainHeightASL _position1 min 0)]; - -if (_vehicle in lineIntersectsWith [_position0, _position1] || {_player distance _vehicle < _distance}) then { - true -} else { - ["Not in Range"] call FUNC(addToTooltip); - false -} diff --git a/addons/interaction/functions/fnc_moveDown.sqf b/addons/interaction/functions/fnc_moveDown.sqf deleted file mode 100644 index 235f12fb1f..0000000000 --- a/addons/interaction/functions/fnc_moveDown.sqf +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Author: Garth de Wet (LH) - * Scrolls through the list down or up - * - * Arguments: - * 0: Amount - * - * Return value: - * None - * - * Example: - * [2] call ace_interaction_fnc_moveDown - * - * Public: No - */ -#include "script_component.hpp" - -private ["_count", "_player", "_vehicle", "_dlgInteractionDialog", "_top", "_i", "", "_ctrl", "_index", "_action", "_color", "_current", "_infoText", "_target"]; - -#define CLAMP(x,low,high) (if(x > high)then{high}else{if(x < low)then{low}else{x}}) -if (isNil QGVAR(MainButton)) exitWith{}; -if (isNil QGVAR(Buttons)) exitWith{}; -_count = (count GVAR(Buttons))- 1; -GVAR(SelectedButton) = CLAMP(GVAR(SelectedButton) + _this, 0, _count); - -_target = GVAR(Target); -_player = ACE_player; -_vehicle = vehicle _player; - -disableSerialization; -_dlgInteractionDialog = uiNamespace getVariable QGVAR(Flow_Display); -_top = GVAR(SelectedButton) - 2; -_i = 0; -while {_i <= 4} do { - _index =_i + _top; - _ctrl = _dlgInteractionDialog displayCtrl (1200 + _i); - if (_index >= 0 && {_index <= _count}) then { - _action = GVAR(Buttons) select _index; - _ctrl ctrlShow true; - _ctrl ctrlSetText (_action select 5); - _color = [1,1,1,1]; - if !([_target, _player] call (_action select 2)) then { - _color = [0.3,0.3,0.3,0.8]; - }; - if (_i == 0 || _i == 4) then { - _color set [3, 0.5]; - }; - if (_i == 1 || _i == 3) then { - _color set [3, 0.75]; - }; - _ctrl ctrlSetTextColor _color; - }else{ - _ctrl ctrlShow false; - }; - _i = _i + 1; -}; - -_ctrl = _dlgInteractionDialog displayCtrl 1000; -_ctrl ctrlSetText ((GVAR(Buttons) select GVAR(SelectedButton)) select 0); -_ctrl = _dlgInteractionDialog displayCtrl 1100; -_current = (GVAR(Buttons) select GVAR(SelectedButton)); -_infoText = ""; -if !([_target, _player] call (_current select 2)) then { - _infoText = "Unavailable"; -}; -_ctrl ctrlSetText _infoText; -_ctrl ctrlShow (_infoText != ""); diff --git a/addons/interaction/functions/fnc_onButtonUp.sqf b/addons/interaction/functions/fnc_onButtonUp.sqf deleted file mode 100644 index da1b55b613..0000000000 --- a/addons/interaction/functions/fnc_onButtonUp.sqf +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Author: commy2 - * On button up - * - * Arguments: - * None - * - * Return value: - * None - * - * Example: - * call ace_interaction_fnc_onButtonUp - * - * Public: No - */ -#include "script_component.hpp" - -private ["_player", "_vehicle", "_target", "_count", "_index", "_action", "_statement", "_condition", "_conditionShow", "_distance"]; - -_player = ACE_player; -_vehicle = vehicle _player; -_target = [GVAR(Target), _player] select (GVAR(MenuType) % 2 == 1); - -_count = count GVAR(Buttons); -_index = call FUNC(getSelectedButton); - -_action = if (_index != -1 && {_index < _count}) then { - GVAR(Buttons) select _index -} else { - ["", {}, {false}, 0, [], "", "", {false}, [], 0] -}; - -(findDisplay 1713999) closeDisplay 1; -closeDialog 0; - - -_statement = _action select 1; -_condition = _action select 2; -_conditionShow = _action select 7; -_distance = _action select 9; - -if ((_distance == 0 || {[GVAR(Target), _distance] call FUNC(isInRange)}) && {[_target, _player] call _condition} && {[_target, _player] call _conditionShow}) then { - [_target, _player] call _statement; -}; diff --git a/addons/interaction/functions/fnc_onClick.sqf b/addons/interaction/functions/fnc_onClick.sqf deleted file mode 100644 index a240823710..0000000000 --- a/addons/interaction/functions/fnc_onClick.sqf +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Author: commy2 - * On click - * - * Arguments: - * Index - * - * Return value: - * None - * - * Example: - * 5 call ace_interaction_fnc_onClick - * - * Public: No - */ -#include "script_component.hpp" -private ["_player", "_vehicle", "_target", "_count", "_index", "_action", "_subMenu", "_statement", "_condition", "_conditionShow", "_distance"]; - -_player = ACE_player; -_vehicle = vehicle _player; -_target = [GVAR(Target), _player] select (GVAR(MenuType) % 2 == 1); - -_count = count GVAR(Buttons); -_index = _this; - -_action = if (_index != -1 && {_index < _count}) then { - GVAR(Buttons) select _index -} else { - ["", {}, {false}, 0, [], "", "", {false}, [], 0] -}; - -_subMenu = _action select 4; - -// back -if (_index == -1) exitWith { - call GVAR(MainButton); -}; - -if (count _subMenu < 2) then { - (findDisplay 1713999) closeDisplay 1; - closeDialog 0; - - _statement = _action select 1; - _condition = _action select 2; - _conditionShow = _action select 7; - _distance = _action select 9; - - if ((_distance == 0 || {[GVAR(Target), _distance] call FUNC(isInRange)}) && {[_target, _player] call _condition} && {[_target, _player] call _conditionShow}) then { - [_target, _player] call _statement; - }; -} else { - if (_subMenu select 1 < 1) then { - [_subMenu select 0] call FUNC(openSubMenu); - } else { - [_subMenu select 0] call FUNC(openSubMenuSelf); - }; -}; diff --git a/addons/interaction/functions/fnc_onSelectMenuDblClick.sqf b/addons/interaction/functions/fnc_onSelectMenuDblClick.sqf deleted file mode 100644 index 18b69ba40d..0000000000 --- a/addons/interaction/functions/fnc_onSelectMenuDblClick.sqf +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Author: CorruptedHeart, commy2 - * On select menu double click - * - * Arguments: - * None - * - * Return value: - * None - * - * Example: - * call ace_interaction_fnc_onSelectMenuDblClick - * - * Public: No - */ -#include "script_component.hpp" - -call compile (lbData [8866, lbCurSel 8866]) call GVAR(SelectAccept); diff --git a/addons/interaction/functions/fnc_openDoor.sqf b/addons/interaction/functions/fnc_openDoor.sqf index 9555502a93..609fa91574 100644 --- a/addons/interaction/functions/fnc_openDoor.sqf +++ b/addons/interaction/functions/fnc_openDoor.sqf @@ -1,6 +1,6 @@ /* * Author: commy2 - * Opens door + * Open door. * * Arguments: * 0: House @@ -16,38 +16,40 @@ */ #include "script_component.hpp" -private ["_info", "_phase", "_position", "_time", "_usedMouseWheel", "_getDoorAnimations"]; - +private "_info"; _info = [MACRO_DOOR_REACH_DISTANCE] call FUNC(getDoor); -EXPLODE_2_PVT(_info,_house,_door); +_info params ["_house", "_door"]; if (isNull _house) exitWith {}; +private "_getDoorAnimations"; _getDoorAnimations = [_house, _door] call FUNC(getDoorAnimations); -EXPLODE_2_PVT(_getDoorAnimations,_animations,_lockedVariable); +_getDoorAnimations params ["_animations", "_lockedVariable"]; -if (count _animations == 0) exitWith {}; +if (_animations isEqualTo []) exitWith {}; if (_house animationPhase (_animations select 0) <= 0 && {_house getVariable [_lockedVariable select 0, 0] == 1}) exitWith { _lockedVariable set [0, _house]; - _lockedVariable spawn compile preprocessFileLineNumbers "\A3\Structures_F\scripts\LockedDoor_open.sqf"; + _lockedVariable spawn compile preprocessFileLineNumbers "\A3\Structures_F\scripts\LockedDoor_open.sqf"; // note: spawn because thats what the house does too. }; GVAR(isOpeningDoor) = true; -playSound "ACE_Sound_Click"; //@todo replace with smth. more fitting -[_house, _animations] spawn { - private ["_house", "_animations", "_phase", "_position", "_time", "_usedMouseWheel"]; - _house = _this select 0; - _animations = _this select 1; +playSound "ACE_Sound_Click"; // @todo replace with smth. more fitting + +[_house, _animations] spawn { // @todo + params ["_house", "_animations"]; + + private ["_phase", "_position", "_time", "_usedMouseWheel"]; _phase = _house animationPhase (_animations select 0); _position = getPosASL ACE_player; _time = ACE_time + 0.2; _usedMouseWheel = false; + waitUntil { if (inputAction "PrevAction" > 0 || {inputAction "NextAction" > 0}) then { _usedMouseWheel = true; diff --git a/addons/interaction/functions/fnc_openMenuSelectUI.sqf b/addons/interaction/functions/fnc_openMenuSelectUI.sqf deleted file mode 100644 index 6141e839b8..0000000000 --- a/addons/interaction/functions/fnc_openMenuSelectUI.sqf +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Author: commy2 - * Opens menu select UI - * - * Arguments: - * 0: Unit - * 1: Vehicle - * - * Return value: - * None - * - * Example: - * [unit, vehicle] call ace_interaction_fnc_openMenuSelectUI - * - * Public: No - */ -#include "script_component.hpp" - -PARAMS_2(_unit,_vehicle); - -private ["_cargo", "_actions"]; - -// Allow interaction with all cargo slots and all FFV slots -_cargo = [_vehicle, ["cargo", "ffv"], true] call EFUNC(common,getVehicleCrew); - -// You can only interact if you are in cargo or FFV yourself. exit otherwise -if !(_unit in _cargo) exitWith {}; - -GVAR(InteractionMenu_Crew) = _cargo; - -// Prepare: add header and "OK" button to select menu -_actions = [localize LSTRING(InteractionMenu), localize LSTRING(Interact)] call FUNC(prepareSelectMenu); - -// Prepare: add all cargo units as options to select menu -{ - if (_x != _unit) then { - _actions = [ - _actions, - [_x] call EFUNC(common,getName), - QUOTE(PATHTOF(UI\dot_ca.paa)), - _forEachIndex - ] call FUNC(addSelectableItem); - }; -} forEach _cargo; - -// Open select menu -[ - _actions, - { - call FUNC(hideMenu); - [0, GVAR(InteractionMenu_Crew) select _this, ""] spawn FUNC(showMenu); - GVAR(InteractionMenu_Crew) = nil; - }, - { - call FUNC(hideMenu); - } -] call FUNC(openSelectMenu); diff --git a/addons/interaction/functions/fnc_openSelectMenu.sqf b/addons/interaction/functions/fnc_openSelectMenu.sqf deleted file mode 100644 index 6e42d3af47..0000000000 --- a/addons/interaction/functions/fnc_openSelectMenu.sqf +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Author: Garth de Wet (LH) - * Opens the select menu UI and sets up the UI - * - * Arguments: - * 0: Items - * 0: Text - * 1: Statement to execute - * 2: Condition before execute - * 3: showDisabled - * 4: Priority - * 5: Icon - * 6: Extra variables passed to the code - * 1: Select Action - * 2: Cancel Action - * - * Return value: - * None - * - * Example: - * [["text", {statement}, {condition}, showDisabled, priority, "icon", [variables]], {selectAction}, {cancelAction}] call ace_interaction_fnc_openSelectMenu - * - * Public: No - */ -#include "script_component.hpp" - -private["_action", "_count", "_customActions", "_i"]; - -if (!(profileNamespace getVariable [QGVAR(FlowMenu), false])) then { - GVAR(SelectAccept) = _this select 1; - GVAR(SelectCancel) = _this select 2; - buttonSetAction [8855, QUOTE( call GVAR(SelectCancel); )]; // Cancel - buttonSetAction [8860, QUOTE( (call compile (lbData [ARR_2(8866, lbCurSel 8866)])) call GVAR(SelectAccept); )]; // Accept - lbSetCurSel [8866, 0]; -}else{ - PARAMS_1(_customActions); - - private ["_count", "_action"]; - - _count = count _customActions; - if (_count == 0) exitWith {}; - _customActions call FUNC(sortOptionsByPriority); - for "_i" from 0 to _count -1 do { - _action = _customActions select _i; - _action set [1, (_this select 1)]; - }; - GVAR(Buttons) = _customActions; - [(_this select 2), true, true, false, ACE_player] call FUNC(initialiseInteraction); -}; diff --git a/addons/interaction/functions/fnc_prepareSelectMenu.sqf b/addons/interaction/functions/fnc_prepareSelectMenu.sqf deleted file mode 100644 index f42d95b75b..0000000000 --- a/addons/interaction/functions/fnc_prepareSelectMenu.sqf +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Author: Garth de Wet (LH) - * Prepares the select menu for use - * - * Arguments: - * 0: Header Text - * 1: Approve Button Text - * - * Return value: - * Container object - * - * Example: - * array = ["Select Explosive", "Place"] call ace_interaction_fnc_prepareSelectMenu - * - * Public: No - */ -#include "script_component.hpp" - -PARAMS_2(_header,_buttonText); - -closeDialog 0; - -if (isNil "_buttonText" or {_buttonText == ""}) then { - _buttonText = localize LSTRING(MakeSelection); -}; - -createDialog "RscACE_SelectAnItem"; -ctrlSetText [8860, _buttonText]; -ctrlSetText [8870, _header]; - -lbClear 8866; - -8866 diff --git a/addons/interaction/functions/fnc_sendAway.sqf b/addons/interaction/functions/fnc_sendAway.sqf index 0dd106de08..546ab9ba3f 100644 --- a/addons/interaction/functions/fnc_sendAway.sqf +++ b/addons/interaction/functions/fnc_sendAway.sqf @@ -1,40 +1,37 @@ /* - * Author: KoffeinFlummi - * Sends a civilian crowd away with a chance of failure + * Author: KoffeinFlummi, commy2 + * Sends a near civilian crowd away with a chance of failure. * * Arguments: * 0: Unit * - * Return value: + * Return Value: * None * * Example: - * [target] call ace_interaction_fnc_sendAway + * [civillian] call ace_interaction_fnc_sendAway * * Public: No */ #include "script_component.hpp" -#define DISTANCE 50 -#define RADIUS 10 +#define SEND_DISTANCE 50 +#define SEND_RADIUS 10 -PARAMS_1(_unit); +params ["_unit"]; -private ["_chance", "_x"]; +_unit playActionNow "GestureGo"; -ACE_player playActionNow "GestureGo"; - -if (count weapons ACE_player > 0) then { - _chance = 0.8; -} else { - _chance = 0.5; -}; +private "_chance"; +_chance = [0.5, 0.8] select (count weapons _unit > 0); { - if (count (weapons _unit) == 0 and random 1 < _chance) then { - [-2, { - (_this select 0) setUnitPos "AUTO"; - (_this select 0) doMove [(getPos (_this select 0) select 0) + DISTANCE * (eyeDirection (_this select 1) select 0), (getPos (_this select 0) select 1) + DISTANCE * (eyeDirection (_this select 1) select 1), 0]; - }, [_x, ACE_player]] call CBA_fnc_globalExecute; + if (count weapons _x == 0 && {random 1 < _chance}) then { + private "_position"; + _position = getPosASL _unit vectorAdd (eyeDirection _unit vectorMultiply SEND_DISTANCE); + _position set [2, 0]; + + ["sendAway", [_x], [_x, _position]] call EFUNC(common,targetEvent); }; -} forEach (_unit nearEntities ["Civilian", RADIUS]); + false +} count (_unit nearEntities ["Civilian", SEND_RADIUS]); diff --git a/addons/interaction/functions/fnc_sortOptionsByPriority.sqf b/addons/interaction/functions/fnc_sortOptionsByPriority.sqf deleted file mode 100644 index 05a4f3bad4..0000000000 --- a/addons/interaction/functions/fnc_sortOptionsByPriority.sqf +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Author: commy2 - * Sort options by priority - * - * Arguments: - * Actions - * - * Return value: - * None - * - * Example: - * customActions call ace_interaction_fnc_sortOptionsByPriority - * - * Public: No - */ -#include "script_component.hpp" - -private ["_actions", "_count", "_index", "_actionN", "_actionM"]; - -_actions = _this; -_count = count _actions; -_index = 0; - -while {_index < _count - 1} do { - _actionN = + _actions select _index; - _actionM = + _actions select (_index + 1); - - if (_actionN select 3 < _actionM select 3) then { - _actions set [_index, _actionM]; - _actions set [_index + 1, _actionN]; - _index = 0; - } else { - _index = _index + 1; - }; -}; diff --git a/addons/interaction/functions/fnc_tapShoulder.sqf b/addons/interaction/functions/fnc_tapShoulder.sqf index b8bb591c6d..ad1fbce6b1 100644 --- a/addons/interaction/functions/fnc_tapShoulder.sqf +++ b/addons/interaction/functions/fnc_tapShoulder.sqf @@ -3,38 +3,26 @@ * Taps a shoulder * * Arguments: - * 0: Player + * 0: Unit * 1: Target - * 2: Shoulder which was tapped + * 2: Shoulder which was tapped [0: left, 1: right] * * Return value: * None * * Example: - * [player, target] call ace_interaction_fnc_tapShoulder + * [player, target, 0] call ace_interaction_fnc_tapShoulder * * Public: No */ #include "script_component.hpp" -PARAMS_3(_tapper,_target,_shoulderNum); +params ["_unit", "_target", "_shoulderNum"]; -if (_target != ACE_player) exitWith { +if (_unit == ACE_player) then { addCamShake [4, 0.5, 5]; - ACE_player playActionNow "PutDown"; - if !(local _target) then { - [[_tapper, _target, _shoulderNum], QUOTE(DFUNC(tapShoulder)), _target] call EFUNC(common,execRemoteFnc); - }; }; -addCamShake [4, 0.5, 5]; +_unit playActionNow "PutDown"; -private ["_message"]; -//localize is converting the escaped <> symbols, so just add them here instead of in the stringtable -if (_shoulderNum == 0) then { - _message = format ["%1 >", (localize LSTRING(YouWereTappedRight))]; -} else { - _message = format ["< %1", (localize LSTRING(YouWereTappedLeft))]; -}; - -[parseText _message] call EFUNC(common,displayTextStructured); +["tapShoulder", [_target], [_target, _shoulderNum]] call EFUNC(common,targetEvent); diff --git a/addons/interaction/functions/fnc_updateTooltipPosition.sqf b/addons/interaction/functions/fnc_updateTooltipPosition.sqf deleted file mode 100644 index 93acd6d203..0000000000 --- a/addons/interaction/functions/fnc_updateTooltipPosition.sqf +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Author: commy2 - * Updates tooltip's position - * - * Arguments: - * 0: Tooltip Display - * 1: X Coordinate - * 2: Y Coordinate - * - * Return value: - * None - * - * Example: - * [player, 0.5, 0.5] call ace_interaction_fnc_updateTooltipPosition - * - * Public: No - */ -#include "script_component.hpp" - -PARAMS_3(_tooltip,_coordinateX,_coordinateY); - -private["_ctrl"]; - -disableSerialization; -_ctrl = ctrlParent _tooltip displayCtrl 40; - -_ctrl ctrlSetPosition [ - _coordinateX + 0.01 * safezoneW, - _coordinateY + 0.01 * safezoneH, - 2.0 / 16 * safezoneW, - 0.3 / 9 * safezoneH -]; -_ctrl ctrlCommit 0;