diff --git a/addons/backpacks/XEH_postInit.sqf b/addons/backpacks/XEH_postInit.sqf index 639bf74919..375fcd5f89 100644 --- a/addons/backpacks/XEH_postInit.sqf +++ b/addons/backpacks/XEH_postInit.sqf @@ -1,3 +1,3 @@ #include "script_component.hpp" -["backpackOpened", DFUNC(backpackOpened)] call EFUNC(common,addEventHandler); +["backpackOpened", {_this call FUNC(backpackOpened)}] call EFUNC(common,addEventHandler); diff --git a/addons/backpacks/functions/fnc_backpackOpened.sqf b/addons/backpacks/functions/fnc_backpackOpened.sqf index 9488bf6bd9..4e61e8fbcc 100644 --- a/addons/backpacks/functions/fnc_backpackOpened.sqf +++ b/addons/backpacks/functions/fnc_backpackOpened.sqf @@ -1,18 +1,19 @@ /* * Author: commy2 + * Someone opened your backpack. Play sound and camshake. Execute locally. * - * Someone opened your backpack. Execute locally. - * - * Argument: + * Arguments: * 0: Who accessed your inventory? (Object) * 1: Unit that wields the backpack (Object) * 2: The backpack object (Object) * - * Return value: - * None. + * Return Value: + * None + * + * Public: No */ #include "script_component.hpp" -private ["_sounds", "_position"]; + params ["_target", "_backpack"]; // do cam shake if the target is the player @@ -20,7 +21,8 @@ if ([_target] call EFUNC(common,isPlayer)) then { addCamShake [4, 0.5, 5]; }; -// play a rustling sound +// play a zipper sound effect +private ["_sounds", "_position"]; _sounds = [ /*"a3\sounds_f\characters\ingame\AinvPknlMstpSlayWpstDnon_medic.wss", @@ -32,8 +34,7 @@ _sounds = [ QUOTE(PATHTO_R(sounds\zip_out.wav)) ]; -_position = _target modelToWorldVisual (_target selectionPosition "Spine3"); -_position = _position call EFUNC(common,positionToASL); +_position = AGLToASL (_target modelToWorldVisual (_target selectionPosition "Spine3")); playSound3D [ _sounds select floor random count _sounds, diff --git a/addons/backpacks/functions/fnc_isBackpack.sqf b/addons/backpacks/functions/fnc_isBackpack.sqf index 3419d2ed38..fab82c505f 100644 --- a/addons/backpacks/functions/fnc_isBackpack.sqf +++ b/addons/backpacks/functions/fnc_isBackpack.sqf @@ -1,23 +1,24 @@ /* * Author: commy2 + * Check if the given backpack is an actual backpack that can store items. Parachute, static weapon packs, etc. will return false. * - * Check if the given backpack is an actual backpack that can store items. Parachute backpacks will return false for example. + * Arguments: + * 0: Backpack * - * Argument: - * 0: A backpack (Object or String) + * Return Value: + * Boolean * - * Return value: - * Boolean (Bool) + * Public: Yes */ #include "script_component.hpp" -private ["_config"]; params ["_backpack"]; if (typeName _backpack == "OBJECT") then { _backpack = typeOf _backpack; }; +private "_config"; _config = configFile >> "CfgVehicles" >> _backpack; -getText (_config >> "vehicleClass") == "backpacks" && {getNumber (_config >> "maximumLoad") > 0} +getText (_config >> "vehicleClass") == "backpacks" && {getNumber (_config >> "maximumLoad") > 0} // return diff --git a/addons/backpacks/functions/fnc_onOpenInventory.sqf b/addons/backpacks/functions/fnc_onOpenInventory.sqf index afeeb21313..154000202d 100644 --- a/addons/backpacks/functions/fnc_onOpenInventory.sqf +++ b/addons/backpacks/functions/fnc_onOpenInventory.sqf @@ -1,17 +1,19 @@ /* * Author: commy2 + * Handle the open inventory event. Camshake and sound on target client. * - * Handle the open inventory event. Display message on target client. + * Arguments: + * 0: Unit + * 1: Backpack * - * Argument: - * Input from "InventoryOpened" eventhandler - * - * Return value: + * Return Value: * false. Always open the inventory dialog. (Bool) + * + * Public: No */ #include "script_component.hpp" -params ["_unit","_backpack"]; +params ["_unit", "_backpack"]; // exit if the target is not a real backpack, i.e. parachute, static weapon bag etc. if !([_backpack] call FUNC(isBackpack)) exitWith {false}; diff --git a/addons/captives/XEH_postInit.sqf b/addons/captives/XEH_postInit.sqf index fec6e84fbe..26f84e6bd9 100644 --- a/addons/captives/XEH_postInit.sqf +++ b/addons/captives/XEH_postInit.sqf @@ -26,7 +26,7 @@ if (isServer) then { ["SetHandcuffed", {_this call FUNC(setHandcuffed)}] call EFUNC(common,addEventHandler); ["SetSurrendered", {_this call FUNC(setSurrendered)}] call EFUNC(common,addEventHandler); -//Medical Integration Events??? +//Medical Integration Events ["medical_onUnconscious", {_this call ACE_Captives_fnc_handleOnUnconscious}] call EFUNC(common,addEventHandler); if (!hasInterface) exitWith {}; diff --git a/addons/captives/functions/fnc_setHandcuffed.sqf b/addons/captives/functions/fnc_setHandcuffed.sqf index a8c8e02fd4..00122862eb 100644 --- a/addons/captives/functions/fnc_setHandcuffed.sqf +++ b/addons/captives/functions/fnc_setHandcuffed.sqf @@ -109,3 +109,6 @@ if (_state) then { showHUD true; }; }; + +//Global Event after changes: +["CaptiveStatusChanged", [_unit, _state, "SetHandcuffed"]] call EFUNC(common,globalEvent); diff --git a/addons/captives/functions/fnc_setSurrendered.sqf b/addons/captives/functions/fnc_setSurrendered.sqf index dd9ac417c5..cdba47a406 100644 --- a/addons/captives/functions/fnc_setSurrendered.sqf +++ b/addons/captives/functions/fnc_setSurrendered.sqf @@ -101,3 +101,6 @@ if (_state) then { }, 0, [_unit, (ACE_time + 20)]] call CBA_fnc_addPerFrameHandler; }; }; + +//Global Event after changes: +["CaptiveStatusChanged", [_unit, _state, "SetSurrendered"]] call EFUNC(common,globalEvent); diff --git a/addons/cargo/functions/fnc_addCargoItem.sqf b/addons/cargo/functions/fnc_addCargoItem.sqf index 17264ec15a..9f349153c0 100644 --- a/addons/cargo/functions/fnc_addCargoItem.sqf +++ b/addons/cargo/functions/fnc_addCargoItem.sqf @@ -6,6 +6,7 @@ * 0: Item Classname * 1: Vehicle * 2: Amount (default: 1) + * 3: Show Hint (default: false) * * Return Value: * None @@ -18,7 +19,7 @@ #include "script_component.hpp" private ["_position", "_item", "_i"]; -params ["_itemClass", "_vehicle", ["_amount", 1]]; +params ["_itemClass", "_vehicle", ["_amount", 1], ["_showHint", false, [false]] ]; TRACE_3("params",_itemClass,_vehicle,_amount); _position = getPos _vehicle; @@ -29,12 +30,12 @@ for "_i" from 1 to _amount do { _item = createVehicle [_itemClass, _position, [], 0, "CAN_COLLIDE"]; // Load item or delete it if no space left - if !([_item, _vehicle] call FUNC(loadItem)) exitWith { + if !([_item, _vehicle, _showHint] call FUNC(loadItem)) exitWith { TRACE_1("no room to load item - deleting",_item); deleteVehicle _item; }; TRACE_1("Item Loaded",_item); - + // Invoke listenable event ["cargoAddedByClass", [_itemClass, _vehicle, _amount]] call EFUNC(common,globalEvent); }; diff --git a/addons/cargo/functions/fnc_initVehicle.sqf b/addons/cargo/functions/fnc_initVehicle.sqf index d436e0d416..8857030cb7 100644 --- a/addons/cargo/functions/fnc_initVehicle.sqf +++ b/addons/cargo/functions/fnc_initVehicle.sqf @@ -45,7 +45,7 @@ if (getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(hasCargo)) != 1) ex private ["_text", "_condition", "_statement", "_icon", "_action"]; _condition = { params ["_target", "_player"]; - GVAR(enable) && {locked _target < 2} && {[_player, _target, []] call EFUNC(common,canInteractWith)} + GVAR(enable) && {locked _target < 2} && {alive _target} && {[_player, _target, []] call EFUNC(common,canInteractWith)} }; _text = localize LSTRING(openMenu); _statement = {GVAR(interactionVehicle) = _target; createDialog QGVAR(menu);}; diff --git a/addons/cargo/functions/fnc_loadItem.sqf b/addons/cargo/functions/fnc_loadItem.sqf index e09d0e1429..11e7638f1b 100644 --- a/addons/cargo/functions/fnc_loadItem.sqf +++ b/addons/cargo/functions/fnc_loadItem.sqf @@ -5,6 +5,7 @@ * Arguments: * 0: Object * 1: Vehicle + * 2: Show Hint (default: true) * * Return value: * Object loaded @@ -18,7 +19,7 @@ private ["_loaded", "_space", "_itemSize"]; -params ["_item", "_vehicle"]; +params ["_item", "_vehicle", ["_showHint", true, [true]] ]; TRACE_2("params",_item,_vehicle); if !([_item, _vehicle] call FUNC(canLoadItemIn)) exitWith { @@ -46,7 +47,9 @@ private ["_itemName", "_vehicleName"]; _itemName = getText (configFile >> "CfgVehicles" >> typeOf _item >> "displayName"); _vehicleName = getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "displayName"); -["displayTextStructured", [[localize LSTRING(LoadedItem), _itemName, _vehicleName], 3.0]] call EFUNC(common,localEvent); +if (_showHint) then { + ["displayTextStructured", [[localize LSTRING(LoadedItem), _itemName, _vehicleName], 3.0]] call EFUNC(common,localEvent); +}; // Invoke listenable event ["cargoLoaded", [_item, _vehicle]] call EFUNC(common,globalEvent); diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index e374a7a716..4bd58ade33 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -83,9 +83,13 @@ ["setDir", {(_this select 0) setDir (_this select 1)}] call FUNC(addEventhandler); ["setFuel", {(_this select 0) setFuel (_this select 1)}] call FUNC(addEventhandler); ["setSpeaker", {(_this select 0) setSpeaker (_this select 1)}] call FUNC(addEventhandler); +["selectLeader", {(_this select 0) selectLeader (_this select 1)}] call FUNC(addEventHandler); +["assignTeam", {(_this select 0) assignTeam (_this select 1)}] call FUNC(addEventHandler); +["setVelocity", {(_this select 0) setVelocity (_this select 1)}] call FUNC(addEventHandler); if (isServer) then { ["hideObjectGlobal", {(_this select 0) hideObjectGlobal (_this select 1)}] call FUNC(addEventHandler); + ["enableSimulationGlobal", {(_this select 0) enableSimulationGlobal (_this select 1)}] call FUNC(addEventHandler); }; @@ -94,8 +98,8 @@ if (isServer) then { ////////////////////////////////////////////////// // ACE events -"ACEg" addPublicVariableEventHandler { _this call FUNC(_handleNetEvent); }; -"ACEc" addPublicVariableEventHandler { _this call FUNC(_handleNetEvent); }; +"ACEg" addPublicVariableEventHandler {_this call FUNC(_handleNetEvent)}; +"ACEc" addPublicVariableEventHandler {_this call FUNC(_handleNetEvent)}; // Synced ACE events // Handle JIP scenario @@ -219,8 +223,29 @@ call FUNC(assignedItemFix); GVAR(ScrollWheelFrame) = diag_frameno; -addMissionEventHandler ["Loaded", {call FUNC(handleScrollWheelInit)}]; -call FUNC(handleScrollWheelInit); +["mainDisplayLoaded", { + [{ + call FUNC(handleScrollWheelInit); + call FUNC(handleModifierKeyInit); + }, [], 0.1] call FUNC(waitAndExecute); // needs delay, otherwise doesn't work without pressing "RESTART" in editor once. Tested in 1.52RC +}] call FUNC(addEventHandler); + +// add PFH to execute event that fires when the main display (46) is created +private "_fnc_initMainDisplayCheck"; +_fnc_initMainDisplayCheck = { + [{ + if !(isNull findDisplay 46) then { + // Raise ACE event locally + ["mainDisplayLoaded", [findDisplay 46]] call FUNC(localEvent); + [_this select 1] call CBA_fnc_removePerFrameHandler; + }; + }, 0, []] call CBA_fnc_addPerFrameHandler; +}; + +call _fnc_initMainDisplayCheck; + +// repeat this every time a savegame is loaded +addMissionEventHandler ["Loaded", _fnc_initMainDisplayCheck]; // @todo remove? enableCamShake true; @@ -273,7 +298,7 @@ if (!isNil QGVAR(PreInit_playerChanged_PFHID)) then { // "playerChanged" event _data = call FUNC(player); - if !(_data isEqualTo GVAR(OldPlayerVehicle)) then { + if !(_data isEqualTo ACE_player) then { private "_oldPlayer"; _oldPlayer = ACE_player; @@ -375,8 +400,8 @@ if (!isNil QGVAR(PreInit_playerChanged_PFHID)) then { // @todo still needed? [QGVAR(StateArrested), false, true, QUOTE(ADDON)] call FUNC(defineVariable); -["displayTextStructured", FUNC(displayTextStructured)] call FUNC(addEventhandler); -["displayTextPicture", FUNC(displayTextPicture)] call FUNC(addEventhandler); +["displayTextStructured", {_this call FUNC(displayTextStructured)}] call FUNC(addEventhandler); +["displayTextPicture", {_this call FUNC(displayTextPicture)}] call FUNC(addEventhandler); ["medical_onUnconscious", { params ["_unit", "_isUnconscious"]; diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index a1f19aab8d..e422206134 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -91,6 +91,9 @@ PREP(getWindDirection); PREP(getZoom); PREP(goKneeling); PREP(hadamardProduct); +PREP(handleModifierKey); +PREP(handleModifierKeyUp); +PREP(handleModifierKeyInit); PREP(handleScrollWheel); PREP(handleScrollWheelInit); PREP(hasItem); @@ -204,6 +207,7 @@ PREP(getReflectorsWithSelections); PREP(getLightProperties); PREP(getLightPropertiesWeapon); PREP(getVehicleCrew); +PREP(getVehicleUAVCrew); // turrets PREP(getTurrets); diff --git a/addons/common/functions/fnc_fixFloating.sqf b/addons/common/functions/fnc_fixFloating.sqf index 5fe94dcef7..24084d2c11 100644 --- a/addons/common/functions/fnc_fixFloating.sqf +++ b/addons/common/functions/fnc_fixFloating.sqf @@ -19,14 +19,17 @@ _object = _this; if (!local _object) exitWith {}; // save and restore hitpoints, see below why -private ["_hitPoints", "_hitPointDamages"]; +private "_hitPointDamages"; +_hitPointDamages = getAllHitPointsDamage _object; -_hitPoints = [_object] call FUNC(getHitpoints); -_hitPointDamages = [_hitPoints, {_object getHitPointDamage _this}] call FUNC(map); +// get correct format for objects without hitpoints +if (_hitPointDamages isEqualTo []) then { + _hitPointDamages = [[],[],[]]; +}; // this prevents physx objects from floating when near other physx objects with allowDamage false _object setDamage damage _object; { - _object setHitPointDamage [_x, _hitPointDamages select _forEachIndex]; -} forEach _hitPoints; + _object setHitIndex [_forEachIndex, _x]; +} forEach (_hitPointDamages select 2); diff --git a/addons/common/functions/fnc_getHitPoints.sqf b/addons/common/functions/fnc_getHitPoints.sqf index 6c0645007e..84099b659a 100644 --- a/addons/common/functions/fnc_getHitPoints.sqf +++ b/addons/common/functions/fnc_getHitPoints.sqf @@ -18,4 +18,12 @@ ACE_DEPRECATED("ace_common_fnc_getHitPoints","3.5.0","getAllHitPointsDamage"); params ["_vehicle"]; -(getAllHitPointsDamage _vehicle select 0) - [""] +private "_hitPointsWithSelections"; +_hitPointsWithSelections = getAllHitPointsDamage _vehicle; + +// get correct format on vehicles without any hitpoints +if (_hitPointsWithSelections isEqualTo []) then { + _hitPointsWithSelections = [[],[],[]]; +}; + +(_hitPointsWithSelections select 0) - [""] diff --git a/addons/common/functions/fnc_getHitPointsWithSelections.sqf b/addons/common/functions/fnc_getHitPointsWithSelections.sqf index 36475672b9..b0b9867cf7 100644 --- a/addons/common/functions/fnc_getHitPointsWithSelections.sqf +++ b/addons/common/functions/fnc_getHitPointsWithSelections.sqf @@ -22,6 +22,11 @@ params ["_vehicle"]; private "_hitPointsWithSelections"; _hitPointsWithSelections = getAllHitPointsDamage _vehicle; +// get correct format on vehicles without any hitpoints +if (_hitPointsWithSelections isEqualTo []) then { + _hitPointsWithSelections = [[],[],[]]; +}; + _hitPointsWithSelections resize 2; _hitPointsWithSelections diff --git a/addons/common/functions/fnc_getVehicleUAVCrew.sqf b/addons/common/functions/fnc_getVehicleUAVCrew.sqf new file mode 100644 index 0000000000..8d9156810a --- /dev/null +++ b/addons/common/functions/fnc_getVehicleUAVCrew.sqf @@ -0,0 +1,17 @@ +/* + * Author: commy2 + * Returns array of uav dummy ais. + * + * Arguments: + * 0: Vehicle + * + * Return Value: + * UAV Dummy Crew + * + * Public: Yes + */ +#include "script_component.hpp" + +params ["_vehicle"]; + +[crew _vehicle, {getText (configFile >> "CfgVehicles" >> typeOf _this >> "simulation") == "UAVPilot"}] call FUNC(filter) // return diff --git a/addons/common/functions/fnc_handleModifierKey.sqf b/addons/common/functions/fnc_handleModifierKey.sqf new file mode 100644 index 0000000000..bfb7e84931 --- /dev/null +++ b/addons/common/functions/fnc_handleModifierKey.sqf @@ -0,0 +1,17 @@ +/* + * Author: commy2 + * Handles key down event for modifier key. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public : No + */ +#include "script_component.hpp" + +if (_this select 3) then {ACE_modifier = 1}; + +false diff --git a/addons/common/functions/fnc_handleModifierKeyInit.sqf b/addons/common/functions/fnc_handleModifierKeyInit.sqf new file mode 100644 index 0000000000..a945f5eba1 --- /dev/null +++ b/addons/common/functions/fnc_handleModifierKeyInit.sqf @@ -0,0 +1,16 @@ +/* + * Author: commy2 + * Initializes the modifier key handler. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public : No + */ +#include "script_component.hpp" + +(findDisplay 46) displayAddEventHandler ["KeyDown", FUNC(handleModifierKey)]; +(findDisplay 46) displayAddEventHandler ["KeyUp", FUNC(handleModifierKeyUp)]; diff --git a/addons/common/functions/fnc_handleModifierKeyUp.sqf b/addons/common/functions/fnc_handleModifierKeyUp.sqf new file mode 100644 index 0000000000..ffa5855115 --- /dev/null +++ b/addons/common/functions/fnc_handleModifierKeyUp.sqf @@ -0,0 +1,17 @@ +/* + * Author: commy2 + * Handles key up event for modifier key. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Public : No + */ +#include "script_component.hpp" + +ACE_modifier = 0; + +false diff --git a/addons/common/functions/fnc_loadPersonLocal.sqf b/addons/common/functions/fnc_loadPersonLocal.sqf index 896b0952f2..5b52b38b05 100644 --- a/addons/common/functions/fnc_loadPersonLocal.sqf +++ b/addons/common/functions/fnc_loadPersonLocal.sqf @@ -41,8 +41,7 @@ if (_slotsOpen) then { _vehicle setVariable [QGVAR(loaded_persons), _loaded, true]; - // @todo never used. Remove? - /*if !([_unit] call FUNC(isAwake)) then { + if !([_unit] call FUNC(isAwake)) then { [{ (_this select 0) params ["_unit", "_vehicle"]; @@ -60,5 +59,5 @@ if (_slotsOpen) then { [_this select 1] call CBA_fnc_removePerFrameHandler; }, 0.5, [_unit, _vehicle]] call CBA_fnc_addPerFrameHandler; - };*/ + }; }; diff --git a/addons/common/functions/fnc_removeEventHandler.sqf b/addons/common/functions/fnc_removeEventHandler.sqf index c869b3d0cc..0c70046706 100644 --- a/addons/common/functions/fnc_removeEventHandler.sqf +++ b/addons/common/functions/fnc_removeEventHandler.sqf @@ -9,7 +9,7 @@ * Return Value: * None * - * Public: No + * Public: Yes */ #include "script_component.hpp" diff --git a/addons/common/functions/fnc_unloadPersonLocal.sqf b/addons/common/functions/fnc_unloadPersonLocal.sqf index 8dd2737b83..67d104a9e4 100644 --- a/addons/common/functions/fnc_unloadPersonLocal.sqf +++ b/addons/common/functions/fnc_unloadPersonLocal.sqf @@ -73,9 +73,7 @@ _unit action ["Eject", vehicle _unit]; _unit setPosASL AGLToASL _emptyPos; - // @todo never used. Remove? - /*if !([_unit] call FUNC(isAwake)) then { - + if !([_unit] call FUNC(isAwake)) then { TRACE_1("Check if isAwake", [_unit] call FUNC(isAwake)); if (driver _unit == _unit) then { @@ -92,7 +90,7 @@ _unit action ["Eject", vehicle _unit]; }; }, [_unit, _anim], 0.5, 0] call FUNC(waitAndExecute); }; - };*/ + }; }, [_unit, _emptyPos], 0.5, 0] call FUNC(waitAndExecute); [_unit, false, GROUP_SWITCH_ID, side group _unit] call FUNC(switchToGroupSide); diff --git a/addons/common/functions/fnc_waitAndExecute.sqf b/addons/common/functions/fnc_waitAndExecute.sqf index c8f078854b..af59e301f7 100644 --- a/addons/common/functions/fnc_waitAndExecute.sqf +++ b/addons/common/functions/fnc_waitAndExecute.sqf @@ -13,7 +13,7 @@ * Example: * [{(_this select 0) setVelocity [0,0,200];}, [player], 10] call ace_common_fnc_waitAndExecute * - * Public: No + * Public: Yes */ #include "script_component.hpp" diff --git a/addons/dagr/stringtable.xml b/addons/dagr/stringtable.xml index 9d95873e64..1abd146800 100644 --- a/addons/dagr/stringtable.xml +++ b/addons/dagr/stringtable.xml @@ -5,21 +5,25 @@ DAGR DAGR DAGR + DAGR Configure DAGR Konfiguruj DAGR Configurar DAGR + Настроить DAGR Toggle DAGR Przełącz DAGR Mostrar DAGR + Вкл./выкл. DAGR Defense Advanced GPS Receiver Defense Advanced GPS Receiver Defense Advanced GPS Receiver + Военный многофункциональный GPS-приёмник diff --git a/addons/dragging/CfgEventHandlers.hpp b/addons/dragging/CfgEventHandlers.hpp index 2ff7d07c0d..7276bc4284 100644 --- a/addons/dragging/CfgEventHandlers.hpp +++ b/addons/dragging/CfgEventHandlers.hpp @@ -7,8 +7,7 @@ class Extended_PreInit_EventHandlers { class Extended_PostInit_EventHandlers { class ADDON { - clientInit = QUOTE(call COMPILE_FILE(XEH_clientInit)); - serverInit = QUOTE(call COMPILE_FILE(XEH_serverInit)); + init = QUOTE(call COMPILE_FILE(XEH_postInit)); }; }; diff --git a/addons/dragging/XEH_clientInit.sqf b/addons/dragging/XEH_postInit.sqf similarity index 50% rename from addons/dragging/XEH_clientInit.sqf rename to addons/dragging/XEH_postInit.sqf index e80d63cfde..5a54f8c8a2 100644 --- a/addons/dragging/XEH_clientInit.sqf +++ b/addons/dragging/XEH_postInit.sqf @@ -1,7 +1,14 @@ // by PabstMirror, commy2 #include "script_component.hpp" -[DFUNC(handleScrollWheel)] call EFUNC(common,addScrollWheelEventHandler); +if (isServer) then { + // release object on hard disconnection. Function is identical to killed + addMissionEventHandler ["HandleDisconnect", {_this call FUNC(handleKilled)}]; +}; + +if (!hasInterface) exitWith {}; + +[{_this call FUNC(handleScrollWheel)}] call EFUNC(common,addScrollWheelEventHandler); if (isNil "ACE_maxWeightDrag") then { ACE_maxWeightDrag = 800; @@ -15,11 +22,11 @@ if (isNil "ACE_maxWeightCarry") then { ["isNotCarrying", {!((_this select 0) getVariable [QGVAR(isCarrying), false])}] call EFUNC(common,addCanInteractWithCondition); // release object on player change. This does work when returning to lobby, but not when hard disconnecting. -["playerChanged", DFUNC(handlePlayerChanged)] call EFUNC(common,addEventhandler); -["playerVehicleChanged", {[ACE_player, objNull] call DFUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler); -["playerWeaponChanged", DFUNC(handlePlayerWeaponChanged)] call EFUNC(common,addEventhandler); +["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler); +["playerVehicleChanged", {[ACE_player, objNull] call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler); +["playerWeaponChanged", {_this call FUNC(handlePlayerWeaponChanged)}] call EFUNC(common,addEventhandler); // handle waking up dragged unit and falling unconscious while dragging -["medical_onUnconscious", DFUNC(handleUnconscious)] call EFUNC(common,addEventhandler); +["medical_onUnconscious", {_this call FUNC(handleUnconscious)}] call EFUNC(common,addEventhandler); //@todo Captivity? diff --git a/addons/dragging/XEH_serverInit.sqf b/addons/dragging/XEH_serverInit.sqf deleted file mode 100644 index 01d78ef4e3..0000000000 --- a/addons/dragging/XEH_serverInit.sqf +++ /dev/null @@ -1,5 +0,0 @@ -// by commy2 -#include "script_component.hpp" - -// release object on hard disconnection. Function is identical to killed -addMissionEventHandler ["HandleDisconnect", DFUNC(handleKilled)]; diff --git a/addons/dragging/functions/fnc_canCarry.sqf b/addons/dragging/functions/fnc_canCarry.sqf index a6b8fed5ab..6ee28edff3 100644 --- a/addons/dragging/functions/fnc_canCarry.sqf +++ b/addons/dragging/functions/fnc_canCarry.sqf @@ -18,7 +18,7 @@ params ["_unit", "_target"]; if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false}; -// a static weapon has to be empty for dragging -if ((typeOf _target) isKindOf "StaticWeapon" && {count crew _target > 0}) exitWith {false}; +// a static weapon has to be empty for dragging (ignore UAV AI) +if (((typeOf _target) isKindOf "StaticWeapon") && {{(getText (configFile >> "CfgVehicles" >> (typeOf _x) >> "simulation")) != "UAVPilot"} count crew _target > 0}) exitWith {false}; alive _target && {vehicle _target == _target} && {_target getVariable [QGVAR(canCarry), false]} && {animationState _target in ["", "unconscious"] || (_target getvariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})} diff --git a/addons/dragging/functions/fnc_canDrag.sqf b/addons/dragging/functions/fnc_canDrag.sqf index 4ab3562ba2..58c4718407 100644 --- a/addons/dragging/functions/fnc_canDrag.sqf +++ b/addons/dragging/functions/fnc_canDrag.sqf @@ -21,7 +21,7 @@ _target = _this select 1; if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false}; -// a static weapon has to be empty for dragging -if ((typeOf _target) isKindOf "StaticWeapon" && {count crew _target > 0}) exitWith {false}; +// a static weapon has to be empty for dragging (ignore UAV AI) +if ((typeOf _target) isKindOf "StaticWeapon" && {{(getText (configFile >> "CfgVehicles" >> (typeOf _x) >> "simulation")) != "UAVPilot"} count crew _target > 0}) exitWith {false}; alive _target && {vehicle _target == _target} && {_target getVariable [QGVAR(canDrag), false]} && {animationState _target in ["", "unconscious"] || (_target getvariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})}; diff --git a/addons/dragging/functions/fnc_carryObject.sqf b/addons/dragging/functions/fnc_carryObject.sqf index 7f70b2bdc5..8bea72b907 100644 --- a/addons/dragging/functions/fnc_carryObject.sqf +++ b/addons/dragging/functions/fnc_carryObject.sqf @@ -17,7 +17,7 @@ params ["_unit", "_target"]; // get attachTo offset and direction. -private ["_position", "_direction"]; +private ["_position", "_direction", "_UAVCrew"]; _position = _target getVariable [QGVAR(carryPosition), [0, 0, 0]]; _direction = _target getVariable [QGVAR(carryDirection), 0]; @@ -48,29 +48,26 @@ if (_target isKindOf "CAManBase") then { _unit setVariable [QGVAR(isCarrying), true, true]; _unit setVariable [QGVAR(carriedObject), _target, true]; -// add scrollwheel action to release object -private "_actionID"; -_actionID = _unit getVariable [QGVAR(ReleaseActionID), -1]; +// add drop action +_unit setVariable [QGVAR(ReleaseActionID), [ + _unit, "DefaultAction", + {!isNull ((_this select 0) getVariable [QGVAR(carriedObject), objNull])}, + {[_this select 0, (_this select 0) getVariable [QGVAR(carriedObject), objNull]] call FUNC(dropObject_carry)} +] call EFUNC(common,addActionEventHandler)]; -if (_actionID != -1) then { - _unit removeAction _actionID; -}; - -_actionID = _unit addAction [ - format ["%1", localize LSTRING(Drop)], - QUOTE([ARR_2(_this select 0, (_this select 0) getVariable [ARR_2(QUOTE(QGVAR(carriedObject)),objNull)])] call FUNC(dropObject_carry)), - nil, - 20, - false, - true, - "", - QUOTE(!isNull (_this getVariable [ARR_2(QUOTE(QGVAR(carriedObject)),objNull)])) -]; - -_unit setVariable [QGVAR(ReleaseActionID), _actionID]; +// show mouse hint +[localize LSTRING(Drop), "", localize LSTRING(LowerRaise)] call EFUNC(interaction,showMouseHint); // check everything [FUNC(carryObjectPFH), 0.5, [_unit, _target]] call CBA_fnc_addPerFrameHandler; // reset current dragging height. GVAR(currentHeightChange) = 0; + +// prevent UAVs from firing +_UAVCrew = _target call EFUNC(common,getVehicleUAVCrew); + +if !(_UAVCrew isEqualTo []) then { + {_target deleteVehicleCrew _x} count _UAVCrew; + _target setVariable [QGVAR(isUAV), true, true]; +}; diff --git a/addons/dragging/functions/fnc_carryObjectPFH.sqf b/addons/dragging/functions/fnc_carryObjectPFH.sqf index d0eb7fda17..b50383707a 100644 --- a/addons/dragging/functions/fnc_carryObjectPFH.sqf +++ b/addons/dragging/functions/fnc_carryObjectPFH.sqf @@ -25,7 +25,7 @@ if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith { }; // drop if the crate is destroyed OR (target moved away from carrier (weapon disasembled)) -if ((!([_target] call EFUNC(common,isAlive))) || {(_unit distance _target) > 10}) then { +if (!alive _target || {_unit distance _target > 10}) then { [_unit, _target] call FUNC(dropObject_carry); [_idPFH] call CBA_fnc_removePerFrameHandler; }; diff --git a/addons/dragging/functions/fnc_dragObject.sqf b/addons/dragging/functions/fnc_dragObject.sqf index d12a98213a..17fbc60c06 100644 --- a/addons/dragging/functions/fnc_dragObject.sqf +++ b/addons/dragging/functions/fnc_dragObject.sqf @@ -14,9 +14,10 @@ */ #include "script_component.hpp" -private ["_position", "_direction", "_offset", "_actionID"]; params ["_unit", "_target"]; +private ["_position", "_direction", "_offset", "_UAVCrew"]; + // get attachTo offset and direction. _position = _target getVariable [QGVAR(dragPosition), [0, 0, 0]]; _direction = _target getVariable [QGVAR(dragDirection), 0]; @@ -37,28 +38,26 @@ if (_target isKindOf "CAManBase") then { _unit setVariable [QGVAR(isDragging), true, true]; _unit setVariable [QGVAR(draggedObject), _target, true]; -// add scrollwheel action to release object -_actionID = _unit getVariable [QGVAR(ReleaseActionID), -1]; +// add drop action +_unit setVariable [QGVAR(ReleaseActionID), [ + _unit, "DefaultAction", + {!isNull ((_this select 0) getVariable [QGVAR(draggedObject), objNull])}, + {[_this select 0, (_this select 0) getVariable [QGVAR(draggedObject), objNull]] call FUNC(dropObject)} +] call EFUNC(common,addActionEventHandler)]; -if (_actionID != -1) then { - _unit removeAction _actionID; -}; - -_actionID = _unit addAction [ - format ["%1", localize LSTRING(Drop)], - QUOTE([ARR_2(_this select 0, (_this select 0) getVariable [ARR_2(QUOTE(QGVAR(draggedObject)),objNull)])] call FUNC(dropObject)), - nil, - 20, - false, - true, - "", - QUOTE(!isNull (_this getVariable [ARR_2(QUOTE(QGVAR(draggedObject)),objNull)])) -]; - -_unit setVariable [QGVAR(ReleaseActionID), _actionID]; +// show mouse hint +[localize LSTRING(Drop), ""] call EFUNC(interaction,showMouseHint); // check everything [FUNC(dragObjectPFH), 0.5, [_unit, _target]] call CBA_fnc_addPerFrameHandler; // reset current dragging height. GVAR(currentHeightChange) = 0; + +// prevent UAVs from firing +_UAVCrew = _target call EFUNC(common,getVehicleUAVCrew); + +if !(_UAVCrew isEqualTo []) then { + {_target deleteVehicleCrew _x} count _UAVCrew; + _target setVariable [QGVAR(isUAV), true, true]; +}; diff --git a/addons/dragging/functions/fnc_dragObjectPFH.sqf b/addons/dragging/functions/fnc_dragObjectPFH.sqf index dea8897b27..f6ff252886 100644 --- a/addons/dragging/functions/fnc_dragObjectPFH.sqf +++ b/addons/dragging/functions/fnc_dragObjectPFH.sqf @@ -25,7 +25,7 @@ if !(_unit getVariable [QGVAR(isDragging), false]) exitWith { }; // drop if the crate is destroyed OR (target moved away from carrier (weapon disasembled)) -if ((!([_target] call EFUNC(common,isAlive))) || {(_unit distance _target) > 10}) then { +if (!alive _target || {_unit distance _target > 10}) then { [_unit, _target] call FUNC(dropObject); [_idPFH] call CBA_fnc_removePerFrameHandler; }; diff --git a/addons/dragging/functions/fnc_dropObject.sqf b/addons/dragging/functions/fnc_dropObject.sqf index 2ae07be091..9da1656b8b 100644 --- a/addons/dragging/functions/fnc_dropObject.sqf +++ b/addons/dragging/functions/fnc_dropObject.sqf @@ -16,8 +16,8 @@ params ["_unit", "_target"]; -// remove scroll wheel action -_unit removeAction (_unit getVariable [QGVAR(ReleaseActionID), -1]); +// remove drop action +[_unit, "DefaultAction", _unit getVariable [QGVAR(ReleaseActionID), -1]] call EFUNC(common,removeActionEventHandler); private "_inBuilding"; _inBuilding = [_unit] call FUNC(isObjectOnObject); @@ -49,6 +49,9 @@ if (_inBuilding) then { _target setPosASL (getPosASL _target vectorAdd [0, 0, 0.05]); }; +// hide mouse hint +[] call EFUNC(interaction,hideMouseHint); + _unit setVariable [QGVAR(isDragging), false, true]; _unit setVariable [QGVAR(draggedObject), objNull, true]; @@ -63,3 +66,8 @@ if !(_target isKindOf "CAManBase") then { if (_unit getvariable ["ACE_isUnconscious", false]) then { [_unit, "unconscious", 2, true] call EFUNC(common,doAnimation); }; + +// recreate UAV crew +if (_target getVariable [QGVAR(isUAV), false]) then { + createVehicleCrew _target; +}; diff --git a/addons/dragging/functions/fnc_dropObject_carry.sqf b/addons/dragging/functions/fnc_dropObject_carry.sqf index 86009ac867..300846bc6c 100644 --- a/addons/dragging/functions/fnc_dropObject_carry.sqf +++ b/addons/dragging/functions/fnc_dropObject_carry.sqf @@ -16,8 +16,8 @@ params ["_unit", "_target"]; -// remove scroll wheel action -_unit removeAction (_unit getVariable [QGVAR(ReleaseActionID), -1]); +// remove drop action +[_unit, "DefaultAction", _unit getVariable [QGVAR(ReleaseActionID), -1]] call EFUNC(common,removeActionEventHandler); private "_inBuilding"; _inBuilding = [_unit] call FUNC(isObjectOnObject); @@ -55,6 +55,9 @@ if (_inBuilding) then { _target setPosASL (getPosASL _target vectorAdd [0, 0, 0.05]); }; +// hide mouse hint +[] call EFUNC(interaction,hideMouseHint); + _unit setVariable [QGVAR(isCarrying), false, true]; _unit setVariable [QGVAR(carriedObject), objNull, true]; @@ -65,3 +68,8 @@ if !(_target isKindOf "CAManBase") then { ["fixPosition", _target, _target] call EFUNC(common,targetEvent); ["fixFloating", _target, _target] call EFUNC(common,targetEvent); }; + +// recreate UAV crew +if (_target getVariable [QGVAR(isUAV), false]) then { + createVehicleCrew _target; +}; diff --git a/addons/dragging/functions/fnc_handleScrollWheel.sqf b/addons/dragging/functions/fnc_handleScrollWheel.sqf index cd613316ec..73c42c2810 100644 --- a/addons/dragging/functions/fnc_handleScrollWheel.sqf +++ b/addons/dragging/functions/fnc_handleScrollWheel.sqf @@ -13,20 +13,15 @@ */ #include "script_component.hpp" -private ["_unit", "_carriedItem", "_position", "_maxHeight"]; - params ["_scrollAmount"]; -// requires modifier key to be hold down -if (missionNamespace getVariable ["ACE_Modifier", 0] == 0) exitWith {false}; +private ["_unit", "_carriedItem", "_position", "_maxHeight"]; _unit = ACE_player; // EH is always assigned. Exit and don't overwrite input if not carrying if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {false}; - - // move carried item 15 cm per scroll interval _scrollAmount = _scrollAmount * 0.15; diff --git a/addons/dragging/functions/fnc_startCarryPFH.sqf b/addons/dragging/functions/fnc_startCarryPFH.sqf index ae5ad17978..eafc9b8e01 100644 --- a/addons/dragging/functions/fnc_startCarryPFH.sqf +++ b/addons/dragging/functions/fnc_startCarryPFH.sqf @@ -26,7 +26,7 @@ if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith { }; // same as dragObjectPFH, checks if object is deleted or dead OR (target moved away from carrier (weapon disasembled)) -if ((!([_target] call EFUNC(common,isAlive))) || {(_unit distance _target) > 10}) then { +if (!alive _target || {_unit distance _target > 10}) then { [_unit, _target] call FUNC(dropObject); [_idPFH] call CBA_fnc_removePerFrameHandler; }; diff --git a/addons/dragging/functions/fnc_startDragPFH.sqf b/addons/dragging/functions/fnc_startDragPFH.sqf index f527cda7d8..1edbd92a99 100644 --- a/addons/dragging/functions/fnc_startDragPFH.sqf +++ b/addons/dragging/functions/fnc_startDragPFH.sqf @@ -26,7 +26,7 @@ if !(_unit getVariable [QGVAR(isDragging), false]) exitWith { }; // same as dragObjectPFH, checks if object is deleted or dead OR (target moved away from carrier (weapon disasembled)) -if ((!([_target] call EFUNC(common,isAlive))) || {(_unit distance _target) > 10}) then { +if (!alive _target || {_unit distance _target > 10}) then { [_unit, _target] call FUNC(dropObject); [_idPFH] call CBA_fnc_removePerFrameHandler; }; diff --git a/addons/dragging/stringtable.xml b/addons/dragging/stringtable.xml index 35f9d6038d..42bd0ccd02 100644 --- a/addons/dragging/stringtable.xml +++ b/addons/dragging/stringtable.xml @@ -49,5 +49,9 @@ Trasporta Нести + + Raise/Lower + Heben/Senken + diff --git a/addons/explosives/functions/fnc_addExplosiveActions.sqf b/addons/explosives/functions/fnc_addExplosiveActions.sqf index 764c0cd7b8..fa00fdd207 100644 --- a/addons/explosives/functions/fnc_addExplosiveActions.sqf +++ b/addons/explosives/functions/fnc_addExplosiveActions.sqf @@ -45,7 +45,7 @@ _children = []; format ["Explosive_%1", _forEachIndex], format [_name + " (%1)", _itemCount select _forEachIndex], getText(_x >> "picture"), - {_this call FUNC(setupExplosive);}, + {[{_this call FUNC(setupExplosive)}, _this] call EFUNC(common,execNextFrame)}, {true}, {}, (configName _x) diff --git a/addons/explosives/stringtable.xml b/addons/explosives/stringtable.xml index a346d3b4be..f23cb2fc00 100644 --- a/addons/explosives/stringtable.xml +++ b/addons/explosives/stringtable.xml @@ -94,16 +94,16 @@ Отмена - + Modifier, rotates - + Modifikator, drehen - + Modificador, girar - + Modificateur, tourner - + Modificatore, rotazione - + Modifikátor, otočit - + Változtatás, forgatás - + Modyfikator, obrót - + Modificador, rotaciona - + Bращать + +Ctrl rotate + +Strg drehen + +Ctrl girar + +Ctrl tourner + +Ctrl rotazione + +Ctrl otočit + +Ctrl forgatás + +Ctrl obrót + +Ctrl rotaciona + +Ctrl Bращать Turn On Thor III diff --git a/addons/goggles/ACE_Settings.hpp b/addons/goggles/ACE_Settings.hpp index 6b3faa1823..a78c2866e0 100644 --- a/addons/goggles/ACE_Settings.hpp +++ b/addons/goggles/ACE_Settings.hpp @@ -1,4 +1,11 @@ + class ACE_Settings { + /*class GVAR(enable) { // @todo + value = 0; + typeName = "BOOL"; + isClientSettable = 1; + displayName = CSTRING(enable); + };*/ class GVAR(showInThirdPerson) { value = 0; typeName = "BOOL"; diff --git a/addons/goggles/CfgEventHandlers.hpp b/addons/goggles/CfgEventHandlers.hpp index 8c7edda20f..67f17fda18 100644 --- a/addons/goggles/CfgEventHandlers.hpp +++ b/addons/goggles/CfgEventHandlers.hpp @@ -1,10 +1,36 @@ + class Extended_PreInit_EventHandlers { class ADDON { init = QUOTE(call COMPILE_FILE(XEH_preInit)); }; }; + class Extended_PostInit_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_postInit)); - }; + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; + +class Extended_Killed_EventHandlers { + class CAManBase { + class ADDON { + killed = QUOTE(_this call FUNC(handleKilled)); + }; + }; +}; + +class Extended_Fired_EventHandlers { + class CAManBase { + class ADDON { + fired = QUOTE(if (local (_this select 0)) then {_this call FUNC(handleFired)}); + }; + }; +}; + +class Extended_Explosion_EventHandlers { + class CAManBase { + class ADDON { + explosion = QUOTE(if (local (_this select 0)) then {_this call FUNC(handleExplosion)}); + }; + }; }; diff --git a/addons/goggles/XEH_postInit.sqf b/addons/goggles/XEH_postInit.sqf index 088ccc477a..4958c8e02b 100644 --- a/addons/goggles/XEH_postInit.sqf +++ b/addons/goggles/XEH_postInit.sqf @@ -1,24 +1,8 @@ -/* - * Author: Garth 'L-H' de Wet - * Sets up the glasses mod for usage. Initialises variables and event handlers. - * Shouldn't be called by a user/modder ever. Done by the engine. - * - * Arguments: - * None - * - * Return Value: - * None - * - * Example: - * None - * - * Public: No - */ #include "script_component.hpp" + if (!hasInterface) exitWith {}; -["ACE3 Common", QGVAR(wipeGlasses), localize LSTRING(WipeGlasses), -{ +["ACE3 Common", QGVAR(wipeGlasses), localize LSTRING(WipeGlasses), { if (!(GETVAR(ace_player,ACE_isUnconscious,false))) exitWith { call FUNC(clearGlasses); true @@ -26,22 +10,29 @@ if (!hasInterface) exitWith {}; false }, {false}, -[20, [true, true, false]], false] call cba_fnc_addKeybind; +[20, [true, true, false]], false] call CBA_fnc_addKeybind; -if isNil(QGVAR(UsePP)) then { +// make sure to stack effect layers in correct order +GVAR(GogglesEffectsLayer) = QGVAR(GogglesEffectsLayer) call BIS_fnc_RSCLayer; +GVAR(GogglesLayer) = QGVAR(GogglesLayer) call BIS_fnc_RSCLayer; + +if (isNil QGVAR(UsePP)) then { GVAR(UsePP) = true; }; -GVAR(PostProcess) = ppEffectCreate ["ColorCorrections", 1995]; +// init pp effects +GVAR(PostProcess) = ppEffectCreate ["ColorCorrections", 1995]; GVAR(PostProcessEyes) = ppEffectCreate ["ColorCorrections", 1992]; -GVAR(PostProcessEyes) ppEffectAdjust[1, 1, 0, [0,0,0,0], [0,0,0,1],[1,1,1,0]]; +GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [0, 0, 0, 1], [1, 1, 1, 0]]; GVAR(PostProcessEyes) ppEffectCommit 0; GVAR(PostProcessEyes) ppEffectEnable false; + GVAR(EffectsActive) = false; + SETGLASSES(ace_player,GLASSESDEFAULT); -GVAR(Current) = "None"; + GVAR(EyesDamageScript) = -1; -GVAR(FrameEvent) = [false, [false,20]]; +GVAR(FrameEvent) = [false, [false, 20]]; GVAR(PostProcessEyes_Enabled) = false; GVAR(DustHandler) = -1; GVAR(RainDrops) = objNull; @@ -50,82 +41,89 @@ GVAR(RainLastLevel) = 0; GVAR(surfaceCache) = ""; GVAR(surfaceCacheIsDust) = false; -FUNC(CheckGlasses) = { - if (GVAR(Current) != (goggles ace_player)) then { - GVAR(Current) = (goggles ace_player); - ["GlassesChanged",[GVAR(Current)]] call EFUNC(common,localEvent); - }; -}; +// init GlassesChanged eventhandler +GVAR(OldGlasses) = "#NULLSTRING"; -player addEventHandler ["Explosion", { - private "_effects"; - if (alive ace_player) then { - call FUNC(ApplyDirtEffect); - if (GETBROKEN) exitWith {}; - if (((_this select 1) call FUNC(GetExplosionIndex)) < getNumber(ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_Resistance")) exitWith {}; - if !([ace_player] call FUNC(isGogglesVisible)) exitWith {["GlassesCracked",[ace_player]] call EFUNC(common,localEvent);}; - _effects = GETGLASSES(ace_player); - _effects set [BROKEN, true]; - SETGLASSES(ace_player,_effects); - if (getText(ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_OverlayCracked") != "" && {cameraOn == ace_player}) then { - if (call FUNC(ExternalCamera)) exitWith {}; - if (isNull(GLASSDISPLAY)) then { - 150 cutRsc["RscACE_Goggles", "PLAIN",1, false]; - }; - (GLASSDISPLAY displayCtrl 10650) ctrlSetText getText(ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_OverlayCracked"); - }; - ["GlassesCracked",[ace_player]] call EFUNC(common,localEvent); - }; -}]; -player addEventHandler ["Killed",{ - GVAR(PostProcessEyes) ppEffectEnable false; - SETGLASSES(ace_player,GLASSESDEFAULT); - call FUNC(removeGlassesEffect); - GVAR(EffectsActive)=false; - ace_player setVariable ["ACE_EyesDamaged", false]; - if (GVAR(EyesDamageScript) != -1) then { - [GVAR(EyesDamageScript)] call CALLSTACK(cba_fnc_removePreFrameHandler); - }; - if (GVAR(DustHandler) != -1) then { - [GVAR(DustHandler)] call CALLSTACK(cba_fnc_removePerFrameHandler); - GVAR(DustHandler) = -1; - }; -}]; -player addEventHandler ["Fired",{[_this select 0, _this select 1] call FUNC(dustHandler);}]; -player AddEventHandler ["Take",{call FUNC(checkGlasses);}]; -player AddEventHandler ["Put", {call FUNC(checkGlasses);}]; +["playerInventoryChanged", { + (_this select 1) params ["", "_currentGlasses"]; -["GlassesChanged",{ - SETGLASSES(ace_player,GLASSESDEFAULT); + if (GVAR(OldGlasses) != _currentGlasses) then { + ["GlassesChanged", [ACE_player, _currentGlasses]] call EFUNC(common,localEvent); + GVAR(OldGlasses) = _currentGlasses; + }; +}] call EFUNC(common,addEventHandler); + +// add glasses eventhandlers +["GlassesChanged", { + params ["_unit", "_glasses"]; + + SETGLASSES(_unit,GLASSESDEFAULT); if (call FUNC(ExternalCamera)) exitWith {call FUNC(RemoveGlassesEffect)}; - if ([ace_player] call FUNC(isGogglesVisible)) then { - [_this select 0] call FUNC(applyGlassesEffect); + if ([_unit] call FUNC(isGogglesVisible)) then { + _glasses call FUNC(applyGlassesEffect); } else { call FUNC(removeGlassesEffect); }; }] call EFUNC(common,addEventHandler); -["GlassesCracked",{ - if (_this select 0 != ace_player) exitWith {}; - ace_player setVariable ["ACE_EyesDamaged", true]; - if (GVAR(EyesDamageScript) != -1) then { - [GVAR(EyesDamageScript)] call CALLSTACK(cba_fnc_removePreFrameHandler); - }; - GVAR(PostProcessEyes) ppEffectAdjust[1, 1, 0, [0,0,0,0], [0.5,0.5,0.5,0.5],[1,1,1,0]]; + +["GlassesCracked", { + params ["_unit"]; + + _unit setVariable ["ACE_EyesDamaged", true]; + + GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [0.5, 0.5, 0.5, 0.5], [1, 1, 1, 0]]; GVAR(PostProcessEyes) ppEffectCommit 0; GVAR(PostProcessEyes) ppEffectEnable true; - GVAR(EyesDamageScript) = [{ - GVAR(PostProcessEyes) ppEffectAdjust[1, 1, 0, [0,0,0,0], [1,1,1,1],[1,1,1,0]]; + + [{ + GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [1, 1, 1, 1], [1, 1, 1, 0]]; GVAR(PostProcessEyes) ppEffectCommit 5; + GVAR(EyesDamageScript) = [{ + params ["_unit"]; + GVAR(PostProcessEyes) ppEffectEnable false; - ace_player setVariable ["ACE_EyesDamaged", false]; - GVAR(EyesDamageScript) = -1; - }, [], 5, 1] call EFUNC(common,waitAndExecute); - }, [], 25, 5] call EFUNC(common,waitAndExecute); + + _unit setVariable ["ACE_EyesDamaged", false]; + + }, _this, 5] call EFUNC(common,waitAndExecute); + + }, _unit, 25] call EFUNC(common,waitAndExecute); + }] call EFUNC(common,addEventHandler); -call FUNC(checkGlasses); -[FUNC(CheckGoggles), 1, []] call CBA_fnc_addPerFrameHandler; -[FUNC(rainEffect), 0.5, []] call CBA_fnc_addPerFrameHandler; -[FUNC(onEachFrame), 0, []] call CBA_fnc_addPerFrameHandler; + +// check goggles +local _fnc_checkGoggles = { + params ["_unit"]; + + if (GVAR(EffectsActive)) then { + if (call FUNC(externalCamera) || {!([_unit] call FUNC(isGogglesVisible))}) then { + call FUNC(removeGlassesEffect); + }; + } else { + if (!(call FUNC(externalCamera)) && {[_unit] call FUNC(isGogglesVisible)}) then { + [goggles _unit] call FUNC(applyGlassesEffect); + }; + }; +}; + +["cameraViewChanged", _fnc_checkGoggles] call EFUNC(common,addEventHandler); +["activeCameraChanged", _fnc_checkGoggles] call EFUNC(common,addEventHandler); + +// goggles effects main PFH +[{ + // rain + call FUNC(applyRainEffect); + + // auto remove effects under water + if (GVAR(EffectsActive) && {[goggles ACE_player] call FUNC(isDivingGoggles) && {underwater ACE_player}}) then { + call FUNC(removeRainEffect); + call FUNC(removeDirtEffect); + call FUNC(removeDustEffect); + }; + + // rotor wash effect + call FUNC(applyRotorWashEffect) +}, 0.5, _fnc_checkGoggles] call CBA_fnc_addPerFrameHandler; diff --git a/addons/goggles/XEH_preInit.sqf b/addons/goggles/XEH_preInit.sqf index 4eb7df91d1..ba5fa2373e 100644 --- a/addons/goggles/XEH_preInit.sqf +++ b/addons/goggles/XEH_preInit.sqf @@ -1,42 +1,31 @@ -/* - * Author: Garth 'L-H' de Wet - * Initialises Goggles. - * - * Arguments: - * None - * - * Return Value: - * None - * - * Example: - * None - * - * Public: No - */ #include "script_component.hpp" ADDON = false; +// effects PREP(applyDirtEffect); -PREP(applyDust); +PREP(applyDustEffect); PREP(applyGlassesEffect); - -PREP(checkGoggles); -PREP(clearGlasses); -PREP(dustHandler); -PREP(externalCamera); -PREP(getExplosionIndex); - -PREP(isDivingGoggles); -PREP(isGogglesVisible); -PREP(isInRotorWash); - -PREP(onEachFrame); -PREP(rainEffect); - +PREP(applyRainEffect); +PREP(applyRotorWashEffect); PREP(removeDirtEffect); PREP(removeDustEffect); PREP(removeGlassesEffect); PREP(removeRainEffect); +// public +PREP(externalCamera); +PREP(isDivingGoggles); +PREP(isGogglesVisible); +PREP(isInRotorWash); + +// general +PREP(clearGlasses); +PREP(getExplosionIndex); + +// eventhandlers +PREP(handleExplosion); +PREP(handleFired); +PREP(handleKilled); + ADDON = true; diff --git a/addons/goggles/anim/model.cfg b/addons/goggles/anim/model.cfg index 00ce647aa7..da614e05db 100644 --- a/addons/goggles/anim/model.cfg +++ b/addons/goggles/anim/model.cfg @@ -1,128 +1,133 @@ -class CfgSkeletons -{ - class Default - { - isDiscrete = 1; - skeletonInherit = ""; - skeletonBones[] = {}; - }; - class OFP2_ManSkeleton - { - isDiscrete = 0; - skeletonInherit = ""; - skeletonBones[] = - { - "Pelvis","", - "Spine","Pelvis", - "Spine1","Spine", - "Spine2","Spine1", - "Spine3","Spine2", - "Camera","Pelvis", - "weapon","Spine1", - "launcher","Spine1", - //Head skeleton in hierarchy - "neck","Spine3", - "neck1","neck", - "head","neck1", - //New facial features - "Face_Hub","head", - "Face_Jawbone","Face_Hub", - "Face_Jowl","Face_Jawbone", - "Face_chopRight","Face_Jawbone", - "Face_chopLeft","Face_Jawbone", - "Face_LipLowerMiddle","Face_Jawbone", - "Face_LipLowerLeft","Face_Jawbone", - "Face_LipLowerRight","Face_Jawbone", - "Face_Chin","Face_Jawbone", - "Face_Tongue","Face_Jawbone", - "Face_CornerRight","Face_Hub", - "Face_CheekSideRight","Face_CornerRight", - "Face_CornerLeft","Face_Hub", - "Face_CheekSideLeft","Face_CornerLeft", - "Face_CheekFrontRight","Face_Hub", - "Face_CheekFrontLeft","Face_Hub", - "Face_CheekUpperRight","Face_Hub", - "Face_CheekUpperLeft","Face_Hub", - "Face_LipUpperMiddle","Face_Hub", - "Face_LipUpperRight","Face_Hub", - "Face_LipUpperLeft","Face_Hub", - "Face_NostrilRight","Face_Hub", - "Face_NostrilLeft","Face_Hub", - "Face_Forehead","Face_Hub", - "Face_BrowFrontRight","Face_Forehead", - "Face_BrowFrontLeft","Face_Forehead", - "Face_BrowMiddle","Face_Forehead", - "Face_BrowSideRight","Face_Forehead", - "Face_BrowSideLeft","Face_Forehead", - "Face_Eyelids","Face_Hub", - "Face_EyelidUpperRight","Face_Hub", - "Face_EyelidUpperLeft","Face_Hub", - "Face_EyelidLowerRight","Face_Hub", - "Face_EyelidLowerLeft","Face_Hub", - "EyeLeft","Face_Hub", - "EyeRight","Face_Hub", - //Left upper side - "LeftShoulder","Spine3", - "LeftArm","LeftShoulder", - "LeftArmRoll","LeftArm", - "LeftForeArm","LeftArmRoll", - "LeftForeArmRoll","LeftForeArm", - "LeftHand","LeftForeArmRoll", - "LeftHandRing","LeftHand", - "LeftHandRing1","LeftHandRing", - "LeftHandRing2","LeftHandRing1", - "LeftHandRing3","LeftHandRing2", - "LeftHandPinky1","LeftHandRing", - "LeftHandPinky2","LeftHandPinky1", - "LeftHandPinky3","LeftHandPinky2", - "LeftHandMiddle1","LeftHand", - "LeftHandMiddle2","LeftHandMiddle1", - "LeftHandMiddle3","LeftHandMiddle2", - "LeftHandIndex1","LeftHand", - "LeftHandIndex2","LeftHandIndex1", - "LeftHandIndex3","LeftHandIndex2", - "LeftHandThumb1","LeftHand", - "LeftHandThumb2","LeftHandThumb1", - "LeftHandThumb3","LeftHandThumb2", - //Right upper side - "RightShoulder","Spine3", - "RightArm","RightShoulder", - "RightArmRoll","RightArm", - "RightForeArm","RightArmRoll", - "RightForeArmRoll","RightForeArm", - "RightHand","RightForeArmRoll", - "RightHandRing","RightHand", - "RightHandRing1","RightHandRing", - "RightHandRing2","RightHandRing1", - "RightHandRing3","RightHandRing2", - "RightHandPinky1","RightHandRing", - "RightHandPinky2","RightHandPinky1", - "RightHandPinky3","RightHandPinky2", - "RightHandMiddle1","RightHand", - "RightHandMiddle2","RightHandMiddle1", - "RightHandMiddle3","RightHandMiddle2", - "RightHandIndex1","RightHand", - "RightHandIndex2","RightHandIndex1", - "RightHandIndex3","RightHandIndex2", - "RightHandThumb1","RightHand", - "RightHandThumb2","RightHandThumb1", - "RightHandThumb3","RightHandThumb2", - //Left lower side - "LeftUpLeg","Pelvis", - "LeftUpLegRoll","LeftUpLeg", - "LeftLeg","LeftUpLegRoll", - "LeftLegRoll","LeftLeg", - "LeftFoot","LeftLegRoll", - "LeftToeBase","LeftFoot", - //Right lower side - "RightUpLeg","Pelvis", - "RightUpLegRoll","RightUpLeg", - "RightLeg","RightUpLegRoll", - "RightLegRoll","RightLeg", - "RightFoot","RightLegRoll", - "RightToeBase","RightFoot" - }; - // location of pivot points (local axes) for hierarchical animation - pivotsModel="A3\anims_f\data\skeleton\SkeletonPivots.p3d"; - }; -}; \ No newline at end of file + +class CfgSkeletons { + class Default { + isDiscrete = 1; + skeletonInherit = ""; + skeletonBones[] = {}; + }; + + class OFP2_ManSkeleton { + isDiscrete = 0; + skeletonInherit = ""; + skeletonBones[] = { + "Pelvis","", + "Spine","Pelvis", + "Spine1","Spine", + "Spine2","Spine1", + "Spine3","Spine2", + "Camera","Pelvis", + "weapon","Spine1", + "launcher","Spine1", + + //Head skeleton in hierarchy + "neck","Spine3", + "neck1","neck", + "head","neck1", + + //New facial features + "Face_Hub","head", + "Face_Jawbone","Face_Hub", + "Face_Jowl","Face_Jawbone", + "Face_chopRight","Face_Jawbone", + "Face_chopLeft","Face_Jawbone", + "Face_LipLowerMiddle","Face_Jawbone", + "Face_LipLowerLeft","Face_Jawbone", + "Face_LipLowerRight","Face_Jawbone", + "Face_Chin","Face_Jawbone", + "Face_Tongue","Face_Jawbone", + "Face_CornerRight","Face_Hub", + "Face_CheekSideRight","Face_CornerRight", + "Face_CornerLeft","Face_Hub", + "Face_CheekSideLeft","Face_CornerLeft", + "Face_CheekFrontRight","Face_Hub", + "Face_CheekFrontLeft","Face_Hub", + "Face_CheekUpperRight","Face_Hub", + "Face_CheekUpperLeft","Face_Hub", + "Face_LipUpperMiddle","Face_Hub", + "Face_LipUpperRight","Face_Hub", + "Face_LipUpperLeft","Face_Hub", + "Face_NostrilRight","Face_Hub", + "Face_NostrilLeft","Face_Hub", + "Face_Forehead","Face_Hub", + "Face_BrowFrontRight","Face_Forehead", + "Face_BrowFrontLeft","Face_Forehead", + "Face_BrowMiddle","Face_Forehead", + "Face_BrowSideRight","Face_Forehead", + "Face_BrowSideLeft","Face_Forehead", + "Face_Eyelids","Face_Hub", + "Face_EyelidUpperRight","Face_Hub", + "Face_EyelidUpperLeft","Face_Hub", + "Face_EyelidLowerRight","Face_Hub", + "Face_EyelidLowerLeft","Face_Hub", + "EyeLeft","Face_Hub", + "EyeRight","Face_Hub", + + //Left upper side + "LeftShoulder","Spine3", + "LeftArm","LeftShoulder", + "LeftArmRoll","LeftArm", + "LeftForeArm","LeftArmRoll", + "LeftForeArmRoll","LeftForeArm", + "LeftHand","LeftForeArmRoll", + "LeftHandRing","LeftHand", + "LeftHandRing1","LeftHandRing", + "LeftHandRing2","LeftHandRing1", + "LeftHandRing3","LeftHandRing2", + "LeftHandPinky1","LeftHandRing", + "LeftHandPinky2","LeftHandPinky1", + "LeftHandPinky3","LeftHandPinky2", + "LeftHandMiddle1","LeftHand", + "LeftHandMiddle2","LeftHandMiddle1", + "LeftHandMiddle3","LeftHandMiddle2", + "LeftHandIndex1","LeftHand", + "LeftHandIndex2","LeftHandIndex1", + "LeftHandIndex3","LeftHandIndex2", + "LeftHandThumb1","LeftHand", + "LeftHandThumb2","LeftHandThumb1", + "LeftHandThumb3","LeftHandThumb2", + + //Right upper side + "RightShoulder","Spine3", + "RightArm","RightShoulder", + "RightArmRoll","RightArm", + "RightForeArm","RightArmRoll", + "RightForeArmRoll","RightForeArm", + "RightHand","RightForeArmRoll", + "RightHandRing","RightHand", + "RightHandRing1","RightHandRing", + "RightHandRing2","RightHandRing1", + "RightHandRing3","RightHandRing2", + "RightHandPinky1","RightHandRing", + "RightHandPinky2","RightHandPinky1", + "RightHandPinky3","RightHandPinky2", + "RightHandMiddle1","RightHand", + "RightHandMiddle2","RightHandMiddle1", + "RightHandMiddle3","RightHandMiddle2", + "RightHandIndex1","RightHand", + "RightHandIndex2","RightHandIndex1", + "RightHandIndex3","RightHandIndex2", + "RightHandThumb1","RightHand", + "RightHandThumb2","RightHandThumb1", + "RightHandThumb3","RightHandThumb2", + + //Left lower side + "LeftUpLeg","Pelvis", + "LeftUpLegRoll","LeftUpLeg", + "LeftLeg","LeftUpLegRoll", + "LeftLegRoll","LeftLeg", + "LeftFoot","LeftLegRoll", + "LeftToeBase","LeftFoot", + + //Right lower side + "RightUpLeg","Pelvis", + "RightUpLegRoll","RightUpLeg", + "RightLeg","RightUpLegRoll", + "RightLegRoll","RightLeg", + "RightFoot","RightLegRoll", + "RightToeBase","RightFoot" + }; + + // location of pivot points (local axes) for hierarchical animation + pivotsModel="A3\anims_f\data\skeleton\SkeletonPivots.p3d"; + }; +}; diff --git a/addons/goggles/functions/fnc_applyDirtEffect.sqf b/addons/goggles/functions/fnc_applyDirtEffect.sqf index 068f7639d2..b10ebc9668 100644 --- a/addons/goggles/functions/fnc_applyDirtEffect.sqf +++ b/addons/goggles/functions/fnc_applyDirtEffect.sqf @@ -9,23 +9,29 @@ * Succeeded * * Example: - * _applied = call ace_goggles_fnc_ApplyDirtEffect; + * _applied = call ace_goggles_fnc_applyDirtEffect * * Public: Yes */ #include "script_component.hpp" -if (cameraOn != ace_player || {call FUNC(externalCamera)}) exitWith{false}; -private ["_dirtImage", "_applied", "_effects"]; -_effects = GETGLASSES(ace_player); +if (GVAR(showInThirdPerson)) exitWith {false}; +if (call FUNC(externalCamera)) exitWith {false}; + +private ["_unit", "_effects"]; + +_unit = ACE_player; + +_effects = GETGLASSES(_unit); _effects set [DIRT, true]; -SETGLASSES(ace_player,_effects); -if ([ace_player] call FUNC(isGogglesVisible)) then{ - _dirtImage = getText(ConfigFile >> "CfgGlasses" >> (goggles ace_player) >> "ACE_OverlayDirt"); +SETGLASSES(_unit,_effects); + +if ([_unit] call FUNC(isGogglesVisible)) then { + local _dirtImage = getText (configFile >> "CfgGlasses" >> goggles _unit >> "ACE_OverlayDirt"); + if (_dirtImage != "") then { - 100 cutRsc["RscACE_GogglesEffects", "PLAIN",0.1, false]; - + GVAR(GogglesEffectsLayer) cutRsc ["RscACE_GogglesEffects", "PLAIN", 0.1, false]; (GETUVAR(GVAR(DisplayEffects),displayNull) displayCtrl 10660) ctrlSetText _dirtImage; }; }; diff --git a/addons/goggles/functions/fnc_applyDust.sqf b/addons/goggles/functions/fnc_applyDust.sqf deleted file mode 100644 index a1ac88c78d..0000000000 --- a/addons/goggles/functions/fnc_applyDust.sqf +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Author: Garth 'L-H' de Wet - * Applies dust to screen. - * - * Arguments: - * None - * - * Return Value: - * None - * - * Example: - * call ace_goggles_fnc_ApplyDust; - * - * Public: Yes - */ -#include "script_component.hpp" - -if (call FUNC(ExternalCamera)) exitWith {}; -if ([ace_player] call FUNC(isGogglesVisible)) exitWith { - 100 cutRsc["RscACE_GogglesEffects", "PLAIN",2,false]; - (uiNamespace getVariable ["ACE_Goggles_DisplayEffects", displayNull] displayCtrl 10662) ctrlSetText format[getText(ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_DustPath"), GETDUSTT(DAMOUNT)+1]; - SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT)+1,0,1)); - SETDUST(DBULLETS,0); -}; - -if (GETVAR(ace_player,ACE_EyesDamaged,false)) exitWith {SETDUST(DACTIVE,false);SETDUST(DBULLETS,0);SETDUST(DAMOUNT,0);}; -SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT)+1,0,2)); - -private "_amount"; -_amount = 1 - (GETDUSTT(DAMOUNT) * 0.125); - -GVAR(PostProcessEyes) ppEffectAdjust[1, 1, 0, [0,0,0,0], [_amount,_amount,_amount,_amount],[1,1,1,0]]; -GVAR(PostProcessEyes) ppEffectCommit 1; -GVAR(PostProcessEyes) ppEffectEnable true; -SETDUST(DBULLETS,0); - -if (GVAR(DustHandler) != -1) then { // should be fixed in dev CBA - [GVAR(DustHandler)] call CALLSTACK(cba_fnc_removePerFrameHandler); - GVAR(DustHandler) = -1; -}; -GVAR(DustHandler) = [{ - if (ACE_diagTime >= GETDUSTT(DTIME) + 3) then { - SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT)-1,0,2)); - private "_amount"; - _amount = 1 - (GETDUSTT(DAMOUNT) * 0.125); - if !(ace_player getVariable ["ACE_EyesDamaged", false]) then { - GVAR(PostProcessEyes) ppEffectAdjust[1, 1, 0, [0,0,0,0], [_amount,_amount,_amount,_amount],[1,1,1,0]]; - GVAR(PostProcessEyes) ppEffectCommit 0.5; - }; - if (GETDUSTT(DAMOUNT) <= 0) then { - GVAR(PostProcessEyes) ppEffectAdjust[1, 1, 0, [0,0,0,0], [1,1,1,1],[1,1,1,0]]; - GVAR(PostProcessEyes) ppEffectCommit 2; - [{GVAR(PostProcessEyes) ppEffectEnable false;}, [], 2, 0.5] call EFUNC(common,waitAndExecute); - SETDUST(DACTIVE,false); - SETDUST(DBULLETS,0); - [GVAR(DustHandler)] call CALLSTACK(cba_fnc_removePerFrameHandler); - GVAR(DustHandler) = -1; - }; - }; -},0,[]] call CALLSTACK(CBA_fnc_addPerFrameHandler); diff --git a/addons/goggles/functions/fnc_applyDustEffect.sqf b/addons/goggles/functions/fnc_applyDustEffect.sqf new file mode 100644 index 0000000000..b052f3eae7 --- /dev/null +++ b/addons/goggles/functions/fnc_applyDustEffect.sqf @@ -0,0 +1,81 @@ +/* + * Author: Garth 'L-H' de Wet + * Applies dust to screen. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * call ace_goggles_fnc_applyDustEffect + * + * Public: Yes + */ +#include "script_component.hpp" + +if (GVAR(showInThirdPerson)) exitWith {}; +if (call FUNC(ExternalCamera)) exitWith {}; + +private ["_unit", "_amount"]; + +_unit = ACE_player; + +if ([_unit] call FUNC(isGogglesVisible)) exitWith { + GVAR(GogglesEffectsLayer) cutRsc ["RscACE_GogglesEffects", "PLAIN", 2, false]; + + ((GETUVAR(GVAR(DisplayEffects),displayNull)) displayCtrl 10662) ctrlSetText format [getText (configFile >> "CfgGlasses" >> goggles _unit >> "ACE_DustPath"), GETDUSTT(DAMOUNT) + 1]; + + SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT) + 1,0,1)); + SETDUST(DBULLETS,0); +}; + +if (GETVAR(_unit,ACE_EyesDamaged,false)) exitWith { + SETDUST(DACTIVE,false); + SETDUST(DBULLETS,0); + SETDUST(DAMOUNT,0); +}; + +SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT) + 1,0,2)); + +_amount = 1 - (GETDUSTT(DAMOUNT) * 0.125); + +GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [_amount, _amount, _amount, _amount], [1, 1, 1, 0]]; +GVAR(PostProcessEyes) ppEffectCommit 1; +GVAR(PostProcessEyes) ppEffectEnable true; + +SETDUST(DBULLETS,0); + +[GVAR(DustHandler)] call CBA_fnc_removePerFrameHandler; +GVAR(DustHandler) = -1; + +GVAR(DustHandler) = [{ + if (ACE_diagTime >= GETDUSTT(DTIME) + 3) then { + SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT)-1,0,2)); + + local _amount = 1 - (GETDUSTT(DAMOUNT) * 0.125); + + if !(_unit getVariable ["ACE_EyesDamaged", false]) then { + GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [_amount, _amount, _amount, _amount], [1, 1, 1, 0]]; + GVAR(PostProcessEyes) ppEffectCommit 0.5; + }; + + if (GETDUSTT(DAMOUNT) <= 0) then { + SETDUST(DACTIVE,false); + SETDUST(DBULLETS,0); + + GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [1, 1, 1, 1], [1, 1, 1, 0]]; + GVAR(PostProcessEyes) ppEffectCommit 2; + + [{ + if (GVAR(DustHandler) == -1) then { + GVAR(PostProcessEyes) ppEffectEnable false + }; + }, [], 2] call EFUNC(common,waitAndExecute); + + [GVAR(DustHandler)] call CBA_fnc_removePerFrameHandler; + GVAR(DustHandler) = -1; + }; + }; +}, 0, []] call CBA_fnc_addPerFrameHandler; diff --git a/addons/goggles/functions/fnc_applyGlassesEffect.sqf b/addons/goggles/functions/fnc_applyGlassesEffect.sqf index 7abb10d448..7be010ef9c 100644 --- a/addons/goggles/functions/fnc_applyGlassesEffect.sqf +++ b/addons/goggles/functions/fnc_applyGlassesEffect.sqf @@ -11,20 +11,23 @@ * None * * Example: - * [goggles ace_player] call ace_goggles_fnc_ApplyGlassesEffect; + * [goggles ace_player] call ace_goggles_fnc_applyGlassesEffect * * Public: No */ #include "script_component.hpp" -private["_postProcessColour", "_postProcessTintAmount", "_glassesClassname", "_glassImagePath"]; - -_glassesClassname = _this select 0; -_postProcessColour = getArray(configFile >> "CfgGlasses" >> _glassesClassname >> "ACE_Color"); -_postProcessTintAmount = getNumber(configFile >> "CfgGlasses" >> _glassesClassname >> "ACE_TintAmount"); +params ["_glasses"]; +// remove old effect call FUNC(removeGlassesEffect); -GVAR(EffectsActive) = true; + +private ["_config", "_postProcessColour", "_postProcessTintAmount", "_imagePath"]; + +_config = configFile >> "CfgGlasses" >> _glasses; + +_postProcessColour = getArray (_config >> "ACE_Color"); +_postProcessTintAmount = getNumber (_config >> "ACE_TintAmount"); if (_postProcessTintAmount != 0 && {GVAR(UsePP)}) then { _postProcessColour set [3, _postProcessTintAmount/100]; @@ -36,20 +39,20 @@ if (_postProcessTintAmount != 0 && {GVAR(UsePP)}) then { GVAR(PostProcess) ppEffectCommit 30; }; -_glassImagePath = getText(configFile >> "CfgGlasses" >> _glassesClassname >> "ACE_Overlay"); -if GETBROKEN then { - _glassImagePath = getText(configFile >> "CfgGlasses" >> _glassesClassname >> "ACE_OverlayCracked"); -}; -if (_glassImagePath != "") then { - 150 cutRsc["RscACE_Goggles", "PLAIN",1, false]; - (GLASSDISPLAY displayCtrl 10650) ctrlSetText _glassImagePath; +_imagePath = getText (_config >> ["ACE_Overlay", "ACE_OverlayCracked"] select GETBROKEN); + +if (_imagePath != "") then { + GVAR(GogglesLayer) cutRsc ["RscACE_Goggles", "PLAIN", 1, false]; + (GLASSDISPLAY displayCtrl 10650) ctrlSetText _imagePath; }; -if GETDIRT then { +if (GETDIRT) then { call FUNC(applyDirtEffect); }; -if GETDUSTT(DACTIVE) then { +if (GETDUSTT(DACTIVE)) then { SETDUST(DAMOUNT,CLAMP(GETDUSTT(DAMOUNT)-1,0,2)); - call FUNC(applyDust); + call FUNC(applyDustEffect); }; + +GVAR(EffectsActive) = true; diff --git a/addons/goggles/functions/fnc_applyRainEffect.sqf b/addons/goggles/functions/fnc_applyRainEffect.sqf new file mode 100644 index 0000000000..7e1260a453 --- /dev/null +++ b/addons/goggles/functions/fnc_applyRainEffect.sqf @@ -0,0 +1,68 @@ +/* + * Author: Garth 'L-H' de Wet + * Handles rain effects being created on glasses. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * call ace_goggles_fnc_applyRainEffect; + * + * Public: No + */ +#include "script_component.hpp" + +private ["_unit", "_fnc_underCover"]; + +_unit = ACE_player; + +if (!alive _unit) exitWith {}; + +_fnc_underCover = { + params ["_unit"]; + + if (vehicle _unit != _unit && {!isTurnedOut _unit}) exitWith {true}; + + // looking up and no roof over head + local _position = eyePos _unit; + positionCameraToWorld [0, 0, 1] select 2 < (positionCameraToWorld [0, 0, 0] select 2) - 0.4 || {(lineIntersects [_position, _position vectorAdd [0, 0, 15], _unit])} // return +}; + +if (!isNull findDisplay 312) exitWith { + if (GVAR(RainActive)) then { + call FUNC(removeRainEffect); + }; +}; + +// Ignore if unit is under water +if !(GVAR(EffectsActive) || {underwater _unit}) exitWith { + call FUNC(RemoveRainEffect); +}; + +if (GVAR(RainLastLevel) != rain) then { + call FUNC(RemoveRainEffect); + + GVAR(RainLastLevel) = rain; + + // Rain is happening + if (GVAR(RainLastLevel) > 0.05 && {!([_unit] call _fnc_underCover)}) then { + GVAR(RainActive) = true; + GVAR(RainDrops) = "#particlesource" createVehicleLocal position _unit; + GVAR(RainDrops) setParticleClass "ACERainEffect"; + GVAR(RainDrops) setDropInterval (0.07 * (1.1 - GVAR(RainLastLevel))); + GVAR(RainDrops) attachTo [vehicle _unit, [0,0,0]]; + }; +} else { + if (GVAR(RainLastLevel) > 0.05) then { + if (GVAR(RainActive) && {[_unit] call _fnc_underCover}) exitWith { + call FUNC(RemoveRainEffect); + }; + + if !(GVAR(RainActive)) then { + GVAR(RainLastLevel) = -1; + }; + }; +}; diff --git a/addons/goggles/functions/fnc_applyRotorWashEffect.sqf b/addons/goggles/functions/fnc_applyRotorWashEffect.sqf new file mode 100644 index 0000000000..7dc088bc4e --- /dev/null +++ b/addons/goggles/functions/fnc_applyRotorWashEffect.sqf @@ -0,0 +1,108 @@ +/* + * Author: Garth 'L-H' de Wet, commy2 + * Handles the rotor wash effects. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * call ace_goggles_fnc_applyRotorWashEffect; + * + * Public: No + */ +#include "script_component.hpp" + +private ["_unit", "_fnc_underCover"]; + +_unit = ACE_player; + +if (!alive _unit) exitWith {}; + +// idk. chaching magic? ends with isInRotorWash check. +GVAR(FrameEvent) set [0, !(GVAR(FrameEvent) select 0)]; + +if (GVAR(FrameEvent) select 0) exitWith { + if (vehicle _unit != _unit && {!isTurnedOut _unit}) exitWith { + (GVAR(FrameEvent) select 1) set [0, false]; + }; + + GVAR(FrameEvent) set [1, ([_unit] call FUNC(isInRotorWash))]; +}; + +// check if the unit is affected by rotor wash +private ["_rotorWash", "_safe"]; + +_rotorWash = GVAR(FrameEvent) select 1; +_safe = false; + +// no rotor wash? remove effects. +if !(_rotorWash select 0) exitWith { + if (GVAR(PostProcessEyes_Enabled)) then { + GVAR(PostProcessEyes_Enabled) = false; + + GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [0, 0, 0, 1], [1, 1, 1, 0]]; + GVAR(PostProcessEyes) ppEffectCommit 2; + + [{ + if (GVAR(DustHandler) == -1) then { + GVAR(PostProcessEyes) ppEffectEnable false; + } + }, [], 2] call EFUNC(common,waitAndExecute); + + [GVAR(DustHandler)] call CBA_fnc_removePerFrameHandler; + GVAR(DustHandler) = -1; + }; +}; + +// check protection of helmet +if (headgear _unit != "") then { + _safe = getNumber (configFile >> "CfgWeapons" >> headgear _unit >> "ACE_Protection") == 1; +}; + +// check protection of goggles +if !(_safe) then { + if !([_unit] call FUNC(isGogglesVisible)) exitWith {}; + + if (GETDUSTT(DAMOUNT) < 2) then { + if !(GETDUSTT(DACTIVE)) then { + SETDUST(DACTIVE,true); + + call FUNC(applyDustEffect); + } else { + if (_rotorWash select 1 > 0.5) then { + call FUNC(applyDustEffect); + }; + }; + }; + + _safe = getNumber (ConfigFile >> "CfgGlasses" >> goggles _unit >> "ACE_Protection") == 1; +}; + +// quit if protected by goggles or helmet +if (_safe) exitWith {}; + +// apply rotor wash effect +if (_rotorWash select 1 > 0) then { + local _scale = 0.7; + + if (_rotorWash select 1 > 0) then { + _scale = CLAMP(0.3 * (_rotorWash select 1),0.1,0.3); + } else { + _scale = 0.1; + }; + + _scale = 1 - _scale; + + [GVAR(DustHandler)] call CBA_fnc_removePerFrameHandler; + GVAR(DustHandler) = -1; + + if !(_unit getVariable ["ACE_EyesDamaged", false]) then { + GVAR(PostProcessEyes_Enabled) = true; + GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0, 0, 0, 0], [_scale, _scale, _scale, _scale], [1, 1, 1, 0]]; + GVAR(PostProcessEyes) ppEffectCommit 0.5; + GVAR(PostProcessEyes) ppEffectEnable true; + }; +}; diff --git a/addons/goggles/functions/fnc_checkGoggles.sqf b/addons/goggles/functions/fnc_checkGoggles.sqf deleted file mode 100644 index 84b86c3da4..0000000000 --- a/addons/goggles/functions/fnc_checkGoggles.sqf +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Author: Garth 'L-H' de Wet - * Performs rain checks and checks to see whether glasses effects have been applied or not. - * Checks for external camera and removes effects. - * - * Arguments: - * None - * - * Return Value: - * None - * - * Example: - * None - * - * Public: No - */ -#include "script_component.hpp" -if (!alive ace_player) exitWith {}; -if (true) then { - // Detect if curator interface is open and disable effects - if !(isNull curatorCamera) exitWith { - if (GVAR(EffectsActive)) then { - call FUNC(removeGlassesEffect); - }; - }; - call FUNC(checkGlasses); - if !([ace_player] call FUNC(isGogglesVisible)) exitWith { - if (GVAR(EffectsActive)) then { - call FUNC(removeGlassesEffect); - }; - }; - if (call FUNC(externalCamera)) exitWith { - if (GVAR(EffectsActive)) then { - call FUNC(removeGlassesEffect); - }; - }; - if !(GVAR(EffectsActive)) then { - [goggles ace_player] call FUNC(applyGlassesEffect); - } else { - if ([goggles ace_player] call FUNC(isDivingGoggles) && {underwater ace_player}) then { - call FUNC(removeRainEffect); - call FUNC(removeDirtEffect); - call FUNC(removeDustEffect); - }; - }; -}; diff --git a/addons/goggles/functions/fnc_clearGlasses.sqf b/addons/goggles/functions/fnc_clearGlasses.sqf index 7fcb05a511..d0b14e4f90 100644 --- a/addons/goggles/functions/fnc_clearGlasses.sqf +++ b/addons/goggles/functions/fnc_clearGlasses.sqf @@ -10,27 +10,31 @@ * None * * Example: - * call ace_goggles_fnc_ClearGlasses; + * call ace_goggles_fnc_clearGlasses * * Public: Yes */ #include "script_component.hpp" -private ["_broken", "_effects"]; +private ["_unit", "_broken", "_effects"]; + +_unit = ACE_player; _broken = GETBROKEN; _effects = GLASSESDEFAULT; _effects set [BROKEN, _broken]; -SETGLASSES(ace_player,_effects); -if ((stance ace_player) != "PRONE") then { - ace_player playActionNow "gestureWipeFace"; +SETGLASSES(_unit,_effects); + +if (stance _unit != "PRONE") then { + _unit playActionNow "gestureWipeFace"; }; + [{ if (cameraView == "INTERNAL") then { addCamShake [5, 1.75, 2]; }; -}, [], 0.3, 0] call EFUNC(common,waitAndExecute); +}, [], 0.3] call EFUNC(common,waitAndExecute); call FUNC(removeDirtEffect); call FUNC(removeRainEffect); diff --git a/addons/goggles/functions/fnc_dustHandler.sqf b/addons/goggles/functions/fnc_dustHandler.sqf deleted file mode 100644 index 44475d1acc..0000000000 --- a/addons/goggles/functions/fnc_dustHandler.sqf +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Author: Garth 'L-H' de Wet - * Determines whether to place dust on the goggles, based on calibre of weapon fired and other requirements. - * - * Arguments: - * 0: Unit - * 1: Weapon - * - * Return Value: - * None - * - * Example: - *ace_player addEventHandler ["Fired", {[_this select 0, _this select 1] call ace_goggles_fnc_dustHandler;}]; - * - * Public: No - */ -#include "script_component.hpp" -private ["_bullets", "_position", "_surface", "_weapon", "_cloudType", "_unit"]; -EXPLODE_2_PVT(_this,_unit,_weapon); -if (_unit != ace_player) exitWith {true}; -_cloudType = ""; - -if (rain > 0.1) exitWith {true}; -if ((stance _unit) != "PRONE") exitWith {true}; - -if (isClass(configFile >> "CfgWeapons" >> _weapon >> "GunParticles" >> "FirstEffect")) then { - _cloudType = getText(configFile >> "CfgWeapons" >> _weapon >> "GunParticles" >> "FirstEffect" >> "effectName"); -} else { - if (isClass(configFile >> "CfgWeapons" >> _weapon >> "GunParticles" >> "effect1")) then { - _cloudType = getText(configFile >> "CfgWeapons" >> _weapon >> "GunParticles" >> "effect1" >> "effectName"); - }; -}; - -if (_cloudType == "") exitWith {true}; - -_position = getPosATL _unit; - -if (surfaceIsWater _position) exitWith {}; -if ((_position select 2) > 0.2) exitWith {}; - -_surface = surfaceType _position; - -if (_surface != GVAR(surfaceCache)) then { - GVAR(surfaceCache) = _surface; - _surface = ([_surface, "#"] call CBA_fnc_split) select 1; - GVAR(surfaceCacheIsDust) = getNumber (ConfigFile >> "CfgSurfaces" >> _surface >> "dust") >= 0.1; -}; - -if (!GVAR(surfaceCacheIsDust)) exitWith {}; - -_bullets = GETDUSTT(DBULLETS); - -if ((ACE_diagTime - GETDUSTT(DTIME)) > 1) then { - _bullets = 0; -}; - -_bullets = _bullets + 1; -SETDUST(DBULLETS,_bullets); -SETDUST(DTIME,ACE_diagTime); - -if (GETDUSTT(DAMOUNT) < 2) then { - private "_bulletsRequired"; - _bulletsRequired = 100; - if (isNumber (ConfigFile >> _cloudType >> "ACE_Goggles_BulletCount")) then { - _bulletsRequired = getNumber (ConfigFile >> _cloudType >> "ACE_Goggles_BulletCount"); - }; - - if (_bulletsRequired <= _bullets) then { - SETDUST(DACTIVE,true); - call FUNC(applyDust); - }; -}; -true diff --git a/addons/goggles/functions/fnc_externalCamera.sqf b/addons/goggles/functions/fnc_externalCamera.sqf index ddc05e6b87..1af09827ab 100644 --- a/addons/goggles/functions/fnc_externalCamera.sqf +++ b/addons/goggles/functions/fnc_externalCamera.sqf @@ -6,15 +6,13 @@ * None * * Return Value: - * Whether the camera is in external view or not. If the "showInThirdPerson" option is checked, this will always return false. + * Whether the camera is in external view or not. * * Example: - * call ace_goggles_fnc_removeRainEffect; + * call ace_goggles_fnc_externalCamera; * * Public: Yes */ #include "script_component.hpp" -if (GVAR(showInThirdPerson)) exitWith { false }; - -(cameraView in ["EXTERNAL", "GROUP"] || {call EFUNC(common,isFeatureCameraActive)}) +cameraView in ["EXTERNAL", "GROUP"] || EFUNC(common,isFeatureCameraActive) // return diff --git a/addons/goggles/functions/fnc_getExplosionIndex.sqf b/addons/goggles/functions/fnc_getExplosionIndex.sqf index 6e16085b2c..9d7c4004c7 100644 --- a/addons/goggles/functions/fnc_getExplosionIndex.sqf +++ b/addons/goggles/functions/fnc_getExplosionIndex.sqf @@ -1,5 +1,5 @@ /* - * Author: Garth 'L-H' de Wet + * Author: Garth 'L-H' de Wet, commy2 * Turns 0-1 damage of explosion Event into a rating system of 0-3 * * Arguments: @@ -13,13 +13,12 @@ * * Public: No */ -private ["_effectIndex"]; +#include "script_component.hpp" -_effectIndex = switch true do { - case (_this <= 0.04): {0}; - case (_this <= 0.06): {1}; - case (_this <= 0.09): {2}; - default {3}; -}; +params ["_damage"]; -_effectIndex +if (_damage <= 0.04) exitWith {0}; +if (_damage <= 0.06) exitWith {1}; +if (_damage <= 0.09) exitWith {2}; + +3 diff --git a/addons/goggles/functions/fnc_handleExplosion.sqf b/addons/goggles/functions/fnc_handleExplosion.sqf new file mode 100644 index 0000000000..795cdd78b1 --- /dev/null +++ b/addons/goggles/functions/fnc_handleExplosion.sqf @@ -0,0 +1,51 @@ +/* + * Author: Garth 'L-H' de Wet, commy2 + * Handles explosions. + * + * Arguments: + * 0: Unit + * + * Return Value: + * Function is handled? + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit"]; + +if (_unit != ACE_player) exitWith {true}; + +call FUNC(applyDirtEffect); + +if (GETBROKEN) exitWith {true}; + +private ["_config", "_effects"]; + +_config = configFile >> "CfgGlasses" >> goggles _unit; + +if ((_this select 1) call FUNC(GetExplosionIndex) < getNumber (_config >> "ACE_Resistance")) exitWith {true}; + +if !([_unit] call FUNC(isGogglesVisible)) exitWith { + ["GlassesCracked", [_unit]] call EFUNC(common,localEvent); + true +}; + +_effects = GETGLASSES(_unit); +_effects set [BROKEN, true]; + +SETGLASSES(_unit,_effects); + +if (getText (_config >> "ACE_OverlayCracked") != "") then { + if (GVAR(showInThirdPerson)) exitWith {}; + if (call FUNC(ExternalCamera)) exitWith {}; + + if (isNull (GLASSDISPLAY)) then { + GVAR(GogglesLayer) cutRsc ["RscACE_Goggles", "PLAIN", 1, false]; + }; + + (GLASSDISPLAY displayCtrl 10650) ctrlSetText getText (_config >> "ACE_OverlayCracked"); +}; + +["GlassesCracked", [_unit]] call EFUNC(common,localEvent); +true diff --git a/addons/goggles/functions/fnc_handleFired.sqf b/addons/goggles/functions/fnc_handleFired.sqf new file mode 100644 index 0000000000..90260d07b3 --- /dev/null +++ b/addons/goggles/functions/fnc_handleFired.sqf @@ -0,0 +1,88 @@ +/* + * Author: Garth 'L-H' de Wet, commy2 + * Determines whether to place dust on the goggles, based on calibre of weapon fired and other requirements. + * + * Arguments: + * 0: Unit + * 1: Weapon + * + * Return Value: + * Function is handled? + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_weapon"]; + +if (_unit != ACE_player) exitWith {true}; + +// no dust in rain +if (rain > 0.1) exitWith {true}; + +// effect only aplies when lying on the ground +if (stance _unit != "PRONE") exitWith {true}; + +private ["_position", "_particleConfig", "_cloudType", "_surface", "_bullets"]; + +// check if the unit really is on the ground and not in a building +_position = getPosATL _unit; + +if (_position select 2 > 0.2) exitWith {true}; + +// get weapon dust effect +_particleConfig = configFile >> "CfgWeapons" >> _weapon >> "GunParticles"; + +_cloudType = ""; + +if (isClass (_particleConfig >> "FirstEffect")) then { // @todo read this with custom / non-standard config classnames + _cloudType = getText (_particleConfig >> "FirstEffect" >> "effectName"); +} else { + if (isClass (_particleConfig >> "effect1")) then { + _cloudType = getText (_particleConfig >> "effect1" >> "effectName"); + }; +}; + +// quit if the weapon causes no dust effect +if (_cloudType == "") exitWith {true}; + +// get if the surface is dusty +if (surfaceIsWater _position) exitWith {true}; + +_surface = surfaceType _position select [1]; // cuts of the leading # + +if (_surface != GVAR(surfaceCache)) then { + GVAR(surfaceCache) = _surface; + GVAR(surfaceCacheIsDust) = getNumber (configFile >> "CfgSurfaces" >> _surface >> "dust") >= 0.1; +}; + +// quit if surface isn't dusty +if (!GVAR(surfaceCacheIsDust)) exitWith {true}; + +// increment dust value with type bullet +_bullets = GETDUSTT(DBULLETS); + +if (ACE_diagTime - GETDUSTT(DTIME) > 1) then { + _bullets = 0; +}; + +_bullets = _bullets + 1; + +SETDUST(DBULLETS,_bullets); +SETDUST(DTIME,ACE_diagTime); + +// apply dust effect if the amount of fired bullets is over the threshold +if (GETDUSTT(DAMOUNT) < 2) then { + local _bulletsRequired = 100; + + if (isNumber (configFile >> _cloudType >> QGVAR(BulletCount))) then { + _bulletsRequired = getNumber (configFile >> _cloudType >> QGVAR(BulletCount)); + }; + + if (_bullets > _bulletsRequired) then { + SETDUST(DACTIVE,true); + call FUNC(applyDustEffect); + }; +}; + +true diff --git a/addons/goggles/functions/fnc_handleKilled.sqf b/addons/goggles/functions/fnc_handleKilled.sqf new file mode 100644 index 0000000000..d156fb684c --- /dev/null +++ b/addons/goggles/functions/fnc_handleKilled.sqf @@ -0,0 +1,32 @@ +/* + * Author: Garth 'L-H' de Wet, commy2 + * Handles the player dying. + * + * Arguments: + * 0: Unit + * + * Return Value: + * Function is handled? + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit"]; + +if (_unit != ACE_player) exitWith {true}; + +GVAR(PostProcessEyes) ppEffectEnable false; + +SETGLASSES(_unit,GLASSESDEFAULT); + +call FUNC(removeGlassesEffect); + +GVAR(EffectsActive) = false; + +_unit setVariable ["ACE_EyesDamaged", false]; + +[GVAR(DustHandler)] call CBA_fnc_removePerFrameHandler; +GVAR(DustHandler) = -1; + +true diff --git a/addons/goggles/functions/fnc_isDivingGoggles.sqf b/addons/goggles/functions/fnc_isDivingGoggles.sqf index bcc6b0db5e..ab5bb74269 100644 --- a/addons/goggles/functions/fnc_isDivingGoggles.sqf +++ b/addons/goggles/functions/fnc_isDivingGoggles.sqf @@ -1,22 +1,24 @@ /* - * Author: Garth 'L-H' de Wet + * Author: commy2 * Determines whether passed goggles is diving goggles or a variant of them. * * Arguments: * 0: Glasses classname * * Return Value: - * Whether diving goggles are worn + * Check if these goggles are diving goggles * * Example: - * [(goggles ace_player)] call ace_goggles_fnc_isDivingGoggles; + * [goggles ace_player] call ace_goggles_fnc_isDivingGoggles; * * Public: Yes */ #include "script_component.hpp" -private ["_result", "_glasses"]; -_glasses = _this select 0; -_result = _glasses == "G_Diving"; -if (_result) exitWith {true}; -_result = [configFile >> "CfgGlasses" >> _glasses, configFile >> "CfgGlasses" >> "G_Diving"] call CBA_fnc_inheritsFrom; -_result + +params ["_glasses"]; + +local _config = configFile >> "CfgGlasses" >> _glasses; + +if (!isClass _config) exitWith {false}; + +getNumber (_config >> "mode") == 1 // return diff --git a/addons/goggles/functions/fnc_isGogglesVisible.sqf b/addons/goggles/functions/fnc_isGogglesVisible.sqf index 80f9de4830..dfa2b97087 100644 --- a/addons/goggles/functions/fnc_isGogglesVisible.sqf +++ b/addons/goggles/functions/fnc_isGogglesVisible.sqf @@ -1,6 +1,6 @@ /* * Author: Garth 'L-H' de Wet - * Determines if goggles are visible on passed unit (Also checks if unit is in vehicle and cameraView is set to GUNNER) + * Determines if goggles are visible on passed unit. * * Arguments: * 0: Unit @@ -16,20 +16,17 @@ #include "script_component.hpp" params ["_unit"]; -private ["_currentGlasses", "_result", "_position", "_visible"]; + +private ["_currentGlasses", "_position"]; _currentGlasses = goggles _unit; -_result = false; -if (_currentGlasses != "") then { - _position = getPosASLW _unit; - if (surfaceIsWater _position && {((_position select 2) < 0.25)}) exitWith { - _result = ([_currentGlasses] call FUNC(isDivingGoggles)); - }; - if (getNumber (ConfigFile >> "CfgGlasses" >> _currentGlasses >> "ACE_Resistance") == 0) exitWith { - _result = false; - }; - _result = !([_currentGlasses] call FUNC(isDivingGoggles)); -}; +if (_currentGlasses == "") exitWith {false}; -_result +// requires ACE_Resistance config entry. Returns false for balaclavas and bandanas. +if (getNumber (configFile >> "CfgGlasses" >> _currentGlasses >> "ACE_Resistance") == 0) exitWith {false}; + +// check if in water and has diving goggles or on land and not diving goggles +_position = getPosASLW _unit; + +(surfaceIsWater _position && {_position select 2 < 0.25}) isEqualTo (_currentGlasses call FUNC(isDivingGoggles)) // return diff --git a/addons/goggles/functions/fnc_isInRotorWash.sqf b/addons/goggles/functions/fnc_isInRotorWash.sqf index ef6391fdc6..5ddc59192a 100644 --- a/addons/goggles/functions/fnc_isInRotorWash.sqf +++ b/addons/goggles/functions/fnc_isInRotorWash.sqf @@ -1,10 +1,10 @@ /* - * Author: Garth 'L-H' de Wet + * Author: Garth 'L-H' de Wet, commy2 * Checks for nearby running helicopters (within 15m) * * Arguments: * 0: Unit - * 1: Radius to check for helicopter Default: 15 (optional) + * 1: Radius to check for helicopter (default: 15) * * Return Value: * : @@ -12,35 +12,31 @@ * 1: Amount of rotor wash. * * Example: - * if (([ace_player, 10] call ace_goggles_fnc_isInRotorWash) select 0) then { hint "Rotor wash"; }; - * if (([ace_player] call ace_goggles_fnc_isInRotorWash) select 0) then { hint "Rotor wash"; }; + * if ([ace_player, 10] call ace_goggles_fnc_isInRotorWash select 0) then { hint "Rotor wash"; }; + * if ([ace_player] call ace_goggles_fnc_isInRotorWash select 0) then { hint "Rotor wash"; }; * * Public: Yes */ #include "script_component.hpp" -private ["_heli", "_unit", "_result", "_radius"]; -_unit = _this select 0; -_radius = 15; -if (count _this > 1) then { - _radius = _this select 1; -}; -_result = [false, _radius + 2]; -_heli = (getPosATL _unit) nearEntities [["Helicopter"], _radius]; +params ["_unit", ["_radius", 15]]; + +local _rotorWash = [false, 0]; + { - if !(_x isKindOf "ParachuteBase") then { - if (isEngineOn _x) then { - private "_distance"; - _distance = (_radius - (_unit distance _x)); - if (_distance != 0) then { - _distance = _distance / _radius; - }; - if (_distance < (_result select 1)) then { - _result = [true, _distance]; - }; + if (isEngineOn _x) then { + local _distance = _unit distance _x; + + // convert distance to 0...1 range, where 0 is the maximum radius + _distance = 1 - _distance / _radius; + + // use highest amount of rotor wash as return value in case of multiple helicopters + if (_distance > _rotorWash select 1) then { + _rotorWash set [0, true]; + _rotorWash set [1, _distance]; }; }; false -} count _heli; +} count (position _unit nearEntities [["Helicopter"], _radius]); -_result +_rotorWash diff --git a/addons/goggles/functions/fnc_onEachFrame.sqf b/addons/goggles/functions/fnc_onEachFrame.sqf deleted file mode 100644 index 85692a0f57..0000000000 --- a/addons/goggles/functions/fnc_onEachFrame.sqf +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Author: Garth 'L-H' de Wet - * Checks whether the player is in the downwash of a helicopter and handles applying effects of that. - * - * Arguments: - * None - * - * Return Value: - * None - * - * Example: - * ["ACE_Goggles_RotorWash", "OnEachFrame", "call ace_goggles_fnc_OnEachFrame;"] call BIS_fnc_addStackedEventHandler; - * - * Public: No - */ -#include "script_component.hpp" -if (isNull(ace_player)) exitWith {}; -GVAR(FrameEvent) set [0, !(GVAR(FrameEvent) select 0)]; -if (GVAR(FrameEvent) select 0) exitWith { - if (vehicle ace_player != ace_player && {!isTurnedOut ACE_player}) exitWith {(GVAR(FrameEvent) select 1) set [0, false]; }; - GVAR(FrameEvent) set [1, ([ace_player] call FUNC(isInRotorWash))]; -}; -private ["_rotorWash","_safe"]; -_rotorWash = GVAR(FrameEvent) select 1; -_safe = false; -if !(_rotorWash select 0) exitWith { - if (GVAR(PostProcessEyes_Enabled)) then { - GVAR(PostProcessEyes_Enabled) = false; - if (GVAR(DustHandler) != -1) then { // should be fixed in dev CBA - [GVAR(DustHandler)] call CALLSTACK(cba_fnc_removePerFrameHandler); - GVAR(DustHandler) = -1; - }; - GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0,0,0,0], [0,0,0,1],[1,1,1,0]]; - GVAR(PostProcessEyes) ppEffectCommit 2; - GVAR(DustHandler) = [{ - GVAR(PostProcessEyes) ppEffectEnable false; - GVAR(DustHandler) = -1; - }, [], 2, 0.5] call EFUNC(common,waitAndExecute); - }; -}; -if ((headgear ace_player) != "") then { - _safe = (getNumber (ConfigFile >> "CfgWeapons" >> (headgear ace_player) >> "ACE_Protection") == 1); -}; -if !(_safe) then { - if !([ace_player] call FUNC(isGogglesVisible)) exitWith{}; - if (GETDUSTT(DAMOUNT) < 2) then { - if (!GETDUSTT(DACTIVE)) then { - SETDUST(DACTIVE,true); - call FUNC(ApplyDust); - } else { - if ((_rotorWash select 1) > 0.5) then { - call FUNC(ApplyDust); - }; - }; - }; - _safe = (getNumber (ConfigFile >> "CfgGlasses" >> GVAR(Current) >> "ACE_Protection") == 1); -}; -if (_safe) exitWith {}; -if ((_rotorWash select 1) <= 15) then { - private "_scale"; - _scale = 0.7; - if ((_rotorWash select 1) != 0) then { - _scale = CLAMP(0.3*(_rotorWash select 1),0.1,0.3); - } else { - _scale = 0.1; - }; - _scale = 1 - _scale; - if (GVAR(DustHandler) != -1) then { // should be fixed in dev CBA - [GVAR(DustHandler)] call CALLSTACK(cba_fnc_removePerFrameHandler); - GVAR(DustHandler) = -1; - }; - if !(ace_player getVariable ["ACE_EyesDamaged", false]) then { - GVAR(PostProcessEyes_Enabled) = true; - GVAR(PostProcessEyes) ppEffectAdjust [1, 1, 0, [0,0,0,0], [_scale,_scale,_scale,_scale],[1,1,1,0]]; - GVAR(PostProcessEyes) ppEffectCommit 0.5; - GVAR(PostProcessEyes) ppEffectEnable true; - }; -}; diff --git a/addons/goggles/functions/fnc_rainEffect.sqf b/addons/goggles/functions/fnc_rainEffect.sqf deleted file mode 100644 index 6f351f4002..0000000000 --- a/addons/goggles/functions/fnc_rainEffect.sqf +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Author: Garth 'L-H' de Wet - * Handles rain effects being created on glasses. - * - * Arguments: - * None - * - * Return Value: - * None - * - * Example: - * call ace_goggles_fnc_rainEffect; - * - * Public: No - */ -#include "script_component.hpp" -private ["_fnc_underCover"]; -if (isNull(ace_player) || {!(alive ace_player)}) exitWith {}; -_fnc_underCover = { - private ["_pos", "_unit"]; - _unit = (_this select 0); - if (vehicle _unit != _unit && {!isTurnedOut _unit}) exitWith {true}; - _pos = eyePos _unit; - ((positionCameraToWorld [0,0,1] select 2) < ((positionCameraToWorld [0,0,0] select 2) - 0.4)) || {(lineIntersects [_pos, _pos vectorAdd [0,0,15], _unit])} -}; -if (!isNull(findDisplay 312)) exitWith { - if (GVAR(RainActive)) then { - call FUNC(RemoveRainEffect); - }; -}; -// Ignore if ace_player is under water -if (!GVAR(EffectsActive) || {underwater ace_player}) exitWith{call FUNC(RemoveRainEffect);}; -if (GVAR(RainLastLevel) != rain) then { - call FUNC(RemoveRainEffect); - GVAR(RainLastLevel) = rain; - // Rain is happening - if (GVAR(RainLastLevel) > 0.05 && {!([ace_player] call _fnc_underCover)}) then { - GVAR(RainActive) = true; - GVAR(RainDrops) = "#particlesource" createVehicleLocal GetPos ace_player; - GVAR(RainDrops) setParticleClass "ACERainEffect"; - GVAR(RainDrops) setDropInterval (0.07 * (1.1 - GVAR(RainLastLevel))); - GVAR(RainDrops) attachTo [vehicle ace_player,[0,0,0]]; - }; -}else{ - if (GVAR(RainLastLevel) > 0.05) then { - if (GVAR(RainActive) && {[ace_player] call _fnc_underCover}) exitWith { - call FUNC(RemoveRainEffect); - }; - if (!GVAR(RainActive)) then { - GVAR(RainLastLevel) = -1; - }; - }; -}; diff --git a/addons/goggles/functions/fnc_removeDirtEffect.sqf b/addons/goggles/functions/fnc_removeDirtEffect.sqf index f7efd39af3..a6d5a232cc 100644 --- a/addons/goggles/functions/fnc_removeDirtEffect.sqf +++ b/addons/goggles/functions/fnc_removeDirtEffect.sqf @@ -9,11 +9,12 @@ * None * * Example: - * call ace_goggles_fnc_removeDirtEffect; + * call ace_goggles_fnc_removeDirtEffect * * Public: Yes */ #include "script_component.hpp" -if (!isNull(GETUVAR(GVAR(DisplayEffects),displayNull))) then { + +if (!isNull (GETUVAR(GVAR(DisplayEffects),displayNull))) then { (GETUVAR(GVAR(DisplayEffects),displayNull) displayCtrl 10660) ctrlSetText ""; }; diff --git a/addons/goggles/functions/fnc_removeDustEffect.sqf b/addons/goggles/functions/fnc_removeDustEffect.sqf index 1e179ed6b4..a04121e8ba 100644 --- a/addons/goggles/functions/fnc_removeDustEffect.sqf +++ b/addons/goggles/functions/fnc_removeDustEffect.sqf @@ -9,11 +9,12 @@ * None * * Example: - * call ace_goggles_fnc_removeDustEffect; + * call ace_goggles_fnc_removeDustEffect * * Public: Yes */ #include "script_component.hpp" -if (!isNull(GETUVAR(GVAR(DisplayEffects),displayNull))) then { + +if (!isNull (GETUVAR(GVAR(DisplayEffects),displayNull))) then { (GETUVAR(GVAR(DisplayEffects),displayNull) displayCtrl 10662) ctrlSetText ""; }; diff --git a/addons/goggles/functions/fnc_removeGlassesEffect.sqf b/addons/goggles/functions/fnc_removeGlassesEffect.sqf index c7965fefbc..658daf1d32 100644 --- a/addons/goggles/functions/fnc_removeGlassesEffect.sqf +++ b/addons/goggles/functions/fnc_removeGlassesEffect.sqf @@ -1,7 +1,6 @@ /* * Author: Garth 'L-H' de Wet - * Removes the glasses effect from the screen, removes dirt effect, removes rain effect, - * removes dust effect. Does not reset array (glasses will still be broken, dirty, ect.) + * Removes the glasses effect from the screen, removes dirt effect, removes rain effect, removes dust effect. Does not reset array (glasses will still be broken, dirty, ect.) * * Arguments: * None @@ -10,15 +9,16 @@ * None * * Example: - * call ace_goggles_fnc_removeGlassesEffect; + * call ace_goggles_fnc_removeGlassesEffect * * Public: Yes */ #include "script_component.hpp" + GVAR(EffectsActive) = false; GVAR(PostProcess) ppEffectEnable false; -if (!isNull(GLASSDISPLAY)) then { +if (!isNull (GLASSDISPLAY)) then { GLASSDISPLAY closeDisplay 0; }; diff --git a/addons/goggles/functions/fnc_removeRainEffect.sqf b/addons/goggles/functions/fnc_removeRainEffect.sqf index 0d322e12da..fb7f3e5e2e 100644 --- a/addons/goggles/functions/fnc_removeRainEffect.sqf +++ b/addons/goggles/functions/fnc_removeRainEffect.sqf @@ -9,13 +9,15 @@ * None * * Example: - * call ace_goggles_fnc_removeRainEffect; + * call ace_goggles_fnc_removeRainEffect * * Public: Yes */ #include "script_component.hpp" -if (!isNull (GVAR(RainDrops))) then { - deleteVehicle (GVAR(RainDrops)); + +if (!isNull GVAR(RainDrops)) then { + deleteVehicle GVAR(RainDrops); }; + GVAR(RainActive) = false; GVAR(RainLastLevel) = 0; diff --git a/addons/grenades/CfgAmmo.hpp b/addons/grenades/CfgAmmo.hpp index 6cb16b0328..5aa33284c8 100644 --- a/addons/grenades/CfgAmmo.hpp +++ b/addons/grenades/CfgAmmo.hpp @@ -1,3 +1,4 @@ + class CfgAmmo { class FlareCore; class FlareBase: FlareCore { diff --git a/addons/grenades/CfgEventHandlers.hpp b/addons/grenades/CfgEventHandlers.hpp index 2587bdf86f..d93f8469bc 100644 --- a/addons/grenades/CfgEventHandlers.hpp +++ b/addons/grenades/CfgEventHandlers.hpp @@ -1,19 +1,20 @@ + class Extended_PreInit_EventHandlers { class ADDON { - init = QUOTE( call COMPILE_FILE(XEH_preInit) ); + init = QUOTE(call COMPILE_FILE(XEH_preInit)); }; }; class Extended_PostInit_EventHandlers { class ADDON { - init = QUOTE( call COMPILE_FILE(XEH_postInit) ); + init = QUOTE(call COMPILE_FILE(XEH_postInit)); }; }; class Extended_FiredBIS_EventHandlers { class CAManBase { class ADDON { - clientFiredBIS = QUOTE( _this call FUNC(throwGrenade) ); + firedBIS = QUOTE(_this call FUNC(throwGrenade)); }; }; }; diff --git a/addons/grenades/CfgVehicles.hpp b/addons/grenades/CfgVehicles.hpp index 7cf2085193..94c60e10d7 100644 --- a/addons/grenades/CfgVehicles.hpp +++ b/addons/grenades/CfgVehicles.hpp @@ -1,9 +1,6 @@ + class CfgVehicles { class NATO_Box_Base; - class EAST_Box_Base; - class IND_Box_Base; - class Box_NATO_Support_F; - class Box_NATO_Grenades_F: NATO_Box_Base { class TransportItems { MACRO_ADDITEM(ACE_HandFlare_White,12); @@ -12,6 +9,7 @@ class CfgVehicles { }; }; + class EAST_Box_Base; class Box_East_Grenades_F: EAST_Box_Base { class TransportItems { MACRO_ADDITEM(ACE_HandFlare_Yellow,12); @@ -20,6 +18,7 @@ class CfgVehicles { }; }; + class IND_Box_Base; class Box_IND_Grenades_F: IND_Box_Base { class TransportItems { MACRO_ADDITEM(ACE_HandFlare_Yellow,12); @@ -28,6 +27,7 @@ class CfgVehicles { }; }; + class Box_NATO_Support_F; class ACE_Box_Misc: Box_NATO_Support_F { class TransportItems { MACRO_ADDITEM(ACE_HandFlare_White,12); diff --git a/addons/grenades/CfgWeapons.hpp b/addons/grenades/CfgWeapons.hpp index 4edc6e6d12..f84c00713a 100644 --- a/addons/grenades/CfgWeapons.hpp +++ b/addons/grenades/CfgWeapons.hpp @@ -1,21 +1,26 @@ + class CfgWeapons { class GrenadeLauncher; - class Throw: GrenadeLauncher { - muzzles[] += {"ACE_HandFlare_WhiteMuzzle", "ACE_HandFlare_RedMuzzle", "ACE_HandFlare_GreenMuzzle", "ACE_HandFlare_YellowMuzzle", "ACE_M84Muzzle"}; + muzzles[] += {"ACE_HandFlare_WhiteMuzzle","ACE_HandFlare_RedMuzzle","ACE_HandFlare_GreenMuzzle","ACE_HandFlare_YellowMuzzle","ACE_M84Muzzle"}; + class ThrowMuzzle; class ACE_HandFlare_WhiteMuzzle: ThrowMuzzle { magazines[] = {"ACE_HandFlare_White"}; }; + class ACE_HandFlare_RedMuzzle: ThrowMuzzle { magazines[] = {"ACE_HandFlare_Red"}; }; + class ACE_HandFlare_GreenMuzzle: ThrowMuzzle { magazines[] = {"ACE_HandFlare_Green"}; }; + class ACE_HandFlare_YellowMuzzle: ThrowMuzzle { magazines[] = {"ACE_HandFlare_Yellow"}; }; + class ACE_M84Muzzle: ThrowMuzzle { magazines[] = {"ACE_M84"}; }; diff --git a/addons/grenades/XEH_postInit.sqf b/addons/grenades/XEH_postInit.sqf index 260bf63f6e..54c2b06e8b 100644 --- a/addons/grenades/XEH_postInit.sqf +++ b/addons/grenades/XEH_postInit.sqf @@ -2,7 +2,7 @@ #include "script_component.hpp" -["flashbangExplosion", DFUNC(flashbangExplosionEH)] call EFUNC(common,addEventHandler); +["flashbangExplosion", {_this call FUNC(flashbangExplosionEH)}] call EFUNC(common,addEventHandler); if (!hasInterface) exitWith {}; @@ -21,4 +21,4 @@ GVAR(flashbangPPEffectCC) ppEffectForceInNVG true; [] call FUNC(nextMode); }, {false}, -[9, [false, false, false]], false] call cba_fnc_addKeybind; //8 Key +[9, [false, false, false]], false] call CBA_fnc_addKeybind; //8 Key diff --git a/addons/grenades/functions/fnc_flashbangExplosionEH.sqf b/addons/grenades/functions/fnc_flashbangExplosionEH.sqf index 1f7e97c47a..b45dc099fc 100644 --- a/addons/grenades/functions/fnc_flashbangExplosionEH.sqf +++ b/addons/grenades/functions/fnc_flashbangExplosionEH.sqf @@ -15,13 +15,14 @@ */ #include "script_component.hpp" -private ["_affected", "_strength", "_posGrenade", "_angleDiff", "_light", "_losCount", "_dirToUnitVector", "_eyeDir", "_eyePos"]; params ["_grenade"]; +private ["_affected", "_strength", "_posGrenade", "_eyePos", "_losCount", "_eyeDir", "_dirToUnitVector", "_angleDiff", "_light"]; + _affected = _grenade nearEntities ["CAManBase", 20]; { - if ((local _x) && {alive _x}) then { + if (local _x && {alive _x}) then { _strength = 1 - ((_x distance _grenade) min 15) / 15; @@ -30,16 +31,19 @@ _affected = _grenade nearEntities ["CAManBase", 20]; if (_x != ACE_player) then { //must be AI [_x, true] call EFUNC(common,disableAI); - _x setSkill ((skill _x) / 50); + + _x setSkill (skill _x / 50); [{ params ["_unit"]; + //Make sure we don't enable AI for unconscious units - if (!(_unit getVariable ["ace_isunconscious", false])) then { + if !(_unit getVariable ["ace_isUnconscious", false]) then { [_unit, false] call EFUNC(common,disableAI); }; + _unit setSkill (skill _unit * 50); - }, [_x], (7 * _strength)] call EFUNC(common,waitAndExecute); + }, [_x], 7 * _strength] call EFUNC(common,waitAndExecute); } else { //Do effects for player // is there line of sight to the grenade? @@ -49,7 +53,7 @@ _affected = _grenade nearEntities ["CAManBase", 20]; //Check for line of sight (check 4 points in case grenade is stuck in an object or underground) _losCount = { - (!lineIntersects [(_posGrenade vectorAdd _x), _eyePos, _grenade, ACE_player]) + !lineIntersects [_posGrenade vectorAdd _x, _eyePos, _grenade, ACE_player] } count [[0,0,0], [0,0,0.2], [0.1, 0.1, 0.1], [-0.1, -0.1, 0.1]]; TRACE_1("Line of sight count (out of 4)",_losCount); @@ -57,9 +61,9 @@ _affected = _grenade nearEntities ["CAManBase", 20]; _strength = _strength / 10; }; - //Add ace_hearing ear ringing sound effect - if ((isClass (configFile >> "CfgPatches" >> "ACE_Hearing")) && {_strength > 0}) then { - [_x, (20 * _strength)] call EFUNC(hearing,earRinging); + // add ace_hearing ear ringing sound effect + if (isClass (configFile >> "CfgPatches" >> "ACE_Hearing") && {_strength > 0}) then { + [_x, 20 * _strength] call EFUNC(hearing,earRinging); }; // account for people looking away by slightly @@ -68,16 +72,16 @@ _affected = _grenade nearEntities ["CAManBase", 20]; _dirToUnitVector = _eyePos vectorFromTo _posGrenade; _angleDiff = acos (_eyeDir vectorDotProduct _dirToUnitVector); - //From 0-45deg, full effect + // from 0-45deg, full effect if (_angleDiff > 45) then { _strength = _strength - _strength * ((_angleDiff - 45) / 120); }; TRACE_1("Final strength for player",_strength); - //Add ace_medical pain effect: - if ((isClass (configFile >> "CfgPatches" >> "ACE_Medical")) && {_strength > 0.1}) then { - [ACE_player, (_strength / 2)] call EFUNC(medical,adjustPainLevel); + // add ace_medical pain effect: + if (isClass (configFile >> "CfgPatches" >> "ACE_Medical") && {_strength > 0.1}) then { + [ACE_player, _strength / 2] call EFUNC(medical,adjustPainLevel); }; // create flash to illuminate environment @@ -87,14 +91,14 @@ _affected = _grenade nearEntities ["CAManBase", 20]; _light setLightColor [1,1,1]; _light setLightDayLight true; - //Delete the light after 0.1 seconds + // delete the light after 0.1 seconds [{ params ["_light"]; deleteVehicle _light; }, [_light], 0.1] call EFUNC(common,waitAndExecute); // blind player - if (_strength > 0.1 && hasInterface) then { + if (hasInterface && {_strength > 0.1}) then { GVAR(flashbangPPEffectCC) ppEffectEnable true; GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,(0.8 + _strength) min 1,[1,1,1,0],[0,0,0,1],[0,0,0,0]]; GVAR(flashbangPPEffectCC) ppEffectCommit 0.01; @@ -102,14 +106,15 @@ _affected = _grenade nearEntities ["CAManBase", 20]; //PARTIALRECOVERY - start decreasing effect over ACE_time [{ params ["_strength"]; + GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,0,[1,1,1,0],[0,0,0,1],[0,0,0,0]]; GVAR(flashbangPPEffectCC) ppEffectCommit (10 * _strength); - }, [_strength], (7 * _strength), 0] call EFUNC(common,waitAndExecute); + }, [_strength], 7 * _strength] call EFUNC(common,waitAndExecute); //FULLRECOVERY - end effect [{ GVAR(flashbangPPEffectCC) ppEffectEnable false; - }, [], (17 * _strength)] call EFUNC(common,waitAndExecute); + }, [], 17 * _strength] call EFUNC(common,waitAndExecute); }; }; }; diff --git a/addons/grenades/functions/fnc_flashbangThrownFuze.sqf b/addons/grenades/functions/fnc_flashbangThrownFuze.sqf index f0e2406b53..21d132464a 100644 --- a/addons/grenades/functions/fnc_flashbangThrownFuze.sqf +++ b/addons/grenades/functions/fnc_flashbangThrownFuze.sqf @@ -14,6 +14,7 @@ * Public: No */ #include "script_component.hpp" + params ["_projectile"]; if (alive _projectile) then { @@ -21,5 +22,6 @@ if (alive _projectile) then { private "_affected"; _affected = _projectile nearEntities ["CAManBase", 50]; + ["flashbangExplosion", _affected, [_projectile]] call EFUNC(common,targetEvent); }; diff --git a/addons/hearing/stringtable.xml b/addons/hearing/stringtable.xml index 1464639123..05dde3a1bf 100644 --- a/addons/hearing/stringtable.xml +++ b/addons/hearing/stringtable.xml @@ -138,6 +138,7 @@ Aktiviere Taubheit im Gefecht? Povolit ztrátu sluchu? Ativar surdez em combate? + Уменьшает возможность игрока слышать звуки при повреждении органов слуха Controls combat deafness and ear ringing. When activated, players can be deafened when a gun is fired in their vicinity or an explosion takes place without hearing protection @@ -165,4 +166,4 @@ Permitir a las unidades por control remoto de zeus que puedan tener daños auditivos. - + \ No newline at end of file diff --git a/addons/hitreactions/ACE_Settings.hpp b/addons/hitreactions/ACE_Settings.hpp index adbbdacaf2..4fa45e8ebc 100644 --- a/addons/hitreactions/ACE_Settings.hpp +++ b/addons/hitreactions/ACE_Settings.hpp @@ -1,3 +1,4 @@ + class ACE_Settings { class GVAR(minDamageToTrigger) { //Minimum mamage needed to trigger falling down while moving. Set to -1 to disable completely. diff --git a/addons/hitreactions/functions/fnc_fallDown.sqf b/addons/hitreactions/functions/fnc_fallDown.sqf index 7fa6453fe2..d93b99bd6b 100644 --- a/addons/hitreactions/functions/fnc_fallDown.sqf +++ b/addons/hitreactions/functions/fnc_fallDown.sqf @@ -1,39 +1,52 @@ -// by commy2 +/* + * Author: commy2 + * Adds reactions to a unit that was hit. EH only runs where to unit is local. Adds screams, falling down, falling from ladders, ejecting from static weapons and camshake for players + * + * Arguments: + * 0: unit + * 1: firer + * 2: damage taken + * + * Return Value: + * None + * + * Public: No + */ #include "script_component.hpp" params ["_unit", "_firer", "_damage"]; +// exit if system is disabled +if (GVAR(minDamageToTrigger) == -1) exitWith {}; + +// don't fall after minor damage +if (_damage < GVAR(minDamageToTrigger)) exitWith {}; + // don't fall on collision damage if (_unit == _firer) exitWith {}; -//Exit if system disabled: -if (GVAR(minDamageToTrigger) == -1) exitWith {}; - -// cam shake for player +// camshake for player if (_unit == ACE_player) then { addCamShake [3, 5, _damage + random 10]; }; +// play scream sound +if (!isNil QUOTE(EFUNC(medical,playInjuredSound))) then { + [_unit] call EFUNC(medical,playInjuredSound); +}; + private "_vehicle"; _vehicle = vehicle _unit; // handle static weapons -if (_vehicle isKindOf "StaticWeapon") exitwith { +if (_vehicle isKindOf "StaticWeapon") exitWith { if (!alive _unit) then { _unit action ["Eject", _vehicle]; unassignVehicle _unit; }; }; -// don't fall after minor damage -if (_damage < GVAR(minDamageToTrigger)) exitWith {}; - -// play sound -if (!isNil QUOTE(EFUNC(medical,playInjuredSound))) then { - [_unit] call EFUNC(medical,playInjuredSound); -}; - -//Don't do animations if in a vehicle (looks weird and animations never reset): +// don't do animations if in a vehicle (looks weird and animations never reset): if (_vehicle != _unit) exitWith {}; // this checks most things, so it doesn't mess with being inside vehicles or while dragging etc. @@ -54,40 +67,52 @@ _velocity = vectorMagnitude velocity _unit; if (_velocity < 2) exitWith {}; // get correct animation by weapon -private ["_isPlayer", "_isRunning", "_anim"]; +private "_anim"; -_isPlayer = [_unit] call EFUNC(common,isPlayer); -_isRunning = _velocity > 4; +call { + private "_weapon"; + _weapon = currentWeapon _unit; -_anim = switch (currentWeapon _unit) do { - case (""): {"AmovPercMsprSnonWnonDf_AmovPpneMstpSnonWnonDnon"}; - case (primaryWeapon _unit): { - if !(_isPlayer) exitWith {"AmovPercMsprSlowWrfldf_AmovPpneMstpSrasWrflDnon"}; - - [ - ["AmovPercMsprSlowWrfldf_AmovPpneMstpSrasWrflDnon_2", "AmovPercMsprSlowWrfldf_AmovPpneMstpSrasWrflDnon"] select _isRunning, - ["AmovPercMsprSlowWrfldf_AmovPpneMstpSrasWrflDnon_2", "AmovPercMsprSlowWrfldf_AmovPpneMstpSrasWrflDnon"] select _isRunning, - "AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDleft", - "AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDright" - ] select floor random 4; + if (_weapon == "") exitWith { + _anim = "AmovPercMsprSnonWnonDf_AmovPpneMstpSnonWnonDnon" }; - case (handgunWeapon _unit): { - if !(_isPlayer) exitWith {"AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon"}; - [ - "AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon", - "AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon", - "AmovPercMstpSrasWpstDnon_AadjPpneMstpSrasWpstDleft", - "AmovPercMstpSrasWpstDnon_AadjPpneMstpSrasWpstDright" - ] select floor random 4; + if (_weapon == primaryWeapon _unit) exitWith { + if ([_unit] call EFUNC(common,isPlayer)) then { + private "_isRunning"; + _isRunning = _velocity > 4; + + _anim = [ + ["AmovPercMsprSlowWrfldf_AmovPpneMstpSrasWrflDnon_2", "AmovPercMsprSlowWrfldf_AmovPpneMstpSrasWrflDnon"] select _isRunning, + ["AmovPercMsprSlowWrfldf_AmovPpneMstpSrasWrflDnon_2", "AmovPercMsprSlowWrfldf_AmovPpneMstpSrasWrflDnon"] select _isRunning, + "AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDleft", + "AmovPercMstpSrasWrflDnon_AadjPpneMstpSrasWrflDright" + ] select floor random 4; + } else { + _anim = "AmovPercMsprSlowWrfldf_AmovPpneMstpSrasWrflDnon"; + }; }; - default {""}; + + if (_weapon == handgunWeapon _unit) exitWith { + if ([_unit] call EFUNC(common,isPlayer)) then { + _anim = [ + "AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon", + "AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon", + "AmovPercMstpSrasWpstDnon_AadjPpneMstpSrasWpstDleft", + "AmovPercMstpSrasWpstDnon_AadjPpneMstpSrasWpstDright" + ] select floor random 4; + } else { + _anim = "AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon"; + }; + }; + + _anim = ""; }; -// exit if no animation for this weapon exists, i.E. binocular or rocket launcher +// exit if no animation for this weapon exists, i.e. binocular or rocket launcher if (_anim == "") exitWith {}; // don't mess with transitions. don't fall then. -if ([_unit] call EFUNC(common,inTransitionAnim)) exitWith {}; - -[_unit, _anim, 2] call EFUNC(common,doAnimation); +if !([_unit] call EFUNC(common,inTransitionAnim)) then { + [_unit, _anim, 2] call EFUNC(common,doAnimation); +}; diff --git a/addons/interact_menu/XEH_clientInit.sqf b/addons/interact_menu/XEH_clientInit.sqf index 44dfddcadd..59fb01a353 100644 --- a/addons/interact_menu/XEH_clientInit.sqf +++ b/addons/interact_menu/XEH_clientInit.sqf @@ -8,17 +8,19 @@ GVAR(cachedBuildingActionPairs) = []; GVAR(ParsedTextCached) = []; -//Setup text/shadow/size/color settings matrix -[] call FUNC(setupTextColors); ["SettingChanged", { - PARAMS_1(_name); - if (_name in [QGVAR(colorTextMax), QGVAR(colorTextMin), QGVAR(colorShadowMax), QGVAR(colorShadowMin), QGVAR(textSize), QGVAR(shadowSetting)]) then { + params ["_name"]; + if (({_x == _name} count [QGVAR(colorTextMax), QGVAR(colorTextMin), QGVAR(colorShadowMax), QGVAR(colorShadowMin), QGVAR(textSize), QGVAR(shadowSetting)]) == 1) then { [] call FUNC(setupTextColors); }; }] call EFUNC(common,addEventhandler); -// Install the render EH on the main display -addMissionEventHandler ["Draw3D", DFUNC(render)]; +["SettingsInitialized", { + //Setup text/shadow/size/color settings matrix + [] call FUNC(setupTextColors); + // Install the render EH on the main display + addMissionEventHandler ["Draw3D", DFUNC(render)]; +}] call EFUNC(common,addEventHandler); //Add Actions to Houses: ["interactMenuOpened", {_this call FUNC(userActions_addHouseActions)}] call EFUNC(common,addEventHandler); @@ -54,7 +56,7 @@ addMissionEventHandler ["Draw3D", DFUNC(render)]; // If no menu is open just quit if (GVAR(openedMenuType) < 0) exitWith {}; - EXPLODE_2_PVT(_this,_unit,_isUnconscious); + params ["_unit", "_isUnconscious"]; if (_unit != ACE_player || !_isUnconscious) exitWith {}; diff --git a/addons/interact_menu/functions/fnc_render.sqf b/addons/interact_menu/functions/fnc_render.sqf index 55ca280c43..54f197a2a3 100644 --- a/addons/interact_menu/functions/fnc_render.sqf +++ b/addons/interact_menu/functions/fnc_render.sqf @@ -14,13 +14,14 @@ BEGIN_COUNTER(fnc_render); -private ["_cursorPos1", "_cursorPos2", "_p1", "_p2", "_forEachIndex", "_x", "_cursorScreenPos", "_closestDistance", "_closestSelection", "_sPos", "_disSq", "_closest", "_cTime", "_delta", "_foundTarget", "_misMatch", "_hoverPath", "_i", "_actionData", "_player", "_target"]; -_foundTarget = false; -_cursorPos1 = positionCameraToWorld [0, 0, 0]; -_cursorPos2 = positionCameraToWorld [0, 0, 2]; +private ["_cursorPos2", "_p1", "_p2", "_forEachIndex", "_x", "_cursorScreenPos", "_closestDistance", "_closestSelection", "_sPos", "_disSq", "_closest", "_cTime", "_delta", "_foundTarget", "_misMatch", "_hoverPath", "_i", "_actionData", "_player", "_target"]; +_foundTarget = false; if (GVAR(openedMenuType) >= 0) then { + // _cursorPos1 = positionCameraToWorld [0, 0, 2]; + _cursorPos2 = positionCameraToWorld [0, 0, 2]; + // Render all available nearby interactions call FUNC(renderActionPoints); diff --git a/addons/interaction/ACE_Settings.hpp b/addons/interaction/ACE_Settings.hpp index 6c97109a37..075c1f056d 100644 --- a/addons/interaction/ACE_Settings.hpp +++ b/addons/interaction/ACE_Settings.hpp @@ -1,3 +1,4 @@ + class ACE_Settings { class GVAR(EnableTeamManagement) { value = 1; diff --git a/addons/interaction/ACE_ZeusActions.hpp b/addons/interaction/ACE_ZeusActions.hpp index 50f203a092..5a7ea9d631 100644 --- a/addons/interaction/ACE_ZeusActions.hpp +++ b/addons/interaction/ACE_ZeusActions.hpp @@ -1,6 +1,5 @@ + class ACE_ZeusActions { - // _target = curatorLogic - // curatorSelected = [objects,groups,waypoints,markers] class ZeusUnits { displayName = "$STR_A3_RscDisplayCurator_ModeUnits_tooltip"; icon = "\A3\UI_F_Curator\Data\Displays\RscDisplayCurator\modeUnits_ca.paa"; @@ -29,12 +28,14 @@ class ACE_ZeusActions { statement = "{_x setUnitPos 'AUTO';} forEach (curatorSelected select 0);"; }; }; + class remoteControl { displayName = "$STR_A3_CfgVehicles_ModuleRemoteControl_F"; icon = "\A3\Modules_F_Curator\Data\portraitRemoteControl_ca.paa"; statement = "_unit = objNull; { if ((side _x in [east,west,resistance,civilian]) && !(isPlayer _x)) exitWith { _unit = _x; }; } forEach (curatorSelected select 0); bis_fnc_curatorObjectPlaced_mouseOver = ['OBJECT',_unit]; (group _target) createUnit ['ModuleRemoteControl_F',[0,0,0],[],0,''];"; }; }; + class ZeusGroups { displayName = "$STR_A3_RscDisplayCurator_ModeGroups_tooltip"; icon = "\A3\UI_F_Curator\Data\Displays\RscDisplayCurator\modeGroups_ca.paa"; @@ -67,6 +68,7 @@ class ACE_ZeusActions { statement = "{ _x setBehaviour 'STEALTH'; } forEach (curatorSelected select 1);"; }; }; + class speed { displayName = "$STR_HC_Menu_Speed"; @@ -86,6 +88,7 @@ class ACE_ZeusActions { statement = "{_x setSpeedMode 'FULL';} forEach (curatorSelected select 1);"; }; }; + class formation { displayName = "$STR_Formation"; @@ -136,6 +139,7 @@ class ACE_ZeusActions { }; }; }; + class ZeusWaypoints { displayName = "Waypoints"; icon = "\A3\UI_F_Curator\Data\Displays\RscDisplayCurator\modeRecent_ca.paa"; @@ -168,6 +172,7 @@ class ACE_ZeusActions { statement = "{ _x setWaypointBehaviour 'STEALTH'; } forEach (curatorSelected select 2);"; }; }; + class speed { displayName = "$STR_HC_Menu_Speed"; @@ -187,6 +192,7 @@ class ACE_ZeusActions { statement = "{ _x setWaypointSpeed 'FULL'; } forEach (curatorSelected select 2);"; }; }; + class formation { displayName = "$STR_Formation"; @@ -237,6 +243,7 @@ class ACE_ZeusActions { }; }; }; + class ZeusMarkers { displayName = "$STR_A3_RscDisplayCurator_ModeMarkers_tooltip"; icon = "\A3\UI_F_Curator\Data\Displays\RscDisplayCurator\modeMarkers_ca.paa"; diff --git a/addons/interaction/CfgEventHandlers.hpp b/addons/interaction/CfgEventHandlers.hpp index 7b003bbe8c..60a8fdfcf6 100644 --- a/addons/interaction/CfgEventHandlers.hpp +++ b/addons/interaction/CfgEventHandlers.hpp @@ -1,6 +1,7 @@ + class Extended_PreInit_EventHandlers { class ADDON { - init = QUOTE( call COMPILE_FILE(XEH_preInit) ); + init = QUOTE(call COMPILE_FILE(XEH_preInit)); }; }; @@ -9,3 +10,11 @@ class Extended_PostInit_EventHandlers { init = QUOTE(call COMPILE_FILE(XEH_postInit)); }; }; + +class Extended_Respawn_EventHandlers { + class CAManBase { + class ADDON { + respawn = QUOTE((_this select 0) setVariable [ARR_3(QUOTE(QGVAR(assignedFireTeam)),(_this select 0) getVariable [ARR_2(QUOTE(QGVAR(assignedFireTeam)),'MAIN')],true)]); + }; + }; +}; diff --git a/addons/interaction/CfgVehicles.hpp b/addons/interaction/CfgVehicles.hpp index abfdb976ab..56fb06a85b 100644 --- a/addons/interaction/CfgVehicles.hpp +++ b/addons/interaction/CfgVehicles.hpp @@ -1,25 +1,28 @@ + class CfgVehicles { - class ACE_Module; - class ACE_ModuleInteraction: ACE_Module { - author = ECSTRING(common,ACETeam); - category = "ACE"; - displayName = CSTRING(Module_DisplayName); - function = "ACE_Interaction_fnc_moduleInteraction"; - scope = 2; - isGlobal = 1; - icon = PATHTOF(UI\Icon_Module_Interaction_ca.paa); - class Arguments { - class EnableTeamManagement { - displayName = CSTRING(EnableTeamManagement_DisplayName); - description = CSTRING(EnableTeamManagement_Description); - typeName = "BOOL"; - defaultValue = 1; - }; + class ACE_Module; + class ACE_ModuleInteraction: ACE_Module { + author = ECSTRING(common,ACETeam); + category = "ACE"; + displayName = CSTRING(Module_DisplayName); + function = "ACE_Interaction_fnc_moduleInteraction"; + scope = 2; + isGlobal = 1; + icon = PATHTOF(UI\Icon_Module_Interaction_ca.paa); + + class Arguments { + class EnableTeamManagement { + displayName = CSTRING(EnableTeamManagement_DisplayName); + description = CSTRING(EnableTeamManagement_Description); + typeName = "BOOL"; + defaultValue = 1; + }; + }; + + class ModuleDescription { + description = CSTRING(Module_Description); + }; }; - class ModuleDescription { - description = CSTRING(Module_Description); - }; - }; class Man; class CAManBase: Man { @@ -77,7 +80,6 @@ class CfgVehicles { priority = 2.1; hotkey = "Y"; }; - class ACE_UnassignTeam { displayName = CSTRING(LeaveTeam); condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canJoinTeam) && {assignedTeam _target != 'MAIN'}); @@ -98,29 +100,29 @@ class CfgVehicles { icon = PATHTOF(UI\team\team_management_ca.paa); hotkey = "J"; }; - class ACE_GetDown { displayName = CSTRING(GetDown); - condition = QUOTE([_target] call DFUNC(canInteractWithCivilian)); - statement = QUOTE([_target] call DFUNC(getDown)); + condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canInteractWithCivilian)); + statement = QUOTE([ARR_2(_player,_target)] call DFUNC(getDown)); showDisabled = 0; priority = 2.2; }; class ACE_SendAway { displayName = CSTRING(SendAway); - condition = QUOTE([_target] call DFUNC(canInteractWithCivilian)); - statement = QUOTE([_target] call DFUNC(sendAway)); + condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canInteractWithCivilian)); + statement = QUOTE([ARR_2(_player,_target)] call DFUNC(sendAway)); showDisabled = 0; priority = 2.0; }; class ACE_Pardon { displayName = CSTRING(Pardon); - condition = QUOTE(rating _target < -2000 && {alive _target} && {side group _player == side group _target}); - statement = QUOTE([ARR_3(_target,'{_this addRating -rating _this}',_target)] call DEFUNC(common,execRemoteFnc)); + condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canPardon)); + statement = QUOTE([ARR_2(_player,_target)] call DFUNC(pardon)); showDisabled = 0; priority = 2.5; }; }; + class ACE_Torso { displayName = CSTRING(Torso); selection = "spine3"; @@ -165,12 +167,11 @@ class CfgVehicles { }; class ACE_Weapon { displayName = CSTRING(Weapon); - position = QUOTE(call FUNC(getWeaponPos)); + position = QUOTE(call DFUNC(getWeaponPos)); distance = 1.50; condition = ""; statement = ""; }; - class ACE_TapShoulderRight { displayName = CSTRING(TapShoulder); selection = "rightshoulder"; @@ -238,7 +239,6 @@ class CfgVehicles { icon = PATHTOF(UI\team\team_yellow_ca.paa); hotkey = "Y"; }; - class ACE_LeaveTeam { displayName = CSTRING(LeaveTeam); condition = QUOTE(assignedTeam _player != 'MAIN'); @@ -405,6 +405,7 @@ class CfgVehicles { }; }; }; + class ACE_SelfActions { class ACE_Passengers { displayName = CSTRING(Passengers); @@ -414,6 +415,7 @@ class CfgVehicles { }; }; }; + class Tank: LandVehicle { class ACE_Actions { class ACE_MainActions { @@ -429,6 +431,7 @@ class CfgVehicles { }; }; }; + class ACE_SelfActions { class ACE_Passengers { displayName = CSTRING(Passengers); @@ -455,6 +458,7 @@ class CfgVehicles { }; }; }; + class ACE_SelfActions { class ACE_Passengers { displayName = CSTRING(Passengers); @@ -464,6 +468,7 @@ class CfgVehicles { }; }; }; + class Plane: Air { class ACE_Actions { class ACE_MainActions { @@ -479,6 +484,7 @@ class CfgVehicles { }; }; }; + class ACE_SelfActions { class ACE_Passengers { displayName = CSTRING(Passengers); @@ -501,7 +507,7 @@ class CfgVehicles { class ACE_Push { displayName = CSTRING(Push); distance = 6; - condition = QUOTE(((getMass _target) <= 2600) && {alive _target} && {(vectorMagnitude (velocity _target)) < 3}); + condition = QUOTE(getMass _target <= 2600 && {alive _target} && {vectorMagnitude velocity _target < 3}); statement = QUOTE(_this call FUNC(push)); showDisabled = 0; priority = -1; @@ -514,6 +520,7 @@ class CfgVehicles { }; }; }; + class ACE_SelfActions { class ACE_Passengers { displayName = CSTRING(Passengers); @@ -539,6 +546,7 @@ class CfgVehicles { }; }; }; + class ACE_SelfActions { class ACE_Passengers { displayName = CSTRING(Passengers); @@ -551,26 +559,29 @@ class CfgVehicles { class StaticMGWeapon: StaticWeapon {}; class HMG_01_base_F: StaticMGWeapon {}; + class HMG_01_high_base_F: HMG_01_base_F { - class ACE_Actions: ACE_Actions { - class ACE_MainActions: ACE_MainActions { - position = "[-0.172852,0.164063,-0.476091]"; - }; - }; + class ACE_Actions: ACE_Actions { + class ACE_MainActions: ACE_MainActions { + position = "[-0.172852,0.164063,-0.476091]"; + }; + }; }; + class AA_01_base_F: StaticMGWeapon { - class ACE_Actions: ACE_Actions { - class ACE_MainActions: ACE_MainActions { - position = "[0,0.515869,-0.200671]"; - }; - }; + class ACE_Actions: ACE_Actions { + class ACE_MainActions: ACE_MainActions { + position = "[0,0.515869,-0.200671]"; + }; + }; }; + class AT_01_base_F: StaticMGWeapon { - class ACE_Actions: ACE_Actions { - class ACE_MainActions: ACE_MainActions { - position = "[0,0.515869,-0.200671]"; - }; - }; + class ACE_Actions: ACE_Actions { + class ACE_MainActions: ACE_MainActions { + position = "[0,0.515869,-0.200671]"; + }; + }; }; class thingX; @@ -581,6 +592,7 @@ class CfgVehicles { selection = ""; distance = 2; condition = "true"; + class ACE_OpenBox { displayName = CSTRING(OpenBox); condition = QUOTE(alive _target); @@ -590,6 +602,7 @@ class CfgVehicles { }; }; }; + class ACE_SelfActions {}; }; @@ -602,6 +615,7 @@ class CfgVehicles { condition = "true"; }; }; + class ACE_SelfActions {}; }; }; diff --git a/addons/interaction/Menu_Config.hpp b/addons/interaction/RscTitles.hpp similarity index 98% rename from addons/interaction/Menu_Config.hpp rename to addons/interaction/RscTitles.hpp index 8359ee560a..f75da59cce 100644 --- a/addons/interaction/Menu_Config.hpp +++ b/addons/interaction/RscTitles.hpp @@ -1,3 +1,4 @@ + #define HSPACE 0.5-2.0/16/2 #define VSPACE 0.5-0.3/9/2 @@ -44,13 +45,15 @@ class ACE_Interaction_Button_Base { class RscListbox; class IGUIBack; class RscText; + #define X_OFFSET 0.2 class RscACE_SelectAnItem { idd = 8854; movingEnable = 0; + class controls { - class back:IGUIBack { + class back: IGUIBack { x = X_OFFSET; y = 0; w = 0.6; @@ -66,7 +69,7 @@ class RscACE_SelectAnItem { style = 0x02; text = ""; }; - class itemList:RscListBox { + class itemList: RscListBox { onMouseButtonDblClick = "_this call ACE_Interaction_fnc_onSelectMenuDblClick"; idc = 8866; x = X_OFFSET + 0.005; @@ -139,18 +142,21 @@ class RscInteractionIcon: RscPicture { w = 2*GUI_GRID_H; h = 2*GUI_GRID_H; }; + class RscInteractionHelperIcon: RscInteractionIcon { x = 20 * GUI_GRID_W; y = 16 * GUI_GRID_H; w = GUI_GRID_H; h = GUI_GRID_H; }; + class RscInteractionText: RscText{ x = 21 * GUI_GRID_W; y = 16 * GUI_GRID_H; - w = 8 * GUI_GRID_W; + w = 24 * GUI_GRID_W; h = 1.5 * GUI_GRID_H; }; + class RscTitles { class GVAR(InteractionHelper) { idd = 9930; diff --git a/addons/interaction/XEH_postInit.sqf b/addons/interaction/XEH_postInit.sqf index 8d97803b1d..ae3ebff5c3 100644 --- a/addons/interaction/XEH_postInit.sqf +++ b/addons/interaction/XEH_postInit.sqf @@ -1,37 +1,52 @@ // by commy2 and esteldunedain - #include "script_component.hpp" ACE_Modifier = 0; -//SelectLeader Event Handler for BecomeLeader action: -[QGVAR(selectLeader), { - PARAMS_2(_group,_leader); - _group selectLeader _leader; +["pardon", {(_this select 0) addRating -rating (_this select 0)}] call EFUNC(common,addEventHandler); + +["getDown", { + params ["_target"]; + + _target setUnitPos "DOWN"; }] call EFUNC(common,addEventHandler); -//Pushing boats from FUNC(push) -[QGVAR(pushBoat), { - params ["_boat", "_newVelocity"]; - _boat setVelocity _newVelocity; -}] call EFUNC(common,addEventHandler); +["sendAway", { + params ["_unit", "_position"]; + _unit setUnitPos "AUTO"; + _unit doMove _position; +}] call EFUNC(common,addEventHandler); if (!hasInterface) exitWith {}; GVAR(isOpeningDoor) = false; +[{_this call FUNC(handleScrollWheel)}] call EFUNC(common,addScrollWheelEventHandler); + +["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); + // restore global fire teams for JIP -private ["_team"]; +private "_team"; { _team = _x getVariable [QGVAR(assignedFireTeam), ""]; if (_team != "") then {_x assignTeam _team}; -} forEach allUnits; + false +} count allUnits; - -// Add keybinds -["ACE3 Common", QGVAR(openDoor), localize LSTRING(OpenDoor), -{ +// add keybinds +["ACE3 Common", QGVAR(openDoor), localize LSTRING(OpenDoor), { // Conditions: canInteract if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific @@ -40,18 +55,16 @@ private ["_team"]; // Statement call EFUNC(interaction,openDoor); true -}, -{ +}, { //Probably don't want any condidtions here, so variable never gets locked down // Statement GVAR(isOpeningDoor) = false; true }, -[57, [false, true, false]], false] call cba_fnc_addKeybind; //Key CTRL+Space +[57, [false, true, false]], false] call CBA_fnc_addKeybind; //Key CTRL+Space -["ACE3 Common", QGVAR(tapShoulder), localize LSTRING(TapShoulder), -{ +["ACE3 Common", QGVAR(tapShoulder), localize LSTRING(TapShoulder), { // Conditions: canInteract if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific @@ -62,24 +75,7 @@ private ["_team"]; true }, {false}, -[20, [true, false, false]], false] call cba_fnc_addKeybind; - -["ACE3 Common", QGVAR(modifierKey), localize LSTRING(ModifierKey), -{ - // Conditions: canInteract - //if !([ACE_player, objNull, ["isNotDragging"]] call EFUNC(common,canInteractWith)) exitWith {false}; // not needed - - // Statement - ACE_Modifier = 1; - // Return false so it doesn't block other actions - false -}, -{ - //Probably don't want any condidtions here, so variable never gets locked down - ACE_Modifier = 0; - false; -}, -[29, [false, false, false]], false] call cba_fnc_addKeybind; +[20, [true, false, false]], false] call CBA_fnc_addKeybind; ["isNotSwimming", {!underwater (_this select 0)}] call EFUNC(common,addCanInteractWithCondition); ["isNotOnLadder", {getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> animationState (_this select 0) >> "ACE_isLadder") != 1}] call EFUNC(common,addCanInteractWithCondition); diff --git a/addons/interaction/XEH_preInit.sqf b/addons/interaction/XEH_preInit.sqf index c2534b44b9..95be20f141 100644 --- a/addons/interaction/XEH_preInit.sqf +++ b/addons/interaction/XEH_preInit.sqf @@ -2,37 +2,38 @@ ADDON = false; +// 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(joinTeam); +PREP(canBecomeLeader); PREP(doBecomeLeader); +PREP(canTapShoulder); +PREP(tapShoulder); +PREP(canPardon); +PREP(pardon); + +// interaction with doors 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(handleScrollWheel); PREP(openDoor); -PREP(openMenuSelectUI); -PREP(openSelectMenu); -PREP(prepareSelectMenu); + +// interaction with boats PREP(push); -PREP(removeTag); -PREP(sendAway); -PREP(showMouseHint); -PREP(sortOptionsByPriority); -PREP(tapShoulder); ADDON = true; diff --git a/addons/interaction/config.cpp b/addons/interaction/config.cpp index 0afb2fc0fe..9659565c3c 100644 --- a/addons/interaction/config.cpp +++ b/addons/interaction/config.cpp @@ -14,6 +14,6 @@ class CfgPatches { #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" -#include "Menu_Config.hpp" +#include "RscTitles.hpp" #include "ACE_Settings.hpp" #include "ACE_ZeusActions.hpp" diff --git a/addons/interaction/functions/fnc_addPassengerActions.sqf b/addons/interaction/functions/fnc_addPassengerActions.sqf index d7e21d4a7b..20de00e315 100644 --- a/addons/interaction/functions/fnc_addPassengerActions.sqf +++ b/addons/interaction/functions/fnc_addPassengerActions.sqf @@ -1,13 +1,13 @@ /* * Author: esteldunedain - * Mount unit actions inside passenger submenu + * Mount unit actions inside passenger submenu. * * Arguments: * 0: Vehicle * 1: Player * 3: Parameters * - * Return value: + * Return Value: * Children actions * * Example: @@ -17,8 +17,8 @@ */ #include "script_component.hpp" -EXPLODE_3_PVT(_this,_vehicle,_player,_parameters); -EXPLODE_1_PVT(_parameters,_unit); +params ["", "", "_parameters"]; +_parameters params ["_unit"]; private ["_varName", "_actionTrees", "_actions"]; @@ -26,11 +26,13 @@ _varName = format [QEGVAR(interact_menu,Act_%1), typeOf _unit]; _actionTrees = missionNamespace getVariable [_varName, []]; _actions = []; -// Mount unit MainActions menu +// Mount unit MainActions menu { - EXPLODE_2_PVT(_x,_actionData,_children); - _actions pushBack [_actionData, _children, _unit]; -} forEach ((_actionTrees select 0) select 1); + _x params ["_actionData", "_children"]; + + _actions pushBack [_actionData, _children, _unit]; + false +} count (_actionTrees select 0 select 1); _actions diff --git a/addons/interaction/functions/fnc_addPassengersActions.sqf b/addons/interaction/functions/fnc_addPassengersActions.sqf index fe557e7ada..7296b34fa2 100644 --- a/addons/interaction/functions/fnc_addPassengersActions.sqf +++ b/addons/interaction/functions/fnc_addPassengersActions.sqf @@ -1,13 +1,13 @@ /* * Author: esteldunedain - * Create one action per passenger + * Create one action per passenger. * * Arguments: * 0: Vehicle * 1: Player * 3: Parameters * - * Return value: + * Return Value: * Children actions * * Example: @@ -17,39 +17,43 @@ */ #include "script_component.hpp" -EXPLODE_3_PVT(_this,_vehicle,_player,_parameters); +params ["_vehicle", "_player"]; -private ["_actions"]; +private "_actions"; _actions = []; { private ["_unit", "_icon"]; + _unit = _x; - if ((_unit != _player) && {(getText (configFile >> "CfgVehicles" >> (typeOf _x) >> "simulation")) != "UAVPilot"}) then { - _icon = switch _unit do { - case (driver _vehicle): { QUOTE(A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_driver_ca.paa) }; - case (gunner _vehicle): { QUOTE(A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_gunner_ca.paa) }; - case (commander _vehicle): { QUOTE(A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_commander_ca.paa) }; - default { "" }; - }; + + if (_unit != _player && {getText (configFile >> "CfgVehicles" >> typeOf _unit >> "simulation") != "UAVPilot"}) then { + _icon = [ + "", + "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_driver_ca.paa", + "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_gunner_ca.paa", + "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_commander_ca.paa" + ] select (([driver _vehicle, gunner _vehicle, commander _vehicle] find _unit) + 1); + if (_unit getVariable [QEGVAR(captives,isHandcuffed), false]) then { _icon = QUOTE(PATHTOEF(captives,UI\handcuff_ca.paa)); }; - _actions pushBack + + _actions pushBack [ [ - [ - str(_unit), - [_unit, true] call EFUNC(common,getName), - _icon, - {}, - {true}, - {_this call FUNC(addPassengerActions);}, - [_unit] - ] call EFUNC(interact_menu,createAction), - [], - _unit - ]; + format ["%1", _unit], + [_unit, true] call EFUNC(common,getName), + _icon, + {}, + {true}, + {_this call FUNC(addPassengerActions)}, + [_unit] + ] call EFUNC(interact_menu,createAction), + [], + _unit + ]; }; -} forEach crew _vehicle; + false +} count crew _vehicle; _actions diff --git a/addons/interaction/functions/fnc_addSelectableItem.sqf b/addons/interaction/functions/fnc_addSelectableItem.sqf deleted file mode 100644 index 74a0e9caea..0000000000 --- a/addons/interaction/functions/fnc_addSelectableItem.sqf +++ /dev/null @@ -1,32 +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_4(_container,_displayName,_picture,_data); - -if (_picture == "" || _picture == "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_applyButtons.sqf b/addons/interaction/functions/fnc_applyButtons.sqf deleted file mode 100644 index 8aa57d5923..0000000000 --- a/addons/interaction/functions/fnc_applyButtons.sqf +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Author: commy2 - * Applies buttons - * - * Arguments: - * None - * - * Return value: - * None - * - * Example: - * call ace_interaction_fnc_applyButtons - * - * Public: No - */ -#include "script_component.hpp" - -private ["_object", "_actions", "_dlgInteractionDialog", "_ctrlInteractionDialog", "_index", "_ctrlInteractionDialogIcon", "_a", "_action", "_count"]; - -_object = GVAR(Target); -_actions = GVAR(Buttons); - - -disableSerialization; -_dlgInteractionDialog = uiNamespace getVariable QGVAR(Dialog); - -/* -for "_a" from 0 to (_count - 1) do { - _action = GVAR(Buttons) select _a; - - _ctrlInteractionDialog = _dlgInteractionDialog displayCtrl (10 + _a); - _ctrlInteractionDialog ctrlShow true; - _ctrlInteractionDialog ctrlSetText (_action select 0); - _ctrlInteractionDialog ctrlEnable (call (_action select 2)); -}; -*/ - -_ctrlInteractionDialog = _dlgInteractionDialog displayCtrl 3; - -GVAR(MainButton) = "(findDisplay 1713999) closeDisplay 1;"; - -if (_object isKindOf "Man") then { - _ctrlInteractionDialog ctrlSetText (if (alive _object) then {name _object} else {_object getVariable ["ACE_Name", "Unknown"]}); -} else { - _ctrlInteractionDialog ctrlSetText (getText (configFile >> "CfgVehicles" >> typeOf _object >> "displayName")); -}; - -for "_index" from 0 to 9 do { - _ctrlInteractionDialog = _dlgInteractionDialog displayCtrl (10 + _index); - _ctrlInteractionDialog ctrlShow true; - - _ctrlInteractionDialogIcon = _dlgInteractionDialog displayCtrl (20 + _index); - - if (_index < _count) then { - _action = GVAR(Buttons) select _index; - _ctrlInteractionDialog ctrlSetText (_action select 0); - _ctrlInteractionDialog ctrlEnable (call (_action select 2)); - - _ctrlInteractionDialogIcon ctrlSetText (_action select 5); - } else { - _ctrlInteractionDialog ctrlSetText ""; - _ctrlInteractionDialog ctrlEnable false; - - _ctrlInteractionDialogIcon ctrlSetText ""; - }; -}; diff --git a/addons/interaction/functions/fnc_canBecomeLeader.sqf b/addons/interaction/functions/fnc_canBecomeLeader.sqf index 1821e41506..3978306fec 100644 --- a/addons/interaction/functions/fnc_canBecomeLeader.sqf +++ b/addons/interaction/functions/fnc_canBecomeLeader.sqf @@ -1,21 +1,20 @@ /* * Author: PabstMirror - * Test if can Become Leader of group + * Test if can Become Leader of group. * * Arguments: - * 0: Target - * 1: Player + * 1: Unit * * Return Value: * Able to become leader of group * * Example: - * [player, player] call ace_interaction_fnc_canBecomeLeader + * [player] call ace_interaction_fnc_canBecomeLeader * * Public: No */ #include "script_component.hpp" -PARAMS_2(_target,_player); +params ["_unit"]; -(count (units group _player) > 1) && {leader group _player != _player} +count units group _unit > 1 && {leader group _unit != _unit} diff --git a/addons/interaction/functions/fnc_canInteractWithCivilian.sqf b/addons/interaction/functions/fnc_canInteractWithCivilian.sqf index c20ac61f94..eb8374191b 100644 --- a/addons/interaction/functions/fnc_canInteractWithCivilian.sqf +++ b/addons/interaction/functions/fnc_canInteractWithCivilian.sqf @@ -1,11 +1,13 @@ /* * Author: commy2 - * Checks if the player can interact with civilian + * Checks if the unit can interact with civilian * * Arguments: - * 0: Target + * 0: Unit + * 1: Target + * 2: Target has to be on the civilian side (default: true) * - * Return value: + * Return Value: * Able to interact with civilian * * Example: @@ -15,10 +17,6 @@ */ #include "script_component.hpp" -EXPLODE_2_PVT(_this,_unit,_isCivilian); +params ["_unit", "_target", ["_isCivilian", true]]; -if (isNil "_isCivilian") then {_isCivilian = true}; - -alive _unit -&& [side _unit != side ACE_player, side group _unit == civilian] select _isCivilian -//&& {count (weapons _unit) == 0} +alive _target && [side _target != side _unit, side group _target == civilian] select _isCivilian // return diff --git a/addons/interaction/functions/fnc_canJoinGroup.sqf b/addons/interaction/functions/fnc_canJoinGroup.sqf index 315da658db..6a3220181d 100644 --- a/addons/interaction/functions/fnc_canJoinGroup.sqf +++ b/addons/interaction/functions/fnc_canJoinGroup.sqf @@ -1,12 +1,12 @@ /* * Author: commy2 - * Checks if the player can join a group + * Checks if the unit can join a group * * Arguments: - * 0: Player + * 0: Unit * 1: Target * - * Return value: + * Return Value: * Able to join a group * * Example: @@ -16,9 +16,9 @@ */ #include "script_component.hpp" -PARAMS_2(_unit,_target); +params ["_unit", "_target"]; alive _target && {!(_target getVariable ["ACE_isUnconscious", false])} && {side group _unit == side group _target} -&& {group _unit != group _target} +&& {group _unit != group _target} // return diff --git a/addons/interaction/functions/fnc_canPardon.sqf b/addons/interaction/functions/fnc_canPardon.sqf new file mode 100644 index 0000000000..a377533018 --- /dev/null +++ b/addons/interaction/functions/fnc_canPardon.sqf @@ -0,0 +1,20 @@ +/* + * Author: commy2 + * Checks if the unit can pardon the target. + * + * Arguments: + * 0: Unit + * 1: Target + * + * Return Value: + * Unit can pardon target + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_target"]; + +alive _target +&& {rating _target < -2000} +&& {side group _unit == side group _target} diff --git a/addons/interaction/functions/fnc_canTapShoulder.sqf b/addons/interaction/functions/fnc_canTapShoulder.sqf index bbeee51b4a..514ac0301b 100644 --- a/addons/interaction/functions/fnc_canTapShoulder.sqf +++ b/addons/interaction/functions/fnc_canTapShoulder.sqf @@ -1,12 +1,12 @@ /* * Author: commy2 - * Checks if the player can tap a shoulder + * Checks if the player can tap a shoulder. * * Arguments: * 0: Player * 1: Target * - * Return value: + * Return Value: * Able to tap a shoulder * * Example: @@ -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_doBecomeLeader.sqf b/addons/interaction/functions/fnc_doBecomeLeader.sqf index 0fd81cbc96..b2a423e0c0 100644 --- a/addons/interaction/functions/fnc_doBecomeLeader.sqf +++ b/addons/interaction/functions/fnc_doBecomeLeader.sqf @@ -1,21 +1,20 @@ /* * Author: PabstMirror - * Become Leader of group + * Become Leader of group. * * Arguments: - * 0: Target - * 1: Player + * 0: Unit * * Return Value: * None * * Example: - * [player, player] call ace_interaction_fnc_doBecomeLeader + * [player] call ace_interaction_fnc_doBecomeLeader * * Public: No */ #include "script_component.hpp" -PARAMS_2(_target,_player); +params ["_unit"]; -[QGVAR(selectLeader), (units group _player), [(group _player), _player]] call EFUNC(common,targetEvent); +["selectLeader", units group _unit, [group _unit, _unit]] call EFUNC(common,targetEvent); diff --git a/addons/interaction/functions/fnc_getDoor.sqf b/addons/interaction/functions/fnc_getDoor.sqf index a085c9a3b8..8261aa44f0 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,19 +17,18 @@ */ #include "script_component.hpp" -PARAMS_1(_distance); +params ["_distance"]; -private ["_position0", "_position1", "_intersections", "_count", "_house", "_door"]; +private ["_position0", "_position1", "_intersections", "_house", "_door"]; _position0 = positionCameraToWorld [0, 0, 0]; _position1 = positionCameraToWorld [0, 0, _distance]; -_intersections = lineIntersectsWith [ATLToASL _position0, ATLToASL _position1, objNull, objNull, true]; +_intersections = lineIntersectsSurfaces [AGLToASL _position0, AGLToASL _position1, cameraOn, objNull, true, 1, "GEOM"]; -_count = count _intersections; -if (_count == 0) exitWith {[objNull, ""]}; +if (_intersections isEqualTo []) exitWith {[objNull, ""]}; -_house = _intersections select (_count - 1); +_house = _intersections select 0 select 2; // shithouse is bugged if (typeOf _house == "") exitWith {[objNull, ""]}; @@ -37,6 +36,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..2dc9711e2c 100644 --- a/addons/interaction/functions/fnc_getDown.sqf +++ b/addons/interaction/functions/fnc_getDown.sqf @@ -1,38 +1,33 @@ /* - * 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 + * 1: Target * - * Return value: + * Return Value: * 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", "_target"]; -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 (_target 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_handleScrollWheel.sqf b/addons/interaction/functions/fnc_handleScrollWheel.sqf new file mode 100644 index 0000000000..793e78c1b3 --- /dev/null +++ b/addons/interaction/functions/fnc_handleScrollWheel.sqf @@ -0,0 +1,23 @@ +/* + * Author: commy2 + * Handles incremental door opening + * + * Arguments: + * 0: scroll amount + * + * Return Value: + * handled + * + * Public: No + */ +#include "script_component.hpp" + +params ["_scroll"]; + +if !(GVAR(isOpeningDoor)) exitWith {false}; + +GVAR(doorTargetPhase) = ((GVAR(doorTargetPhase) + (_scroll / (1.2 * 12))) max 0) min 1; + +GVAR(usedScrollWheel) = true; + +true 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_hideMouseHint.sqf b/addons/interaction/functions/fnc_hideMouseHint.sqf index 69acba25a2..39f43e7fa3 100644 --- a/addons/interaction/functions/fnc_hideMouseHint.sqf +++ b/addons/interaction/functions/fnc_hideMouseHint.sqf @@ -15,7 +15,8 @@ */ #include "script_component.hpp" -if (isNull (uiNamespace getVariable ["ACE_Helper_Display", objNull])) exitWith{}; +if (isNull (uiNamespace getVariable ["ACE_Helper_Display", objNull])) exitWith {}; (QGVAR(InteractionHelper) call BIS_fnc_rscLayer) cutText ["", "PLAIN"]; + showHUD true; 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_joinTeam.sqf b/addons/interaction/functions/fnc_joinTeam.sqf index c2a542d4af..9283e7b474 100644 --- a/addons/interaction/functions/fnc_joinTeam.sqf +++ b/addons/interaction/functions/fnc_joinTeam.sqf @@ -1,35 +1,39 @@ /* * Author: commy2 - * Assigns a unit to the team + * Unit joins a fire team. * * Arguments: * 0: Unit * 1: Team * - * Return value: + * Return Value: * None * * Example: - * [target, "YELLOW"] call ace_interaction_fnc_joinTeam + * [player, "YELLOW"] call ace_interaction_fnc_joinTeam * * Public: No */ #include "script_component.hpp" -PARAMS_2(_unit,_team); - -private ["_message"]; +params ["_unit", "_team"]; +// make sure correct team is set on JIP _unit setVariable [QGVAR(assignedFireTeam), _team, true]; -[_unit, format ["{_this assignTeam '%1'}", _team]] call EFUNC(common,execRemoteFnc); +// join fire team on every machine in that group +["assignTeam", units group _unit, [_unit, _team]] call EFUNC(common,targetEvent); + +// display message if (_unit == ACE_player) then { - _message = if (_team == "MAIN") then { - localize LSTRING(LeftTeam); + private "_message"; + + if (_team == "MAIN") then { + _message = localize LSTRING(LeftTeam); } else { _team = localize format [LSTRING(Team%1), _team]; - format [localize LSTRING(JoinedTeam), _team]; + _message = format [localize LSTRING(JoinedTeam), _team]; }; - [_message] call EFUNC(common,displayTextStructured); + ["displayTextStructured", _message] call EFUNC(common,localEvent); }; diff --git a/addons/interaction/functions/fnc_moduleInteraction.sqf b/addons/interaction/functions/fnc_moduleInteraction.sqf index 4d6ef3f1c0..425ee9d6e4 100644 --- a/addons/interaction/functions/fnc_moduleInteraction.sqf +++ b/addons/interaction/functions/fnc_moduleInteraction.sqf @@ -1,13 +1,13 @@ /* * Author: bux578 - * Initializes the Interaction module + * Initializes the Interaction module. * * Arguments: * 0: Logic - * 1: ??? + * 1: Units * 2: Activation State * - * Return value: + * Return Value: * None * * Example: @@ -17,10 +17,7 @@ */ #include "script_component.hpp" -private ["_logic", "_activated"]; - -_logic = _this select 0; -_activated = _this select 2; +params ["_logic", "", "_activated"]; if !(_activated) exitWith {}; 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..b2249d1589 100644 --- a/addons/interaction/functions/fnc_openDoor.sqf +++ b/addons/interaction/functions/fnc_openDoor.sqf @@ -1,12 +1,12 @@ /* * Author: commy2 - * Opens door + * Open door. * * Arguments: * 0: House * 1: Door * - * Return value: + * Return Value: * None * * Example: @@ -16,56 +16,56 @@ */ #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 call BIS_fnc_LockedDoorOpen; }; +playSound "ACE_Sound_Click"; // @todo replace with smth. more fitting + +GVAR(doorTargetPhase) = _house animationPhase (_animations select 0); GVAR(isOpeningDoor) = true; -playSound "ACE_Sound_Click"; //@todo replace with smth. more fitting +GVAR(usedScrollWheel) = false; -[_house, _animations] spawn { - private ["_house", "_animations", "_phase", "_position", "_time", "_usedMouseWheel"]; - _house = _this select 0; - _animations = _this select 1; +[{ + (_this select 0) params ["_house", "_animations", "_position", "_time", "_frame"]; - _phase = _house animationPhase (_animations select 0); - _position = getPosASL ACE_player; + if !(GVAR(isOpeningDoor)) exitWith { + [_this select 1] call CBA_fnc_removePerFrameHandler; - _time = ACE_time + 0.2; - _usedMouseWheel = false; - waitUntil { - if (inputAction "PrevAction" > 0 || {inputAction "NextAction" > 0}) then { - _usedMouseWheel = true; + // didn't use incremental opening. Just do animation normally. + if !(GVAR(usedScrollWheel)) then { + private "_phase"; + _phase = [0, 1] select (_house animationPhase (_animations select 0) < 0.5); + + {_house animate [_x, _phase]; false} count _animations; }; - - _phase = _phase + (inputAction "PrevAction" / 12) min 1; - _phase = _phase - (inputAction "NextAction" / 12) max 0; - - {_house animate [_x, _phase]} forEach _animations; - - !GVAR(isOpeningDoor) || {getPosASL ACE_player distance _position > 1} }; - if (!_usedMouseWheel && {ACE_time < _time} && {[ACE_player, objNull, []] call EFUNC(common,canInteractWith)}) then { - _phase = [0, 1] select (_house animationPhase (_animations select 0) < 0.5); - - {_house animate [_x, _phase]} forEach _animations; + // check if player moved too far away + if (getPosASL ACE_player distance _position > 1) exitWith { + GVAR(isOpeningDoor) = false; }; - GVAR(isOpeningDoor) = false; -}; + // this allows for holding the door in it's current state. + if (ACE_time > _time && {diag_frameno > _frame}) then { + GVAR(usedScrollWheel) = true; + }; + + // do incremental door opening + {_house animate [_x, GVAR(doorTargetPhase)]; false} count _animations; +}, 0.1, [_house, _animations, getPosASL ACE_player, ACE_time + 0.2, diag_frameno + 2]] call CBA_fnc_addPerFrameHandler; 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_pardon.sqf b/addons/interaction/functions/fnc_pardon.sqf new file mode 100644 index 0000000000..00fe2f6d17 --- /dev/null +++ b/addons/interaction/functions/fnc_pardon.sqf @@ -0,0 +1,18 @@ +/* + * Author: commy2 + * Unit pardons target unit. + * + * Arguments: + * 0: Unit + * 1: Target + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +params ["", "_target"]; + +["pardon", [_target], [_target]] call EFUNC(common,targetEvent); 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_push.sqf b/addons/interaction/functions/fnc_push.sqf index 86ad673d9c..9a6c86a18e 100644 --- a/addons/interaction/functions/fnc_push.sqf +++ b/addons/interaction/functions/fnc_push.sqf @@ -4,7 +4,7 @@ * * Arguments: * 0: Boat - * 1: Player + * 1: Unit * * Return Value: * None @@ -14,13 +14,13 @@ * * Public: No */ - #include "script_component.hpp" -params ["_boat", "_player"]; +params ["_boat", "_unit"]; -private ["_newVelocity"]; +private "_newVelocity"; +_newVelocity = vectorDir _unit; +_newVelocity set [2, 0.25]; +_newVelocity = _newVelocity vectorMultiply 2; -_newVelocity = [2 * (vectorDir _player select 0), 2 * (vectorDir _player select 1), 0.5]; - -[QGVAR(pushBoat), [_boat], [_boat, _newVelocity]] call EFUNC(common,targetEvent); +["setVelocity", [_boat], [_boat, _newVelocity]] call EFUNC(common,targetEvent); 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_showMouseHint.sqf b/addons/interaction/functions/fnc_showMouseHint.sqf index e3a9b45f94..e8f279cc0c 100644 --- a/addons/interaction/functions/fnc_showMouseHint.sqf +++ b/addons/interaction/functions/fnc_showMouseHint.sqf @@ -20,18 +20,16 @@ #define GUI_GRID_W (0.025) #define GUI_GRID_H (0.04) -private ["_scroll", "_display"]; +params ["_leftClick", "_rightClick", ["_scroll", ""]]; -PARAMS_2(_leftClick,_rightClick); -_scroll = ""; -if (count _this > 2) then { - _scroll = _this select 2; -}; +(QGVAR(InteractionHelper) call BIS_fnc_rscLayer) cutRsc [QGVAR(InteractionHelper), "PLAIN", 0.5, false]; -(QGVAR(InteractionHelper) call BIS_fnc_rscLayer) cutRsc [QGVAR(InteractionHelper), "PLAIN",0.5, false]; disableSerialization; + +private "_display"; _display = uiNamespace getVariable ["ACE_Helper_Display", objNull]; -if (isNull _display) exitWith{}; + +if (isNull _display) exitWith {}; (_display displayCtrl 1000) ctrlSetText _leftClick; (_display displayCtrl 1001) ctrlSetText _rightClick; @@ -44,10 +42,12 @@ if (isNull _display) exitWith{}; if (_scroll == "") exitWith { (_display displayCtrl 1002) ctrlShow false; (_display displayCtrl 1202) ctrlShow false; - (_display displayCtrl 1001) ctrlSetPosition [21 * GUI_GRID_W, 18 * GUI_GRID_H, 8 * GUI_GRID_W, 1.5 * GUI_GRID_H]; - (_display displayCtrl 1201) ctrlSetPosition [20 * GUI_GRID_W, 18.5 * GUI_GRID_H, 1 * GUI_GRID_W, 1 * GUI_GRID_H]; + (_display displayCtrl 1001) ctrlSetPosition [21 * GUI_GRID_W, 18 * GUI_GRID_H, 24 * GUI_GRID_W, 1.5 * GUI_GRID_H]; + (_display displayCtrl 1201) ctrlSetPosition [20 * GUI_GRID_W, 18.5 * GUI_GRID_H, 1.5 * GUI_GRID_W, 1 * GUI_GRID_H]; (_display displayCtrl 1001) ctrlCommit 0; (_display displayCtrl 1201) ctrlCommit 0; }; + (_display displayCtrl 1002) ctrlSetText _scroll; + showHUD false; 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..2061f1806f 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: + * 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; diff --git a/addons/main/script_macros.hpp b/addons/main/script_macros.hpp index f7ec3a3fa3..c2ecab058b 100644 --- a/addons/main/script_macros.hpp +++ b/addons/main/script_macros.hpp @@ -99,6 +99,11 @@ #define ACE_isHC (!hasInterface && !isDedicated) +//By default CBA's TRACE/LOG/WARNING spawn a buffer, which can cause messages to be logged out of order: +#ifdef CBA_DEBUG_SYNCHRONOUS + #define CBA_fnc_log { params ["_file","_lineNum","_message"]; diag_log [diag_frameNo, diag_tickTime, time, _file + ":"+str(_lineNum + 1), _message]; } +#endif + #define ACE_LOG(module,level,message) diag_log text ACE_LOGFORMAT(module,level,message) #define ACE_LOGFORMAT(module,level,message) FORMAT_2(QUOTE([ACE] (module) %1: %2),level,message) diff --git a/addons/medical/functions/fnc_moduleAssignMedicalVehicle.sqf b/addons/medical/functions/fnc_moduleAssignMedicalVehicle.sqf index 9744ce5f7b..8481aaf293 100644 --- a/addons/medical/functions/fnc_moduleAssignMedicalVehicle.sqf +++ b/addons/medical/functions/fnc_moduleAssignMedicalVehicle.sqf @@ -12,11 +12,9 @@ * * Public: No */ - - #include "script_component.hpp" -private ["_setting", "_objects", "_list", "_splittedList", "_nilCheckPassedList", "_parsedList"]; +private ["_setting", "_objects", "_list", "_splittedList", "_nilCheckPassedList", "_parsedList", "_xVehicle"]; params [["_logic", objNull, [objNull]]]; if (!isNull _logic) then { @@ -42,9 +40,11 @@ if (!isNull _logic) then { if (!(_objects isEqualTo []) && _parsedList isEqualTo []) then { { if (!isnil "_x") then { - if (typeName _x == typeName objNull) then { + if (typeName _x == typeName objNull) then { if (local _x) then { - _x setvariable [QGVAR(medicClass), _setting, true]; + _xVehicle = vehicle _x; + TRACE_3("setting medical vehicle", _x, _xVehicle, (typeOf _xVehicle)); + _xVehicle setvariable [QGVAR(medicClass), _setting, true]; }; }; }; @@ -52,11 +52,12 @@ if (!isNull _logic) then { }; { if (!isnil "_x") then { - if (typeName _x == typeName objNull) then { + if (typeName _x == typeName objNull) then { if (local _x) then { + TRACE_2("setting medical vehicle", _x, (typeOf _x)); _x setvariable [QGVAR(medicClass), _setting, true]; }; }; }; } foreach _parsedList; - }; +}; diff --git a/addons/medical/functions/fnc_setUnconscious.sqf b/addons/medical/functions/fnc_setUnconscious.sqf index 3de62db974..cb9fff0693 100644 --- a/addons/medical/functions/fnc_setUnconscious.sqf +++ b/addons/medical/functions/fnc_setUnconscious.sqf @@ -21,6 +21,11 @@ #define DEFAULT_DELAY (round(random(10)+5)) +// only run this after the settings are initialized +if !(EGVAR(common,settingsInitFinished)) exitWith { + EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(setUnconscious), _this]; +}; + private ["_animState", "_originalPos", "_startingTime", "_isDead"]; params ["_unit", ["_set", true], ["_minWaitingTime", DEFAULT_DELAY], ["_force", false]]; diff --git a/addons/medical/stringtable.xml b/addons/medical/stringtable.xml index 17944e83c3..de25b550b4 100644 --- a/addons/medical/stringtable.xml +++ b/addons/medical/stringtable.xml @@ -1,4 +1,4 @@ - + @@ -2221,6 +2221,7 @@ Heal fully bandaged hitpoints Lecz w pełni zabandażowane hitpointy Curar miembros totalmente vendados + Исцелять полностью перебинтованные части тела Pain is only temporarily suppressed @@ -3438,11 +3439,13 @@ Heal hitpoints Lecz hitpointy Curar puntos de vida + Исцелять части тела Heal fully bandaged hitpoints Po bandażowaniu ulecz hitpointy, usuwając z nich ślady krwi i przywracając im pełną sprawność. Curar miembros totalmente vendados + Исцелять полностью перебинтованные части тела Pain suppression @@ -3839,11 +3842,13 @@ This person (%1) is awake and cannot be loaded Ta osoba (%1) jest przytomna i nie może zostać załadowana Esta persona (%1) está despierto y no puede ser cargado + Боец (%1) в сознании и не может быть погружен There is no tourniquet on this body part! Na tej części ciała nie ma stazy! No hay torniquete en esta parte del cuerpo! + Нет жгута на этой части тела! diff --git a/addons/noradio/CfgEventhandlers.hpp b/addons/noradio/CfgEventhandlers.hpp index d960e896df..386d98d241 100644 --- a/addons/noradio/CfgEventhandlers.hpp +++ b/addons/noradio/CfgEventhandlers.hpp @@ -1,6 +1,6 @@ + class Extended_PostInit_EventHandlers { - class ADDON { - clientInit = QUOTE(call COMPILE_FILE(XEH_post_initClient)); - serverInit = QUOTE(call COMPILE_FILE(XEH_post_initServer)); - }; -}; \ No newline at end of file + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; diff --git a/addons/noradio/XEH_postInit.sqf b/addons/noradio/XEH_postInit.sqf new file mode 100644 index 0000000000..4aeccffd62 --- /dev/null +++ b/addons/noradio/XEH_postInit.sqf @@ -0,0 +1,24 @@ +// by commy2 +#include "script_component.hpp" + +// unmute unit if that player disconnects +if (isServer) then { + addMissionEventHandler ["HandleDisconnect", { + [_this select 0, "isPlayer"] call EFUNC(common,unmuteUnit); + }]; +}; + +if (!hasInterface) exitWith {}; + +// mutes/unmutes units when the player changes +["playerChanged", { + params ["_newPlayer", "_oldPlayer"]; + + // mute the new player + [_newPlayer, "isPlayer"] call EFUNC(common,muteUnit); + + // unmute the old player + if (alive _oldPlayer) then { + [_oldPlayer, "isPlayer"] call EFUNC(common,unmuteUnit); + }; +}] call EFUNC(common,addEventhandler); diff --git a/addons/noradio/XEH_post_initClient.sqf b/addons/noradio/XEH_post_initClient.sqf deleted file mode 100644 index ecd80a6436..0000000000 --- a/addons/noradio/XEH_post_initClient.sqf +++ /dev/null @@ -1,27 +0,0 @@ -// by commy2 -#include "script_component.hpp" - -/* -[{ - if (!isNull ACE_player) then { - [(_this select 1)] call cba_fnc_removePerFrameHandler; - - [ACE_player, "isPlayer"] call EFUNC(common,muteUnit); - }; -}, 0, []] call CBA_fnc_addPerFrameHandler; -*/ - -if (!hasInterface) exitWith {}; - -// Mutes/unmutes units when the player changes -["playerChanged", { - EXPLODE_2_PVT(_this,_newPlayer,_oldPlayer); - - // On player change mute the new player - [_newPlayer, "isPlayer"] call EFUNC(common,muteUnit); - - // Unmute the old player - if (alive _oldPlayer) then { - [_oldPlayer, "isPlayer"] call EFUNC(common,unmuteUnit); - }; -}] call EFUNC(common,addEventhandler); diff --git a/addons/noradio/XEH_post_initServer.sqf b/addons/noradio/XEH_post_initServer.sqf deleted file mode 100644 index ae2dc16ec1..0000000000 --- a/addons/noradio/XEH_post_initServer.sqf +++ /dev/null @@ -1,6 +0,0 @@ -// by commy2 -#include "script_component.hpp" - -addMissionEventHandler ["HandleDisconnect", { - [_this select 0, "isPlayer"] call EFUNC(common,unmuteUnit); -}]; diff --git a/addons/optics/XEH_postInit.sqf b/addons/optics/XEH_postInit.sqf index 64226fcf3d..6214178ac9 100644 --- a/addons/optics/XEH_postInit.sqf +++ b/addons/optics/XEH_postInit.sqf @@ -7,7 +7,7 @@ GVAR(camera) = objNull; 0 = 0 spawn { waituntil {!isNull ACE_player}; - waituntil {sleep 1; {_x != GVAR(camera)} count allMissionObjects "camera" == 0}; + waituntil {sleep 1; {_x != GVAR(camera)} count allMissionObjects "camera" == 0 && {isNull curatorCamera}}; GVAR(camera) cameraEffect ["TERMINATE", "BACK"]; camDestroy GVAR(camera); diff --git a/addons/repair/stringtable.xml b/addons/repair/stringtable.xml index d77500e77f..d4b9527f09 100644 --- a/addons/repair/stringtable.xml +++ b/addons/repair/stringtable.xml @@ -183,12 +183,14 @@ Dodaj części zam. Adicionar partes sobressalentes Añadir repuestos + Добавлять запчасти Add spare parts to vehicles (requires Cargo component)? Czy dodać do pojazdów części zamienne? Wymaga włączonego cargo. Adicionar partes sobressalentes aos veículos (requer o componente de carga)? ¿Añadir repuestos para vehículos (requiere componente de carga)? + Добавлять запасные части в технику (требуется модуль Грузоперевозок)? Repair >> @@ -942,58 +944,68 @@ Dodaj części zam. Adicionar partes sobressalentes Añadir repuestos + Добавить запчасти Add spare parts to one or multiple objects Dodaj części zamienne do jednego lub wielu obiektów. Adicionar partes sobressalentes para um ou mais objetos Añadir repuestos a uno o varios objetos + Добавить запасные части в одно или несколько транспортных средств List Lista Lista Lista + Список List of objects that will get spare parts added, separated by commas. Lista obiektów, które otrzymają części zamienne, oddzielone przecinkiem. Lista de objetos que ganharão partes sobressalentes, dividos por vírgulas. Lista de los objetos que tendrán repuestos añadidos, separados por comas. + Список транспортных средств, в которые будут добавляться запчасти, разделенный запятыми. Part Część Parte Pieza + Запчасть Spare part. Część zamienna. Parte sobressalente Pieza de recambio. + Запасная часть. Amount Ilość Quantidade Cantidad + Количество Number of selected spare parts. Ilość wybranych części zamiennych. Número de partes sobressalentes. Número de piezas de repuesto seleccionados. + Число выбранных запасных частей. Wheel repair requirements Wym. naprawy kół Requisitos de reparación de ruedas + Для ремонта колес требуется Items required to remove/replace wheels Przedmioty potrzebne do wymiany kół Elementos necesarios para quitar/cambiar ruedas + Предметы, которые требуются для снятия/замены колес diff --git a/addons/respawn/ACE_Settings.hpp b/addons/respawn/ACE_Settings.hpp index 5c947b8670..f704d25412 100644 --- a/addons/respawn/ACE_Settings.hpp +++ b/addons/respawn/ACE_Settings.hpp @@ -1,3 +1,4 @@ + class ACE_Settings { class GVAR(SavePreDeathGear) { value = 0; diff --git a/addons/respawn/CfgAddons.hpp b/addons/respawn/CfgAddons.hpp index 111613615e..50ea187915 100644 --- a/addons/respawn/CfgAddons.hpp +++ b/addons/respawn/CfgAddons.hpp @@ -1,3 +1,4 @@ + class CfgAddons { class GVAR(Rallypoints) { list[] = {"ACE_Rallypoint_West", "ACE_Rallypoint_East", "ACE_Rallypoint_Independent", "ACE_Rallypoint_West_Base", "ACE_Rallypoint_East_Base", "ACE_Rallypoint_Independent_Base"}; diff --git a/addons/respawn/CfgVehicleClasses.hpp b/addons/respawn/CfgVehicleClasses.hpp index ab9c9b6c7e..817ee8150f 100644 --- a/addons/respawn/CfgVehicleClasses.hpp +++ b/addons/respawn/CfgVehicleClasses.hpp @@ -1,3 +1,4 @@ + class CfgVehicleClasses { class GVAR(Rallypoints) { displayName = CSTRING(EditorCategory); diff --git a/addons/respawn/CfgVehicles.hpp b/addons/respawn/CfgVehicles.hpp index aa99b4e942..8fdfb5f0fc 100644 --- a/addons/respawn/CfgVehicles.hpp +++ b/addons/respawn/CfgVehicles.hpp @@ -1,3 +1,4 @@ + class CfgVehicles { class ACE_Module; class ACE_ModuleRespawn: ACE_Module { @@ -6,7 +7,7 @@ class CfgVehicles { displayName = CSTRING(Module_DisplayName); function = QFUNC(module); scope = 2; - isGlobal = 1; + isGlobal = 0; icon = QUOTE(PATHTOF(UI\Icon_Module_Respawn_ca.paa)); class Arguments { @@ -24,6 +25,7 @@ class CfgVehicles { defaultValue = 1; }; }; + class ModuleDescription { description = CSTRING(Module_Description); }; diff --git a/addons/respawn/XEH_postInit.sqf b/addons/respawn/XEH_postInit.sqf index ada5765e86..22be7b86ac 100644 --- a/addons/respawn/XEH_postInit.sqf +++ b/addons/respawn/XEH_postInit.sqf @@ -2,4 +2,4 @@ #include "script_component.hpp" ["rallypointMoved", {_this call FUNC(updateRallypoint)}] call EFUNC(common,addEventhandler); -["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler); // hide enemy rallypoint markers +["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler); // hide enemy rallypoint markers diff --git a/addons/respawn/XEH_preInit.sqf b/addons/respawn/XEH_preInit.sqf index dd116f108c..eda5293876 100644 --- a/addons/respawn/XEH_preInit.sqf +++ b/addons/respawn/XEH_preInit.sqf @@ -13,7 +13,6 @@ PREP(moduleFriendlyFire); PREP(moduleRallypoint); PREP(moveRallypoint); PREP(removeBody); -PREP(removeDisconnectedPlayer); PREP(restoreGear); PREP(showFriendlyFireMessage); PREP(teleportToRallypoint); diff --git a/addons/respawn/functions/fnc_canMoveRallypoint.sqf b/addons/respawn/functions/fnc_canMoveRallypoint.sqf index d5f325c067..174d76c69d 100644 --- a/addons/respawn/functions/fnc_canMoveRallypoint.sqf +++ b/addons/respawn/functions/fnc_canMoveRallypoint.sqf @@ -1,33 +1,30 @@ /* - Name: ACE_Respawn_fnc_canMoveRallypoint - - Author(s): - commy2 - - Description: - checks if a unit can move a rally point - - Parameters: - 0: OBJECT - unit - 1: OBJECT - side - - Returns: - BOOLEAN -*/ - + * Author: commy2 + * Checks if a unit can move a rally point. + * + * Arguments: + * 0: Unit + * 1: Side + * + * Return Value: + * Can move + * + * Example: + * [ACE_Player, side ACE_Player] call ace_respawn_fnc_canMoveRallypoint + * + * Public: No + */ #include "script_component.hpp" -private ["_unit", "_side"]; +params ["_unit", "_side"]; -_unit = _this select 0; -_side = _this select 1; +// player has to be a rallypoint mover. group leader by default +if !(_unit getVariable ["ACE_canMoveRallypoint", false]) exitWith {false}; -// rallypoint names are defined in CfgVehicles.hpp - -_unit getVariable ["ACE_canMoveRallypoint", false] -&& {!isNull ([ +// rallypoint of that side has to exist +!isNull ([ objNull, missionNamespace getVariable ["ACE_Rallypoint_West", objNull], missionNamespace getVariable ["ACE_Rallypoint_East", objNull], missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull] -] select ([west, east, independent] find _side) + 1)} +] select ([west, east, independent] find _side) + 1) // return diff --git a/addons/respawn/functions/fnc_handleInitPostServer.sqf b/addons/respawn/functions/fnc_handleInitPostServer.sqf index 914334cc25..a1e46c1caf 100644 --- a/addons/respawn/functions/fnc_handleInitPostServer.sqf +++ b/addons/respawn/functions/fnc_handleInitPostServer.sqf @@ -1,26 +1,39 @@ -// by commy2 -// execute on server only! +/* + * Author: commy2 + * Handle XEH Init Post on Server. + * Execution on server only. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [ACE_Player] call ace_respawn_fnc_handleInitPostServer + * + * Public: No + */ #include "script_component.hpp" -PARAMS_1(_unit); +params ["_unit"]; -private ["_group0", "_rallypoint"]; +private ["_groupUnit", "_rallypoint", "_leaderVarName"]; -_group0 = group _unit; // _group-is a reserved veriable and shouldn't be used +_groupUnit = group _unit; // _group is a reserved veriable and shouldn't be used _rallypoint = [ objNull, missionNamespace getVariable ["ACE_Rallypoint_West", objNull], missionNamespace getVariable ["ACE_Rallypoint_East", objNull], missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull] -] select ([west, east, independent] find side _group0) + 1; +] select ([west, east, independent] find side _groupUnit) + 1; // exit if no moveable rallypoint is placed for that side if (isNull _rallypoint) exitWith {}; // find leader -private "_leaderVarName"; -_leaderVarName = _group0 getVariable [QGVAR(leaderVarName), ""]; +_leaderVarName = _groupUnit getVariable [QGVAR(leaderVarName), ""]; // exit if group already has a playable slot assigned as rallypoint leader if (_leaderVarName != "") exitWith { @@ -31,7 +44,7 @@ if (_leaderVarName != "") exitWith { }; // treat group leader -_unit = leader _group0; +_unit = leader _groupUnit; _leaderVarName = vehicleVarName _unit; @@ -47,6 +60,6 @@ if (_leaderVarName == "") then { }; // prevent group from getting multiple leaders; use this to assign rallypoint moving ability on JIP -_group0 setVariable [QGVAR(leaderVarName), _leaderVarName]; +_groupUnit setVariable [QGVAR(leaderVarName), _leaderVarName]; _unit setVariable ["ACE_canMoveRallypoint", true, true]; diff --git a/addons/respawn/functions/fnc_handleKilled.sqf b/addons/respawn/functions/fnc_handleKilled.sqf index 99ec308c1c..200e3c98c8 100644 --- a/addons/respawn/functions/fnc_handleKilled.sqf +++ b/addons/respawn/functions/fnc_handleKilled.sqf @@ -1,31 +1,30 @@ /* - Name: ACE_Respawn_fnc_handleKilled - - Author(s): - bux578 - - Description: - Handles the XEH Killed event - - Parameters: - 0: OBJECT - Killed unit - 1: OBJECT - Attacker - - Returns: - VOID -*/ - + * Author: bux578 + * Handles the XEH killed event. + * + * Arguments: + * 0: Unit + * 1: Killer + * + * Return Value: + * None + * + * Example: + * [ACE_player, bad_dude] call ace_respawn_fnc_handleKilled + * + * Public: No + */ #include "script_component.hpp" -PARAMS_1(_killedUnit); +params ["_unit"]; // Saves the gear when the player! (and only him) is killed -if (ACE_player == _killedUnit) then { +if (ACE_player == _unit) then { GVAR(unitGear) = []; if (GVAR(SavePreDeathGear)) then { - GVAR(unitGear) = [_killedUnit] call EFUNC(common,getAllGear); - GVAR(unitGear) pushBack [currentWeapon _killedUnit, currentMuzzle _killedUnit, currentWeaponMode _killedUnit]; + GVAR(unitGear) = [_unit] call EFUNC(common,getAllGear); + GVAR(unitGear) pushBack [currentWeapon _unit, currentMuzzle _unit, currentWeaponMode _unit]; }; }; diff --git a/addons/respawn/functions/fnc_handlePlayerChanged.sqf b/addons/respawn/functions/fnc_handlePlayerChanged.sqf index db699066bc..7d595e6a44 100644 --- a/addons/respawn/functions/fnc_handlePlayerChanged.sqf +++ b/addons/respawn/functions/fnc_handlePlayerChanged.sqf @@ -1,44 +1,28 @@ -// by commy2 +/* + * Author: commy2 + * Handle player changed event. Updates visibility of Rallypoint markers. + * + * Arguments: + * 0: New Unit + * + * Return Value: + * None + * + * Example: + * [ACE_player] call ace_respawn_fnc_handlePlayerChanged + * + * Public: No + */ #include "script_component.hpp" -private "_newUnit"; +params ["_newUnit"]; -_newUnit = _this select 0; +private "_side"; +_side = side group _newUnit; -switch (side group _newUnit) do { - case (west): { - ((missionNamespace getVariable ["ACE_Rallypoint_West", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 1; - ((missionNamespace getVariable ["ACE_Rallypoint_East", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_West_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 1; - ((missionNamespace getVariable ["ACE_Rallypoint_East_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_Independent_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - }; - - case (east): { - ((missionNamespace getVariable ["ACE_Rallypoint_West", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_East", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 1; - ((missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_West_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_East_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 1; - ((missionNamespace getVariable ["ACE_Rallypoint_Independent_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - }; - - case (independent): { - ((missionNamespace getVariable ["ACE_Rallypoint_West", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_East", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 1; - ((missionNamespace getVariable ["ACE_Rallypoint_West_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_East_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_Independent_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 1; - }; - - default { - ((missionNamespace getVariable ["ACE_Rallypoint_West", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_East", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_West_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_East_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_Independent_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - }; -}; +((GETMVAR(ACE_Rallypoint_West, objNull)) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal ([0, 1] select (_side == west)); +((GETMVAR(ACE_Rallypoint_West_Base, objNull)) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal ([0, 1] select (_side == west)); +((GETMVAR(ACE_Rallypoint_East, objNull)) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal ([0, 1] select (_side == east)); +((GETMVAR(ACE_Rallypoint_East_Base, objNull)) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal ([0, 1] select (_side == east)); +((GETMVAR(ACE_Rallypoint_Independent, objNull)) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal ([0, 1] select (_side == independent)); +((GETMVAR(ACE_Rallypoint_Independent_Base, objNull)) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal ([0, 1] select (_side == independent)); diff --git a/addons/respawn/functions/fnc_handleRespawn.sqf b/addons/respawn/functions/fnc_handleRespawn.sqf index 33a0ec09e5..ab5ecedbda 100644 --- a/addons/respawn/functions/fnc_handleRespawn.sqf +++ b/addons/respawn/functions/fnc_handleRespawn.sqf @@ -1,32 +1,29 @@ /* - Name: ACE_Respawn_fnc_handleRespawn - - Author(s): - bux578 - - Description: - Handles the XEH Respawn event - - Parameters: - 0: OBJECT - Respawned Unit - 1: ? - - Returns: - VOID -*/ - + * Author: bux578 + * Handles the XEH Respawn event. + * + * Arguments: + * 0: Unit + * 1: Corpse + * + * Return Value: + * None + * + * Example: + * [ACE_Player, old_body_lying_on_floor] call ace_respawn_fnc_handleRespawn + * + * Public: No + */ #include "script_component.hpp" -private ["_respawnedUnit"]; - -_respawnedUnit = _this select 0; +params ["_unit"]; // Restores the gear when the player respawns if (GVAR(SavePreDeathGear)) then { - [_respawnedUnit, GVAR(unitGear)] call FUNC(restoreGear); + [_unit, GVAR(unitGear)] call FUNC(restoreGear); }; // fix for setVariable public being lost on respawn for machines that JIP after the command was broadcasted -if (_respawnedUnit getVariable ["ACE_canMoveRallypoint", false]) then { - _respawnedUnit setVariable ["ACE_canMoveRallypoint", true, true]; +if (_unit getVariable ["ACE_canMoveRallypoint", false]) then { + _unit setVariable ["ACE_canMoveRallypoint", true, true]; }; diff --git a/addons/respawn/functions/fnc_initRallypoint.sqf b/addons/respawn/functions/fnc_initRallypoint.sqf index bb295a1809..dba1ae5d0a 100644 --- a/addons/respawn/functions/fnc_initRallypoint.sqf +++ b/addons/respawn/functions/fnc_initRallypoint.sqf @@ -1,52 +1,51 @@ /* - Name: ACE_Respawn_fnc_initRallypoint - - Author(s): - commy2 - - Description: - init code for rally points - - Parameters: - 0: OBJECT - rally - - Returns: - VOID -*/ - + * Author: commy2 + * Init code for rallypoints. + * + * Arguments: + * 0: Rallypoint Object + * 1: Respawn Marker + * 2: Side + * + * Return Value: + * None + * + * Example: + * [respawn_object, "", west] call ace_respawn_fnc_initRallypoint + * + * Public: No + */ #include "script_component.hpp" -PARAMS_3(_rallypoint,_respawnMarker,_side); +params ["_rallypoint", "_respawnMarker", "_side"]; private "_name"; _name = typeOf _rallypoint; // init visible marker if (hasInterface) then { - // fix init having wrong position, vars etc. - [_rallypoint, _respawnMarker, _side, _name] spawn { - PARAMS_4(_rallypoint,_respawnMarker,_side,_name); + [{ + params ["_rallypoint", "_respawnMarker", "_side", "_name"]; - private ["_marker", "_type"]; + private ["_marker", "_type", "_date"]; _marker = format ["ACE_Marker_%1", _name]; - // exit if it already exist + // exit if marker already exist if (_marker in allMapMarkers) exitWith {}; _marker = createMarkerLocal [_marker, getPosASL _rallypoint]; _type = ["selector_selectedFriendly", "selector_selectedEnemy"] select (_respawnMarker == ""); _marker setMarkerTypeLocal _type; - _marker setMarkerAlphaLocal ([0,1] select (_side == playerSide)); // playerSide to guarantee init + _marker setMarkerAlphaLocal ([0,1] select (_side == playerSide)); // playerSide to guarantee init - private "_markerDate"; - _markerDate = _rallypoint getVariable [QGVAR(markerDate), ""]; + _date = _rallypoint getVariable [QGVAR(markerDate), ""]; - _marker setMarkerTextLocal _markerDate; + _marker setMarkerTextLocal _date; _rallypoint setVariable [QGVAR(marker), _marker]; - }; + }, [_rallypoint, _respawnMarker, _side, _name], 0.1] call EFUNC(common,waitAndExecute); }; if (!isServer) exitWith {}; @@ -62,7 +61,6 @@ if (isNil _name) then { }; ["rallypointMoved", [_rallypoint, _side]] call EFUNC(common,globalEvent); - } else { deleteVehicle _rallypoint; ACE_LOGERROR("Multiple Rallypoints of same type."); diff --git a/addons/respawn/functions/fnc_module.sqf b/addons/respawn/functions/fnc_module.sqf index 8921c75f54..ea6ba555d5 100644 --- a/addons/respawn/functions/fnc_module.sqf +++ b/addons/respawn/functions/fnc_module.sqf @@ -1,26 +1,23 @@ - /* - Name: ACE_Respawn_fnc_module - - Author(s): - KoffeinFlummi, bux578, esteldunedain, commy2 - - Description: - initializes the respawn module - - Parameters: - 0: OBJECT - logic - 1: ARRAY - synced units - 2: BOOLEAN - activated - - Returns: - VOID -*/ - +/* + * Author: KoffeinFlummi, bux578, esteldunedain, commy2 + * Initializes the respawn module. + * + * Arguments: + * 0: Logic + * 1: Synced units + * 2: Activated + * + * Return Value: + * None + * + * Example: + * [logic, [ACE_Player], true] call ace_respawn_fnc_module + * + * Public: No + */ #include "script_component.hpp" -PARAMS_3(_logic,_units,_activated); - -if !(isServer) exitWith {}; +params ["_logic", "_units", "_activated"]; if !(_activated) exitWith {}; @@ -29,20 +26,18 @@ GVAR(Module) = true; [_logic, QGVAR(SavePreDeathGear), "SavePreDeathGear"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(RemoveDeadBodiesDisconnected), "RemoveDeadBodiesDisconnected"] call EFUNC(common,readSettingFromModule); -if (isServer) then { - if (GVAR(RemoveDeadBodiesDisconnected)) then { - addMissionEventHandler ["HandleDisconnect", { - [{ - PARAMS_1(_unit); +if (isServer && {GVAR(RemoveDeadBodiesDisconnected)}) then { + addMissionEventHandler ["HandleDisconnect", { + [{ + params ["_unit"]; - if (!alive _unit) then { - deleteVehicle _unit; - }; - }, - _this, 4, 1] call EFUNC(common,waitAndExecute); - false - }]; - }; + if (!alive _unit) then { + deleteVehicle _unit; + }; + }, + _this, 4] call EFUNC(common,waitAndExecute); + false + }]; }; ACE_LOGINFO("Respawn Module Initialized."); diff --git a/addons/respawn/functions/fnc_moduleFriendlyFire.sqf b/addons/respawn/functions/fnc_moduleFriendlyFire.sqf index 2d81372e85..f5b982f0ea 100644 --- a/addons/respawn/functions/fnc_moduleFriendlyFire.sqf +++ b/addons/respawn/functions/fnc_moduleFriendlyFire.sqf @@ -1,32 +1,33 @@ /* - Name: ACE_Respawn_fnc_moduleFriendlyFire - - Author(s): - commy2 - - Description: - initializes the Friendly Fire Messages module - - Parameters: - 0: OBJECT - logic - 1: ARRAY - synced units - 2: BOOLEAN - activated - - Returns: - VOID -*/ - + * Author: commy2 + * Initializes the friendly fire module. + * + * Arguments: + * 0: Logic + * 1: Synced units + * 2: Activated + * + * Return Value: + * None + * + * Example: + * [logic, [ACE_Player], true] call ace_respawn_fnc_moduleFriendlyFire + * + * Public: No + */ #include "script_component.hpp" -_this spawn { - PARAMS_3(_logic,_units,_activated); +params ["_logic", "_units", "_activated"]; - if !(_activated) exitWith {}; +if !(_activated) exitWith {}; - if (isServer) then { +// this is done for JIP compatibility +if (isServer) then { + [{ missionNamespace setVariable [QGVAR(showFriendlyFireMessage), true]; publicVariable QGVAR(showFriendlyFireMessage); - }; - - ACE_LOGINFO("Friendly Fire Messages Module Initialized."); + }, + [], 0.1] call EFUNC(common,waitAndExecute); }; + +ACE_LOGINFO("Friendly Fire Messages Module Initialized."); diff --git a/addons/respawn/functions/fnc_moduleRallypoint.sqf b/addons/respawn/functions/fnc_moduleRallypoint.sqf index 86a83bf061..89baed660f 100644 --- a/addons/respawn/functions/fnc_moduleRallypoint.sqf +++ b/addons/respawn/functions/fnc_moduleRallypoint.sqf @@ -1,29 +1,29 @@ /* - Name: ACE_Respawn_fnc_moduleRallypoint - - Author(s): - commy2 - - Description: - initializes the Rallypoint module - - Parameters: - 0: OBJECT - logic - 1: ARRAY - synced units - 2: BOOLEAN - activated - - Returns: - VOID -*/ - + * Author: commy2 + * Initializes the Rallypoint module. + * + * Arguments: + * 0: Logic + * 1: Synced units + * 2: Activated + * + * Return Value: + * None + * + * Example: + * [logic, [ACE_Player], true] call ace_respawn_fnc_moduleRallypoint + * + * Public: No + */ #include "script_component.hpp" -PARAMS_3(_logic,_units,_activated); +params ["_logic", "_units", "_activated"]; if !(_activated) exitWith {}; { _x setVariable ["ACE_canMoveRallypoint", true]; -} forEach _units; + false +} count _units; ACE_LOGINFO("Rallypoint Module Initialized."); diff --git a/addons/respawn/functions/fnc_moveRallypoint.sqf b/addons/respawn/functions/fnc_moveRallypoint.sqf index d512c23886..bf96905343 100644 --- a/addons/respawn/functions/fnc_moveRallypoint.sqf +++ b/addons/respawn/functions/fnc_moveRallypoint.sqf @@ -1,52 +1,47 @@ /* - Name: ACE_Respawn_fnc_moveRallypoint - - Author(s): - commy2 - - Description: - Moves a rallypoint to the player's location - - Parameters: - 0: OBJECT - unit - 1: OBJECT - side - - Returns: - VOID -*/ - + * Author: commy2 + * Moves a rallypoint to the players location. + * + * Arguments: + * 0: Unit + * 1: Side + * + * Return Value: + * None + * + * Example: + * [ACE_Player, side ACE_Player] call ace_respawn_fnc_moveRallypoint + * + * Public: No + */ #include "script_component.hpp" -PARAMS_2(_unit,_side); +params ["_unit", "_side"]; private ["_rallypoint", "_position"]; -// rallypoint names are defined in CfgVehicles.hpp - _rallypoint = [ - objNull, - missionNamespace getVariable ["ACE_Rallypoint_West", objNull], - missionNamespace getVariable ["ACE_Rallypoint_East", objNull], - missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull] + objNull, + missionNamespace getVariable ["ACE_Rallypoint_West", objNull], + missionNamespace getVariable ["ACE_Rallypoint_East", objNull], + missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull] ] select ([west, east, independent] find _side) + 1; -TRACE_3("moving rally",_unit, _rallypoint, (typeOf _rallypoint)); +TRACE_3("moving rally",_unit,_rallypoint,typeOf _rallypoint); if (isNull _rallypoint) exitWith {}; _position = getPosATL _unit; _position = _position findEmptyPosition [0, 2, typeOf _rallypoint]; -if (count _position == 0) then {_position = getPosATL _unit}; + +if (_position isEqualTo []) then {_position = getPosATL _unit}; _position set [2, 0]; [localize LSTRING(Deploy)] call EFUNC(common,displayTextStructured); [{ - _rallypoint = _this select 0; - _unit = _this select 1; - _position = _this select 2; - _rallypoint = _this select 3; + params ["_rallypoint", "_unit", "_position"]; _rallypoint setPosATL _position; _unit reveal _rallypoint; @@ -56,5 +51,4 @@ _position set [2, 0]; ["rallypointMoved", [_rallypoint, _side, _position]] call EFUNC(common,globalEvent); [localize LSTRING(Deployed)] call EFUNC(common,displayTextStructured); -}, -[_rallypoint, _unit, _position, _rallypoint], 5, 1] call EFUNC(common,waitAndExecute); +}, [_rallypoint, _unit, _position], 5] call EFUNC(common,waitAndExecute); diff --git a/addons/respawn/functions/fnc_removeBody.sqf b/addons/respawn/functions/fnc_removeBody.sqf index e00f633e6c..e9676696a1 100644 --- a/addons/respawn/functions/fnc_removeBody.sqf +++ b/addons/respawn/functions/fnc_removeBody.sqf @@ -1,36 +1,27 @@ /* - Name: ACE_Respawn_fnc_removeBody - - Author(s): - bux578 - - Description: - removes a given body - - Parameters: - 0: OBJECT - body - 1: BOOLEAN - forceRemove // not used atm - - Returns: - VOID -*/ - + * Author: bux578, commy2 + * Removes a given body. + * + * Arguments: + * 0: Body + * + * Return Value: + * None + * + * Example: + * [corpse] call ace_respawn_fnc_removeBody + * + * Public: No + */ #include "script_component.hpp" -private ["_body", "_forceRemove", "_bodyRemoveTimer"]; +params ["_body", "_forceRemove"]; -_body = _this select 0; -_forceRemove = _this select 1; - -_bodyRemoveTimer = GVAR(BodyRemoveTimer) max 0; - -// could be used for SpecOps missions. -if (_forceRemove) then { - _bodyRemoveTimer = 2; -}; +private "_bodyRemoveTimer"; +_bodyRemoveTimer = [GVAR(BodyRemoveTimer) max 0, 2] select _forceRemove; // could be used for SpecOps missions. [{ // hideBody takes ~20s till body is fully underground // a better hideBody would make this more aesthetic deleteVehicle _this; -}, _body, _bodyRemoveTimer, 1] call EFUNC(common,waitAndExecute); +}, _body, _bodyRemoveTimer] call EFUNC(common,waitAndExecute); diff --git a/addons/respawn/functions/fnc_removeDisconnectedPlayer.sqf b/addons/respawn/functions/fnc_removeDisconnectedPlayer.sqf deleted file mode 100644 index 7bd0a6707f..0000000000 --- a/addons/respawn/functions/fnc_removeDisconnectedPlayer.sqf +++ /dev/null @@ -1,31 +0,0 @@ -/* - Name: ACE_Respawn_fnc_removeDisconnectedPlayer - - Author(s): - commy2 - - Description: - handles the disconnected event - - Parameters: - 0: BOOLEAN - forceRemove // not used atm - - Returns: - VOID -*/ - -#include "script_component.hpp" - -private ["_forceRemove", "_body", "_uid"]; - -_forceRemove = _this select 0; - -{ - if (getPlayerUID _x == _uid) exitWith { - _body = _x; - }; -} forEach playableUnits; - -if (!isNil "_body" && {!alive _body}) then { - [_body, _forceRemove] call FUNC(removeBody); -}; diff --git a/addons/respawn/functions/fnc_restoreGear.sqf b/addons/respawn/functions/fnc_restoreGear.sqf index fd3f03d7aa..e8a512e127 100644 --- a/addons/respawn/functions/fnc_restoreGear.sqf +++ b/addons/respawn/functions/fnc_restoreGear.sqf @@ -1,34 +1,22 @@ /* - Name: ACE_Respawn_fnc_restoreGear - - Author(s): - bux578 - - Description: - Restores previously saved gear - - Parameters: - 0: OBJECT - unit - 1: ARRAY - Array containing all gear (result of ACE_common_fnc_getAllGear) - - Returns: - VOID -*/ - + * Author: bux578 + * Restores previously saved gear. + * + * Arguments: + * 0: Unit + * 1: All Gear based on return value of ACE_common_fnc_getAllGear + * + * Return Value: + * None + * + * Example: + * [ACE_Player, stored_allGear] call ace_respawn_fnc_restoreGear + * + * Public: No + */ #include "script_component.hpp" -PARAMS_2(_unit,_allGear); - -private ["_unit", "_allGear", "_headgear", "_goggles", -"_uniform", "_uniformitems", -"_vest", "_vestitems", -"_backpack", "_backpackitems", "_backpa", -"_primaryweapon", "_primaryweaponitems", "_primaryweaponmagazine", -"_secondaryweapon", "_secondaryweaponitems", "_secondaryweaponmagazine", -"_handgunweapon", "_handgunweaponitems", "_handgunweaponmagazine", -"_assigneditems", "_binocular", -"_activeWeaponAndMuzzle", "_activeWeapon", "_activeMuzzle", "_activeWeaponMode"]; - +params ["_unit", "_allGear"]; // remove all starting gear of a player removeAllWeapons _unit; @@ -40,77 +28,66 @@ removeAllAssignedItems _unit; clearAllItemsFromBackpack _unit; removeBackpack _unit; -_headgear = _allGear select 0; -_goggles = _allGear select 1; -_uniform = _allGear select 2; -_uniformitems = _allGear select 3; -_vest = _allGear select 4; -_vestitems = _allGear select 5; -_backpack = _allGear select 6; -_backpackitems = _allGear select 7; -_primaryweapon = _allGear select 8; -_primaryweaponitems = _allGear select 9; -_primaryweaponmagazine = _allGear select 10; -_secondaryweapon = _allGear select 11; -_secondaryweaponitems = _allGear select 12; -_secondaryweaponmagazine = _allGear select 13; -_handgunweapon = _allGear select 14; -_handgunweaponitems = _allGear select 15; -_handgunweaponmagazine = _allGear select 16; -_assigneditems = _allGear select 17; -_binocular = _allGear select 18; -_activeWeaponAndMuzzle = _allGear select 19; - +_allGear params [ + "_headgear", "_goggles", + "_uniform", "_uniformitems", + "_vest", "_vestitems", + "_backpack", "_backpackitems", + "_primaryweapon", "_primaryweaponitems", "_primaryweaponmagazine", + "_secondaryweapon", "_secondaryweaponitems", "_secondaryweaponmagazine", + "_handgunweapon", "_handgunweaponitems", "_handgunweaponmagazine", + "_assigneditems", "_binocular", + "_activeWeaponAndMuzzle" +]; // start restoring the items -if (_headgear != "") then { - _unit addHeadgear _headgear; -}; -if (_uniform != "") then { - _unit forceAddUniform _uniform; -}; -if (_vest != "") then { - _unit addVest _vest; -}; -if (_goggles != "") then { - _unit addGoggles _goggles; -}; +if (_headgear != "") then {_unit addHeadgear _headgear}; +if (_goggles != "") then {_unit addGoggles _goggles}; +if (_uniform != "") then {_unit forceAddUniform _uniform}; +if (_vest != "") then {_unit addVest _vest}; { _unit addItemToUniform _x; -} forEach _uniformitems; + false +} count _uniformitems; { _unit addItemToVest _x; -} forEach _vestitems; + false +} count _vestitems; private "_flagRemoveDummyBag"; -_flagRemoveDummyBag = false; -if (format["%1", _backpack] != "") then { +if (format ["%1", _backpack] != "") then { _unit addBackpack _backpack; - _backpa = unitBackpack _unit; - clearMagazineCargoGlobal _backpa; - clearWeaponCargoGlobal _backpa; - clearItemCargoGlobal _backpa; + // make sure the backpack is empty. Some bags are prefilled by config + private "_backpackObject"; + _backpackObject = unitBackpack _unit; + + clearMagazineCargoGlobal _backpackObject; + clearWeaponCargoGlobal _backpackObject; + clearItemCargoGlobal _backpackObject; + { _unit addItemToBackpack _x; - } forEach _backpackitems; + false + } count _backpackitems; + _flagRemoveDummyBag = false; } else { // dummy backpack to ensure mags being loaded - _unit addBackpack "B_Kitbag_Base"; + _unit addBackpack "Bag_Base"; _flagRemoveDummyBag = true; }; - // primaryWeapon if ((_primaryweapon != "") && {_primaryweapon != "ACE_FakePrimaryWeapon"}) then { { _unit addMagazine _x; - } forEach _primaryweaponmagazine; + false + } count _primaryweaponmagazine; _unit addWeapon _primaryweapon; @@ -118,15 +95,16 @@ if ((_primaryweapon != "") && {_primaryweapon != "ACE_FakePrimaryWeapon"}) then if (_x != "") then { _unit addPrimaryWeaponItem _x; }; - } forEach _primaryweaponitems; + false + } count _primaryweaponitems; }; - // secondaryWeapon if (_secondaryweapon != "") then { { _unit addMagazine _x; - } forEach _secondaryweaponmagazine; + false + } count _secondaryweaponmagazine; _unit addWeapon _secondaryweapon; @@ -134,15 +112,16 @@ if (_secondaryweapon != "") then { if (_x != "") then { _unit addSecondaryWeaponItem _x; }; - } forEach _secondaryweaponitems; + false + } count _secondaryweaponitems; }; - // handgun if (_handgunweapon != "") then { { _unit addMagazine _x; - } forEach _handgunweaponmagazine; + false + } count _handgunweaponmagazine; _unit addWeapon _handgunweapon; @@ -150,20 +129,19 @@ if (_handgunweapon != "") then { if (_x != "") then { _unit addHandgunItem _x; }; - } forEach _handgunweaponitems; + false + } count _handgunweaponitems; }; - // remove dummy bagpack if (_flagRemoveDummyBag) then { removeBackpack _unit; }; - -_assignedItems = _assignedItems - [_binocular]; +_assignedItems deleteAt (_assignedItems find _binocular); // items -{_unit linkItem _x} forEach _assignedItems; +{_unit linkItem _x; false} count _assignedItems; _unit addWeapon _binocular; @@ -178,24 +156,24 @@ if ("Laserdesignator" in assignedItems _unit) then { }; // restore the last active weapon, muzzle and weaponMode -_activeWeapon = _activeWeaponAndMuzzle select 0; -_activeMuzzle = _activeWeaponAndMuzzle select 1; -_activeWeaponMode = _activeWeaponAndMuzzle select 2; - -if (!(_activeMuzzle isEqualTo "") and - !(_activeMuzzle isEqualTo _activeWeapon) and - (_activeMuzzle in getArray (configfile >> "CfgWeapons" >> _activeWeapon >> "muzzles"))) then { +_activeWeaponAndMuzzle params ["_activeWeapon", "_activeMuzzle", "_activeWeaponMode"]; +if ( + (_activeMuzzle != "") && + {_activeMuzzle != _activeWeapon} && + {_activeMuzzle in getArray (configfile >> "CfgWeapons" >> _activeWeapon >> "muzzles")} +) then { _unit selectWeapon _activeMuzzle; } else { - if (!(_activeWeapon isEqualTo "")) then { + if (_activeWeapon != "") then { _unit selectWeapon _activeWeapon; }; }; -if (!(currentWeapon _unit isEqualTo "")) then { - private ["_index"]; +if (currentWeapon _unit != "") then { + private "_index"; _index = 0; + while { _index < 100 && {currentWeaponMode _unit != _activeWeaponMode} } do { diff --git a/addons/respawn/functions/fnc_showFriendlyFireMessage.sqf b/addons/respawn/functions/fnc_showFriendlyFireMessage.sqf index 1fdd10da4e..1c5a7b7cc2 100644 --- a/addons/respawn/functions/fnc_showFriendlyFireMessage.sqf +++ b/addons/respawn/functions/fnc_showFriendlyFireMessage.sqf @@ -1,28 +1,24 @@ /* - Name: ACE_Respawn_fnc_showFriendlyFireMessages - - Author(s): - commy2 - - Description: - shows a message in system chat of who killed who - - Parameters: - 0: OBJECT - unit - 1: OBJECT - killer - - Returns: - VOID -*/ - + * Author: commy2 + * Shows a message in system chat of who killed whom. + * + * Arguments: + * 0: Unitn + * 1: Killer + * + * Return Value: + * None + * + * Example: + * [ACE_Player, killer] call ace_module_fnc_functionName + * + * Public: No + */ #include "script_component.hpp" -private ["_unit", "_killer"]; +params ["_unit", "_killer"]; -_unit = _this select 0; -_killer = _this select 1; - -if (_unit != _killer && side group _unit in [side group ACE_player, civilian] && {side group _killer == side group ACE_player}) then { +if (_unit != _killer && {side group _unit in [side group ACE_player, civilian]} && {side group _killer == side group ACE_player}) then { systemChat format ["%1 was killed by %2", [_unit] call EFUNC(common,getName), [_killer] call EFUNC(common,getName)]; // Raise ACE globalEvent diff --git a/addons/respawn/functions/fnc_teleportToRallypoint.sqf b/addons/respawn/functions/fnc_teleportToRallypoint.sqf index 59a9766114..88bd0d6d52 100644 --- a/addons/respawn/functions/fnc_teleportToRallypoint.sqf +++ b/addons/respawn/functions/fnc_teleportToRallypoint.sqf @@ -1,29 +1,25 @@ /* * Author: commy2 - * teleports a unit to a rallypoint + * Teleports a unit to a rallypoint * * Arguments: - * 0: unit - * 1: side? - * 2: teleport to base + * 0: Unit + * 1: Side + * 2: Rallypoint name * * Return Value: - * Nothing + * None * * Example: - * [,,] call ACE_Respawn_fnc_teleportToRallypoint; + * [ACE_player, side ACE_Player, rallypoint_name] call ace_respawn_fnc_teleportToRallypoint; * * Public: No */ #include "script_component.hpp" -PARAMS_3(_unit,_side,_rallypoint); +params ["_unit", "_side", "_rallypoint"]; -private ["_toBase"]; - -// rallypoint names are defined in CfgVehicles.hpp - -//IGNORE_PRIVATE_WARNING("_Base") +private "_toBase"; _toBase = _rallypoint find "_Base" != -1; _rallypoint = missionNamespace getVariable [_rallypoint, objNull], @@ -31,4 +27,5 @@ _rallypoint = missionNamespace getVariable [_rallypoint, objNull], if (isNull _rallypoint) exitWith {}; _unit setPosASL getPosASL _rallypoint; + [[localize LSTRING(TeleportedToRallypoint), localize LSTRING(TeleportedToBase)] select _toBase] call EFUNC(common,displayTextStructured); diff --git a/addons/respawn/functions/fnc_updateRallypoint.sqf b/addons/respawn/functions/fnc_updateRallypoint.sqf index 248955155a..8b34f87019 100644 --- a/addons/respawn/functions/fnc_updateRallypoint.sqf +++ b/addons/respawn/functions/fnc_updateRallypoint.sqf @@ -1,11 +1,23 @@ -// by commy2 +/* + * Author: commy2 + * Updates marker position and texts. + * + * Arguments: + * 0: Marker + * 1: Side + * 2: Position + * + * Return Value: + * None + * + * Example: + * [marker_name, side ACE_Player, getPos ACE_Player] call ace_respawn_fnc_updateRallypoint + * + * Public: No + */ #include "script_component.hpp" -private ["_rallypoint", "_side", "_position"]; - -_rallypoint = _this select 0; -_side = _this select 1; -_position = _this select 2; +params ["_rallypoint", "_side", "_position"]; if (!hasInterface) exitWith {}; diff --git a/addons/respawn/stringtable.xml b/addons/respawn/stringtable.xml index 0b4a06ff7f..e44150ff10 100644 --- a/addons/respawn/stringtable.xml +++ b/addons/respawn/stringtable.xml @@ -201,6 +201,7 @@ Удалять трупы игроков после дисконнекта? + This module enables you to configure ACE functionality specific to respawns. Moduł ten pozwala dostosować ustawienia odrodzenia (respawnu). Dieses Modul erlaubt es die Respawn-Einstellungen anzupassen. Tento modul umožňuje nastavení znovuzrození (spawn). @@ -220,6 +221,7 @@ Сообщения об огне по своим + Using this module in your mission will make it so any friendly fire kills will be displayed in form of a message in chat. Użycie tego modułu na misji spowoduje wyświetlenie wiadomości na czacie w przypadku, kiedy zostanie popełniony friendly fire - wyświetlona zostanie wtedy wiadomość kto kogo zabił. Zobrazí zprávu v chatu v případě, když budete střílet na vlastní jednotky. Ve zprávě se zobrazí kdo na koho střílel, popř. kdo koho zabil. Usando este módulo em uma missão para exibir mensagens chat, no caso de quando você faz um fogo amigo - então a mensagem será exibida mostrando quem matou quem. diff --git a/addons/safemode/CfgEventHandlers.hpp b/addons/safemode/CfgEventHandlers.hpp index eefe61652b..0cd959a047 100644 --- a/addons/safemode/CfgEventHandlers.hpp +++ b/addons/safemode/CfgEventHandlers.hpp @@ -1,12 +1,12 @@ class Extended_PreInit_EventHandlers { class ADDON { - init = QUOTE(call COMPILE_FILE(XEH_preInit) ); + init = QUOTE(call COMPILE_FILE(XEH_preInit)); }; }; class Extended_PostInit_EventHandlers { class ADDON { - clientInit = QUOTE( call COMPILE_FILE(XEH_postInit) ); + init = QUOTE(call COMPILE_FILE(XEH_postInit)); }; }; diff --git a/addons/safemode/XEH_postInit.sqf b/addons/safemode/XEH_postInit.sqf index c7132dd76c..f3ab06d20e 100644 --- a/addons/safemode/XEH_postInit.sqf +++ b/addons/safemode/XEH_postInit.sqf @@ -7,8 +7,7 @@ if (!hasInterface) exitWith {}; //["Soldier", {_player = ACE_player; if (currentWeapon _player in (_player getVariable [QGVAR(safedWeapons), []])) then {[false] call FUNC(setSafeModeVisual)}] call EFUNC(common,addInfoDisplayEventHandler); //@todo addEventHandler infoDisplayChanged with select 1 == "Soldier" - -// Add keybinds +// add keybinds ["ACE3 Weapons", QGVAR(safeMode), localize LSTRING(SafeMode), { // Conditions: canInteract @@ -21,4 +20,4 @@ if (!hasInterface) exitWith {}; true }, {false}, -[41, [false, true, false]], false] call cba_fnc_addKeybind; +[41, [false, true, false]], false] call CBA_fnc_addKeybind; diff --git a/addons/safemode/functions/fnc_lockSafety.sqf b/addons/safemode/functions/fnc_lockSafety.sqf index 54fa254716..9fe429a49b 100644 --- a/addons/safemode/functions/fnc_lockSafety.sqf +++ b/addons/safemode/functions/fnc_lockSafety.sqf @@ -20,10 +20,10 @@ // don't immediately switch back if (inputAction "nextWeapon" > 0) exitWith {}; -private ["_safedWeapons", "_condition", "_statement", "_id", "_picture"]; - params ["_unit", "_weapon", "_muzzle"]; +private ["_safedWeapons", "_picture"]; + _safedWeapons = _unit getVariable [QGVAR(safedWeapons), []]; if (_weapon in _safedWeapons) exitWith { @@ -35,47 +35,39 @@ _safedWeapons pushBack _weapon; _unit setVariable [QGVAR(safedWeapons), _safedWeapons]; if (_unit getVariable [QGVAR(actionID), -1] == -1) then { - _condition = { - params ["", "_caller"]; - if ( - [_caller] call EFUNC(common,canUseWeapon) - && { - if (currentMuzzle _caller in (_caller getVariable [QGVAR(safedWeapons), []])) then { - if (inputAction "nextWeapon" > 0) exitWith { - [_this select 1, currentWeapon _caller, currentMuzzle _caller] call FUNC(unlockSafety); - false - }; - true - } else {false} - } - ) then { - // player hud - [false] call FUNC(setSafeModeVisual); - true - } else { - // player hud - [true] call FUNC(setSafeModeVisual); - false - } - }; - - _statement = { - params ["", "_caller"]; - [_caller, currentWeapon _caller, currentMuzzle _caller] call FUNC(unlockSafety); - }; - - //_id = [_unit, format ["%1", localize LSTRING(TakeOffSafety)], "DefaultAction", _condition, {}, {true}, _statement, 10] call EFUNC(common,addActionMenuEventHandler); - _id = [_unit, "DefaultAction", _condition, {}] call EFUNC(common,addActionEventHandler); - - _unit setVariable [QGVAR(actionID), _id]; + _unit setVariable [QGVAR(actionID), [ + _unit, "DefaultAction", { + if ( + [_this select 1] call EFUNC(common,canUseWeapon) + && { + if (currentMuzzle (_this select 1) in ((_this select 1) getVariable [QGVAR(safedWeapons), []])) then { + if (inputAction "nextWeapon" > 0) exitWith { + [_this select 1, currentWeapon (_this select 1), currentMuzzle (_this select 1)] call FUNC(unlockSafety); + false + }; + true + } else {false} + } + ) then { + // player hud + [false] call FUNC(setSafeModeVisual); + true + } else { + // player hud + [true] call FUNC(setSafeModeVisual); + false + }; + }, {} + ] call EFUNC(common,addActionEventHandler)]; }; -if ((typeName _muzzle) == (typeName "")) then { - _unit selectWeapon _muzzle; //_weapon +if (typeName _muzzle == "STRING") then { + _unit selectWeapon _muzzle; }; // play fire mode selector sound [_unit, _weapon, _muzzle] call FUNC(playChangeFiremodeSound); +// show info box _picture = getText (configFile >> "CfgWeapons" >> _weapon >> "picture"); [localize LSTRING(PutOnSafety), _picture] call EFUNC(common,displayTextPicture); diff --git a/addons/safemode/functions/fnc_playChangeFiremodeSound.sqf b/addons/safemode/functions/fnc_playChangeFiremodeSound.sqf index 3fa29f3d88..5da4aeb672 100644 --- a/addons/safemode/functions/fnc_playChangeFiremodeSound.sqf +++ b/addons/safemode/functions/fnc_playChangeFiremodeSound.sqf @@ -16,23 +16,28 @@ */ #include "script_component.hpp" -private ["_sound", "_position"]; - params ["_unit", "_weapon"]; +private ["_sound", "_position"]; + _sound = getArray (configFile >> "CfgWeapons" >> _weapon >> "changeFiremodeSound"); -if (count _sound == 0) exitWith { +if (_sound isEqualTo []) exitWith { playSound "ACE_Sound_Click"; }; -// add file extension -if ({(toLower (_sound select 0) find _x == (count toArray (_sound select 0) - count toArray _x) - 1)} count [".wav", ".ogg", ".wss"] == 0) then { - _sound set [0, (_sound select 0) + ".wss"]; -}; - -_position = _unit modelToWorldVisual (_unit selectionPosition "RightHand"); -_position set [2, (_position select 2) + ((getPosASLW _unit select 2) - (getPosATL _unit select 2) max 0)]; +// get position where to play the sound (position of the weapon) +_position = AGLToASL (_unit modelToWorldVisual (_unit selectionPosition "RightHand")); _sound params ["_filename", ["_volume", 1], ["_soundPitch", 1], ["_distance", 0]]; + +if (_filename == "") exitWith { + playSound "ACE_Sound_Click"; +}; + +// add file extension .wss as default +if !(toLower (_filename select [count _filename - 4]) in [".wav", ".ogg", ".wss"]) then { + _filename = format ["%1.wss", _filename]; +}; + playSound3D [_filename, objNull, false, _position, _volume, _soundPitch, _distance]; diff --git a/addons/safemode/functions/fnc_setSafeModeVisual.sqf b/addons/safemode/functions/fnc_setSafeModeVisual.sqf index 43f4bc79b6..492d5c6996 100644 --- a/addons/safemode/functions/fnc_setSafeModeVisual.sqf +++ b/addons/safemode/functions/fnc_setSafeModeVisual.sqf @@ -15,17 +15,17 @@ */ #include "script_component.hpp" -private ["_control", "_config"]; - params ["_show"]; disableSerialization; +private "_control"; _control = (uiNamespace getVariable ["ACE_dlgSoldier", displayNull]) displayCtrl 187; if (isNull _control) exitWith {}; if (_show) then { + private "_config"; _config = configFile >> "RscInGameUI" >> "RscUnitInfoSoldier" >> "WeaponInfoControlsGroupLeft" >> "controls" >> "CA_ModeTexture"; _control ctrlSetPosition [getNumber (_config >> "x"), getNumber (_config >> "y"), getNumber (_config >> "w"), getNumber (_config >> "h")]; diff --git a/addons/safemode/functions/fnc_unlockSafety.sqf b/addons/safemode/functions/fnc_unlockSafety.sqf index 35fdb0dee5..ef01766872 100644 --- a/addons/safemode/functions/fnc_unlockSafety.sqf +++ b/addons/safemode/functions/fnc_unlockSafety.sqf @@ -17,24 +17,19 @@ */ #include "script_component.hpp" -private ["_safedWeapons", "_id", "_picture"]; - params ["_unit", "_weapon", "_muzzle"]; +private ["_safedWeapons", "_picture"]; + _safedWeapons = _unit getVariable [QGVAR(safedWeapons), []]; +_safedWeapons deleteAt (_safedWeapons find _weapon); -if (_weapon in _safedWeapons) then { - _safedWeapons = _safedWeapons - [_weapon]; +_unit setVariable [QGVAR(safedWeapons), _safedWeapons]; - _unit setVariable [QGVAR(safedWeapons), _safedWeapons]; - - if (count _safedWeapons == 0) then { - _id = _unit getVariable [QGVAR(actionID), -1]; - - //[_unit, "DefaultAction", _id] call EFUNC(common,removeActionMenuEventHandler); - [_unit, "DefaultAction", _id] call EFUNC(common,removeActionEventHandler); - _unit setVariable [QGVAR(actionID), -1]; - }; +// remove action if all weapons have put their safety on +if (_safedWeapons isEqualTo []) then { + [_unit, "DefaultAction", _unit getVariable [QGVAR(actionID), -1]] call EFUNC(common,removeActionEventHandler); + _unit setVariable [QGVAR(actionID), -1]; }; _unit selectWeapon _muzzle; @@ -74,5 +69,6 @@ if (inputAction "nextWeapon" > 0) then { // player hud [true] call FUNC(setSafeModeVisual); +// show info box _picture = getText (configFile >> "CfgWeapons" >> _weapon >> "picture"); [localize LSTRING(TookOffSafety), _picture] call EFUNC(common,displayTextPicture); diff --git a/addons/sandbag/CfgEventHandlers.hpp b/addons/sandbag/CfgEventHandlers.hpp index 17911f6b1f..da53514f3b 100644 --- a/addons/sandbag/CfgEventHandlers.hpp +++ b/addons/sandbag/CfgEventHandlers.hpp @@ -1,19 +1,28 @@ + class Extended_PreInit_EventHandlers { class ADDON { - init = QUOTE( call COMPILE_FILE(XEH_preInit) ); + init = QUOTE(call COMPILE_FILE(XEH_preInit)); }; }; class Extended_PostInit_EventHandlers { class ADDON { - init = QUOTE( call COMPILE_FILE(XEH_postInit) ); + init = QUOTE(call COMPILE_FILE(XEH_postInit)); }; }; class Extended_Init_EventHandlers { class ACE_SandbagObject { class ADDON { - init = QUOTE(_this call DEFUNC(dragging,initObject)); + init = QUOTE(_this call EFUNC(dragging,initObject)); }; }; -}; \ No newline at end of file +}; + +class Extended_Killed_EventHandlers { + class CAManBase { + class ADDON { + killed = QUOTE(_this call FUNC(handleKilled)); + }; + }; +}; diff --git a/addons/sandbag/CfgVehicles.hpp b/addons/sandbag/CfgVehicles.hpp index 5a9b530062..a2b255318e 100644 --- a/addons/sandbag/CfgVehicles.hpp +++ b/addons/sandbag/CfgVehicles.hpp @@ -1,14 +1,15 @@ + class CfgVehicles { class Man; class CAManBase: Man { class ACE_SelfActions { - class ACE_Sandbags { + class GVAR(place) { displayName = CSTRING(DeploySandbag); - condition = QUOTE(call FUNC(canDeploy)); - //wait a frame to handle "Do When releasing action menu key" option: - statement = QUOTE([ARR_2({_this call FUNC(deploy)}, [])] call EFUNC(common,execNextFrame)); + condition = QUOTE(_this call FUNC(canDeploy)); + //wait a frame to handle "Do When releasing action menu key" option + statement = QUOTE([ARR_2({_this call FUNC(deploy)},_this)] call EFUNC(common,execNextFrame)); exceptions[] = {"isNotSwimming"}; - showDisabled = 1; + showDisabled = 0; priority = 4; icon = PATHTOF(UI\icon_sandbag_ca.paa); }; @@ -26,8 +27,8 @@ class CfgVehicles { MACRO_ADDITEM(ACE_Sandbag_empty,1); }; }; - /* - class ACE_Item_Sandbag: Item_Base_F { + + /*class ACE_Item_Sandbag: Item_Base_F { author = ECSTRING(common,ACETeam); scope = 2; scopeCurator = 2; @@ -39,8 +40,8 @@ class CfgVehicles { count = 1; }; }; - }; - */ + };*/ + class thingX; class ACE_SandbagObject: thingX { author = ECSTRING(common,ACETeam); @@ -55,10 +56,10 @@ class CfgVehicles { nameSound = "Bunker"; icon = PATHTOF(UI\icon_sandbag_ca.paa); accuracy = 1000; - destrType = "DestructDefault"; class DestructionEffects {}; + class Damage { tex[] = {}; mat[] = { @@ -67,28 +68,19 @@ class CfgVehicles { "z\ace\addons\sandbag\data\bag_destruct.rvmat" }; }; + class ACE_Actions { class ACE_MainActions { selection = ""; distance = 5; condition = "true"; + class ACE_PickUp { selection = ""; displayName = CSTRING(PICKUPSB); distance = 4; - condition = QUOTE(!(_player getVariable [ARR_2('ace_sandbag_usingSandbag',false)])); - statement = QUOTE([ARR_2(_target,_player)] call FUNC(pickup)); - showDisabled = 0; - exceptions[] = {}; - priority = 5; - icon = PATHTOF(UI\icon_sandbag_ca.paa); - }; - class ACE_Carry { - selection = ""; - displayName = CSTRING(CARRYSB); - distance = 4; - condition = QUOTE(!(_player getVariable [ARR_2('ace_sandbag_usingSandbag',false)])); - statement = QUOTE([ARR_2(_target,_player)] call FUNC(carry)); + condition = QUOTE(!(_player getVariable [ARR_2(QUOTE(QGVAR(isUsingSandbag)),false)])); + statement = QUOTE([ARR_2(_player,_target)] call FUNC(pickup)); showDisabled = 0; exceptions[] = {}; priority = 5; @@ -97,6 +89,7 @@ class CfgVehicles { }; }; }; + class ACE_SandbagObject_NoGeo: ACE_SandbagObject { scope = 1; model = PATHTOF(data\ace_sandbag_nogeo.p3d); diff --git a/addons/sandbag/XEH_postInit.sqf b/addons/sandbag/XEH_postInit.sqf index d1c0ad0766..c3f99c2a9b 100644 --- a/addons/sandbag/XEH_postInit.sqf +++ b/addons/sandbag/XEH_postInit.sqf @@ -1,15 +1,27 @@ #include "script_component.hpp" -GVAR(placer) = objNull; +if (isServer) then { + // Cancel deploy on hard disconnection. Function is identical to killed + addMissionEventHandler ["HandleDisconnect", {_this call FUNC(handleKilled)}]; +}; + +if (!hasInterface) exitWith {}; + GVAR(sandBag) = objNull; GVAR(deployPFH) = -1; GVAR(deployDirection) = 0; -// Cancel deploy sandbag if interact menu opened -["interactMenuOpened", { - if (GVAR(deployPFH) != -1 && {!isNull (GVAR(sandBag))}) then { - call FUNC(deployCancel); - }; -}] call EFUNC(common,addEventHandler); +[{_this call FUNC(handleScrollWheel)}] call EFUNC(common,addScrollWheelEventHandler); -[{_this call DFUNC(handleScrollWheel)}] call EFUNC(common,addScrollWheelEventHandler); +// Cancel deploy sandbag if interact menu opened +["interactMenuOpened", {[ACE_player] call FUNC(handleInteractMenuOpened)}] call EFUNC(common,addEventHandler); + +// Cancel deploy on player change. This does work when returning to lobby, but not when hard disconnecting. +["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler); +["playerInventoryChanged", {_this call FUNC(handlePlayerInventoryChanged)}] call EFUNC(common,addEventhandler); +["playerVehicleChanged", {[ACE_player, objNull] call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler); + +// handle waking up dragged unit and falling unconscious while dragging +["medical_onUnconscious", {_this call FUNC(handleUnconscious)}] call EFUNC(common,addEventhandler); + +//@todo Captivity? diff --git a/addons/sandbag/XEH_preInit.sqf b/addons/sandbag/XEH_preInit.sqf index 1978913723..444dca7ae0 100644 --- a/addons/sandbag/XEH_preInit.sqf +++ b/addons/sandbag/XEH_preInit.sqf @@ -3,12 +3,15 @@ ADDON = false; PREP(canDeploy); -PREP(carry); PREP(deploy); PREP(deployCancel); PREP(deployConfirm); -PREP(drop); +PREP(handleInteractMenuOpened); +PREP(handleKilled); +PREP(handlePlayerChanged); +PREP(handlePlayerInventoryChanged); PREP(handleScrollWheel); +PREP(handleUnconscious); PREP(pickup); ADDON = true; diff --git a/addons/sandbag/functions/fnc_canDeploy.sqf b/addons/sandbag/functions/fnc_canDeploy.sqf index 0c5fda5b4c..d26569f4ab 100644 --- a/addons/sandbag/functions/fnc_canDeploy.sqf +++ b/addons/sandbag/functions/fnc_canDeploy.sqf @@ -1,5 +1,5 @@ /* - * Author: Ruthberg + * Author: Ruthberg, commy2 * Checks if the player can deploy a sandbag * * Arguments: @@ -9,7 +9,7 @@ * Can deploy * * Example: - * [] call ace_sandbag_fnc_canDeploy + * [ACE_player] call ace_sandbag_fnc_canDeploy * * Public: No */ @@ -17,13 +17,13 @@ #define SURFACE_BLACKLIST ["water", "concrete", "tarmac", "wood", "metal", "roof_tin", "roof_tiles", "wood_int", "concrete_int", "tiles_int", "metal_int", "stony", "rock", "int_concrete", "int_tiles", "int_wood", "tiling", "wavymetal", "int_metal"] -if !([ACE_player, "ACE_Sandbag_empty"] call EFUNC(common,hasItem)) exitWith { false }; -if (ACE_player getVariable [QGVAR(usingSandbag), false]) exitWith { false }; -if ((getPosATL ACE_player select 2) - (getPos ACE_player select 2) > 1E-5) exitWith { false }; +params ["_unit"]; + +if !("ACE_Sandbag_empty" in items _unit) exitWith {false}; private ["_surfaceClass", "_surfaceType"]; -_surfaceClass = ([surfaceType (position ACE_player), "#"] call CBA_fnc_split) select 1; +_surfaceClass = (surfaceType getPosASL _unit) select [1]; _surfaceType = getText (configfile >> "CfgSurfaces" >> _surfaceClass >> "soundEnviron"); !(_surfaceType in SURFACE_BLACKLIST) diff --git a/addons/sandbag/functions/fnc_carry.sqf b/addons/sandbag/functions/fnc_carry.sqf deleted file mode 100644 index 84ab8c1883..0000000000 --- a/addons/sandbag/functions/fnc_carry.sqf +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Author: Ruthberg - * Carry sandbag - * - * Arguments: - * 0: sandbag - * 1: unit - * - * Return Value: - * None - * - * Example: - * [_sandbag, _unit] call ace_sandbag_fnc_carry - * - * Public: No - */ -#include "script_component.hpp" - -params ["_sandbag", "_unit"]; - -_unit playActionNow "PutDown"; - -_unit setVariable [QGVAR(usingSandbag), true]; -[{ - params ["_sandbag", "_unit"]; - - GVAR(carrier) = ACE_player; - - [GVAR(carrier), "ACE_Sandbag", true] call EFUNC(common,setForceWalkStatus); - - deleteVehicle _sandbag; - - GVAR(sandBag) = createVehicle ["ACE_SandbagObject_NoGeo", [0, 0, 0], [], 0, "NONE"]; - GVAR(sandBag) enableSimulationGlobal false; - - // Force physx update - { - _x setPosASL (getPosASL _x); - } count (GVAR(carrier) nearObjects ["ACE_SandbagObject", 5]); - - GVAR(carryPFH) = [{ - if (GVAR(carrier) != ACE_player) exitWith { - call FUNC(drop); - }; - GVAR(sandBag) setPosASL ((eyePos ACE_player) vectorAdd (positionCameraToWorld [0, 0, 1] vectorDiff positionCameraToWorld [0, 0, 0])); - GVAR(sandBag) setDir (GVAR(deployDirection) + getDir ACE_player); - }, 0, []] call CBA_fnc_addPerFrameHandler; - - [localize LSTRING(DropSandbag), "", ""] call EFUNC(interaction,showMouseHint); - - GVAR(carrier) setVariable [QGVAR(drop), - [GVAR(carrier), "DefaultAction", - {GVAR(carryPFH) != -1 && !isNull (GVAR(sandBag))}, - {call FUNC(drop);} - ] call EFUNC(common,AddActionEventHandler)]; -}, [_sandbag, _unit], 1, 0.5] call EFUNC(common,waitAndExecute); diff --git a/addons/sandbag/functions/fnc_deploy.sqf b/addons/sandbag/functions/fnc_deploy.sqf index 5bb162e029..de5bd9458e 100644 --- a/addons/sandbag/functions/fnc_deploy.sqf +++ b/addons/sandbag/functions/fnc_deploy.sqf @@ -1,47 +1,61 @@ /* - * Author: Garth 'L-H' de Wet, Ruthberg + * Author: Garth 'L-H' de Wet, Ruthberg, edited by commy2 for better MP and eventual AI support * Starts the deploy process for sandbags. * * Arguments: - * None + * 0: unit * * Return Value: * None * * Example: - * [] call ace_sandbag_fnc_deploy + * [ACE_player] call ace_sandbag_fnc_deploy * * Public: No */ #include "script_component.hpp" -closeDialog 0; +params ["_unit"]; -GVAR(placer) = ACE_player; +// prevent the placing unit from running +[_unit, "ACE_Sandbag", true] call EFUNC(common,setForceWalkStatus); -[GVAR(placer), "ACE_Sandbag", true] call EFUNC(common,setForceWalkStatus); +// create the sandbag +private "_sandBag"; +_sandBag = createVehicle ["ACE_SandbagObject_NoGeo", [0, 0, 0], [], 0, "NONE"]; -GVAR(sandBag) = createVehicle ["ACE_SandbagObject_NoGeo", [0, 0, 0], [], 0, "NONE"]; -GVAR(sandBag) enableSimulationGlobal false; +GVAR(sandBag) = _sandBag; +// prevent collisions with sandbag +["enableSimulationGlobal", [_sandBag, false]] call EFUNC(common,serverEvent); + +GVAR(deployDirection) = 0; + +// pfh that runs while the deployment is in progress GVAR(deployPFH) = [{ - if (GVAR(placer) != ACE_player) exitWith { - call FUNC(deployCancel); - }; - GVAR(sandBag) setPosASL ((eyePos ACE_player) vectorAdd (positionCameraToWorld [0, 0, 1] vectorDiff positionCameraToWorld [0, 0, 0])); - GVAR(sandBag) setDir (GVAR(deployDirection) + getDir ACE_player); -}, 0, []] call CBA_fnc_addPerFrameHandler; + (_this select 0) params ["_unit", "_sandBag"]; + if (isNull _sandBag) exitWith { + [_unit] call FUNC(deployCancel); + }; + + _sandBag setPosASL (eyePos _unit vectorAdd (positionCameraToWorld [0, 0, 1] vectorDiff positionCameraToWorld [0, 0, 0])); + _sandBag setDir (GVAR(deployDirection) + getDir _unit); +}, 0, [_unit, _sandBag]] call CBA_fnc_addPerFrameHandler; + +// add mouse button action and hint [localize LSTRING(ConfirmDeployment), localize LSTRING(CancelDeployment), localize LSTRING(ScrollAction)] call EFUNC(interaction,showMouseHint); -GVAR(placer) setVariable [QGVAR(Deploy), - [GVAR(placer), "DefaultAction", - {GVAR(deployPFH) != -1 && !isNull (GVAR(sandBag))}, - {call FUNC(deployConfirm);} -] call EFUNC(common,AddActionEventHandler)]; +_unit setVariable [QGVAR(Deploy), [ + _unit, "DefaultAction", + {GVAR(deployPFH) != -1}, + {[_this select 0] call FUNC(deployConfirm)} +] call EFUNC(common,addActionEventHandler)]; -GVAR(placer) setVariable [QGVAR(Cancel), - [GVAR(placer), "zoomtemp", - {GVAR(deployPFH) != -1 && !isNull (GVAR(sandBag))}, - {call FUNC(deployCancel);} -] call EFUNC(common,AddActionEventHandler)]; +_unit setVariable [QGVAR(Cancel), [ + _unit, "zoomtemp", + {GVAR(deployPFH) != -1}, + {[_this select 0] call FUNC(deployCancel)} +] call EFUNC(common,addActionEventHandler)]; + +_unit setVariable [QGVAR(isDeploying), true, true]; diff --git a/addons/sandbag/functions/fnc_deployCancel.sqf b/addons/sandbag/functions/fnc_deployCancel.sqf index bb7480a59e..9186ddbf57 100644 --- a/addons/sandbag/functions/fnc_deployCancel.sqf +++ b/addons/sandbag/functions/fnc_deployCancel.sqf @@ -1,35 +1,36 @@ /* - * Author: Garth 'L-H' de Wet, Ruthberg + * Author: Garth 'L-H' de Wet, Ruthberg, edited by commy2 for better MP and eventual AI support * Cancels sandbag deployment * * Arguments: - * None + * 0: unit * * Return Value: * None * * Example: - * [] call ace_sandbag_fnc_deployCancel + * [ACE_player] call ace_sandbag_fnc_deployCancel * * Public: No */ #include "script_component.hpp" -if (isNull GVAR(placer)) exitWith {}; +params ["_unit"]; -[GVAR(deployPFH)] call cba_fnc_removePerFrameHandler; +// enable running again +[_unit, "ACE_Sandbag", false] call EFUNC(common,setForceWalkStatus); -if (!isNull (GVAR(sandBag))) then { - deleteVehicle GVAR(sandBag); -}; +// delete placement dummy +deleteVehicle GVAR(sandBag); -[GVAR(placer), "ACE_Sandbag", false] call EFUNC(Common,setForceWalkStatus); +// remove deployment pfh +[GVAR(deployPFH)] call CBA_fnc_removePerFrameHandler; +GVAR(deployPFH) = -1; +// remove mouse button actions call EFUNC(interaction,hideMouseHint); -[GVAR(placer), "DefaultAction", GVAR(placer) getVariable [QGVAR(Deploy), -1]] call EFUNC(Common,removeActionEventHandler); -[GVAR(placer), "zoomtemp", GVAR(placer) getVariable [QGVAR(Cancel), -1]] call EFUNC(Common,removeActionEventHandler); -GVAR(placer) addItem "ACE_Sandbag_empty"; +[_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(common,removeActionEventHandler); +[_unit, "zoomtemp", _unit getVariable [QGVAR(Cancel), -1]] call EFUNC(common,removeActionEventHandler); -GVAR(sandBag) = objNull; -GVAR(placer) = objNull; +_unit setVariable [QGVAR(isDeploying), false, true]; diff --git a/addons/sandbag/functions/fnc_deployConfirm.sqf b/addons/sandbag/functions/fnc_deployConfirm.sqf index 61264c15fe..62848dd0cd 100644 --- a/addons/sandbag/functions/fnc_deployConfirm.sqf +++ b/addons/sandbag/functions/fnc_deployConfirm.sqf @@ -1,51 +1,59 @@ /* - * Author: Garth 'L-H' de Wet, Ruthberg + * Author: Garth 'L-H' de Wet, Ruthberg, edited by commy2 for better MP and eventual AI support * Confirms sandbag deployment * * Arguments: - * None + * 0: unit * * Return Value: * None * * Example: - * [] call ace_sandbag_fnc_deployConfirm + * [ACE_player] call ace_sandbag_fnc_deployConfirm * * Public: No */ #include "script_component.hpp" -if (isNull GVAR(sandBag) || isNull GVAR(placer)) exitWith {}; +params ["_unit"]; -[GVAR(deployPFH)] call cba_fnc_removePerFrameHandler; +// enable running again +[_unit, "ACE_Sandbag", false] call EFUNC(common,setForceWalkStatus); -[GVAR(placer), "ACE_Sandbag", false] call EFUNC(Common,setForceWalkStatus); -[GVAR(placer), "DefaultAction", GVAR(placer) getVariable [QGVAR(Deploy), -1]] call EFUNC(Common,removeActionEventHandler); -[GVAR(placer), "zoomtemp", GVAR(placer) getVariable [QGVAR(Cancel), -1]] call EFUNC(Common,removeActionEventHandler); +// remove sandbag from inventory +_unit removeItem "ACE_Sandbag_empty"; -call EFUNC(interaction,hideMouseHint); - -GVAR(placer) playActionNow "PutDown"; - -GVAR(placer) setVariable [QGVAR(usingSandbag), true]; +// delete placement dummy and create real sandbag [{ - _this setVariable [QGVAR(usingSandbag), false]; -}, GVAR(placer), 1.5, 0.5] call EFUNC(common,waitAndExecute); + if (isNull GVAR(sandBag)) exitWith {}; + + params ["_unit"]; + + private ["_position", "_direction", "_sandBag"]; -[{ - private ["_sandBag", "_position", "_direction"]; _position = getPosASL GVAR(sandBag); _direction = getDir GVAR(sandBag); deleteVehicle GVAR(sandBag); _sandBag = createVehicle ["ACE_SandbagObject", [0, 0, 0], [], 0, "NONE"]; - _sandBag enableSimulationGlobal true; _sandBag setPosASL _position; _sandBag setDir _direction; - GVAR(placer) removeItem "ACE_Sandbag_empty"; - GVAR(sandBag) = objNull; - GVAR(placer) = objNull; -}, [], 1.0, 0.5] call EFUNC(common,waitAndExecute); +}, [_unit], 1] call EFUNC(common,waitAndExecute); + +// remove deployment pfh +[GVAR(deployPFH)] call CBA_fnc_removePerFrameHandler; +GVAR(deployPFH) = -1; + +// remove mouse button actions +call EFUNC(interaction,hideMouseHint); + +[_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(common,removeActionEventHandler); +[_unit, "zoomtemp", _unit getVariable [QGVAR(Cancel), -1]] call EFUNC(common,removeActionEventHandler); + +// play animation +_unit playActionNow "PutDown"; + +_unit setVariable [QGVAR(isDeploying), false, true]; diff --git a/addons/sandbag/functions/fnc_drop.sqf b/addons/sandbag/functions/fnc_drop.sqf deleted file mode 100644 index 3ba825d423..0000000000 --- a/addons/sandbag/functions/fnc_drop.sqf +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Author: Garth 'L-H' de Wet, Ruthberg - * Drop sandbag - * - * Arguments: - * None - * - * Return Value: - * None - * - * Example: - * [] call ace_sandbag_fnc_deployCancel - * - * Public: No - */ -#include "script_component.hpp" - -if (isNull GVAR(sandBag) || isNull GVAR(carrier)) exitWith {}; - -[GVAR(carryPFH)] call cba_fnc_removePerFrameHandler; - -[GVAR(carrier), "ACE_Sandbag", false] call EFUNC(Common,setForceWalkStatus); -[GVAR(carrier), "DefaultAction", GVAR(carrier) getVariable [QGVAR(drop), -1]] call EFUNC(Common,removeActionEventHandler); - -call EFUNC(interaction,hideMouseHint); - -GVAR(carrier) playActionNow "PutDown"; - -[{ - _this setVariable [QGVAR(usingSandbag), false]; -}, GVAR(carrier), 1.5, 0.5] call EFUNC(common,waitAndExecute); - -[{ - private ["_sandBag", "_position", "_direction"]; - _position = getPosASL GVAR(sandBag); - _direction = getDir GVAR(sandBag); - - deleteVehicle GVAR(sandBag); - - _sandBag = createVehicle ["ACE_SandbagObject", [0, 0, 0], [], 0, "NONE"]; - _sandBag enableSimulationGlobal true; - _sandBag setPosASL _position; - _sandBag setDir _direction; - - GVAR(sandBag) = objNull; - GVAR(carrier) = objNull; -}, [], 1.0, 0.5] call EFUNC(common,waitAndExecute); diff --git a/addons/sandbag/functions/fnc_handleInteractMenuOpened.sqf b/addons/sandbag/functions/fnc_handleInteractMenuOpened.sqf new file mode 100644 index 0000000000..f4ea5891c7 --- /dev/null +++ b/addons/sandbag/functions/fnc_handleInteractMenuOpened.sqf @@ -0,0 +1,19 @@ +/* + * Author: commy2 + * Handle opening of interaction menu. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" + +params ["_unit"]; + +if (_unit getVariable [QGVAR(isDeploying), false]) then { + [_unit] call FUNC(deployCancel); +}; diff --git a/addons/sandbag/functions/fnc_handleKilled.sqf b/addons/sandbag/functions/fnc_handleKilled.sqf new file mode 100644 index 0000000000..63babd3f52 --- /dev/null +++ b/addons/sandbag/functions/fnc_handleKilled.sqf @@ -0,0 +1,19 @@ +/* + * Author: commy2 + * Handle death. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" + +params ["_unit"]; + +if (_unit getVariable [QGVAR(isDeploying), false]) then { + [_unit] call FUNC(deployCancel); +}; diff --git a/addons/sandbag/functions/fnc_handlePlayerChanged.sqf b/addons/sandbag/functions/fnc_handlePlayerChanged.sqf new file mode 100644 index 0000000000..f27a295903 --- /dev/null +++ b/addons/sandbag/functions/fnc_handlePlayerChanged.sqf @@ -0,0 +1,24 @@ +/* + * Author: commy2 + * Handle player changes. + * + * Arguments: + * 0: New Player Unit + * 1: Old Player Unit + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" + +params ["_newPlayer", "_oldPlayer"]; + +if (_newPlayer getVariable [QGVAR(isDeploying), false]) then { + [_newPlayer] call FUNC(deployCancel); +}; + +if (_oldPlayer getVariable [QGVAR(isDeploying), false]) then { + [_oldPlayer] call FUNC(deployCancel); +}; diff --git a/addons/sandbag/functions/fnc_handlePlayerInventoryChanged.sqf b/addons/sandbag/functions/fnc_handlePlayerInventoryChanged.sqf new file mode 100644 index 0000000000..9f5920edd1 --- /dev/null +++ b/addons/sandbag/functions/fnc_handlePlayerInventoryChanged.sqf @@ -0,0 +1,22 @@ +/* + * Author: commy2 + * Handle the InventoryChanged event. + * + * Arguments: + * 0: Unit + * 1: Weapon + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" + +params ["_unit"]; + +if (_unit getVariable [QGVAR(isDeploying), false]) then { + if !("ACE_Sandbag_empty" in items _unit) then { + [_unit] call FUNC(deployCancel); + }; +}; diff --git a/addons/sandbag/functions/fnc_handleUnconscious.sqf b/addons/sandbag/functions/fnc_handleUnconscious.sqf new file mode 100644 index 0000000000..7e0e257158 --- /dev/null +++ b/addons/sandbag/functions/fnc_handleUnconscious.sqf @@ -0,0 +1,19 @@ +/* + * Author: commy2 + * Handle unconsciousness. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" + +params ["_unit"]; + +if (_unit getVariable [QGVAR(isDeploying), false]) then { + [_unit] call FUNC(deployCancel); +}; diff --git a/addons/sandbag/functions/fnc_pickup.sqf b/addons/sandbag/functions/fnc_pickup.sqf index dd0b93fd59..7e04d047fd 100644 --- a/addons/sandbag/functions/fnc_pickup.sqf +++ b/addons/sandbag/functions/fnc_pickup.sqf @@ -3,27 +3,32 @@ * Pick up sandbag * * Arguments: - * 0: sandbag - * 1: unit + * 0: unit + * 1: sandbag * * Return Value: * None * * Example: - * [_sandbag, _unit] call ace_sandbag_fnc_pickup + * [_unit, _sandbag] call ace_sandbag_fnc_pickup * * Public: No */ #include "script_component.hpp" -params ["_sandbag", "_unit"]; +params ["_unit", "_sandbag"]; _unit playActionNow "PutDown"; -_unit setVariable [QGVAR(usingSandbag), true]; +_unit setVariable [QGVAR(isUsingSandbag), true]; + [{ - params ["_sandbag", "_unit"]; - _unit setVariable [QGVAR(usingSandbag), false]; + params ["_unit", "_sandbag"]; + + _unit setVariable [QGVAR(isUsingSandbag), false]; + + if (isNull _sandbag) exitWith {}; + deletevehicle _sandbag; // Force physx update @@ -32,4 +37,4 @@ _unit setVariable [QGVAR(usingSandbag), true]; } count (_unit nearObjects ["ACE_SandbagObject", 5]); [_unit, "ACE_Sandbag_empty"] call EFUNC(common,addToInventory); -}, [_sandbag, _unit], 1.5, 0.5] call EFUNC(common,waitAndExecute); +}, [_unit, _sandbag], 1.5] call EFUNC(common,waitAndExecute); diff --git a/addons/sandbag/stringtable.xml b/addons/sandbag/stringtable.xml index 5576add969..c67173466c 100644 --- a/addons/sandbag/stringtable.xml +++ b/addons/sandbag/stringtable.xml @@ -146,16 +146,16 @@ Aqui não tem areia - + Modifier, rotates - + Modifikator, drehen - + Modificador, girar - + Modificateur, tourner - + Modificatore, rotazione - + Modifikátor, otočit - + Változtatás, forgatás - + Modyfikator, obrót - + Modificador, rotaciona - + Bращать + +Ctrl rotate + +Strg drehen + +Ctrl girar + +Ctrl tourner + +Ctrl rotazione + +Ctrl otočit + +Ctrl forgatás + +Ctrl obrót + +Ctrl rotaciona + +Ctrl Bращать \ No newline at end of file diff --git a/addons/slideshow/functions/fnc_createSlideshow.sqf b/addons/slideshow/functions/fnc_createSlideshow.sqf index bed2a2ae7f..792905db0f 100644 --- a/addons/slideshow/functions/fnc_createSlideshow.sqf +++ b/addons/slideshow/functions/fnc_createSlideshow.sqf @@ -10,7 +10,7 @@ * 4: Slide Duration (0 disables automatic transitions) * * Return Value: - * Parsed List + * None * * Example: * [[object1, object2, object3], [controller1], ["images\image1.paa", "images\image2.paa"], ["Action1", "Action2"], 5] call ace_slideshow_fnc_createSlideshow @@ -20,21 +20,24 @@ #include "script_component.hpp" private ["_currentSlideshow", "_slidesAction", "_varString"]; -params ["_objects", "_controllers", "_images", "_names", "_duration"]; +params [ + ["_objects", [], [[]] ], + ["_controllers", [], [[]] ], + ["_images", [], [[]] ], + ["_names", [], [[]] ], + ["_duration", 0, [0]] +]; // Verify data -if (count _images != count _names || {count _images == 0} || {count _names == 0}) exitWith { - ACE_LOGERROR("Slideshow Images or Names fields can NOT be empty and must have equal number of items!"); +if (_objects isEqualTo []) exitWith { + ACE_LOGERROR("Slideshow Objects field must NOT be empty!"); +}; +if (count _images != count _names || {_images isEqualTo []} || {_names isEqualTo []}) exitWith { + ACE_LOGERROR("Slideshow Images or Names fields must NOT be empty and must have equal number of items!"); }; -// Objects synced to the module -{ - _objects pushBack _x; - nil -} count (synchronizedObjects _logic); - // If no controllers use objects as controllers -if (count _controllers == 0) then { +if (_controllers isEqualTo []) then { _controllers = _objects; }; @@ -54,7 +57,7 @@ _currentSlideshow = GVAR(slideshows); // Local variable in case GVAR gets change // If interaction menu module is not present, set default duration value if !(["ace_interact_menu"] call EFUNC(common,isModLoaded)) then { - _duration = 5; + _duration = NOINTERACTMENU_DURATION; ACE_LOGINFO_1("Interaction Menu module not present, defaulting duration value to %1",_duration); }; @@ -62,7 +65,7 @@ if !(["ace_interact_menu"] call EFUNC(common,isModLoaded)) then { if (_duration == 0) then { { // Add Slides sub-action and populate with images - _slidesAction = [QGVAR(Slides), localize LSTRING(Interaction), "", {}, {true}, {(_this select 2) call FUNC(addSlideActions)}, [_objects,_images,_names,_x,_currentSlideshow], [0,0,0], 2] call EFUNC(interact_menu,createAction); + _slidesAction = [QGVAR(Slides), localize LSTRING(Interaction), "", {}, {true}, {(_this select 2) call FUNC(addSlideActions)}, [_objects, _images, _names, _x, _currentSlideshow], [0, 0, 0], 2] call EFUNC(interact_menu,createAction); [_x, 0, ["ACE_MainActions"], _slidesAction] call EFUNC(interact_menu,addActionToObject); nil } count _controllers; diff --git a/addons/slideshow/functions/fnc_moduleInit.sqf b/addons/slideshow/functions/fnc_moduleInit.sqf index 7da64cd3cc..f09dab678d 100644 --- a/addons/slideshow/functions/fnc_moduleInit.sqf +++ b/addons/slideshow/functions/fnc_moduleInit.sqf @@ -30,7 +30,13 @@ _images = [_logic getVariable ["Images", ""], true, false] call FUNC(makeList); _names = [_logic getVariable ["Names", ""], true, false] call FUNC(makeList); _duration = _logic getVariable ["Duration", 0]; +// Objects synced to the module +{ + _objects pushBack _x; + nil +} count (synchronizedObjects _logic); + // Prepare with actions [_objects, _controllers, _images, _names, _duration] call FUNC(createSlideshow); -ACE_LOGINFO_2("Slideshow Module Initialized for: %1 with Duration: %2", _objects, _duration); +ACE_LOGINFO_1("Slideshow Module Initialized on %1 Objects", count _objects); diff --git a/addons/slideshow/script_component.hpp b/addons/slideshow/script_component.hpp index 12f60ee1ab..3acd23c0ee 100644 --- a/addons/slideshow/script_component.hpp +++ b/addons/slideshow/script_component.hpp @@ -10,3 +10,6 @@ #endif #include "\z\ace\addons\main\script_macros.hpp" + + +#define NOINTERACTMENU_DURATION 5 diff --git a/addons/spectator/functions/fnc_setSpectator.sqf b/addons/spectator/functions/fnc_setSpectator.sqf index f94d9d9f68..efa7000b8f 100644 --- a/addons/spectator/functions/fnc_setSpectator.sqf +++ b/addons/spectator/functions/fnc_setSpectator.sqf @@ -72,8 +72,10 @@ if (_set) then { closeDialog 0; }; - // Create the display - (findDisplay 46) createDisplay QGVAR(interface); + [{ + // Create the display + (findDisplay 46) createDisplay QGVAR(interface); + }, []] call EFUNC(common,execNextFrame); // Cache and disable nametag settings if (["ace_nametags"] call EFUNC(common,isModLoaded)) then { diff --git a/addons/tacticalladder/CfgEventHandlers.hpp b/addons/tacticalladder/CfgEventHandlers.hpp index 737cae5e43..f9ceb35aa5 100644 --- a/addons/tacticalladder/CfgEventHandlers.hpp +++ b/addons/tacticalladder/CfgEventHandlers.hpp @@ -1,3 +1,4 @@ + class Extended_PreInit_EventHandlers { class ADDON { init = QUOTE( call COMPILE_FILE(XEH_preInit) ); @@ -9,3 +10,11 @@ class Extended_PostInit_EventHandlers { init = QUOTE( call COMPILE_FILE(XEH_postInit) ); }; }; + +class Extended_Killed_EventHandlers { + class CAManBase { + class ADDON { + killed = QUOTE(_this call FUNC(handleKilled)); + }; + }; +}; diff --git a/addons/tacticalladder/CfgVehicles.hpp b/addons/tacticalladder/CfgVehicles.hpp index a1eda1a955..1457c4ddee 100644 --- a/addons/tacticalladder/CfgVehicles.hpp +++ b/addons/tacticalladder/CfgVehicles.hpp @@ -5,8 +5,8 @@ class CfgVehicles { class ACE_SelfActions { class ACE_TacticalLadders { displayName = CSTRING(Deploy); - condition = QUOTE((backpack ACE_player) == QUOTE(QUOTE(ACE_TacticalLadder_Pack))); - statement = QUOTE(call FUNC(deployTL)); + condition = QUOTE(backpack _player == 'ACE_TacticalLadder_Pack'); + statement = QUOTE([_player] call FUNC(deployTL)); exceptions[] = {}; showDisabled = 1; priority = 4; @@ -33,7 +33,7 @@ class CfgVehicles { }; class House; - class ACE_Tactical_Ladder: House { + class ACE_TacticalLadder: House { XEH_ENABLED; displayName = CSTRING(DisplayName); class DestructionEffects {}; @@ -42,6 +42,7 @@ class CfgVehicles { autocenter = 0; featureSize = 12; ladders[] = {{"start","end"}}; + class AnimationSources { class rotate { source = "user"; @@ -62,28 +63,31 @@ class CfgVehicles { class extract_10: extract_1 {}; class extract_11: extract_1 {}; }; + class ACE_Actions { class ACE_MainActions { selection = "roadway"; distance = 5; condition = "true"; + class ACE_PickUp { selection = ""; displayName = CSTRING(Pickup); distance = 4; condition = QUOTE((backpack ACE_player) == ''); - statement = QUOTE([ARR_2(_target,_player)] call FUNC(pickupTL)); + statement = QUOTE([ARR_2(_player,_target)] call FUNC(pickupTL)); showDisabled = 0; exceptions[] = {}; priority = 5; }; + class ACE_Position { selection = ""; displayName = CSTRING(Position); distance = 4; condition = "true"; //wait a frame to handle "Do When releasing action menu key" option: - statement = QUOTE([ARR_2({_this call FUNC(positionTL)}, [ARR_2(_target,_player)])] call EFUNC(common,execNextFrame)); + statement = QUOTE([ARR_2({_this call FUNC(positionTL)},[ARR_2(_player,_target)])] call EFUNC(common,execNextFrame)); showDisabled = 0; exceptions[] = {}; priority = 5; diff --git a/addons/tacticalladder/XEH_postInit.sqf b/addons/tacticalladder/XEH_postInit.sqf index f0091ec7fa..8ebf776987 100644 --- a/addons/tacticalladder/XEH_postInit.sqf +++ b/addons/tacticalladder/XEH_postInit.sqf @@ -1,15 +1,28 @@ #include "script_component.hpp" +if (!hasInterface) exitWith {}; + GVAR(ladder) = objNull; GVAR(cancelTime) = 0; GVAR(currentStep) = 3; GVAR(currentAngle) = 0; -// Cancel tactical ladder deployment if the interact menu is opened -["interactMenuOpened", { +/*["interactMenuOpened", { if ((ACE_time > GVAR(cancelTime)) && !isNull GVAR(ladder)) then { GVAR(ladder) call FUNC(cancelTLdeploy); }; -}] call EFUNC(common,addEventHandler); +}] call EFUNC(common,addEventHandler);*/ -[{(_this select 0) call FUNC(handleScrollWheel);}] call EFUNC(Common,addScrollWheelEventHandler); +// Cancel adjustment if interact menu opens +["interactMenuOpened", {[ACE_player] call FUNC(handleInteractMenuOpened)}] call EFUNC(common,addEventHandler); + +[{_this call FUNC(handleScrollWheel)}] call EFUNC(common,addScrollWheelEventHandler); + +// Cancel adjusting on player change. +["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler); +["playerVehicleChanged", {[ACE_player, objNull] call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler); + +// handle falling unconscious +["medical_onUnconscious", {_this call FUNC(handleUnconscious)}] call EFUNC(common,addEventhandler); + +// @todo captivity? diff --git a/addons/tacticalladder/XEH_preInit.sqf b/addons/tacticalladder/XEH_preInit.sqf index e434974c9a..cb1d3a8cf3 100644 --- a/addons/tacticalladder/XEH_preInit.sqf +++ b/addons/tacticalladder/XEH_preInit.sqf @@ -5,7 +5,11 @@ ADDON = false; PREP(cancelTLdeploy); PREP(confirmTLdeploy); PREP(deployTL); +PREP(handleKilled); +PREP(handleInteractMenuOpened); +PREP(handlePlayerChanged); PREP(handleScrollWheel); +PREP(handleUnconscious); PREP(pickupTL); PREP(positionTL); diff --git a/addons/tacticalladder/functions/fnc_cancelTLdeploy.sqf b/addons/tacticalladder/functions/fnc_cancelTLdeploy.sqf index 456d245832..c134df31d1 100644 --- a/addons/tacticalladder/functions/fnc_cancelTLdeploy.sqf +++ b/addons/tacticalladder/functions/fnc_cancelTLdeploy.sqf @@ -1,9 +1,10 @@ /* - * Author: Rocko, Ruthberg + * Author: Rocko, Ruthberg, commy2 * Cancel tactical ladder deployment * * Arguments: - * 0: ladder + * 0: unit + * 1: ladder * * Return Value: * None @@ -17,16 +18,23 @@ #define __ANIMS ["extract_1","extract_2","extract_3","extract_4","extract_5","extract_6","extract_7","extract_8","extract_9","extract_10","extract_11"] -params ["_ladder"]; +params ["_unit", "_ladder"]; + +// enable running again +[_unit, "ACE_Ladder", false] call EFUNC(common,setForceWalkStatus); detach _ladder; + _ladder animate ["rotate", 0]; + { _ladder animate [_x, 0]; } count __ANIMS; +// remove mouse buttons and hint call EFUNC(interaction,hideMouseHint); -[ACE_player, "DefaultAction", ACE_player getVariable [QGVAR(Deploy), -1]] call EFUNC(Common,removeActionEventHandler); -[ACE_player, "zoomtemp", ACE_player getVariable [QGVAR(Cancel), -1]] call EFUNC(Common,removeActionEventHandler); + +[_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(Common,removeActionEventHandler); +[_unit, "zoomtemp", _unit getVariable [QGVAR(Cancel), -1]] call EFUNC(Common,removeActionEventHandler); GVAR(ladder) = objNull; diff --git a/addons/tacticalladder/functions/fnc_confirmTLdeploy.sqf b/addons/tacticalladder/functions/fnc_confirmTLdeploy.sqf index 764e5c73d8..0094e460dc 100644 --- a/addons/tacticalladder/functions/fnc_confirmTLdeploy.sqf +++ b/addons/tacticalladder/functions/fnc_confirmTLdeploy.sqf @@ -1,9 +1,10 @@ /* - * Author: Rocko, Ruthberg + * Author: Rocko, Ruthberg, commy2 * Confirm tactical ladder deployment * * Arguments: - * 0: ladder + * 0: unit + * 1: ladder * * Return Value: * Success @@ -15,18 +16,26 @@ */ #include "script_component.hpp" -params ["_ladder"]; +params ["_unit", "_ladder"]; + +// enable running again +[_unit, "ACE_Ladder", false] call EFUNC(common,setForceWalkStatus); private ["_pos1", "_pos2"]; -_pos1 = getPosASL GVAR(ladder); -_pos2 = (GVAR(ladder) modelToWorld (GVAR(ladder) selectionPosition "check2")) call EFUNC(common,positionToASL); -if (lineIntersects [_pos1, _pos2, GVAR(ladder)]) exitWith { false }; -call EFUNC(interaction,hideMouseHint); -[ACE_player, "DefaultAction", ACE_player getVariable [QGVAR(Deploy), -1]] call EFUNC(Common,removeActionEventHandler); -[ACE_player, "zoomtemp", ACE_player getVariable [QGVAR(Cancel), -1]] call EFUNC(Common,removeActionEventHandler); +_pos1 = getPosASL _ladder; +_pos2 = AGLToASL (_ladder modelToWorld (_ladder selectionPosition "check2")); + +if (lineIntersects [_pos1, _pos2, _ladder]) exitWith {false}; detach _ladder; + +// remove mouse buttons and hint +call EFUNC(interaction,hideMouseHint); + +[_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(common,removeActionEventHandler); +[_unit, "zoomtemp", _unit getVariable [QGVAR(Cancel), -1]] call EFUNC(common,removeActionEventHandler); + GVAR(ladder) = objNull; true diff --git a/addons/tacticalladder/functions/fnc_deployTL.sqf b/addons/tacticalladder/functions/fnc_deployTL.sqf index 14c386dda1..b0eb1e0f68 100644 --- a/addons/tacticalladder/functions/fnc_deployTL.sqf +++ b/addons/tacticalladder/functions/fnc_deployTL.sqf @@ -3,32 +3,35 @@ * Deploy tactical ladder * * Arguments: - * None + * 0: unit * * Return Value: * None * * Example: - * [] call ace_tacticalladder_fnc_deployTL + * [_unit] call ace_tacticalladder_fnc_deployTL * * Public: No */ #include "script_component.hpp" -if ((backpack ACE_player) != "ACE_TacticalLadder_Pack") exitWith {}; +params ["_unit"]; + +if (backpack _unit != 'ACE_TacticalLadder_Pack') exitWith {}; + +removeBackpack _unit; private ["_pos", "_offset", "_ladder"]; -removeBackpack ACE_player; +_pos = _unit modelToWorld [0,0,0]; +_offset = if ((_unit call CBA_fnc_getUnitAnim select 0) == "prone") then { 1 } else {0.8}; -_pos = ACE_player modelToWorld [0,0,0]; -_offset = if ((ACE_player call CBA_fnc_getUnitAnim select 0) == "prone") then { 1 } else {0.8}; -_pos set [0, (_pos select 0) + (sin (direction ACE_player) * _offset)]; -_pos set [1, (_pos select 1) + (cos (direction ACE_player) * _offset)]; -_pos set [2, [ACE_player] call CBA_fnc_realHeight]; +_pos set [0, (_pos select 0) + (sin getDir _unit) * _offset]; +_pos set [1, (_pos select 1) + (cos getDir _unit) * _offset]; +_pos set [2, [_unit] call CBA_fnc_realHeight]; -_ladder = "ACE_Tactical_Ladder" createVehicle _pos; +_ladder = "ACE_TacticalLadder" createVehicle _pos; _ladder setPos _pos; -_ladder setDir (direction ACE_player); +_ladder setDir getDir _unit; -ACE_player reveal _ladder; +_unit reveal _ladder; diff --git a/addons/tacticalladder/functions/fnc_handleInteractMenuOpened.sqf b/addons/tacticalladder/functions/fnc_handleInteractMenuOpened.sqf new file mode 100644 index 0000000000..c7187acd55 --- /dev/null +++ b/addons/tacticalladder/functions/fnc_handleInteractMenuOpened.sqf @@ -0,0 +1,19 @@ +/* + * Author: commy2 + * Handle opening of interaction menu. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" + +params ["_unit"]; + +if (!isNull (GETMVAR(GVAR(ladder),objNull)) && {GVAR(ladder) in attachedObjects _unit}) then { + [_unit, GVAR(ladder)] call FUNC(cancelTLdeploy); +}; diff --git a/addons/tacticalladder/functions/fnc_handleKilled.sqf b/addons/tacticalladder/functions/fnc_handleKilled.sqf new file mode 100644 index 0000000000..c5d6aa1314 --- /dev/null +++ b/addons/tacticalladder/functions/fnc_handleKilled.sqf @@ -0,0 +1,19 @@ +/* + * Author: commy2 + * Handle death. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" + +params ["_unit"]; + +if (!isNull (GETMVAR(ladder,objNull)) && {GVAR(ladder) in attachedObjects _unit}) then { + [_unit, GVAR(ladder)] call FUNC(cancelTLdeploy); +}; diff --git a/addons/tacticalladder/functions/fnc_handlePlayerChanged.sqf b/addons/tacticalladder/functions/fnc_handlePlayerChanged.sqf new file mode 100644 index 0000000000..07118acbaf --- /dev/null +++ b/addons/tacticalladder/functions/fnc_handlePlayerChanged.sqf @@ -0,0 +1,26 @@ +/* + * Author: commy2 + * Handle player changes. + * + * Arguments: + * 0: New Player Unit + * 1: Old Player Unit + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" + +if (isNull (GETGVAR(ladder,objNull))) exitWith {}; + +params ["_newPlayer", "_oldPlayer"]; + +if (GVAR(ladder) in attachedObjects _newPlayer) then { + [_newPlayer, GVAR(ladder)] call FUNC(cancelTLdeploy); +}; + +if (GVAR(ladder) in attachedObjects _oldPlayer) then { + [_oldPlayer, GVAR(ladder)] call FUNC(cancelTLdeploy); +}; diff --git a/addons/tacticalladder/functions/fnc_handleScrollWheel.sqf b/addons/tacticalladder/functions/fnc_handleScrollWheel.sqf index 6b5107b814..0b64d89610 100644 --- a/addons/tacticalladder/functions/fnc_handleScrollWheel.sqf +++ b/addons/tacticalladder/functions/fnc_handleScrollWheel.sqf @@ -41,7 +41,7 @@ if (GETMVAR(ACE_Modifier,0) == 0) then { }; } else { // Tilting - GVAR(currentAngle) = 0 max (GVAR(currentAngle) + _scroll) min 90; + GVAR(currentAngle) = 0 max (GVAR(currentAngle) + _scroll) min 30; GVAR(ladder) animate ["rotate", GVAR(currentAngle)]; }; diff --git a/addons/tacticalladder/functions/fnc_handleUnconscious.sqf b/addons/tacticalladder/functions/fnc_handleUnconscious.sqf new file mode 100644 index 0000000000..e9ce28d524 --- /dev/null +++ b/addons/tacticalladder/functions/fnc_handleUnconscious.sqf @@ -0,0 +1,19 @@ +/* + * Author: commy2 + * Handle unconsciousness. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" + +params ["_unit"]; + +if (!isNull (GETMVAR(ladder,objNull)) && {GVAR(ladder) in attachedObjects _unit}) then { + [_unit, GVAR(ladder)] call FUNC(cancelTLdeploy); +}; diff --git a/addons/tacticalladder/functions/fnc_pickupTL.sqf b/addons/tacticalladder/functions/fnc_pickupTL.sqf index ad409f8870..d8e313a17b 100644 --- a/addons/tacticalladder/functions/fnc_pickupTL.sqf +++ b/addons/tacticalladder/functions/fnc_pickupTL.sqf @@ -1,26 +1,27 @@ /* - * Author: Rocko, Ruthberg + * Author: Rocko, Ruthberg, commy2 * Pick up tactical ladder * * Arguments: - * 0: ladder - * 1: unit + * 0: unit + * 1: ladder * * Return Value: * Success * * Example: - * [_ladder, _unit] call ace_tacticalladder_fnc_pickupTL + * [_unit, _ladder] call ace_tacticalladder_fnc_pickupTL * * Public: No */ #include "script_component.hpp" -if ((backpack ACE_player) != "") exitWith { false }; +params ["_unit", "_ladder"]; -params ["_ladder", "_unit"]; +if (backpack _unit != "") exitWith {false}; deleteVehicle _ladder; + _unit addBackpack "ACE_TacticalLadder_Pack"; true diff --git a/addons/tacticalladder/functions/fnc_positionTL.sqf b/addons/tacticalladder/functions/fnc_positionTL.sqf index 1035101556..1e7f0db209 100644 --- a/addons/tacticalladder/functions/fnc_positionTL.sqf +++ b/addons/tacticalladder/functions/fnc_positionTL.sqf @@ -3,14 +3,14 @@ * Position tactical ladder * * Arguments: - * 0: sandbag - * 1: unit + * 0: unit + * 1: ladder * * Return Value: * None * * Example: - * [_ladder, _unit] call ace_tacticalladder_fnc_positionTL + * [_unit, _ladder] call ace_tacticalladder_fnc_positionTL * * Public: No */ @@ -18,13 +18,17 @@ #define __ANIMS ["extract_1","extract_2","extract_3","extract_4","extract_5","extract_6","extract_7","extract_8","extract_9","extract_10","extract_11"] -params ["_ladder", "_unit"]; +params ["_unit", "_ladder"]; + +// prevent the placing unit from running +[_unit, "ACE_Ladder", true] call EFUNC(common,setForceWalkStatus); { _ladder animate [_x, 0]; } count __ANIMS; -_unit switchMove "amovpercmstpslowwrfldnon_player_idlesteady03"; +[_unit, "amovpercmstpslowwrfldnon_player_idlesteady03", 2] call EFUNC(common,doAnimation); + _ladder attachTo [_unit, [0, 0.75, 0], ""]; // Position ladder in front of player _ladder animate ["rotate", 0]; @@ -37,16 +41,17 @@ GVAR(cancelTime) = ACE_time + 1; // Workaround to prevent accidental canceling GVAR(currentStep) = 3; GVAR(currentAngle) = 0; +// add mouse buttons and hints [localize LSTRING(Deploy), localize LSTRING(Drop), localize LSTRING(Adjust)] call EFUNC(interaction,showMouseHint); -ACE_player setVariable [QGVAR(Deploy), - [ACE_player, "DefaultAction", +_unit setVariable [QGVAR(Deploy), [ + _unit, "DefaultAction", {!isNull GVAR(ladder)}, - {GVAR(ladder) call FUNC(confirmTLdeploy);} -] call EFUNC(common,AddActionEventHandler)]; + {[_this select 0, GVAR(ladder)] call FUNC(confirmTLdeploy)} +] call EFUNC(common,addActionEventHandler)]; -ACE_player setVariable [QGVAR(Cancel), - [ACE_player, "zoomtemp", +_unit setVariable [QGVAR(Cancel), [ + _unit, "zoomtemp", {!isNull GVAR(ladder)}, - {GVAR(ladder) call FUNC(cancelTLdeploy);} -] call EFUNC(common,AddActionEventHandler)]; + {[_this select 0, GVAR(ladder)] call FUNC(cancelTLdeploy)} +] call EFUNC(common,addActionEventHandler)]; diff --git a/addons/tacticalladder/stringtable.xml b/addons/tacticalladder/stringtable.xml index a05c82efb2..98e041b1af 100644 --- a/addons/tacticalladder/stringtable.xml +++ b/addons/tacticalladder/stringtable.xml @@ -38,15 +38,8 @@ Derrubar escada - Adjust ladder - Leiter einstellen - Reguluj drabinę - Upravit žebřík - Ajustar escalera - Ajustar escada - Régler l'échelle - Létra állítása - Выровнять лестницу + Extend, +Ctrl tilt + Ausfahren, +Strg kippen Position ladder diff --git a/addons/tripod/CfgEventHandlers.hpp b/addons/tripod/CfgEventHandlers.hpp index d700ed4c85..ed59062ad5 100644 --- a/addons/tripod/CfgEventHandlers.hpp +++ b/addons/tripod/CfgEventHandlers.hpp @@ -1,3 +1,4 @@ + class Extended_PreInit_EventHandlers { class ADDON { init = QUOTE( call COMPILE_FILE(XEH_preInit) ); @@ -17,3 +18,11 @@ class Extended_Init_EventHandlers { }; }; }; + +class Extended_Killed_EventHandlers { + class CAManBase { + class ADDON { + killed = QUOTE(_this call FUNC(handleKilled)); + }; + }; +}; diff --git a/addons/tripod/CfgVehicles.hpp b/addons/tripod/CfgVehicles.hpp index 2a689ba349..60486b8afb 100644 --- a/addons/tripod/CfgVehicles.hpp +++ b/addons/tripod/CfgVehicles.hpp @@ -2,15 +2,13 @@ class CfgVehicles { class Man; class CAManBase: Man { class ACE_SelfActions { - class ACE_Equipment { - class GVAR(place) { - displayName = CSTRING(Placedown); - condition = QUOTE([ARR_2(_player,'ACE_Tripod')] call EFUNC(common,hasItem)); - statement = QUOTE([ARR_2(_player,'ACE_Tripod')] call FUNC(place)); - showDisabled = 0; - priority = 2; - icon = PATHTOF(UI\w_sniper_tripod_ca.paa); - }; + class GVAR(place) { + displayName = CSTRING(Placedown); + condition = QUOTE([ARR_2(_player,'ACE_Tripod')] call EFUNC(common,hasItem)); + statement = QUOTE([ARR_2(_player,'ACE_Tripod')] call FUNC(place)); + showDisabled = 0; + priority = 2; + icon = PATHTOF(UI\w_sniper_tripod_ca.paa); }; }; }; @@ -37,9 +35,13 @@ class CfgVehicles { class thingX; class ACE_TripodObject: thingX { XEH_ENABLED; + EGVAR(dragging,canDrag) = 1; + EGVAR(dragging,dragPosition[]) = {0,1,0}; + EGVAR(dragging,dragDirection) = 0; scope = 2; displayName = CSTRING(DisplayName); model = PATHTOF(data\sniper_tripod.p3d); + class AnimationSources { class slide_down_tripod { source = "user"; @@ -52,32 +54,32 @@ class CfgVehicles { class retract_leg_2: retract_leg_1 {}; class retract_leg_3: retract_leg_2 {}; }; - EGVAR(dragging,canDrag) = 1; - EGVAR(dragging,dragPosition[]) = {0,1,0}; - EGVAR(dragging,dragDirection) = 0; + class ACE_Actions { class ACE_MainActions { selection = ""; distance = 5; condition = "true"; + class ACE_Pickup { selection = ""; displayName = CSTRING(PickUp); distance = 5; condition = "true"; - statement = QUOTE([ARR_2(_target,_player)] call FUNC(pickup)); + statement = QUOTE([ARR_2(_player,_target)] call FUNC(pickup)); showDisabled = 0; exceptions[] = {}; priority = 5; icon = PATHTOF(UI\w_sniper_tripod_ca.paa); }; + class ACE_Adjust { selection = ""; displayName = CSTRING(Adjust); distance = 5; condition = "true"; //wait a frame to handle "Do When releasing action menu key" option: - statement = QUOTE([ARR_2({_this call FUNC(adjust)}, [_target])] call EFUNC(common,execNextFrame)); + statement = QUOTE([ARR_2({_this call FUNC(adjust)}, [ARR_2(_player,_target)])] call EFUNC(common,execNextFrame)); showDisabled = 0; exceptions[] = {}; priority = 5; diff --git a/addons/tripod/XEH_postInit.sqf b/addons/tripod/XEH_postInit.sqf index 706aaecae9..6f2dc9b7e0 100644 --- a/addons/tripod/XEH_postInit.sqf +++ b/addons/tripod/XEH_postInit.sqf @@ -1,16 +1,21 @@ #include "script_component.hpp" -GVAR(adjuster) = objNull; -GVAR(adjusting) = false; +if (!hasInterface) exitWith {}; + GVAR(adjustPFH) = -1; GVAR(height) = 0; // Cancel adjustment if interact menu opens -["interactMenuOpened", { - if (GVAR(adjustPFH) != -1 && GVAR(adjusting)) then { - GVAR(adjusting) = false; - }; -}] call EFUNC(common,addEventHandler); +["interactMenuOpened", {[ACE_player] call FUNC(handleInteractMenuOpened)}] call EFUNC(common,addEventHandler); -[{(_this select 0) call FUNC(handleScrollWheel);}] call EFUNC(Common,addScrollWheelEventHandler); +[{_this call FUNC(handleScrollWheel)}] call EFUNC(common,addScrollWheelEventHandler); + +// Cancel adjusting on player change. +["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler); +["playerVehicleChanged", {[ACE_player, objNull] call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler); + +// handle falling unconscious +["medical_onUnconscious", {_this call FUNC(handleUnconscious)}] call EFUNC(common,addEventhandler); + +// @todo captivity? diff --git a/addons/tripod/XEH_preInit.sqf b/addons/tripod/XEH_preInit.sqf index f27b707936..1699258b47 100644 --- a/addons/tripod/XEH_preInit.sqf +++ b/addons/tripod/XEH_preInit.sqf @@ -3,7 +3,11 @@ ADDON = false; PREP(adjust); +PREP(handleInteractMenuOpened); +PREP(handleKilled); +PREP(handlePlayerChanged); PREP(handleScrollWheel); +PREP(handleUnconscious); PREP(pickup); PREP(place); diff --git a/addons/tripod/functions/fnc_adjust.sqf b/addons/tripod/functions/fnc_adjust.sqf index 1ba99cedbe..2b8659b2a4 100644 --- a/addons/tripod/functions/fnc_adjust.sqf +++ b/addons/tripod/functions/fnc_adjust.sqf @@ -9,37 +9,39 @@ * None * * Example: - * [tripod] call ace_tripod_fnc_adjust + * [ACE_player, tripod] call ace_tripod_fnc_adjust * * Public: No */ #include "script_component.hpp" -params ["_tripod"]; +params ["_unit", "_tripod"]; -GVAR(adjuster) = ACE_player; -GVAR(adjusting) = true; +_unit setVariable [QGVAR(adjusting), true, true]; +// add PFH to adjust the tripod animation GVAR(adjustPFH) = [{ - params ["_args", "_pfhId"]; - _args params ["_tripod"]; + (_this select 0) params ["_unit", "_tripod"]; - if (GVAR(adjuster) != ACE_player || !GVAR(adjusting)) exitWith { + if (!(_unit getVariable [QGVAR(adjusting), false]) || {isNull _tripod} || {_unit distance _tripod > 5}) exitWith { call EFUNC(interaction,hideMouseHint); - [ACE_player, "DefaultAction", ACE_player getVariable [QGVAR(Adjust), -1]] call EFUNC(Common,removeActionEventHandler); - [_pfhId] call cba_fnc_removePerFrameHandler; + + [_unit, "DefaultAction", _unit getVariable [QGVAR(Adjust), -1]] call EFUNC(common,removeActionEventHandler); + + [_this select 1] call CBA_fnc_removePerFrameHandler; }; { _tripod animate [_x, 1 - GVAR(height)]; } count ["slide_down_tripod", "retract_leg_1", "retract_leg_2", "retract_leg_3"]; -}, 0, [_tripod]] call CBA_fnc_addPerFrameHandler; +}, 0, [_unit, _tripod]] call CBA_fnc_addPerFrameHandler; +// add mouse button action and hint [localize "STR_ACE_Tripod_Done", "", localize "STR_ACE_Tripod_ScrollAction"] call EFUNC(interaction,showMouseHint); -ACE_player setVariable [QGVAR(Adjust), - [ACE_player, "DefaultAction", - {GVAR(adjustPFH) != -1 && GVAR(adjusting)}, - {GVAR(adjusting) = false;} -] call EFUNC(common,AddActionEventHandler)]; +_unit setVariable [QGVAR(Adjust), [ + _unit, "DefaultAction", + {GVAR(adjustPFH) != -1}, + {(_this select 0) setVariable [QGVAR(adjusting), false, true]} +] call EFUNC(common,addActionEventHandler)]; diff --git a/addons/tripod/functions/fnc_handleInteractMenuOpened.sqf b/addons/tripod/functions/fnc_handleInteractMenuOpened.sqf new file mode 100644 index 0000000000..8c49359d96 --- /dev/null +++ b/addons/tripod/functions/fnc_handleInteractMenuOpened.sqf @@ -0,0 +1,19 @@ +/* + * Author: commy2 + * Handle opening of interaction menu. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" + +params ["_unit"]; + +if (_unit getVariable [QGVAR(adjusting), false]) then { + _unit setVariable [QGVAR(adjusting), false, true]; +}; diff --git a/addons/tripod/functions/fnc_handleKilled.sqf b/addons/tripod/functions/fnc_handleKilled.sqf new file mode 100644 index 0000000000..ee28fc1f45 --- /dev/null +++ b/addons/tripod/functions/fnc_handleKilled.sqf @@ -0,0 +1,19 @@ +/* + * Author: commy2 + * Handle death. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" + +params ["_unit"]; + +if (_unit getVariable [QGVAR(adjusting), false]) then { + _unit setVariable [QGVAR(adjusting), false, true]; +}; diff --git a/addons/tripod/functions/fnc_handlePlayerChanged.sqf b/addons/tripod/functions/fnc_handlePlayerChanged.sqf new file mode 100644 index 0000000000..dd0cad6533 --- /dev/null +++ b/addons/tripod/functions/fnc_handlePlayerChanged.sqf @@ -0,0 +1,24 @@ +/* + * Author: commy2 + * Handle player changes. + * + * Arguments: + * 0: New Player Unit + * 1: Old Player Unit + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" + +params ["_newPlayer", "_oldPlayer"]; + +if (_newPlayer getVariable [QGVAR(adjusting), false]) then { + _newPlayer setVariable [QGVAR(adjusting), false, true]; +}; + +if (_oldPlayer getVariable [QGVAR(adjusting), false]) then { + _oldPlayer setVariable [QGVAR(adjusting), false, true]; +}; diff --git a/addons/tripod/functions/fnc_handleScrollWheel.sqf b/addons/tripod/functions/fnc_handleScrollWheel.sqf index 973a57dd2f..1589bbc476 100644 --- a/addons/tripod/functions/fnc_handleScrollWheel.sqf +++ b/addons/tripod/functions/fnc_handleScrollWheel.sqf @@ -17,7 +17,7 @@ params ["_scroll"]; -if (GETMVAR(ACE_Modifier,0) == 0 || GVAR(adjustPFH) == -1) exitWith { false }; +if (GVAR(adjustPFH) == -1) exitWith {false}; GVAR(height) = 0 max (GVAR(height) + (_scroll / 20)) min 1; diff --git a/addons/tripod/functions/fnc_handleUnconscious.sqf b/addons/tripod/functions/fnc_handleUnconscious.sqf new file mode 100644 index 0000000000..f81cecea58 --- /dev/null +++ b/addons/tripod/functions/fnc_handleUnconscious.sqf @@ -0,0 +1,19 @@ +/* + * Author: commy2 + * Handle unconsciousness. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Public: No +*/ +#include "script_component.hpp" + +params ["_unit"]; + +if (_unit getVariable [QGVAR(adjusting), false]) then { + _unit setVariable [QGVAR(adjusting), false, true]; +}; diff --git a/addons/tripod/functions/fnc_pickup.sqf b/addons/tripod/functions/fnc_pickup.sqf index 24fc26ea1d..886aa5087e 100644 --- a/addons/tripod/functions/fnc_pickup.sqf +++ b/addons/tripod/functions/fnc_pickup.sqf @@ -3,28 +3,31 @@ * Pick up tripod * * Arguments: - * 0: tripod - * 1: unit + * 0: unit + * 1: tripod * * Return value: * None * * Example: - * [tripod, player] call ace_tripod_fnc_pickup + * [ACE_player, tripod] call ace_tripod_fnc_pickup * * Public: No */ #include "script_component.hpp" -params ["_tripod", "_unit"]; +params ["_unit", "_tripod"]; -if ((_unit call CBA_fnc_getUnitAnim) select 0 == "stand") then { - _unit playMove "AmovPercMstpSrasWrflDnon_diary"; +if (stance _unit == "STAND") then { + [_unit, "AmovPercMstpSrasWrflDnon_diary"] call EFUNC(common,doAnimation); }; [{ - params ["_tripod", "_unit"]; + params ["_unit", "_tripod"]; + + if (isNull _tripod) exitWith {}; + + deleteVehicle _tripod; [_unit, "ACE_Tripod"] call EFUNC(common,addToInventory); - deleteVehicle _tripod; -}, [_tripod, _unit], 1, 0]call EFUNC(common,waitAndExecute); +}, [_unit, _tripod], 1] call EFUNC(common,waitAndExecute); diff --git a/addons/tripod/functions/fnc_place.sqf b/addons/tripod/functions/fnc_place.sqf index ce7f445885..3168703f31 100644 --- a/addons/tripod/functions/fnc_place.sqf +++ b/addons/tripod/functions/fnc_place.sqf @@ -20,34 +20,37 @@ params ["_unit", "_tripodClass"]; _unit removeItem _tripodClass; -if ((_unit call CBA_fnc_getUnitAnim) select 0 == "stand") then { - _unit playMove "AmovPercMstpSrasWrflDnon_diary"; +if (stance _unit == "STAND") then { + [_unit, "AmovPercMstpSrasWrflDnon_diary"] call EFUNC(common,doAnimation); }; [{ params ["_unit"]; private ["_direction", "_position", "_tripod"]; + _direction = getDir _unit; - _position = (getPosASL _unit) vectorAdd [0.8 * sin(_direction), 0.8 * cos(_direction), 0.02]; + _position = getPosASL _unit vectorAdd [0.8 * sin _direction, 0.8 * cos _direction, 0.02]; _tripod = "ACE_TripodObject" createVehicle [0, 0, 0]; + { _tripod animate [_x, 1]; } count ["slide_down_tripod", "retract_leg_1", "retract_leg_2", "retract_leg_3"]; [{ - params ["_args", "_pfhId"]; - _args params ["_tripod", "_direction", "_position"]; + (_this select 0) params ["_tripod", "_direction", "_position"]; if (_tripod animationPhase "slide_down_tripod" == 1) then { _tripod setDir _direction; _tripod setPosASL _position; - if ((getPosATL _tripod select 2) - (getPos _tripod select 2) < 1E-5) then { + + if ((getPosATL _tripod select 2) - (getPos _tripod select 2) < 1E-5) then { // if not on object, then adjust to surface normale _tripod setVectorUp (surfaceNormal (position _tripod)); }; - [_pfhId] call CBA_fnc_removePerFrameHandler; + + [_this select 1] call CBA_fnc_removePerFrameHandler; }; }, 0, [_tripod, _direction, _position]] call CBA_fnc_addPerFrameHandler; -}, [_unit], 1, 0] call EFUNC(common,waitAndExecute); +}, [_unit], 1] call EFUNC(common,waitAndExecute); diff --git a/addons/tripod/stringtable.xml b/addons/tripod/stringtable.xml index e87c89e6ff..c6366ba8de 100644 --- a/addons/tripod/stringtable.xml +++ b/addons/tripod/stringtable.xml @@ -59,15 +59,15 @@ Готово - + Modifier, adjust - + Modyfikator, regulacja - + Modificador, ajuste - + Modifikátor, regulace - + Modifikator, anpassen - + Modificador, ajuste - + modifier, régler - + Módosító, szabályzás - + Модификатор, подстройка + adjust + regulacja + ajuste + regulace + anpassen + ajuste + régler + szabályzás + подстройка diff --git a/addons/ui/$PBOPREFIX$ b/addons/ui/$PBOPREFIX$ index 601bbd5f60..9b6ac48f4f 100644 --- a/addons/ui/$PBOPREFIX$ +++ b/addons/ui/$PBOPREFIX$ @@ -1 +1 @@ -z\ace\Addons\ui \ No newline at end of file +z\ace\addons\ui \ No newline at end of file diff --git a/addons/ui/README.md b/addons/ui/README.md index c16d2c04e5..340e3ad0f6 100644 --- a/addons/ui/README.md +++ b/addons/ui/README.md @@ -1,7 +1,7 @@ ace_ui ======= -Changes the chat contrast on the map to allow easier reading. +Removes vignette and changes the chat contrast on the map to allow easier reading. ## Maintainers diff --git a/addons/ui/RscChat.hpp b/addons/ui/RscChat.hpp new file mode 100644 index 0000000000..46d8ff0acb --- /dev/null +++ b/addons/ui/RscChat.hpp @@ -0,0 +1,15 @@ +class RscText; +class RscDisplayChat { + class controls { + delete Line; + delete Background; + class CA_Background: RscText { + colorBackground[] = {0.5, 0.5, 0.5, 0.33}; // Make the chat entry field slightly darker + }; + }; +}; + +class RscChatListDefault { + colorBackground[] = {0, 0, 0, 0.5}; // Make the chat background darker + colorMessageProtocol[] = {0.85, 0.85, 0.85, 1}; // And the chat text brighter +}; diff --git a/addons/ui/RscVignette.hpp b/addons/ui/RscVignette.hpp new file mode 100644 index 0000000000..1da39c2118 --- /dev/null +++ b/addons/ui/RscVignette.hpp @@ -0,0 +1,4 @@ +class RscPicture; +class RscVignette: RscPicture { + text = ""; // Remove Vignette Texture +}; diff --git a/addons/ui/config.cpp b/addons/ui/config.cpp index d2f4d114e4..f545600758 100644 --- a/addons/ui/config.cpp +++ b/addons/ui/config.cpp @@ -6,25 +6,11 @@ class CfgPatches { weapons[] = {}; requiredVersion = REQUIRED_VERSION; requiredAddons[] = {"ace_common"}; - author[] = {"VKing"}; + author[] = {"VKing", "Jonpas"}; authorUrl = "http://ace3mod.com/"; VERSION_CONFIG; }; }; -class RscText; - -class RscDisplayChat { - class controls { - delete Line; - delete Background; - class CA_Background: RscText { - colorBackground[] = {0.5,0.5,0.5,0.33}; // Make the chat entry field slightly darker - }; - }; -}; - -class RscChatListDefault { - colorBackground[] = {0,0,0,0.5}; // Make the chat background darker - colorMessageProtocol[] = {0.85,0.85,0.85,1}; // And the chat text brighter -}; +#include "RscChat.hpp" +#include "RscVignette.hpp" diff --git a/addons/ui/functions/script_component.hpp b/addons/ui/functions/script_component.hpp deleted file mode 100644 index 656228f742..0000000000 --- a/addons/ui/functions/script_component.hpp +++ /dev/null @@ -1 +0,0 @@ -#include "\z\ace\addons\ui\script_component.hpp" diff --git a/addons/ui/script_component.hpp b/addons/ui/script_component.hpp index a1a210701c..a0fa713f9f 100644 --- a/addons/ui/script_component.hpp +++ b/addons/ui/script_component.hpp @@ -1,5 +1,5 @@ #define COMPONENT ui -#include "\z\ace\Addons\main\script_mod.hpp" +#include "\z\ace\addons\main\script_mod.hpp" #ifdef DEBUG_ENABLED_UI #define DEBUG_MODE_FULL @@ -9,5 +9,4 @@ #define DEBUG_SETTINGS DEBUG_SETTINGS_UI #endif -#include "\z\ace\Addons\main\script_macros.hpp" - +#include "\z\ace\addons\main\script_macros.hpp" diff --git a/addons/weaponselect/ACE_Settings.hpp b/addons/weaponselect/ACE_Settings.hpp index 7b60527449..2214451247 100644 --- a/addons/weaponselect/ACE_Settings.hpp +++ b/addons/weaponselect/ACE_Settings.hpp @@ -1,3 +1,4 @@ + class ACE_Settings { class GVAR(DisplayText) { typeName = "BOOL"; diff --git a/addons/weaponselect/CfgEventHandlers.hpp b/addons/weaponselect/CfgEventHandlers.hpp index f409a36e5a..fd928fde2a 100644 --- a/addons/weaponselect/CfgEventHandlers.hpp +++ b/addons/weaponselect/CfgEventHandlers.hpp @@ -13,8 +13,8 @@ class Extended_PostInit_EventHandlers { class Extended_FiredBIS_EventHandlers { class CAManBase { - class GVAR(ThrowGrenade) { - clientFiredBIS = QUOTE(if (_this select 0 == ACE_player) then {_this call FUNC(throwGrenade)};); + class GVAR(throwGrenade) { + clientFiredBIS = QUOTE(if (_this select 0 == ACE_player) then {_this call FUNC(throwGrenade)}); }; }; }; diff --git a/addons/weaponselect/XEH_postInit.sqf b/addons/weaponselect/XEH_postInit.sqf index 3da7fda785..491a86f39d 100644 --- a/addons/weaponselect/XEH_postInit.sqf +++ b/addons/weaponselect/XEH_postInit.sqf @@ -3,9 +3,8 @@ if (!hasInterface) exitWith {}; -// Add keybinds -["ACE3 Weapons", QGVAR(SelectPistolNew), localize LSTRING(SelectPistol), -{ +// add keybinds +["ACE3 Weapons", QGVAR(SelectPistolNew), localize LSTRING(SelectPistol), { // Conditions: canInteract if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific @@ -16,10 +15,9 @@ if (!hasInterface) exitWith {}; false }, {false}, -[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 1 Key) +[0, [false, false, false]], false] call CBA_fnc_addKeybind; //Unbound (was 1 Key) -["ACE3 Weapons", QGVAR(SelectRifleNew), localize LSTRING(SelectRifle), -{ +["ACE3 Weapons", QGVAR(SelectRifleNew), localize LSTRING(SelectRifle), { // Conditions: canInteract if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific @@ -30,10 +28,9 @@ if (!hasInterface) exitWith {}; false }, {false}, -[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 2 Key) +[0, [false, false, false]], false] call CBA_fnc_addKeybind; //Unbound (was 2 Key) -["ACE3 Weapons", QGVAR(SelectRifleMuzzleNew), localize LSTRING(SelectRifleMuzzle), -{ +["ACE3 Weapons", QGVAR(SelectRifleMuzzleNew), localize LSTRING(SelectRifleMuzzle), { // Conditions: canInteract if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific @@ -44,10 +41,9 @@ if (!hasInterface) exitWith {}; false }, {false}, -[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 3 Key) +[0, [false, false, false]], false] call CBA_fnc_addKeybind; //Unbound (was 3 Key) -["ACE3 Weapons", QGVAR(SelectLauncherNew), localize LSTRING(SelectLauncher), -{ +["ACE3 Weapons", QGVAR(SelectLauncherNew), localize LSTRING(SelectLauncher), { // Conditions: canInteract if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific @@ -58,10 +54,9 @@ if (!hasInterface) exitWith {}; false }, {false}, -[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 4 Key) +[0, [false, false, false]], false] call CBA_fnc_addKeybind; //Unbound (was 4 Key) -["ACE3 Weapons", QGVAR(SelectBinocularNew), localize LSTRING(SelectBinocular), -{ +["ACE3 Weapons", QGVAR(SelectBinocularNew), localize LSTRING(SelectBinocular), { // Conditions: canInteract if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific @@ -72,38 +67,35 @@ if (!hasInterface) exitWith {}; false }, {false}, -[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 5 Key) +[0, [false, false, false]], false] call CBA_fnc_addKeybind; //Unbound (was 5 Key) -["ACE3 Weapons", QGVAR(SelectGrenadeFrag), localize LSTRING(SelectGrenadeFrag), -{ +["ACE3 Weapons", QGVAR(SelectGrenadeFrag), localize LSTRING(SelectGrenadeFrag), { // Conditions: canInteract if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific if !([ACE_player] call EFUNC(common,canUseWeapon)) exitWith {false}; // Statement - [ACE_player] call FUNC(selectGrenadeFrag); + [ACE_player, 1] call FUNC(selectNextGrenade); true }, {false}, -[7, [false, false, false]], false] call cba_fnc_addKeybind; //6 Key +[7, [false, false, false]], false] call CBA_fnc_addKeybind; //6 Key -["ACE3 Weapons", QGVAR(SelectGrenadeOther), localize LSTRING(SelectGrenadeOther), -{ +["ACE3 Weapons", QGVAR(SelectGrenadeOther), localize LSTRING(SelectGrenadeOther), { // Conditions: canInteract if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific if !([ACE_player] call EFUNC(common,canUseWeapon)) exitWith {false}; // Statement - [ACE_player] call FUNC(selectGrenadeOther); + [ACE_player, 2] call FUNC(selectNextGrenade); true }, {false}, -[8, [false, false, false]], false] call cba_fnc_addKeybind; //7 Key +[8, [false, false, false]], false] call CBA_fnc_addKeybind; //7 Key -["ACE3 Weapons", QGVAR(HolsterWeapon), localize LSTRING(HolsterWeapon), -{ +["ACE3 Weapons", QGVAR(HolsterWeapon), localize LSTRING(HolsterWeapon), { // Conditions: canInteract if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific @@ -125,10 +117,9 @@ if (!hasInterface) exitWith {}; true }, {false}, -[11, [false, false, false]], false] call cba_fnc_addKeybind; //0 Key +[11, [false, false, false]], false] call CBA_fnc_addKeybind; //0 Key -["ACE3 Vehicles", QGVAR(EngineOn), localize LSTRING(EngineOn), -{ +["ACE3 Vehicles", QGVAR(EngineOn), localize LSTRING(EngineOn), { // Conditions: canInteract if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific @@ -139,10 +130,9 @@ if (!hasInterface) exitWith {}; true }, {false}, -[3, [false, false, false]], false] call cba_fnc_addKeybind; //2 Key +[3, [false, false, false]], false] call CBA_fnc_addKeybind; //2 Key -["ACE3 Vehicles", QGVAR(EngineOff), localize LSTRING(EngineOff), -{ +["ACE3 Vehicles", QGVAR(EngineOff), localize LSTRING(EngineOff), { // Conditions: canInteract if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific @@ -153,10 +143,9 @@ if (!hasInterface) exitWith {}; true }, {false}, -[2, [false, false, false]], false] call cba_fnc_addKeybind; //1 Key +[2, [false, false, false]], false] call CBA_fnc_addKeybind; //1 Key -["ACE3 Vehicles", QGVAR(SelectMainGunNew), localize LSTRING(SelectMainGun), -{ +["ACE3 Vehicles", QGVAR(SelectMainGunNew), localize LSTRING(SelectMainGun), { // Conditions: canInteract if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific @@ -167,10 +156,9 @@ if (!hasInterface) exitWith {}; true }, {false}, -[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 3 Key) +[0, [false, false, false]], false] call CBA_fnc_addKeybind; //Unbound (was 3 Key) -["ACE3 Vehicles", QGVAR(SelectMachineGunNew), localize LSTRING(SelectMachineGun), -{ +["ACE3 Vehicles", QGVAR(SelectMachineGunNew), localize LSTRING(SelectMachineGun), { // Conditions: canInteract if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific @@ -181,10 +169,9 @@ if (!hasInterface) exitWith {}; true }, {false}, -[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 4 Key) +[0, [false, false, false]], false] call CBA_fnc_addKeybind; //Unbound (was 4 Key) -["ACE3 Vehicles", QGVAR(SelectMissilesNew), localize LSTRING(SelectMissiles), -{ +["ACE3 Vehicles", QGVAR(SelectMissilesNew), localize LSTRING(SelectMissiles), { // Conditions: canInteract if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific @@ -195,10 +182,9 @@ if (!hasInterface) exitWith {}; true }, {false}, -[0, [false, false, false]], false] call cba_fnc_addKeybind; //Unbound (was 5 Key) +[0, [false, false, false]], false] call CBA_fnc_addKeybind; //Unbound (was 5 Key) -["ACE3 Vehicles", QGVAR(FireSmokeLauncher), localize LSTRING(FireSmokeLauncher), -{ +["ACE3 Vehicles", QGVAR(FireSmokeLauncher), localize LSTRING(FireSmokeLauncher), { // Conditions: canInteract if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific @@ -209,4 +195,4 @@ if (!hasInterface) exitWith {}; true }, {false}, -[10, [false, false, false]], false] call cba_fnc_addKeybind; //9 Key +[10, [false, false, false]], false] call CBA_fnc_addKeybind; //9 Key diff --git a/addons/weaponselect/XEH_preInit.sqf b/addons/weaponselect/XEH_preInit.sqf index 4c5216c2f6..1f324f7fb0 100644 --- a/addons/weaponselect/XEH_preInit.sqf +++ b/addons/weaponselect/XEH_preInit.sqf @@ -2,67 +2,36 @@ ADDON = false; -PREP(countMagazinesForGrenadeMuzzle); PREP(displayGrenadeTypeAndNumber); -PREP(findNextGrenadeMagazine); -PREP(findNextGrenadeMuzzle); PREP(fireSmokeLauncher); -PREP(getSelectedGrenade); PREP(playChangeFiremodeSound); PREP(putWeaponAway); -PREP(selectGrenadeAll); -PREP(selectGrenadeFrag); -PREP(selectGrenadeOther); +PREP(selectNextGrenade); PREP(selectWeaponMode); PREP(selectWeaponMuzzle); PREP(selectWeaponVehicle); -PREP(setNextGrenadeMuzzle); PREP(throwGrenade); -// prepare grenades from config -GVAR(CurrentGrenadeMuzzleIsFrag) = true; -GVAR(CurrentGrenadeMuzzleFrag) = ""; -GVAR(CurrentGrenadeMuzzleOther) = ""; +// collect frag and other grenades separately +GVAR(GrenadesAll) = []; +GVAR(GrenadesFrag) = []; +GVAR(GrenadesNonFrag) = []; -// Collect frag and other muzzles separately -with uiNamespace do { - private ["_magazines", "_magazine", "_ammo", "_explosive"]; - if (isNil QGVAR(FragMuzzles)) then { - GVAR(FragMuzzles) = []; - GVAR(NonFragMuzzles) = []; - GVAR(AllMuzzles) = []; +private ["_magazines", "_ammo", "_explosive"]; - GVAR(FragMagazines) = []; - GVAR(NonFragMagazines) = []; - GVAR(AllMagazines) = []; +{ + _magazines = getArray (configFile >> "CfgWeapons" >> "Throw" >> _x >> "magazines"); - { - _magazines = getArray (configFile >> "CfgWeapons" >> "Throw" >> _x >> "magazines"); - _magazine = _magazines select 0; + GVAR(GrenadesAll) append _magazines; - _ammo = getText (configfile >> "CfgMagazines" >> _magazine >> "ammo"); - _explosive = getNumber (configfile >> "CfgAmmo" >> _ammo >> "explosive"); + { + _ammo = getText (configfile >> "CfgMagazines" >> _x >> "ammo"); + _explosive = getNumber (configfile >> "CfgAmmo" >> _ammo >> "explosive"); - if (_explosive == 0) then { - GVAR(NonFragMuzzles) pushBack _x; - GVAR(NonFragMagazines) pushBack _magazines; - } else { - GVAR(FragMuzzles) pushBack _x; - GVAR(FragMagazines) pushBack _magazines; - }; - - GVAR(AllMuzzles) pushBack _x; - GVAR(AllMagazines) pushBack _magazines; - - } forEach getArray (configfile >> "CfgWeapons" >> "Throw" >> "muzzles"); - }; -}; - -GVAR(FragMuzzles) = uiNamespace getVariable QGVAR(FragMuzzles); -GVAR(NonFragMuzzles) = uiNamespace getVariable QGVAR(NonFragMuzzles); -GVAR(AllMuzzles) = uiNamespace getVariable QGVAR(AllMuzzles); -GVAR(FragMagazines) = uiNamespace getVariable QGVAR(FragMagazines); -GVAR(NonFragMagazines) = uiNamespace getVariable QGVAR(NonFragMagazines); -GVAR(AllMagazines) = uiNamespace getVariable QGVAR(AllMagazines); + ([GVAR(GrenadesFrag), GVAR(GrenadesNonFrag)] select (_explosive == 0)) pushBack _x; + false + } count _magazines; + false +} count getArray (configfile >> "CfgWeapons" >> "Throw" >> "muzzles"); ADDON = true; diff --git a/addons/weaponselect/functions/fnc_countMagazinesForGrenadeMuzzle.sqf b/addons/weaponselect/functions/fnc_countMagazinesForGrenadeMuzzle.sqf deleted file mode 100644 index 572a83edf1..0000000000 --- a/addons/weaponselect/functions/fnc_countMagazinesForGrenadeMuzzle.sqf +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Author: esteldunedain - * Count how many grenade magazines the unit has on the uniform and vest. - * - * Arguments: - * 0: Unit - * 1: Muzzle Class - * - * Return Value: - * 0: Number of magazines - * 1: First magazine name - * - * Example: - * [player, currentMuzzle player] call ace_weaponselect_fnc_countMagazinesForGrenadeMuzzle - * - * Public: No - */ -#include "script_component.hpp" - -private ["_uniformMags", "_vestMags", "_backpackMags", "_numberOfMagazines", "_magazineClasses", "_firstMagazine"]; - -params ["_unit", "_muzzle"]; - -_uniformMags = getMagazineCargo uniformContainer _unit; -_vestMags = getMagazineCargo vestContainer _unit; -_backpackMags = getMagazineCargo backpackContainer _unit; - -_numberOfMagazines = 0; -_magazineClasses = getArray (configFile >> "CfgWeapons" >> "Throw" >> _muzzle >> "magazines"); -_firstMagazine = _magazineClasses select 0; - -{ - private ["_indexInUniform", "_indexInVest", "_indexInBackpack"]; - - _indexInUniform = (_uniformMags select 0) find _x; - if (_indexInUniform > -1) then { - _numberOfMagazines = _numberOfMagazines + ((_uniformMags select 1) select _indexInUniform); - _firstMagazine = _x; - }; - - _indexInVest = (_vestMags select 0) find _x; - if (_indexInVest > -1) then { - _numberOfMagazines = _numberOfMagazines + ((_vestMags select 1) select _indexInVest); - _firstMagazine = _x; - }; - - _indexInBackpack = (_backpackMags select 0) find _x; - if (_indexInBackpack > -1) then { - _numberOfMagazines = _numberOfMagazines + ((_backpackMags select 1) select _indexInBackpack); - _firstMagazine = _x; - }; - -} forEach _magazineClasses; - -[_numberOfMagazines, _firstMagazine] diff --git a/addons/weaponselect/functions/fnc_displayGrenadeTypeAndNumber.sqf b/addons/weaponselect/functions/fnc_displayGrenadeTypeAndNumber.sqf index 37956d2121..6ae945e2fd 100644 --- a/addons/weaponselect/functions/fnc_displayGrenadeTypeAndNumber.sqf +++ b/addons/weaponselect/functions/fnc_displayGrenadeTypeAndNumber.sqf @@ -1,10 +1,10 @@ /* - * Author: esteldunedain + * Author: esteldunedain, commy2 * Display a grenade type and quantity. * * Arguments: - * 0: magazine class - * 1: number of magazines + * 0: grenade magazine class + * 1: number of grenades * * Return Value: * None @@ -18,14 +18,14 @@ if !(GVAR(DisplayText)) exitwith {}; +params ["_magazine", "_numberofGrenades"]; + private ["_color", "_name", "_text", "_picture"]; -params ["_magazine", "_numberofMagazines"]; - -_color = [[1, 0, 0], [1, 1, 1]] select (_numberofMagazines > 0); +_color = [[1, 0, 0], [1, 1, 1]] select (_numberofGrenades > 0); _name = getText (configFile >> "CfgMagazines" >> _magazine >> "displayNameShort"); -_text = [format["%1 x%2", _name, _numberofMagazines], _color] call EFUNC(common,stringToColoredText); +_text = [format ["%1 x%2", _name, _numberofGrenades], _color] call EFUNC(common,stringToColoredText); _picture = getText (configFile >> "CfgMagazines" >> _magazine >> "picture"); -[_text, _picture] call EFUNC(common,displayTextPicture); +["displayTextPicture", [_text, _picture]] call EFUNC(common,localEvent); diff --git a/addons/weaponselect/functions/fnc_findNextGrenadeMagazine.sqf b/addons/weaponselect/functions/fnc_findNextGrenadeMagazine.sqf deleted file mode 100644 index 2b2370260a..0000000000 --- a/addons/weaponselect/functions/fnc_findNextGrenadeMagazine.sqf +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Author: commy2 - * Find the next Grenade Magazine. - * - * Arguments: - * 0: Grenade Type ("All", "Frag", "NonFrag") - * - * Return Value: - * Magazine classname - * - * Example: - * ["All"] call ace_weaponselect_fnc_findNextGrenadeMagazine - * - * Public: No - */ -#include "script_component.hpp" - -private ["_allMags", "_allMuzzles", "_magazines", "_start", "_index", "_nextMagazine"]; - -params ["_type"]; - -_allMags = missionNamespace getVariable [format [QGVAR(%1Magazines), _type], []]; -_allMuzzles = missionNamespace getVariable [format [QGVAR(%1Muzzles), _type], []]; - -_magazines = magazines ACE_player; - -_start = [GVAR(CurrentGrenadeMuzzleOther), GVAR(CurrentGrenadeMuzzleFrag)] select GVAR(CurrentGrenadeMuzzleIsFrag); -_index = _allMuzzles find _start; - -scopeName "SearchMain"; - -_nextMagazine = ""; -for "_index" from (_index + 1) to (count _allMuzzles - 1) do { - { - if (_x in (_allMags select _index)) exitWith {_nextMagazine = _x; breakTo "SearchMain"}; - } count _magazines; -}; - -if (_nextMagazine != "") exitWith {_nextMagazine}; - -for "_index" from 0 to _index do { - { - if (_x in (_allMags select _index)) exitWith {_nextMagazine = _x; breakTo "SearchMain"}; - } count _magazines; -}; - -_nextMagazine diff --git a/addons/weaponselect/functions/fnc_findNextGrenadeMuzzle.sqf b/addons/weaponselect/functions/fnc_findNextGrenadeMuzzle.sqf deleted file mode 100644 index 5aa096f44e..0000000000 --- a/addons/weaponselect/functions/fnc_findNextGrenadeMuzzle.sqf +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Author: commy2 - * Find the next Grenade Muzzle. - * - * Arguments: - * 0: Grenade Type ("All", "Frag", "NonFrag") - * - * Return Value: - * Class name of next throw muzzle - * - * Example: - * ["All"] call ace_weaponselect_fnc_findNextGrenadeMuzzle - * - * Public: No - */ -#include "script_component.hpp" - -private ["_allMags", "_allMuzzles", "_magazines", "_start", "_index", "_nextMuzzle"]; - -params ["_type"]; - -_allMags = missionNamespace getVariable [format [QGVAR(%1Magazines), _type], []]; -_allMuzzles = missionNamespace getVariable [format [QGVAR(%1Muzzles), _type], []]; - -_magazines = magazines ACE_player; - -_start = [GVAR(CurrentGrenadeMuzzleOther), GVAR(CurrentGrenadeMuzzleFrag)] select GVAR(CurrentGrenadeMuzzleIsFrag); -_index = _allMuzzles find _start; - -scopeName "SearchMain"; - -_nextMuzzle = ""; -for "_index" from (_index + 1) to (count _allMuzzles - 1) do { - { - if (_x in (_allMags select _index)) exitWith {_nextMuzzle = _allMuzzles select _index; breakTo "SearchMain"}; - } count _magazines; -}; - -if (_nextMuzzle != "") exitWith {_nextMuzzle}; - -for "_index" from 0 to _index do { - { - if (_x in (_allMags select _index)) exitWith {_nextMuzzle = _allMuzzles select _index; breakTo "SearchMain"}; - } count _magazines; -}; - -_nextMuzzle diff --git a/addons/weaponselect/functions/fnc_fireSmokeLauncher.sqf b/addons/weaponselect/functions/fnc_fireSmokeLauncher.sqf index 20ef674dae..71ef89ecf6 100644 --- a/addons/weaponselect/functions/fnc_fireSmokeLauncher.sqf +++ b/addons/weaponselect/functions/fnc_fireSmokeLauncher.sqf @@ -15,10 +15,10 @@ */ #include "script_component.hpp" -private ["_turret", "_weapons"]; - params ["_vehicle"]; +private ["_turret", "_weapons"]; + _turret = [_vehicle] call EFUNC(common,getTurretCommander); _weapons = _vehicle weaponsTurret _turret; @@ -29,11 +29,10 @@ if ( ) then { //This doesn't work reliably for vehilces with additional weapons for the commander. Select smoke launcher instead. - private "_index"; - // avoid infinite loop if !("SmokeLauncher" in _weapons) exitWith {}; + private "_index"; _index = 0; while { _vehicle currentWeaponTurret _turret != "SmokeLauncher" @@ -46,8 +45,9 @@ if ( // fire away! private "_logic"; - _logic = createGroup sideLogic createUnit ["Logic", [0,0,0], [], 0, "NONE"]; + _logic action ["useWeapon", _vehicle, commander _vehicle, 0]; + deleteVehicle _logic; }; diff --git a/addons/weaponselect/functions/fnc_getSelectedGrenade.sqf b/addons/weaponselect/functions/fnc_getSelectedGrenade.sqf deleted file mode 100644 index aa89a13c98..0000000000 --- a/addons/weaponselect/functions/fnc_getSelectedGrenade.sqf +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Author: commy2 - * Returns the selected Grenade Muzzle. - * - * Arguments: - * None - * - * Return Value: - * Class name of selected throw muzzle - * - * Example: - * [] call ace_weaponselect_fnc_getSelectedGrenade - * - * Public: No - */ -#include "script_component.hpp" - -[GVAR(CurrentGrenadeMuzzleOther), GVAR(CurrentGrenadeMuzzleFrag)] select GVAR(CurrentGrenadeMuzzleIsFrag) diff --git a/addons/weaponselect/functions/fnc_playChangeFiremodeSound.sqf b/addons/weaponselect/functions/fnc_playChangeFiremodeSound.sqf index c79f03c6f2..28ef5d21e5 100644 --- a/addons/weaponselect/functions/fnc_playChangeFiremodeSound.sqf +++ b/addons/weaponselect/functions/fnc_playChangeFiremodeSound.sqf @@ -1,6 +1,6 @@ /* * Author: commy2 - * Play the change firemode sound for specified weapon at units position. + * Play weapon firemode change sound. * * Arguments: * 0: Unit @@ -16,32 +16,24 @@ */ #include "script_component.hpp" -private ["_sound"]; - params ["_unit", "_weapon"]; +private ["_sound", "_position"]; + _sound = getArray (configFile >> "CfgWeapons" >> _weapon >> "changeFiremodeSound"); -if (count _sound == 0) exitWith {}; +if (_sound isEqualTo []) exitWith {}; -// add file extension -if call { - { - if (toLower (_sound select 0) find _x == count toArray (_sound select 0) - count toArray _x - 1) exitWith {false}; - true - } forEach [".wav", ".ogg", ".wss"]; -} then { - _sound set [0, (_sound select 0) + ".wss"]; +// get position where to play the sound (position of the weapon) +_position = AGLToASL (_unit modelToWorldVisual (_unit selectionPosition "RightHand")); + +_sound params ["_filename", ["_volume", 1], ["_soundPitch", 1], ["_distance", 0]]; + +if (_filename == "") exitWith {}; + +// add file extension .wss as default +if !(toLower (_filename select [count _filename - 4]) in [".wav", ".ogg", ".wss"]) then { + _filename = format ["%1.wss", _filename]; }; -// add default volume, pitch and distance -if (count _sound < 2) then {_sound pushBack 1}; -if (count _sound < 3) then {_sound pushBack 1}; -if (count _sound < 4) then {_sound pushBack 0}; - -private "_position"; - -_position = _unit modelToWorldVisual (_unit selectionPosition "RightHand"); -_position set [2, (_position select 2) + ((getPosASLW _unit select 2) - (getPosATL _unit select 2) max 0)]; - -playSound3D [_sound select 0, objNull, false, _position, _sound select 1, _sound select 2, _sound select 3]; +playSound3D [_filename, objNull, false, _position, _volume, _soundPitch, _distance]; diff --git a/addons/weaponselect/functions/fnc_putWeaponAway.sqf b/addons/weaponselect/functions/fnc_putWeaponAway.sqf index faddb4d869..fd1e463a4d 100644 --- a/addons/weaponselect/functions/fnc_putWeaponAway.sqf +++ b/addons/weaponselect/functions/fnc_putWeaponAway.sqf @@ -11,7 +11,7 @@ * Example: * [player] call ace_weaponselect_fnc_putWeaponAway * - * Public: NO + * Public: Yes */ #include "script_component.hpp" diff --git a/addons/weaponselect/functions/fnc_selectGrenadeAll.sqf b/addons/weaponselect/functions/fnc_selectGrenadeAll.sqf deleted file mode 100644 index a68670184a..0000000000 --- a/addons/weaponselect/functions/fnc_selectGrenadeAll.sqf +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Author: esteldunedain, commy2 - * Cycle through all grenades. - * - * Arguments: - * 0: Unit - * - * Return Value: - * None - * - * Example: - * [player] call ace_weaponselect_fnc_selectGrenadeAll - * - * Public: No - */ -#include "script_component.hpp" - -private ["_text", "_nextMuzzle"]; - -params ["_unit"]; - -_nextMuzzle = ["All"] call FUNC(findNextGrenadeMuzzle); - -if (_nextMuzzle != "") then { - - private ["_magazines", "_magazine", "_count", "_return"]; - _magazines = GVAR(AllMagazines) select (GVAR(AllMuzzles) find _nextMuzzle); - reverse _magazines; - - _magazine = ""; - _count = {_return = _x in _magazines; if (_return) then {_magazine = _x}; _return} count magazines _unit; - - // There is a muzzle with magazines --> cycle to it - [_unit, _nextMuzzle] call FUNC(setNextGrenadeMuzzle); - - [_magazine, _count] call FUNC(displayGrenadeTypeAndNumber); - -} else { - // There is a no muzzle with magazines --> select nothing - GVAR(CurrentGrenadeMuzzleFrag) = ""; GVAR(CurrentGrenadeMuzzleOther) = ""; - - if (GVAR(DisplayText)) then { - _text = [localize LSTRING(NoGrenadesLeft), [1,0,0]] call EFUNC(common,stringToColoredText); - [composeText [lineBreak, _text]] call EFUNC(common,displayTextStructured); - }; -}; - -if (_nextMuzzle in GVAR(FragMuzzles)) then { - GVAR(CurrentGrenadeMuzzleFrag) = _nextMuzzle; - GVAR(CurrentGrenadeMuzzleIsFrag) = true; -} else { - GVAR(CurrentGrenadeMuzzleOther) = _nextMuzzle; - GVAR(CurrentGrenadeMuzzleIsFrag) = false; -}; diff --git a/addons/weaponselect/functions/fnc_selectGrenadeFrag.sqf b/addons/weaponselect/functions/fnc_selectGrenadeFrag.sqf deleted file mode 100644 index c221b6cc30..0000000000 --- a/addons/weaponselect/functions/fnc_selectGrenadeFrag.sqf +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Author: esteldunedain, commy2 - * Cycle through frags. - * - * Arguments: - * 0: Unit - * - * Return Value: - * None - * - * Example: - * [player] call ace_weaponselect_fnc_selectGrenadeFrag - * - * Public: No - */ -#include "script_component.hpp" - -private ["_text", "_nextMuzzle"]; - -params ["_unit"]; - -_nextMuzzle = ["Frag"] call FUNC(findNextGrenadeMuzzle); - -if (_nextMuzzle != "") then { - GVAR(CurrentGrenadeMuzzleFrag) = _nextMuzzle; - - private ["_magazines", "_magazine", "_count", "_return"]; - _magazines = GVAR(FragMagazines) select (GVAR(FragMuzzles) find _nextMuzzle); - reverse _magazines; - - _magazine = ""; - _count = {_return = _x in _magazines; if (_return) then {_magazine = _x}; _return} count magazines _unit; - - // There is a muzzle with magazines --> cycle to it - [_unit, _nextMuzzle] call FUNC(setNextGrenadeMuzzle); - - [_magazine, _count] call FUNC(displayGrenadeTypeAndNumber); - -} else { - // There is a no muzzle with magazines --> select nothing - GVAR(CurrentGrenadeMuzzleFrag) = ""; - if (GVAR(DisplayText)) then { - _text = [localize LSTRING(NoFragsLeft), [1,0,0]] call EFUNC(common,stringToColoredText); - [composeText [lineBreak, _text]] call EFUNC(common,displayTextStructured); - }; -}; - -GVAR(CurrentGrenadeMuzzleIsFrag) = true; diff --git a/addons/weaponselect/functions/fnc_selectGrenadeOther.sqf b/addons/weaponselect/functions/fnc_selectGrenadeOther.sqf deleted file mode 100644 index 2f219989eb..0000000000 --- a/addons/weaponselect/functions/fnc_selectGrenadeOther.sqf +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Author: esteldunedain, commy2 - * Cycle through non explosive grenades. - * - * Arguments: - * 0: Unit - * - * Return Value: - * None - * - * Example: - * [player] call ace_weaponselect_fnc_selectGrenadeOther - * - * Public: No - */ -#include "script_component.hpp" - -private ["_nextMuzzle", "_text"]; - -params ["_unit"]; - -_nextMuzzle = ["NonFrag"] call FUNC(findNextGrenadeMuzzle); - -if (_nextMuzzle != "") then { - GVAR(CurrentGrenadeMuzzleOther) = _nextMuzzle; - - private ["_magazines", "_magazine", "_count", "_return"]; - _magazines = GVAR(NonFragMagazines) select (GVAR(NonFragMuzzles) find _nextMuzzle); - reverse _magazines; - - _magazine = ""; - _count = {_return = _x in _magazines; if (_return) then {_magazine = _x}; _return} count magazines _unit; - - // There is a muzzle with magazines --> cycle to it - [_unit, _nextMuzzle] call FUNC(setNextGrenadeMuzzle); - - [_magazine, _count] call FUNC(displayGrenadeTypeAndNumber); - -} else { - // There is a no muzzle with magazines --> select nothing - GVAR(CurrentGrenadeMuzzleOther) = ""; - if (GVAR(DisplayText)) then { - _text = [localize LSTRING(NoMiscGrenadeLeft), [1,0,0]] call EFUNC(common,stringToColoredText); - [composeText [lineBreak, _text]] call EFUNC(common,displayTextStructured); - }; -}; - -GVAR(CurrentGrenadeMuzzleIsFrag) = false; diff --git a/addons/weaponselect/functions/fnc_selectNextGrenade.sqf b/addons/weaponselect/functions/fnc_selectNextGrenade.sqf new file mode 100644 index 0000000000..d4a00b5718 --- /dev/null +++ b/addons/weaponselect/functions/fnc_selectNextGrenade.sqf @@ -0,0 +1,78 @@ +/* + * Author: commy2 + * Select the next grenade. + * + * Arguments: + * 0: Unit + * 1: Grenade type [0: all, 1: frags, 2: non-frags] (default: 0) + * + * Return Value: + * Selecting successful? + * + * Example: + * [player] call ace_weaponselect_fnc_selectNextGrenade + * + * Public: Yes + */ +#include "script_component.hpp" + +params ["_unit", ["_type", 0]]; + +private ["_currentGrenade", "_magazines", "_grenades", "_nextGrenadeIndex", "_nextGrenade", "_uniformGrenades", "_vestGrenades", "_backpackGrenades"]; + +// get currently selected grenade +_currentGrenade = currentThrowable _unit; + +// get correct array format if no grenade is selected +if (_currentGrenade isEqualTo []) then { + _currentGrenade = ["", ""]; +}; + +_currentGrenade = _currentGrenade select 0; + +// get available magazines for that unit +_magazines = magazines _unit; + +_grenades = []; + +{ + if (_x in _magazines) then { + _grenades pushBack _x; + }; + false +} count ([GVAR(GrenadesAll), GVAR(GrenadesFrag), GVAR(GrenadesNonFrag)] select _type); + +// abort if no grenades are available +if (_grenades isEqualTo []) exitWith {false}; + +// get next grenade muzzle +_nextGrenadeIndex = (_grenades find _currentGrenade) + 1; + +// roll over if the last grenade was selected +if (_nextGrenadeIndex >= count _grenades) then { + _nextGrenadeIndex = 0; +}; + +_nextGrenade = _grenades select _nextGrenadeIndex; + +// abort if the same grenade would be selected +if (_currentGrenade == _nextGrenade) exitWith {false}; + +// current best method to select a grenade: remove all grenades except the one you want to select, then add them back +_uniformGrenades = [uniformItems _unit, {_x in GVAR(GrenadesAll) && {_x != _nextGrenade}}] call EFUNC(common,filter); +_vestGrenades = [vestItems _unit, {_x in GVAR(GrenadesAll) && {_x != _nextGrenade}}] call EFUNC(common,filter); +_backpackGrenades = [backpackItems _unit, {_x in GVAR(GrenadesAll) && {_x != _nextGrenade}}] call EFUNC(common,filter); + +// remove all grenades except those we are switching to --> this breaks the selector +{_unit removeItemFromUniform _x; false} count _uniformGrenades; +{_unit removeItemFromVest _x; false} count _vestGrenades; +{_unit removeItemFromBackpack _x; false} count _backpackGrenades; + +// readd grenades +{_unit addItemToUniform _x; false} count _uniformGrenades; +{_unit addItemToVest _x; false} count _vestGrenades; +{_unit addItemToBackpack _x; false} count _backpackGrenades; + +[_nextGrenade, {_x == _nextGrenade} count _magazines] call FUNC(displayGrenadeTypeAndNumber); + +true diff --git a/addons/weaponselect/functions/fnc_setNextGrenadeMuzzle.sqf b/addons/weaponselect/functions/fnc_setNextGrenadeMuzzle.sqf deleted file mode 100644 index ce7ec55393..0000000000 --- a/addons/weaponselect/functions/fnc_setNextGrenadeMuzzle.sqf +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Author: esteldunedain - * Select the next grenade muzzle to throw. - * - * Arguments: - * 0: Unit - * 1: Muzzlename - * - * Return Value: - * None - * - * Example: - * [player, currentMuzzle player] call ace_weaponselect_fnc_setNextGrenadeMuzzle - * - * Public: No - */ -#include "script_component.hpp" - -private ["_uniformMags", "_vestMags", "_backpackMags", "_i", "_uniformMagsToRemove", "_vestMagsToRemove", "_backpackMagsToRemove", "_firstMagazine", "_throwMuzzleNames"]; - -params ["_unit", "_muzzle"]; - -_uniformMags = getMagazineCargo uniformContainer _unit; -_vestMags = getMagazineCargo vestContainer _unit; -_backpackMags = getMagazineCargo backpackContainer _unit; - -_uniformMagsToRemove = []; -_vestMagsToRemove = []; -_backpackMagsToRemove = []; - -_firstMagazine = ""; -_throwMuzzleNames = getArray (configfile >> "CfgWeapons" >> "Throw" >> "muzzles"); - -// Collect which magazines to remove -{ - private "_muzzleMagazines"; - _muzzleMagazines = getArray (configFile >> "CfgWeapons" >> "Throw" >> _x >> "magazines" ); - - if (_x != _muzzle) then { - - { - private "_index"; - _index = (_uniformMags select 0) find _x; - if (_index > -1) then { - _uniformMagsToRemove = _uniformMagsToRemove + [[_x, (_uniformMags select 1) select _index]]; - }; - - _index = (_vestMags select 0) find _x; - if (_index > -1) then { - _vestMagsToRemove = _vestMagsToRemove + [[_x, (_vestMags select 1) select _index]]; - }; - - _index = (_backpackMags select 0) find _x; - if (_index > -1) then { - _backpackMagsToRemove = _backpackMagsToRemove + [[_x, (_backpackMags select 1) select _index]]; - }; - } forEach _muzzleMagazines; - - } else { - - { - private "_index"; - _index = (_uniformMags select 0) find _x; - if (_index > -1) then { - _firstMagazine = _x; - }; - - _index = (_vestMags select 0) find _x; - if (_index > -1) then { - _firstMagazine = _x; - }; - - _index = (_backpackMags select 0) find _x; - if (_index > -1) then { - _firstMagazine = _x; - }; - } forEach _muzzleMagazines; - - }; -} forEach _throwMuzzleNames; - -// Remove all magazines except those we are switching to --> this breaks the selector -{ - for [{_i = 0}, {_i < (_x select 1)}, {_i = _i + 1}] do { - _unit removeItem (_x select 0); - }; -} forEach _uniformMagsToRemove; - -{ - for [{_i = 0}, {_i < (_x select 1)}, {_i = _i + 1}] do { - _unit removeItem (_x select 0); - }; -} forEach _vestMagsToRemove; - -{ - for [{_i = 0}, {_i < (_x select 1)}, {_i = _i + 1}] do { - _unit removeItem (_x select 0); - }; -} forEach _backpackMagsToRemove; - -// Readd magazines -{ - for [{_i = 0}, {_i < (_x select 1)}, {_i = _i + 1}] do { - _unit addItemToUniform (_x select 0); - }; -} forEach _uniformMagsToRemove; - -{ - for [{_i = 0}, {_i < (_x select 1)}, {_i = _i + 1}] do { - _unit addItemToVest (_x select 0); - }; -} forEach _vestMagsToRemove; - -{ - for [{_i = 0}, {_i < (_x select 1)}, {_i = _i + 1}] do { - _unit addItemToBackpack (_x select 0); - }; -} forEach _backpackMagsToRemove; diff --git a/addons/zeus/stringtable.xml b/addons/zeus/stringtable.xml index 71601745f9..46aadce4a2 100644 --- a/addons/zeus/stringtable.xml +++ b/addons/zeus/stringtable.xml @@ -21,7 +21,7 @@ Proporciona controle sobre diversos aspectos do Zeus. Fourni le contrôle des différents aspects de Zeus Különböző beállítási lehetőségeket biztosít a Zeus részeihez. - Обеспечивает контроль над различными аспектами работы Зевса. + Позволяет контролировать различные аспекты Зевса. Ascension Messages @@ -299,4 +299,4 @@ Añadir cualquier objeto creado a todos los directores en la misión - + \ No newline at end of file