Skip to content

Commit

Permalink
Merge branch 'master' into disposable-cleanup-magazine-replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
johnb432 committed Aug 2, 2024
2 parents 1db80c3 + acea974 commit 991ff47
Show file tree
Hide file tree
Showing 19 changed files with 127 additions and 67 deletions.
8 changes: 7 additions & 1 deletion addons/accessory/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include "script_component.hpp"

if (!hasInterface) exitWith {};
ADDON = false;

if (!hasInterface) exitWith {
ADDON = true;
};

#include "XEH_PREP.hpp"

Expand Down Expand Up @@ -41,3 +45,5 @@ GVAR(usageHash) = createHashMap;
false
}
] call CBA_fnc_addItemContextMenuOption;

ADDON = true;
16 changes: 12 additions & 4 deletions addons/common/fnc_canAddItem.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ if (_unit isKindOf "CAManBase") then {
_checkUniform
&& {TYPE_UNIFORM in _allowedSlots}
&& {
private _maxLoad = maxLoad uniformContainer _unit;
if (_maxLoad == 0) exitWith { false };
_mass == 0
|| {
// each time subtract whole number of items which can be put in container
_count = _count - floor (maxLoad uniformContainer _unit * (1 - loadUniform _unit) / _mass);
_count = _count - floor (_maxLoad * (1 - loadUniform _unit) / _mass);
_count <= 0
}
}
Expand All @@ -115,9 +117,11 @@ if (_unit isKindOf "CAManBase") then {
_checkVest
&& {TYPE_VEST in _allowedSlots}
&& {
private _maxLoad = maxLoad vestContainer _unit;
if (_maxLoad == 0) exitWith { false };
_mass == 0
|| {
_count = _count - floor (maxLoad vestContainer _unit * (1 - loadVest _unit) / _mass);
_count = _count - floor (_maxLoad * (1 - loadVest _unit) / _mass);
_count <= 0
}
}
Expand All @@ -127,9 +131,11 @@ if (_unit isKindOf "CAManBase") then {
_checkBackpack
&& {TYPE_BACKPACK in _allowedSlots}
&& {
private _maxLoad = maxLoad backpackContainer _unit;
if (_maxLoad == 0) exitWith { false };
_mass == 0
|| {
_count = _count - floor (maxLoad backpackContainer _unit * (1 - loadBackpack _unit) / _mass);
_count = _count - floor (_maxLoad * (1 - loadBackpack _unit) / _mass);
_count <= 0
}
}
Expand All @@ -138,9 +144,11 @@ if (_unit isKindOf "CAManBase") then {
false
} else {
// is a vehicle, crate etc.
private _maxLoad = maxLoad _unit;
if (_maxLoad == 0) exitWith { false };
_mass == 0
|| {
_count = _count - floor (maxLoad _unit * (1 - load _unit) / _mass);
_count = _count - floor (_maxLoad * (1 - load _unit) / _mass);
_count <= 0
}
};
25 changes: 18 additions & 7 deletions addons/common/fnc_getMuzzles.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,34 @@ Returns:
Examples:
(begin example)
_muzzles = "M4A1_RCO_GL" call CBA_fnc_getMuzzles
-> ["M4_ACOG_Muzzle", "M203Muzzle"]
_muzzles = "arifle_AK12_GL_F" call CBA_fnc_getMuzzles
-> ["arifle_AK12_GL_F","EGLM"]
(end)
Author:
commy2
commy2, johnb43
---------------------------------------------------------------------------- */
SCRIPT(getMuzzles);

params [["_weapon", "", [""]]];

private _muzzles = getArray (configFile >> "CfgWeapons" >> _weapon >> "muzzles");
private _config = configFile >> "CfgWeapons" >> _weapon;

if (!isClass _config) exitWith {
[] // return
};

private _muzzles = [];

// Get config case muzzle names
{
if (_x == "this") then {
_muzzles set [_forEachIndex, _weapon];
_muzzles pushBack (configName _config);
} else {
if (isClass (_config >> _x)) then {
_muzzles pushBack (configName (_config >> _x));
};
};
} forEach _muzzles;
} forEach getArray (_config >> "muzzles");

_muzzles
_muzzles // return
4 changes: 2 additions & 2 deletions addons/common/fnc_uniqueUnitItems.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Function: CBA_fnc_uniqueUnitItems
Description:
Retrievs a unique list of items in the units inventory.
Retrieves a unique list of items in the units inventory.
Parameters:
_unit - Unit to retrieve the items from
Expand All @@ -16,7 +16,7 @@ Parameters:
Example:
(begin example)
_allItems = [player, true, false] call CBA_fnc_uniqueUnitItems
_allItems = [player, true, false] call CBA_fnc_uniqueUnitItems
(end)
Returns:
Expand Down
4 changes: 2 additions & 2 deletions addons/diagnostic/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ GVAR(projectileMaxLines) = 20;
GVAR(projectileStartedDrawing) = false;
GVAR(projectileTrackedUnits) = [];

ADDON = true;

if (getMissionConfigValue ["EnableTargetDebug", 0] == 1 || {getNumber (configFile >> "EnableTargetDebug") == 1}) then {
INFO("EnableTargetDebug is enabled.");

Expand Down Expand Up @@ -71,3 +69,5 @@ if (getMissionConfigValue ["EnableTargetDebug", 0] == 1 || {getNumber (configFil
}];
};
};

ADDON = true;
32 changes: 28 additions & 4 deletions addons/disposable/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ ADDON = false;

#include "initSettings.inc.sqf"

if (configProperties [configFile >> "CBA_DisposableLaunchers"] isEqualTo []) exitWith {};
if (configProperties [configFile >> "CBA_DisposableLaunchers"] isEqualTo []) exitWith {
ADDON = true;
};

#include "XEH_PREP.hpp"

Expand Down Expand Up @@ -36,7 +38,29 @@ private _cfgMagazines = configFile >> "CfgMagazines";
{
private _launcher = configName _x;
private _magazine = configName (_cfgMagazines >> (getArray (_cfgWeapons >> _launcher >> "magazines") select 0));
getArray _x params ["_loadedLauncher", "_usedLauncher"];

if (_magazine == "") then {
ERROR_1("Launcher %1 has an undefined magazine.",_launcher);

continue;
};

(getArray _x) params [["_loadedLauncher", "", [""]], ["_usedLauncher", "", [""]]];

if (_loadedLauncher == "") then {
ERROR_1("Launcher %1 has an undefined loaded launcher.",_launcher);

continue;
};

if (_usedLauncher == "") then {
ERROR_1("Launcher %1 has an undefined used launcher.",_launcher);

continue;
};

private _configLoadedLauncher = _cfgWeapons >> _loadedLauncher;
_loadedLauncher = configName _configLoadedLauncher;

GVAR(LoadedLaunchers) setVariable [_launcher, _loadedLauncher];
GVAR(UsedLaunchers) setVariable [_launcher, _usedLauncher];
Expand All @@ -49,12 +73,12 @@ private _cfgMagazines = configFile >> "CfgMagazines";
GVAR(MagazineLaunchers) setVariable [_magazine, _loadedLauncher];
};

GVAR(allowedSlotsLaunchers) set [_loadedLauncher, getArray (_cfgWeapons >> _loadedLauncher >> "WeaponSlotsInfo" >> "allowedSlots")];
GVAR(allowedSlotsLaunchers) set [_loadedLauncher, getArray (_configLoadedLauncher >> "WeaponSlotsInfo" >> "allowedSlots")];

// check if mass entries add up
private _massLauncher = getNumber (_cfgWeapons >> _launcher >> "WeaponSlotsInfo" >> "mass");
private _massMagazine = getNumber (_cfgMagazines >> _magazine >> "mass");
private _massLoadedLauncher = getNumber (_cfgWeapons >> _loadedLauncher >> "WeaponSlotsInfo" >> "mass");
private _massLoadedLauncher = getNumber (_configLoadedLauncher >> "WeaponSlotsInfo" >> "mass");
private _massUsedLauncher = getNumber (_cfgWeapons >> _usedLauncher >> "WeaponSlotsInfo" >> "mass");

if (_massLauncher != _massUsedLauncher) then {
Expand Down
7 changes: 5 additions & 2 deletions addons/events/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ if (isServer) then {
#include "backwards_comp.inc.sqf"
#include "initSettings.inc.sqf"

ADDON = true;
if (!hasInterface) exitWith {
ADDON = true;
};

if (!hasInterface) exitWith {};
PREP(playerEvent);

GVAR(skipCheckingUserActions) = true;
Expand Down Expand Up @@ -95,3 +96,5 @@ GVAR(alt) = false;
private _states = [];
_states resize 20;
GVAR(userKeyStates) = _states apply {false};

ADDON = true;
36 changes: 22 additions & 14 deletions addons/events/fnc_addPlayerEventHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ Description:
Adds a player event handler.
Possible events:
"unit" - player controlled unit changed
"weapon" - currently selected weapon change
"turretweapon" - currently selected turret weapon change
"muzzle" - currently selected muzzle change
"weaponMode" - currently selected weapon mode change
"loadout" - players loadout changed
"vehicle" - players current vehicle changed
"turret" - position in vehicle changed
"visionMode" - player changed to normal/night/thermal view
"cameraView" - camera mode changed ("Internal", "External", "Gunner" etc.)
"featureCamera" - camera changed (Curator, Arsenal, Spectator etc.)
"visibleMap" - opened or closed map
"group" - player group changes
"leader" - leader of player changes
"unit" - player controlled unit changed
"weapon" - currently selected weapon change
"turretweapon" - currently selected turret weapon change
"muzzle" - currently selected muzzle change
"weaponMode" - currently selected weapon mode change
"loadout" - players loadout changed
"vehicle" - players current vehicle changed
"turret" - position in vehicle changed
"turretOpticsMode" - turret zoom (FOV) changed
"visionMode" - player changed to normal/night/thermal view
"cameraView" - camera mode changed ("Internal", "External", "Gunner" etc.)
"featureCamera" - camera changed (Curator, Arsenal, Spectator etc.)
"visibleMap" - opened or closed map
"group" - player group changes
"leader" - leader of player changes
Parameters:
_type - Event handler type. <STRING>
Expand Down Expand Up @@ -103,6 +104,12 @@ private _id = switch (_type) do {
};
[QGVAR(turretEvent), _function] call CBA_fnc_addEventHandler // return id
};
case "turretopticsmode": {
if (_applyRetroactively) then {
[GVAR(oldUnit), getTurretOpticsMode GVAR(oldUnit), -1] call _function;
};
[QGVAR(turretOpticsModeEvent), _function] call CBA_fnc_addEventHandler;
};
case "visionmode": {
if (_applyRetroactively) then {
[GVAR(oldUnit), currentVisionMode GVAR(oldUnit), -1] call _function;
Expand Down Expand Up @@ -158,6 +165,7 @@ if (_id != -1) then {
GVAR(oldLoadoutNoAmmo) = [];
GVAR(oldVehicle) = objNull;
GVAR(oldTurret) = [];
GVAR(oldTurretOpticsMode) = -1;
GVAR(oldVisionMode) = -1;
GVAR(oldCameraView) = "";
GVAR(oldFeatureCamera) = "";
Expand Down
22 changes: 7 additions & 15 deletions addons/events/fnc_playerEvent.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,14 @@ SCRIPT(playerEvent);
private _unit = missionNamespace getVariable ["bis_fnc_moduleRemoteControl_unit", player];
private _vehicle = vehicle _unit;

private _controlledEntity = _unit;
if (!isNull getConnectedUAV _unit) then {
private _uavControl = UAVControl getConnectedUAV _unit;
_uavControl = _uavControl param [(_uavControl find _unit) + 1, ""]; // Will be position STRING if actively controlling, or OBJECT if not.
if (_uavControl isEqualTo "DRIVER") exitWith {
_controlledEntity = driver getConnectedUAV _unit;
};

if (_uavControl isEqualTo "GUNNER") exitWith {
_controlledEntity = gunner getConnectedUAV _unit;
};
};

// Unlike CBA_fnc_turretPath, this will return [-1] when player is driver
private _turret = _vehicle unitTurret _unit;

private _state = [
_unit, group _unit, leader _unit,
currentWeapon _unit, currentMuzzle _unit, currentWeaponMode _unit,
getUnitLoadout _unit, _vehicle, _turret, _vehicle currentWeaponTurret _turret,
currentVisionMode _controlledEntity, cameraView
currentVisionMode focusOn, cameraView, getTurretOpticsMode _unit
];

if (_state isNotEqualTo GVAR(oldState)) then {
Expand All @@ -54,7 +41,7 @@ if (_state isNotEqualTo GVAR(oldState)) then {
"", "_newGroup", "_newLeader",
"_newWeapon", "_newMuzzle", "_newWeaponMode",
"_newLoadout", "", "", "_newTurretWeapon",
"_newVisionMode", "_newCameraView"
"_newVisionMode", "_newCameraView", "_newTurretOpticsMode"
];

// These events should fire if the context of the state has changed.
Expand Down Expand Up @@ -137,4 +124,9 @@ if (_state isNotEqualTo GVAR(oldState)) then {
[QGVAR(cameraViewEvent), [_unit, _newCameraView, GVAR(oldCameraView)]] call CBA_fnc_localEvent;
GVAR(oldCameraView) = _newCameraView; // This assignment may be returned.
};

if (_newTurretOpticsMode isNotEqualTo GVAR(oldTurretOpticsMode)) then {
[QGVAR(turretOpticsModeEvent), [_unit, _newTurretOpticsMode, GVAR(oldTurretOpticsMode)]] call CBA_fnc_localEvent;
GVAR(oldTurretOpticsMode) = _newTurretOpticsMode;
};
};
6 changes: 4 additions & 2 deletions addons/help/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//#define DEBUG_MODE_FULL
#include "script_component.hpp"

if (!hasInterface) exitWith {};

ADDON = false;

if (!hasInterface) exitWith {
ADDON = true;
};

// bwc
FUNC(help) = BIS_fnc_help;

Expand Down
8 changes: 5 additions & 3 deletions addons/keybinding/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#include "script_component.hpp"
SCRIPT(XEH_preInit);

if (!hasInterface) exitWith {};
ADDON = false;

#include "XEH_PREP.hpp"
if (!hasInterface) exitWith {
ADDON = true;
};

ADDON = false;
#include "XEH_PREP.hpp"

// Load DIK to string conversion table.
with uiNamespace do {
Expand Down
2 changes: 1 addition & 1 deletion addons/keybinding/fnc_gui_editKey.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ _ctrlButtonUndo ctrlAddEventHandler ["ButtonClick", {
}];

// --- update parent display if this one is closed
_display displayAddEventHandler ["unload", {
_display displayAddEventHandler ["Unload", {
[] call FUNC(gui_update);
}];

Expand Down
2 changes: 1 addition & 1 deletion addons/main/script_mod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define VERSION_AR MAJOR,MINOR,PATCHLVL,BUILD

// MINIMAL required version for the Mod. Components can specify others..
#define REQUIRED_VERSION 2.14
#define REQUIRED_VERSION 2.16

/*
// Defined DEBUG_MODE_NORMAL in a few CBA_fncs to prevent looped logging :)
Expand Down
8 changes: 6 additions & 2 deletions addons/optics/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ ADDON = false;

if (configProperties [configFile >> "CBA_PIPItems"] isEqualTo [] && {
configProperties [configFile >> "CBA_CarryHandleTypes"] isEqualTo []
}) exitWith {};
}) exitWith {
ADDON = true;
};

#include "XEH_PREP.hpp"

if (!hasInterface) exitWith {};
if (!hasInterface) exitWith {
ADDON = true;
};

#include "initKeybinds.inc.sqf"

Expand Down
Loading

0 comments on commit 991ff47

Please sign in to comment.