Skip to content

Commit

Permalink
Merged main
Browse files Browse the repository at this point in the history
  • Loading branch information
johnb432 committed Feb 8, 2024
2 parents a9bf200 + 1649422 commit 20c4332
Show file tree
Hide file tree
Showing 74 changed files with 2,056 additions and 848 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ CHANGELOG.md
sqfvm.exe
ArmaScriptCompiler.exe
*.sqfc
!extras/**/*.zip
2 changes: 1 addition & 1 deletion addons/advanced_fatigue/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ call FUNC(renderDebugLines);
}, true] call CBA_fnc_addPlayerEventHandler;

// - Duty factors -------------------------------------------------------------
if (["ace_medical"] call EFUNC(common,isModLoaded)) then {
if (GVAR(medicalLoaded)) then {
[QEGVAR(medical,pain), { // 0->1.0, 0.5->1.05, 1->1.1
linearConversion [0, 1, _this getVariable [QEGVAR(medical,pain), 0], 1, 1.1, true];
}] call FUNC(addDutyFactor);
Expand Down
1 change: 1 addition & 0 deletions addons/advanced_fatigue/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ GVAR(dutyList) = createHashMap;
GVAR(setAnimExclusions) = [];
GVAR(inertia) = 0;
GVAR(inertiaCache) = createHashMap;
GVAR(medicalLoaded) = ["ace_medical"] call EFUNC(common,isModLoaded);

ADDON = true;
12 changes: 8 additions & 4 deletions addons/advanced_fatigue/functions/fnc_mainLoop.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ if (isNull objectParent ACE_player && {_currentSpeed > 0.1} && {isTouchingGround
};

// Oxygen calculation
private _oxygen = 1 - 0.131 * GVAR(respiratoryRate) ^ 2;
private _oxygen = 1 - 0.131 * GVAR(respiratoryRate) ^ 2; // Default AF oxygen saturation

if (GVAR(medicalLoaded) && {EGVAR(medical_vitals,simulateSpo2)}) then {
_oxygen = (ACE_player getVariable [QEGVAR(medical,spo2), 97]) / 100;
};

// Calculate muscle damage increase
GVAR(muscleDamage) = GVAR(muscleDamage) + (_currentWork / GVAR(peakPower)) ^ 3.2 * MUSCLE_TEAR_RATE;
Expand Down Expand Up @@ -123,9 +127,9 @@ private _respiratorySampleDivisor = 1 / (RESPIRATORY_BUFFER * 4.72 * GVAR(VO2Max
GVAR(respiratoryRate) = (GVAR(respiratoryRate) + _currentWork * _respiratorySampleDivisor * _aePowerRatio) min 1;

// Calculate a pseudo-perceived fatigue, which is used for effects
private _aeReservePercentage = (GVAR(ae1Reserve) / AE1_MAXRESERVE + GVAR(ae2Reserve) / AE2_MAXRESERVE) / 2;
private _anReservePercentage = GVAR(anReserve) / AN_MAXRESERVE;
private _perceivedFatigue = 1 - (_anReservePercentage min _aeReservePercentage);
GVAR(aeReservePercentage) = (GVAR(ae1Reserve) / AE1_MAXRESERVE + GVAR(ae2Reserve) / AE2_MAXRESERVE) / 2;
GVAR(anReservePercentage) = GVAR(anReserve) / AN_MAXRESERVE;
private _perceivedFatigue = 1 - (GVAR(anReservePercentage) min GVAR(aeReservePercentage));

#ifdef DEBUG_MODE_FULL
systemChat format ["---- muscleDamage: %1 ----", GVAR(muscleDamage) toFixed 8];
Expand Down
9 changes: 9 additions & 0 deletions addons/arsenal/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ call FUNC(compileStats);
EGVAR(common,blockItemReplacement) = false;
}] call CBA_fnc_addEventHandler;

[QGVAR(cargoChanged), {
params ["_display"];
// Only update actions if necessary, this can get performance-intensive using the arrow keys
if (!GVAR(updateActionsOnCargoChange)) exitWith {};
private _actionInfo = [_display];
_actionInfo append GVAR(actionInfo);
[QGVAR(displayActions), _actionInfo] call CBA_fnc_localEvent;
}] call CBA_fnc_addEventHandler;

// Setup Tools tab
[keys (uiNamespace getVariable [QGVAR(configItemsTools), createHashMap]), LLSTRING(toolsTab), TOOLS_TAB_ICON, -1, true] call FUNC(addRightPanelButton);

Expand Down
2 changes: 2 additions & 0 deletions addons/arsenal/defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@
#define IDC_statsNextPage 53
#define IDC_statsCurrentPage 54
#define IDC_actionsBox 90
#define IDC_actionsBackground1 90010
#define IDC_actionsBackground2 90011
#define IDC_actionsText1 9001
#define IDC_actionsButton1 9002
#define IDC_actionsText2 9003
Expand Down
8 changes: 7 additions & 1 deletion addons/arsenal/functions/fnc_addAction.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* 3: Actions <ARRAY of ARRAYS>
* 4: Condition <CODE> (default: {true})
* 5: Scope editor <NUMBER> (default: 2)
* 6: Update when cargo content changes <BOOL> (default: false)
*
* Return Value:
* 0: Array of IDs <ARRAY of STRINGS>
Expand All @@ -30,7 +31,8 @@ params [
["_title", "", [""]],
["_actions", [], [[]]],
["_rootCondition", {true}, [{}]],
["_scopeEditor", 2, [0]]
["_scopeEditor", 2, [0]],
["_updateOnCargoChange", false, [false]]
];

// Compile actions from config (in case this is called before preInit)
Expand Down Expand Up @@ -119,4 +121,8 @@ private _group = [];
};
} forEach _tabs;

if (_updateOnCargoChange) then {
GVAR(updateActionsOnCargoChange) = true;
};

_return
6 changes: 6 additions & 0 deletions addons/arsenal/functions/fnc_compileActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ private _actionList = [

private _configGroupEntries = "true" configClasses (configFile >> QGVAR(actions));

GVAR(updateActionsOnCargoChange) = false;

{
private _scopeEditor = getNumber (_x >> "scopeEditor");

Expand All @@ -48,6 +50,10 @@ private _configGroupEntries = "true" configClasses (configFile >> QGVAR(actions)
private _rootDisplayName = getText (_x >> "displayName");
private _rootCondition = getText (_x >> "condition");
private _rootTabs = getArray (_x >> "tabs");
private _updateOnCargoChanged = getNumber (_x >> "updateOnCargoChanged");
if (_updateOnCargoChanged > 0) then {
GVAR(updateActionsOnCargoChange) = true;
};

if (_rootCondition != "") then {
_rootCondition = compile _rootCondition;
Expand Down
44 changes: 35 additions & 9 deletions addons/arsenal/functions/fnc_handleActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*
* Public: No
*/

params ["_display", "_control", "_curSel", "_itemCfg"];

GVAR(actionsInfo) = [_control, _curSel, _itemCfg];
Expand Down Expand Up @@ -46,13 +45,12 @@ private _groups = (GVAR(actionList) select _panel) select {
};

private _show = _groups isNotEqualTo [];
private _ctrl = _display displayCtrl IDC_actionsBox;
_ctrl ctrlShow _show;
_ctrl ctrlCommit 0.15;
private _actionsBoxCtrl = _display displayCtrl IDC_actionsBox;
_actionsBoxCtrl ctrlShow _show;
_actionsBoxCtrl ctrlCommit 0.15;

if (!_show) exitWith {};

private _actionsBoxCtrl = _display displayCtrl IDC_actionsBox;
private _actionsCurrentPageCtrl = _display displayCtrl IDC_actionsCurrentPage;

private _currentPage = GVAR(currentActionPage);
Expand Down Expand Up @@ -83,10 +81,11 @@ _actionsCurrentPageCtrl ctrlSetFade 0;
_actionsCurrentPageCtrl ctrlShow true;
_actionsCurrentPageCtrl ctrlCommit 0;

private _activeCtrls = [];
{
_x params ["", "_type", "_label", "_statement"];

private _idc = 9001 + _forEachIndex * 2;
private _idc = IDC_actionsText1 + _forEachIndex * 2;
private _actionTextCtrl = _display displayCtrl _idc;
private _actionButtonCtrl = _display displayCtrl (_idc + 1);

Expand All @@ -99,27 +98,49 @@ _actionsCurrentPageCtrl ctrlCommit 0;
[true] call FUNC(refresh);
}] call CBA_fnc_execNextFrame;
}];

if (_activeCtrls isNotEqualTo []) then {
(ctrlPosition (_activeCtrls select -1)) params ["", "_lastPosY", "", "_lastPosH"];
_actionButtonCtrl ctrlSetPositionY (_lastPosY + _lastPosH + GRID_H);
} else {
_actionButtonCtrl ctrlSetPositionY (6 * GRID_H);
};

_actionButtonCtrl ctrlAddEventHandler ["ButtonClick", _statement];
_actionButtonCtrl ctrlSetText _label;
_actionButtonCtrl ctrlSetFade 0;
_actionButtonCtrl ctrlEnable true;
_actionButtonCtrl ctrlCommit 0;
_actionTextCtrl ctrlSetFade 1;
_actionTextCtrl ctrlEnable false;
_actionTextCtrl ctrlCommit 0;
_activeCtrls pushBack _actionButtonCtrl;
};
case ACTION_TYPE_TEXT: {
private _text = call _statement;

if (isNil "_text") then {
_text = "";
};
if (_text isEqualType []) then {
_text = _text joinString endl;
};
if (_activeCtrls isNotEqualTo []) then {
(ctrlPosition (_activeCtrls select -1)) params ["", "_lastPosY", "", "_lastPosH"];
_actionTextCtrl ctrlSetPositionY (_lastPosY + _lastPosH + GRID_H);
} else {
_actionTextCtrl ctrlSetPositionY (5 * GRID_H);
};

_actionTextCtrl ctrlSetText _text;
_actionTextCtrl ctrlSetPositionH (ctrlTextHeight _actionTextCtrl);
_actionTextCtrl ctrlSetFade 0;
_actionTextCtrl ctrlEnable false;
_actionTextCtrl ctrlCommit 0;
_actionButtonCtrl ctrlSetFade 1;
_actionButtonCtrl ctrlEnable false;
_actionButtonCtrl ctrlCommit 0;
_activeCtrls pushBack _actionTextCtrl;
};
default {
_actionTextCtrl ctrlSetFade 1;
Expand All @@ -134,7 +155,7 @@ _actionsCurrentPageCtrl ctrlCommit 0;
private _actionCount = count _items;

{
private _idc = 9001 + _x * 2;
private _idc = IDC_actionsText1 + _x * 2;
private _actionTextCtrl = _display displayCtrl _idc;
private _actionButtonCtrl = _display displayCtrl (_idc + 1);

Expand All @@ -145,6 +166,11 @@ private _actionCount = count _items;
} forEach ([0, 1, 2, 3, 4] select [_actionCount, 5]);

private _pos = ctrlPosition _actionsBoxCtrl;
_pos set [3, ([11, (5 * _actionCount) + 6] select (_actionCount > 0)) * GRID_H];
_actionsBoxCtrl ctrlSetPosition _pos;
(ctrlPosition (_activeCtrls select -1)) params ["", "_lastPosY", "", "_lastPosH"];
private _actionsBoxHeight = _lastPosY + _lastPosH + GRID_H;
_actionsBoxCtrl ctrlSetPositionH _actionsBoxHeight;
_actionsBoxCtrl ctrlCommit 0;

private _background = _display displayCtrl IDC_actionsBackground1;
_background ctrlSetPositionH _actionsBoxHeight;
_background ctrlCommit 0;
9 changes: 5 additions & 4 deletions addons/arsenal/ui/RscAttributes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,22 +450,22 @@ class GVAR(display) {
h = QUOTE(55 * GRID_H);
class controls {
class actionsStaticBackground1: ctrlStaticBackground {
idc = -1;
idc = IDC_actionsBackground1;
x = QUOTE(0);
y = QUOTE(0);
w = QUOTE(47 * GRID_W);
h = QUOTE(56 * GRID_H);
h = QUOTE(55 * GRID_H);
colorBackground[]={0.1,0.1,0.1,0.5};
};
class actionsStaticBackground2: ctrlStaticBackground {
idc = -1;
idc = IDC_actionsBackground2;
x = QUOTE(0);
y = QUOTE(0);
w = QUOTE(47 * GRID_W);
h = QUOTE(5 * GRID_H);
colorBackground[]={0.1,0.1,0.1,0.8};
};
class actionsText1: RscText {
class actionsText1: RscTextMulti {
idc = IDC_actionsText1;
fade = 1;
x = QUOTE(0 * GRID_W);
Expand All @@ -479,6 +479,7 @@ class GVAR(display) {
};
class actionsButton1: ctrlButton {
idc = IDC_actionsButton1;
onMouseEnter = QUOTE(ctrlSetFocus (_this select 0));
fade = 1;
text = "";
x = QUOTE(1 * GRID_W);
Expand Down
14 changes: 14 additions & 0 deletions addons/cargo/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,17 @@ class Extended_PostInit_EventHandlers {
init = QUOTE(call COMPILE_SCRIPT(XEH_postInit));
};
};

class Extended_Killed_EventHandlers {
class CAManBase {
class ADDON {
killed = QUOTE((_this select 0) call FUNC(handleDeployInterrupt));
};
};
};

class Extended_DisplayLoad_EventHandlers {
class RscDisplayMission {
ADDON = QUOTE(_this call COMPILE_SCRIPT(XEH_missionDisplayLoad));
};
};
6 changes: 6 additions & 0 deletions addons/cargo/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ PREP(addCargoItem);
PREP(addCargoVehiclesActions);
PREP(canLoadItemIn);
PREP(canUnloadItem);
PREP(deployCancel);
PREP(deployConfirm);
PREP(getCargoSpaceLeft);
PREP(getNameItem);
PREP(getSelectedItem);
PREP(getSizeItem);
PREP(handleDestroyed);
PREP(handleDeployInterrupt);
PREP(handleScrollWheel);
PREP(initObject);
PREP(initVehicle);
PREP(loadItem);
Expand All @@ -16,6 +21,7 @@ PREP(removeCargoItem);
PREP(renameObject);
PREP(setSize);
PREP(setSpace);
PREP(startDeploy);
PREP(startLoadIn);
PREP(startUnload);
PREP(unloadCarryItem);
Expand Down
11 changes: 11 additions & 0 deletions addons/cargo/XEH_missionDisplayLoad.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "script_component.hpp"

params ["_display"];

_display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}];
_display displayAddEventHandler ["MouseButtonDown", {
// Right clicking cancels deployment
if (_this select 1 == 1) then {
ACE_player call FUNC(handleDeployInterrupt);
};
}];
55 changes: 51 additions & 4 deletions addons/cargo/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
}] call CBA_fnc_addEventHandler;

["ace_unloadCargo", {
params ["_item", "_vehicle", ["_unloader", objNull]];
TRACE_3("UnloadCargo EH",_item,_vehicle,_unloader);
params ["_item", "_vehicle", ["_unloader", objNull], ["_place", []]];
TRACE_4("UnloadCargo EH",_item,_vehicle,_unloader,_place);

private _unloaded = [_item, _vehicle, _unloader] call FUNC(unloadItem); // returns true if successful
private _unloaded = [_item, _vehicle, _unloader, _place] call FUNC(unloadItem); // returns true if successful

// Show hint as feedback
private _hint = [LSTRING(unloadingFailed), LSTRING(unloadedItem)] select _unloaded;
Expand All @@ -36,13 +36,25 @@
};
}] call CBA_fnc_addEventHandler;

// Direction must be set before setting position according to wiki
[QGVAR(setDirAndUnload), {
params ["_item", "_emptyPosAGL", "_direction"];

_item setDir _direction;

[QGVAR(serverUnload), [_item, _emptyPosAGL]] call CBA_fnc_serverEvent;
}] call CBA_fnc_addEventHandler;

// hideObjectGlobal must be executed before setPos to ensure light objects are rendered correctly
// Do both on server to ensure they are executed in the correct order
[QGVAR(serverUnload), {
params ["_item", "_emptyPosAGL"];

_item hideObjectGlobal false;
_item setPosASL (AGLtoASL _emptyPosAGL);

[_item, "blockDamage", QUOTE(ADDON), false] call EFUNC(common,statusEffect_set);
// Let objects remain invulernable for a short while after placement
[EFUNC(common,statusEffect_set), [_item, "blockDamage", QUOTE(ADDON), false], 2] call CBA_fnc_waitAndExecute;
}] call CBA_fnc_addEventHandler;

[QGVAR(paradropItem), {
Expand Down Expand Up @@ -166,3 +178,38 @@ if (isServer) then {
_bodyBag setVariable [QGVAR(customName), [_target, false, true] call EFUNC(common,getName), true];
}] call CBA_fnc_addEventHandler;
};

// Set variables, even on machines without interfaces, just to be safe
GVAR(selectedItem) = objNull;
GVAR(itemPreviewObject) = objNull;
GVAR(deployPFH) = -1;
GVAR(deployDistance) = -1;
GVAR(deployDirection) = 0;
GVAR(deployHeight) = 0;
GVAR(canDeploy) = false;

if (!hasInterface) exitWith {};

// Cancel object deployment if interact menu opened
["ace_interactMenuOpened", {ACE_player call FUNC(handleDeployInterrupt)}] call CBA_fnc_addEventHandler;

// Cancel deploy on player change. This does work when returning to lobby, but not when hard disconnecting
["unit", LINKFUNC(handleDeployInterrupt)] call CBA_fnc_addPlayerEventHandler;
["vehicle", {(_this select 0) call FUNC(handleDeployInterrupt)}] call CBA_fnc_addPlayerEventHandler;
["weapon", {(_this select 0) call FUNC(handleDeployInterrupt)}] call CBA_fnc_addPlayerEventHandler;

// When changing feature cameras, stop deployment
["featureCamera", {(_this select 0) call FUNC(handleDeployInterrupt)}] call CBA_fnc_addPlayerEventHandler;

// Handle falling unconscious while trying to deploy
["ace_unconscious", {(_this select 0) call FUNC(handleDeployInterrupt)}] call CBA_fnc_addEventHandler;

// Handle surrendering and handcuffing
["ace_captiveStatusChanged", {
params ["_unit", "_state"];

// If surrendered or handcuffed, stop deployment
if (_state) then {
_unit call FUNC(handleDeployInterrupt);
};
}] call CBA_fnc_addEventHandler;
Loading

0 comments on commit 20c4332

Please sign in to comment.