Skip to content

Commit

Permalink
Merge branch 'master' of github.com:acemod/ACE3
Browse files Browse the repository at this point in the history
  • Loading branch information
thojkooi committed May 21, 2016
2 parents 54caadf + f69142d commit 7f8bfa0
Show file tree
Hide file tree
Showing 23 changed files with 111 additions and 79 deletions.
28 changes: 27 additions & 1 deletion addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ GVAR(OldPlayerVehicle) = vehicle objNull;
GVAR(OldPlayerTurret) = [objNull] call FUNC(getTurretIndex);
GVAR(OldPlayerWeapon) = currentWeapon objNull;
GVAR(OldPlayerInventory) = [];
GVAR(OldPlayerInventoryNoAmmo) = [];
GVAR(OldPlayerVisionMode) = currentVisionMode objNull;
GVAR(OldCameraView) = "";
GVAR(OldVisibleMap) = false;
Expand Down Expand Up @@ -385,7 +386,32 @@ GVAR(OldIsCamera) = false;
if !(_data isEqualTo GVAR(OldPlayerInventory)) then {
// Raise ACE event locally
GVAR(OldPlayerInventory) = _data;
["playerInventoryChanged", [ACE_player, _data]] call FUNC(localEvent);

// we don't want to trigger this just because your ammo counter decreased.
_data = + GVAR(OldPlayerInventory);

private _weaponInfo = _data param [0, []];
if !(_weaponInfo isEqualTo []) then {
_weaponInfo set [4, primaryWeaponMagazine ACE_player];
_weaponInfo deleteAt 5;
};

_weaponInfo = _data param [1, []];
if !(_weaponInfo isEqualTo []) then {
_weaponInfo set [4, secondaryWeaponMagazine ACE_player];
_weaponInfo deleteAt 5;
};

_weaponInfo = _data param [2, []];
if !(_weaponInfo isEqualTo []) then {
_weaponInfo set [4, handgunMagazine ACE_player];
_weaponInfo deleteAt 5;
};

if !(_data isEqualTo GVAR(OldPlayerInventoryNoAmmo)) then {
GVAR(OldPlayerInventoryNoAmmo) = _data;
["playerInventoryChanged", [ACE_player, [ACE_player, false] call FUNC(getAllGear)]] call FUNC(localEvent);
};
};

// "playerVisionModeChanged" event
Expand Down
2 changes: 2 additions & 0 deletions addons/common/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ if (isServer) then {
GVAR(statusEffect_Names) = [];
GVAR(statusEffect_isGlobal) = [];

GVAR(setHearingCapabilityMap) = [];

//////////////////////////////////////////////////
// Set up PlayerChanged eventhandler for pre init (EH is installed in postInit)
//////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions addons/common/functions/fnc_assignedItemFix.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ GVAR(AssignedItemsShownItems) = [
];

["playerInventoryChanged", {
params ["_unit", "_assignedItems"];
params ["_unit"];

_assignedItems = _assignedItems param [9, ["","","","","",""]]; // ["ItemMap","ItemGPS","ItemRadio","ItemCompass","ItemWatch","NVGoggles"]
private _assignedItems = getUnitLoadout _unit param [9, ["","","","","",""]]; // ["ItemMap","ItemGPS","ItemRadio","ItemCompass","ItemWatch","NVGoggles"]

GVAR(AssignedItemsShownItems) = [
!((_assignedItems select 0) isEqualTo "") && {getText (configFile >> "CfgWeapons" >> _assignedItems select 0 >> "ACE_hideItemType") != "map"},
Expand Down
6 changes: 4 additions & 2 deletions addons/common/functions/fnc_getAllGear.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@
*/
#include "script_component.hpp"

ACE_DEPRECATED("ace_common_fnc_getAllGear","3.7.0","getUnitLoadout");
params ["_unit", ["_showDeprecated", true]];

params ["_unit"];
if (_showDeprecated) then {
ACE_DEPRECATED("ace_common_fnc_getAllGear","3.7.0","getUnitLoadout");
};

if (isNull _unit) exitWith {[
"",
Expand Down
42 changes: 19 additions & 23 deletions addons/common/functions/fnc_setHearingCapability.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,45 @@
* Arguments:
* 0: id <STRING>
* 1: settings <NUMBER>
* 2: add (default: true) <BOOL>
* 2: add [true] OR remove [false] (default: true) <BOOL>
*
* Return Value:
* None
*
* Public: Yes
* Example:
* ["earwax", 0.5, true] call ace_common_fnc_setHearingCapability
*
* Note: uses player
* Public: Yes
*/
#include "script_component.hpp"

params ["_id", "_settings", ["_add", true]];

private _map = missionNamespace getVariable [QGVAR(setHearingCapabilityMap),[]];
params ["_id", "_setting", ["_add", true]];

private _exists = false;
private _lowestVolume = 1;

{
if (_id == _x select 0) exitWith {
GVAR(setHearingCapabilityMap) = GVAR(setHearingCapabilityMap) select {
_x params ["_xID", "_xSetting"];
if (_id == _xID) then {
_exists = true;
if (_add) then {
_x set [1, _settings];
_x set [1, _setting];
_lowestVolume = _lowestVolume min _setting;
true
} else {
_map set [_forEachIndex, 0];
_map = _map - [0];
false
};
} else {
_lowestVolume = _lowestVolume min _xSetting;
true
};
} forEach _map;
};

if (!_exists && _add) then {
_map pushBack [_id, _settings];
_lowestVolume = _lowestVolume min _setting;
GVAR(setHearingCapabilityMap) pushBack [_id, _setting];
};

missionNamespace setVariable [QGVAR(setHearingCapabilityMap), _map];

// find lowest volume
private _lowestVolume = 1;

{
_lowestVolume = (_x select 1) min _lowestVolume;
false
} count _map;

// in game sounds
0 fadeSound _lowestVolume;
0 fadeRadio _lowestVolume;
Expand Down
1 change: 1 addition & 0 deletions addons/fcs/functions/fnc_adjustRange.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ private _min = getNumber (_turretConfig >> QGVAR(MinDistance));
private _max = getNumber (_turretConfig >> QGVAR(MaxDistance));

private _distance = _vehicle getVariable [format ["%1_%2", QGVAR(Distance), _turret], _min];
TRACE_4("",_distance,_delta,_min,_max);

_distance = _distance + _delta;
_distance = _distance min _max;
Expand Down
1 change: 1 addition & 0 deletions addons/fcs/functions/fnc_calculateSolution.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
#include "script_component.hpp"
params ["_vehicle","_turret","_distance","_angleTarget"];
TRACE_4("params",_vehicle,_turret,_distance,_angleTarget);

private _FCSMagazines = [];
private _FCSElevation = [];
Expand Down
6 changes: 5 additions & 1 deletion addons/fcs/functions/fnc_canUseFCS.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
* Return Value:
* Boolean <BOOL>
*
* Example:
* [] call ace_fcs_fnc_canUseFCS
*
* Public: No
*/
#include "script_component.hpp"

getNumber ([configFile >> "CfgVehicles" >> typeOf vehicle ACE_player, [ACE_player] call EFUNC(common,getTurretIndex)] call EFUNC(common,getTurretConfigPath) >> QGVAR(Enabled)) == 1
&& {cameraView == "GUNNER"} // return
&& {cameraView == "GUNNER"}
&& {!([ACE_player] call CBA_fnc_canUseWeapon)} //Not Turned Out
3 changes: 3 additions & 0 deletions addons/fcs/functions/fnc_keyUp.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "script_component.hpp"

params ["_vehicle", "_turret", "_distance", ["_showHint", false], ["_playSound", true]];
TRACE_5("params",_vehicle,_turret,_distance,_showHint,_playSound);

private _turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret] call EFUNC(common,getTurretConfigPath);

Expand All @@ -23,6 +24,8 @@ if (isNil "_distance") then {
getNumber (_turretConfig >> QGVAR(MaxDistance)),
getNumber (_turretConfig >> QGVAR(MinDistance))
] call FUNC(getRange);
} else {
((uiNamespace getVariable ["ACE_dlgRangefinder", displayNull]) displayCtrl 1713151) ctrlSetText ([_distance, 4, 0] call CBA_fnc_formatNumber);
};

// MOVING TARGETS
Expand Down
6 changes: 4 additions & 2 deletions addons/goggles/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ GVAR(surfaceCacheIsDust) = false;
GVAR(OldGlasses) = "<null>";

["playerInventoryChanged", {
private _currentGlasses = (_this select 1) param [7, ""];
params ["_unit"];

private _currentGlasses = goggles _unit;

if (GVAR(OldGlasses) != _currentGlasses) then {
["GlassesChanged", [ACE_player, _currentGlasses]] call EFUNC(common,localEvent);
["GlassesChanged", [_unit, _currentGlasses]] call EFUNC(common,localEvent);
GVAR(OldGlasses) = _currentGlasses;
};
}] call EFUNC(common,addEventHandler);
Expand Down
16 changes: 0 additions & 16 deletions addons/hearing/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,6 @@ class Extended_Init_EventHandlers {
};
};

class Extended_FiredNear_EventHandlers {
class AllVehicles {
class GVAR(FiredNear) {
clientFiredNear = QUOTE(_this call FUNC(firedNear););
};
};
};

class Extended_Explosion_EventHandlers {
class CAManBase {
class GVAR(ExplosionNear) {
clientExplosion = QUOTE(_this call FUNC(explosionNear););
};
};
};

class Extended_Respawn_EventHandlers {
class CAManBase {
class ADDON {
Expand Down
4 changes: 4 additions & 0 deletions addons/hearing/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ GVAR(volumeAttenuation) = 1;
// Only run PFEH and install event handlers if combat deafness is enabled
if (!GVAR(EnableCombatDeafness)) exitWith {};

//Add XEH:
["CAManBase", "FiredNear", FUNC(firedNear)] call CBA_fnc_addClassEventHandler;
["CAManBase", "Explosion", FUNC(explosionNear)] call CBA_fnc_addClassEventHandler;

// Update hearing protection now:
[] call FUNC(updateHearingProtection);

Expand Down
3 changes: 0 additions & 3 deletions addons/hearing/functions/fnc_explosionNear.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
*/
#include "script_component.hpp"

// Only run if combat deafness is enabled
if (!GVAR(EnableCombatDeafness)) exitWith {};

params ["_unit", "_damage"];

if (_unit != ACE_player) exitWith {};
Expand Down
3 changes: 0 additions & 3 deletions addons/hearing/functions/fnc_firedNear.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
*/
#include "script_component.hpp"

// Only run if combat deafness is enabled
if (!GVAR(EnableCombatDeafness)) exitWith {};

params ["_object", "_firer", "_distance", "_weapon", "", "", "_ammo"];

//Only run if firedNear object is player or player's vehicle:
Expand Down
13 changes: 7 additions & 6 deletions addons/hearing/functions/fnc_updateVolume.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
*/
#include "script_component.hpp"

if (!alive ACE_player) exitWith {
if (missionNameSpace getVariable [QGVAR(disableVolumeUpdate), false]) exitWith {};
TRACE_1("dead - removing hearing effects",ACE_player);
[QUOTE(ADDON), 1, true] call EFUNC(common,setHearingCapability);
};

(_this select 0) params ["_justUpdateVolume"];

GVAR(deafnessDV) = (GVAR(deafnessDV) min 20) max 0;
Expand Down Expand Up @@ -54,9 +60,4 @@ if (ACE_player getVariable ["ACE_isUnconscious", false]) then {
_volume = _volume min GVAR(UnconsciousnessVolume);
};

private _soundTransitionTime = if (_justUpdateVolume) then {0.1} else {1};

_soundTransitionTime fadeSound _volume;
_soundTransitionTime fadeSpeech _volume;
ACE_player setVariable ["tf_globalVolume", _volume];
if (!isNil "acre_api_fnc_setGlobalVolume") then {[_volume^(0.33)] call acre_api_fnc_setGlobalVolume;};
[QUOTE(ADDON), _volume, true] call EFUNC(common,setHearingCapability);
4 changes: 0 additions & 4 deletions addons/medical/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,15 @@ if (isServer) then {["placedInBodyBag", FUNC(serverRemoveBody)] call EFUNC(commo
params ["_unit", "_status"];
if (local _unit) then {
if (_status) then {
_unit setVariable ["tf_globalVolume", 0.4];
_unit setVariable ["tf_voiceVolume", 0, true];
_unit setVariable ["tf_unable_to_use_radio", true, true];

_unit setVariable ["acre_sys_core_isDisabled", true, true];
if (!isNil "acre_api_fnc_setGlobalVolume") then { [0.4^0.33] call acre_api_fnc_setGlobalVolume; };
} else {
_unit setVariable ["tf_globalVolume", 1];
_unit setVariable ["tf_voiceVolume", 1, true];
_unit setVariable ["tf_unable_to_use_radio", false, true];

_unit setVariable ["acre_sys_core_isDisabled", false, true];
if (!isNil "acre_api_fnc_setGlobalVolume") then { [1] call acre_api_fnc_setGlobalVolume; };
};
};
}] call EFUNC(common,addEventHandler);
Expand Down
Loading

0 comments on commit 7f8bfa0

Please sign in to comment.