diff --git a/addons/advanced_ballistics/functions/fnc_displayProtractor.sqf b/addons/advanced_ballistics/functions/fnc_displayProtractor.sqf index 1f7e2ecde7..5ad6cb111e 100644 --- a/addons/advanced_ballistics/functions/fnc_displayProtractor.sqf +++ b/addons/advanced_ballistics/functions/fnc_displayProtractor.sqf @@ -28,7 +28,7 @@ if (currentWeapon ACE_player != primaryWeapon ACE_player) exitWith { false }; 2 cutText ["", "PLAIN"]; EGVAR(weather,WindInfo) = false; -0 cutText ["", "PLAIN"]; +(["RscWindIntuitive"] call BIS_fnc_rscLayer) cutText ["", "PLAIN"]; GVAR(Protractor) = true; [{ diff --git a/addons/attach/functions/fnc_attach.sqf b/addons/attach/functions/fnc_attach.sqf index 6362edb33c..305c3c0960 100644 --- a/addons/attach/functions/fnc_attach.sqf +++ b/addons/attach/functions/fnc_attach.sqf @@ -49,7 +49,7 @@ if (_unit == _attachToVehicle) then { //Self Attachment } else { GVAR(placeAction) = PLACE_WAITING; - [_unit, QGVAR(vehAttach), true] call EFUNC(common,setForceWalkStatus); + [_unit, "forceWalk", "ACE_Attach", true] call EFUNC(common,statusEffect_set); [{[localize LSTRING(PlaceAction), ""] call EFUNC(interaction,showMouseHint)}, []] call EFUNC(common,execNextFrame); _unit setVariable [QGVAR(placeActionEH), [_unit, "DefaultAction", {true}, {GVAR(placeAction) = PLACE_APPROVE;}] call EFUNC(common,AddActionEventHandler)]; @@ -88,7 +88,7 @@ if (_unit == _attachToVehicle) then { //Self Attachment {!([_attachToVehicle, _unit, _itemClassname] call FUNC(canAttach))}) then { [_idPFH] call CBA_fnc_removePerFrameHandler; - [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); + [_unit, "forceWalk", "ACE_Attach", false] call EFUNC(common,statusEffect_set); [] call EFUNC(interaction,hideMouseHint); [_unit, "DefaultAction", (_unit getVariable [QGVAR(placeActionEH), -1])] call EFUNC(common,removeActionEventHandler); _unit removeAction _actionID; diff --git a/addons/captives/functions/fnc_handleRespawn.sqf b/addons/captives/functions/fnc_handleRespawn.sqf index 7e97501576..bdd4915d68 100644 --- a/addons/captives/functions/fnc_handleRespawn.sqf +++ b/addons/captives/functions/fnc_handleRespawn.sqf @@ -40,12 +40,12 @@ if (_respawn > 3) then { if (_unit getVariable [QGVAR(isHandcuffed), false]) then { [_unit, false] call FUNC(setHandcuffed); }; - [_unit, QGVAR(Handcuffed), false] call EFUNC(common,setCaptivityStatus); + [_unit, "setCaptive", QGVAR(Handcuffed), false] call EFUNC(common,statusEffect_set); if (_unit getVariable [QGVAR(isSurrendering), false]) then { [_unit, false] call FUNC(setSurrendered); }; - [_unit, QGVAR(Surrendered), false] call EFUNC(common,setCaptivityStatus); + [_unit, "setCaptive", QGVAR(Surrendered), false] call EFUNC(common,statusEffect_set); if (_oldUnit getVariable [QGVAR(isEscorting), false]) then { _oldUnit setVariable [QGVAR(isEscorting), false, true]; diff --git a/addons/captives/functions/fnc_setHandcuffed.sqf b/addons/captives/functions/fnc_setHandcuffed.sqf index 1e686ea849..0a17e0378c 100644 --- a/addons/captives/functions/fnc_setHandcuffed.sqf +++ b/addons/captives/functions/fnc_setHandcuffed.sqf @@ -28,7 +28,7 @@ if ((_unit getVariable [QGVAR(isHandcuffed), false]) isEqualTo _state) exitWith if (_state) then { _unit setVariable [QGVAR(isHandcuffed), true, true]; - [_unit, QGVAR(Handcuffed), true] call EFUNC(common,setCaptivityStatus); + [_unit, "setCaptive", QGVAR(Handcuffed), true] call EFUNC(common,statusEffect_set); if (_unit getVariable [QGVAR(isSurrendering), false]) then { //If surrendering, stop [_unit, false] call FUNC(setSurrendered); @@ -89,7 +89,7 @@ if (_state) then { }, [_unit], 0.01] call EFUNC(common,waitAndExecute); } else { _unit setVariable [QGVAR(isHandcuffed), false, true]; - [_unit, QGVAR(Handcuffed), false] call EFUNC(common,setCaptivityStatus); + [_unit, "setCaptive", QGVAR(Handcuffed), false] call EFUNC(common,statusEffect_set); //remove AnimChanged EH private _animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1]; diff --git a/addons/captives/functions/fnc_setSurrendered.sqf b/addons/captives/functions/fnc_setSurrendered.sqf index aa65c1273d..e65bd86bd0 100644 --- a/addons/captives/functions/fnc_setSurrendered.sqf +++ b/addons/captives/functions/fnc_setSurrendered.sqf @@ -33,7 +33,7 @@ if (_state) then { _unit setVariable [QGVAR(isSurrendering), true, true]; - [_unit, QGVAR(Surrendered), true] call EFUNC(common,setCaptivityStatus); + [_unit, "setCaptive", QGVAR(Surrendered), true] call EFUNC(common,statusEffect_set); if (_unit == ACE_player) then { ["captive", [false, false, false, false, false, false, false, false]] call EFUNC(common,showHud); @@ -65,7 +65,7 @@ if (_state) then { }, [_unit], 0.01] call EFUNC(common,waitAndExecute); } else { _unit setVariable [QGVAR(isSurrendering), false, true]; - [_unit, QGVAR(Surrendered), false] call EFUNC(common,setCaptivityStatus); + [_unit, "setCaptive", QGVAR(Surrendered), false] call EFUNC(common,statusEffect_set); //remove AnimChanged EH private _animChangedEHID = _unit getVariable [QGVAR(surrenderAnimEHID), -1]; diff --git a/addons/common/CfgEventHandlers.hpp b/addons/common/CfgEventHandlers.hpp index bea7b6e7bc..55a1df4c7c 100644 --- a/addons/common/CfgEventHandlers.hpp +++ b/addons/common/CfgEventHandlers.hpp @@ -23,9 +23,6 @@ class Extended_InitPost_EventHandlers { class GVAR(setName) { init = QUOTE(if (local (_this select 0)) then {_this call FUNC(setName)};); }; - class GVAR(forceWalk) { - init = QUOTE(_this call FUNC(applyForceWalkStatus)); - }; class GVAR(muteUnit) { init = QUOTE(_this call FUNC(muteUnitHandleInitPost)); }; @@ -43,6 +40,9 @@ class Extended_Respawn_EventHandlers { class GVAR(RESETDefaults) { respawn = QUOTE(_this call FUNC(resetAllDefaults)); }; + class GVAR(statusEffect) { + respawn = QUOTE(_this call FUNC(statusEffect_respawnEH)); + }; }; class CAManBase { class GVAR(muteUnit) { @@ -50,3 +50,12 @@ class Extended_Respawn_EventHandlers { }; }; }; + +class Extended_Local_EventHandlers { + class All { + class GVAR(statusEffect) { + local = QUOTE(_this call FUNC(statusEffect_localEH)); + }; + }; +}; + diff --git a/addons/common/CfgLocationTypes.hpp b/addons/common/CfgLocationTypes.hpp new file mode 100644 index 0000000000..8ff7ba8674 --- /dev/null +++ b/addons/common/CfgLocationTypes.hpp @@ -0,0 +1,16 @@ +//Create a location type that won't be drawn on the map +//Ref: https://community.bistudio.com/wiki/Location + +class CfgLocationTypes { + class ACE_HashLocation { + color[] = {0,0,0,0}; + drawStyle = "bananas"; + font = "PuristaMedium"; + importance = 5; + name = "HashLocation"; + shadow = 0; + size = 0; + textSize = 0.0; + texture = ""; + }; +}; diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 22cf7a944e..65b9804da5 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -1,5 +1,6 @@ // ACE - Common // #define ENABLE_PERFORMANCE_COUNTERS +// #define DEBUG_MODE_FULL #include "script_component.hpp" @@ -57,6 +58,39 @@ // Eventhandlers ////////////////////////////////////////////////// +//Status Effect EHs: +["setStatusEffect", {_this call FUNC(statusEffect_set)}] call FUNC(addEventHandler); +["forceWalk", false, ["ACE_SwitchUnits", "ACE_Attach", "ACE_dragging", "ACE_Explosives", "ACE_Ladder", "ACE_Sandbag", "ACE_refuel", "ACE_rearm", "ACE_dragging"]] call FUNC(statusEffect_addType); +["blockSprint", false, []] call FUNC(statusEffect_addType); +["setCaptive", true, [QEGVAR(captives,Handcuffed), QEGVAR(captives,Surrendered), QEGVAR(medical,unconscious)]] call FUNC(statusEffect_addType); +["blockDamage", false, ["fixCollision"]] call FUNC(statusEffect_addType); + +["forceWalk", { + params ["_object", "_set"]; + TRACE_2("forceWalk EH",_object,_set); + _object forceWalk (_set > 0); +}] call FUNC(addEventHandler); +["blockSprint", { //Name reversed from `allowSprint` because we want NOR logic + params ["_object", "_set"]; + TRACE_2("blockSprint EH",_object,_set); + _object allowSprint (_set == 0); +}] call FUNC(addEventHandler); +["setCaptive", { + params ["_object", "_set"]; + TRACE_2("setCaptive EH",_object,_set); + _object setCaptive (_set > 0); +}] call FUNC(addEventHandler); +["blockDamage", { //Name reversed from `allowDamage` because we want NOR logic + params ["_object", "_set"]; + if ((_object isKindOf "CAManBase") && {(["ace_medical"] call FUNC(isModLoaded))}) then { + TRACE_2("blockDamage EH (using medical)",_object,_set); + _object setvariable [QEGVAR(medical,allowDamage), (_set == 0), true]; + } else { + TRACE_2("blockDamage EH (using allowDamage)",_object,_set); + _object allowDamage (_set == 0); + }; +}] call FUNC(addEventHandler); + //Add a fix for BIS's zeus remoteControl module not reseting variables on DC when RC a unit //This variable is used for isPlayer checks if (isServer) then { @@ -431,9 +465,6 @@ if (!isNil QGVAR(PreInit_playerChanged_PFHID)) then { // Eventhandlers for player controlled machines ////////////////////////////////////////////////// -// @todo still needed? -[QGVAR(StateArrested), false, true, QUOTE(ADDON)] call FUNC(defineVariable); - ["displayTextStructured", {_this call FUNC(displayTextStructured)}] call FUNC(addEventhandler); ["displayTextPicture", {_this call FUNC(displayTextPicture)}] call FUNC(addEventhandler); diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 1b7bdc624c..ce67009b4f 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -10,7 +10,6 @@ PREP(addToInventory); PREP(assignedItemFix); PREP(assignObjectsInList); PREP(ambientBrightness); -PREP(applyForceWalkStatus); PREP(ASLToPosition); PREP(binarizeNumber); PREP(blurScreen); @@ -53,8 +52,8 @@ PREP(fixLoweredRifleAnimation); PREP(fixPosition); PREP(getAllDefinedSetVariables); PREP(getAllGear); -PREP(getCaptivityStatus); PREP(getDeathAnim); +PREP(getCaptivityStatus); PREP(getDefaultAnim); PREP(getDefinedVariable); PREP(getDefinedVariableDefault); @@ -170,6 +169,13 @@ PREP(setVariablePublic); PREP(setVolume); PREP(sortAlphabeticallyBy); PREP(showHud); +PREP(statusEffect_addType); +PREP(statusEffect_get); +PREP(statusEffect_localEH); +PREP(statusEffect_resetVariables); +PREP(statusEffect_respawnEH); +PREP(statusEffect_sendEffects); +PREP(statusEffect_set); PREP(stringCompare); PREP(stringToColoredText); PREP(stringRemoveWhiteSpace); @@ -316,6 +322,8 @@ if (isServer) then { call FUNC(loadSettingsOnServer); }; +GVAR(statusEffect_Names) = []; +GVAR(statusEffect_isGlobal) = []; ////////////////////////////////////////////////// // Set up PlayerChanged eventhandler for pre init diff --git a/addons/common/config.cpp b/addons/common/config.cpp index c38c3fd3e7..f78e19d063 100644 --- a/addons/common/config.cpp +++ b/addons/common/config.cpp @@ -14,6 +14,7 @@ class CfgPatches { #include "CfgEventHandlers.hpp" +#include "CfgLocationTypes.hpp" #include "CfgSounds.hpp" #include "CfgVehicles.hpp" #include "CfgWeapons.hpp" diff --git a/addons/common/functions/fnc_applyForceWalkStatus.sqf b/addons/common/functions/fnc_applyForceWalkStatus.sqf deleted file mode 100644 index 656e4a6d25..0000000000 --- a/addons/common/functions/fnc_applyForceWalkStatus.sqf +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Author: Pabst Mirror - * Applys the forceWalk status of an unit. Called from Extended_InitPost_EventHandlers. - * - * Arguments: - * 0: Unit - * - * Return Value: - * None - * - * Example: - * [ACE_Player] call ace_common_fnc_applyForceWalkStatus - * - * Public: No - */ -#include "script_component.hpp" - -params ["_unit"]; - -private _forceWalkNumber = _unit getVariable ["ACE_forceWalkStatusNumber", 0]; - -_unit forceWalk (_forceWalkNumber > 0); diff --git a/addons/common/functions/fnc_fixCollision.sqf b/addons/common/functions/fnc_fixCollision.sqf index 1d55eb1454..c0cf7b93e7 100644 --- a/addons/common/functions/fnc_fixCollision.sqf +++ b/addons/common/functions/fnc_fixCollision.sqf @@ -15,8 +15,8 @@ // allowDamage requires local object if (!local _this) exitWith {}; -// prevent collision damage, @todo allowDamage API -_this allowDamage false; +// prevent collision damage +[_this, "blockDamage", "fixCollision", true] call FUNC(statusEffect_set); // re-allow damage after 2 seconds -[{_this allowDamage true}, _this, 2, 0] call EFUNC(common,waitAndExecute); +[{[_this, "blockDamage", "fixCollision", false] call FUNC(statusEffect_set);}, _this, 2] call EFUNC(common,waitAndExecute); diff --git a/addons/common/functions/fnc_fixFloating.sqf b/addons/common/functions/fnc_fixFloating.sqf index 5391402ca4..1d8da1c8a4 100644 --- a/addons/common/functions/fnc_fixFloating.sqf +++ b/addons/common/functions/fnc_fixFloating.sqf @@ -1,6 +1,7 @@ /* * Author: commy2 * Attempt to fix floating physx with disabled damage after setPosXXX commands. + * Handles the "fixFloating" event * * Arguments: * PhysX object @@ -16,6 +17,11 @@ params ["_object"]; // setHitPointDamage requires local object if (!local _object) exitWith {}; +//Ignore mans +if (_object isKindOf "CAManBase") exitWith {}; + +//We need to manually set allowDamage to true for setHitIndex to function +["blockDamage", [_object, 0]] call FUNC(localEvent); // save and restore hitpoints, see below why private _hitPointDamages = getAllHitPointsDamage _object; @@ -31,3 +37,8 @@ _object setDamage damage _object; { _object setHitIndex [_forEachIndex, _x]; } forEach (_hitPointDamages select 2); + +//manually re-enable allowDamage to previous setting (ref statusEffect_funcs) +private _effectVarName = format [QGVAR(effect_%1), "blockDamage"]; +private _effectNumber = _object getVariable [_effectVarName, 0]; +["blockDamage", [_object, _effectNumber]] call FUNC(localEvent); diff --git a/addons/common/functions/fnc_getCaptivityStatus.sqf b/addons/common/functions/fnc_getCaptivityStatus.sqf index e2663a892e..ab4c27956e 100644 --- a/addons/common/functions/fnc_getCaptivityStatus.sqf +++ b/addons/common/functions/fnc_getCaptivityStatus.sqf @@ -14,15 +14,7 @@ params ["_unit"]; -private _captivityReasons = missionNamespace getVariable ["ACE_captivityReasons", []]; -private _unitCaptivityStatus = [captiveNum _unit, count _captivityReasons] call FUNC(binarizeNumber); +//Now just a wrapper for FUNC(statusEffect_get) [No longer used in ace as of 3.5] +ACE_DEPRECATED("ace_common_fnc_getCaptivityStatus","3.7.0","ace_common_fnc_statusEffect_get"); -private _unitCaptivityReasons = []; - -{ - if (_unitCaptivityStatus select _forEachIndex) then { - _unitCaptivityReasons pushBack _x; - }; -} forEach _captivityReasons; - -_unitCaptivityReasons +([_unit, "setCaptive"] call FUNC(statusEffect_get)) select 1 diff --git a/addons/common/functions/fnc_getForceWalkStatus.sqf b/addons/common/functions/fnc_getForceWalkStatus.sqf index 16eca5ccc7..89042b19dd 100644 --- a/addons/common/functions/fnc_getForceWalkStatus.sqf +++ b/addons/common/functions/fnc_getForceWalkStatus.sqf @@ -17,16 +17,7 @@ params ["_unit"]; -private _forceWalkReasons = missionNamespace getVariable ["ACE_forceWalkReasons", []]; -private _unitForceWalkNumber = _unit getVariable ["ACE_forceWalkStatusNumber", 0]; -private _unitForceWalkStatus = [_unitForceWalkNumber, count _forceWalkReasons] call FUNC(binarizeNumber); +//Now just a wrapper for FUNC(statusEffect_get) [No longer used in ace as of 3.5] +ACE_DEPRECATED("ace_common_fnc_getForceWalkStatus","3.7.0","ace_common_fnc_statusEffect_get"); -private _unitForceWalkReasons = []; - -{ - if (_unitForceWalkStatus select _forEachIndex) then { - _unitForceWalkReasons pushBack _x; - }; -} forEach _forceWalkReasons; - -_unitForceWalkReasons +([_unit, "forceWalk"] call FUNC(statusEffect_get)) select 1 diff --git a/addons/common/functions/fnc_resetAllDefaults.sqf b/addons/common/functions/fnc_resetAllDefaults.sqf index d9850ffd5b..6432f3759e 100644 --- a/addons/common/functions/fnc_resetAllDefaults.sqf +++ b/addons/common/functions/fnc_resetAllDefaults.sqf @@ -19,11 +19,6 @@ _unit setVariable ["ACE_isUnconscious", nil, true]; if (isPlayer _unit) then { [true] call FUNC(setVolume); - // [false] call FUNC(disableKeyInput); //func does not exist - - if (["ace_medical"] call FUNC(isModLoaded)) then { - // [false] call EFUNC(medical,effectBlackOut); //func does not exist - }; if !(isNil QGVAR(DISABLE_USER_INPUT_COLLECTION)) then { // clear all disable user input @@ -40,5 +35,3 @@ if (isPlayer _unit) then { }; false } count ([_unit] call FUNC(getAllDefinedSetVariables)); - -_unit setVariable ["ACE_forceWalkStatusNumber", 0, true]; diff --git a/addons/common/functions/fnc_setCaptivityStatus.sqf b/addons/common/functions/fnc_setCaptivityStatus.sqf index 3e84c1753d..062c126f81 100644 --- a/addons/common/functions/fnc_setCaptivityStatus.sqf +++ b/addons/common/functions/fnc_setCaptivityStatus.sqf @@ -16,28 +16,7 @@ params ["_unit", "_reason", "_status"]; -private _captivityReasons = missionNamespace getVariable ["ACE_captivityReasons", []]; +//Now just a wrapper for FUNC(statusEffect_set) [No longer used in ace as of 3.5] +ACE_DEPRECATED("ace_common_fnc_setCaptivityStatus","3.7.0","ace_common_fnc_statusEffect_set"); -// register new reason (these reasons are shared publicly, since units can change ownership, but keep their captivity status) -if !(_reason in _captivityReasons) then { - _captivityReasons pushBack _reason; - - ACE_captivityReasons = _captivityReasons; - publicVariable "ACE_captivityReasons"; -}; - -// get reasons why the unit is captive already and update to the new status -private _unitCaptivityReasons = _unit call FUNC(getCaptivityStatus); - -private _captivityReasonsBooleans = []; - -{ - _captivityReasonsBooleans set [_forEachIndex, (_captivityReasons select _forEachIndex) in _unitCaptivityReasons]; -} forEach _captivityReasons; - -_captivityReasonsBooleans set [_captivityReasons find _reason, _status]; - -private _bitmask = _captivityReasonsBooleans call FUNC(toBitmask); - -// actually apply the setCaptive command globaly -[[_unit, _bitmask], "{(_this select 0) setCaptive (_this select 1)}", _unit] call FUNC(execRemoteFnc); +[_unit, "setCaptive", _reason, _status] call FUNC(statusEffect_set); diff --git a/addons/common/functions/fnc_setForceWalkStatus.sqf b/addons/common/functions/fnc_setForceWalkStatus.sqf index 3842457395..800040d978 100644 --- a/addons/common/functions/fnc_setForceWalkStatus.sqf +++ b/addons/common/functions/fnc_setForceWalkStatus.sqf @@ -20,29 +20,7 @@ params ["_unit", "_reason", "_status"]; -private _forceWalkReasons = missionNamespace getVariable ["ACE_forceWalkReasons", []]; +//Now just a wrapper for FUNC(statusEffect_set) [No longer used in ace as of 3.5] +ACE_DEPRECATED("ace_common_fnc_setForceWalkStatus","3.7.0","ace_common_fnc_statusEffect_set"); -// register new reason (these reasons are shared publicly, since units can change ownership, but keep their forceWalk status) -if !(_reason in _forceWalkReasons) then { - _forceWalkReasons pushBack _reason; - ACE_forceWalkReasons = _forceWalkReasons; - publicVariable "ACE_forceWalkReasons"; -}; - -// get reasons why the unit is forceWalking already and update to the new status -private _unitForceWalkReasons = [_unit] call FUNC(getForceWalkStatus); - -private _forceWalkReasonsBooleans = []; - -{ - _forceWalkReasonsBooleans set [_forEachIndex, (_forceWalkReasons select _forEachIndex) in _unitForceWalkReasons]; -} forEach _forceWalkReasons; - -_forceWalkReasonsBooleans set [_forceWalkReasons find _reason, _status]; - -private _bitmaskNumber = _forceWalkReasonsBooleans call FUNC(toBitmask); - -_unit setVariable ["ACE_forceWalkStatusNumber", _bitmaskNumber, true]; - -// actually apply the forceWalk command globaly -[[_unit], QFUNC(applyForceWalkStatus), 2] call FUNC(execRemoteFnc); +[_unit, "forceWalk", _reason, _status] call FUNC(statusEffect_set); diff --git a/addons/common/functions/fnc_statusEffect_addType.sqf b/addons/common/functions/fnc_statusEffect_addType.sqf new file mode 100644 index 0000000000..afd7ff7be7 --- /dev/null +++ b/addons/common/functions/fnc_statusEffect_addType.sqf @@ -0,0 +1,37 @@ +/* + * Author: PabstMirror + * Adds a status effect that will be handled. + * + * Arguments: + * 0: Status Effect Name, this should match a corisponding event name + * 1: Send event globaly + * 2: Common Effect Reaons to pre-seed durring init + * + * Return Value: + * Nothing + * + * Example: + * ["setCaptive", true, []] call ace_common_fnc_statusEffect_addType + * + * Public: No + */ +// #define DEBUG_MODE_FULL +#include "script_component.hpp" + +params [["_name", "", [""]], ["_isGlobal", false, [false]], ["_commonReasonsArray", [], [[]]]]; +TRACE_3("params",_name,_isGlobal,_commonReasonsArray); + +if (_name == "") exitWith {ACE_LOGERROR_1("addStatusEffect - Bad Name %1", _this)}; +if (_name in GVAR(statusEffect_Names)) exitWith {ACE_LOGWARNING_1("addStatusEffect - Effect Already Added (note, will not update global bit) %1", _this)}; + +GVAR(statusEffect_Names) pushBack _name; +GVAR(statusEffect_isGlobal) pushBack _isGlobal; + +//We add reasons at any time, but more efficenet to add all common ones at one time during init +if (isServer && {!(_commonReasonsArray isEqualTo [])}) then { + //Switch case to lower: + { + _commonReasonsArray set [_forEachIndex, toLower _x]; + } forEach _commonReasonsArray; + missionNamespace setVariable [(format [QGVAR(statusEffects_%1), _name]), _commonReasonsArray, true]; +}; diff --git a/addons/common/functions/fnc_statusEffect_get.sqf b/addons/common/functions/fnc_statusEffect_get.sqf new file mode 100644 index 0000000000..2d7e17e0ec --- /dev/null +++ b/addons/common/functions/fnc_statusEffect_get.sqf @@ -0,0 +1,63 @@ +/* + * Author: PabstMirror + * Retrives list of current status effects + * + * Arguments: + * 0: vehicle that it will be attached to (player or vehicle) + * 1: Effect Name + * + * Return Value: + * Effect status + * 0: is activly set (if false, the effect is ignored and never modified) + * 1: reasons why it is set true (list of strings, count of 0 = false, 1+ = true) + * + * Example: + * [player, "forceWalk"] call ace_common_fnc_statusEffect_get + * + * Public: Yes + */ +// #define DEBUG_MODE_FULL +#include "script_component.hpp" + +params [["_object", objNull, [objNull]], ["_effectName", "", [""]]]; +TRACE_2("params",_object,_effectName); + +if (isNull _object) exitWith { + TRACE_1("null",_object); + [false, []] +}; + +[_object, false] call FUNC(statusEffect_resetVariables); //Check for mismatch + +//List of reasons +private _statusReasons = missionNamespace getVariable [(format [QGVAR(statusEffects_%1), _effectName]), []]; +if (_statusReasons isEqualTo []) exitWith { + TRACE_1("no reasons - bad effect?",_statusReasons); + [false, []] +}; + +//Get Effect Number +private _effectVarName = format [QGVAR(effect_%1), _effectName]; +private _effectNumber = _object getVariable [_effectVarName, -1]; +TRACE_2("current",_effectVarName,_effectNumber); + +if (_effectNumber == -1) exitWith { //Nil array - no effect + [false, []] +}; +if (_effectNumber == 0) exitWith { //empty array - false effect + [true, []] +}; + +//if no change: skip sending publicVar and events +private _effectBoolArray = [_effectNumber, count _statusReasons] call FUNC(binarizeNumber); +TRACE_2("bitArray",_statusIndex,_effectBoolArray); + +private _activeEffects = []; +{ + if (_x) then { + _activeEffects pushBack (_statusReasons select _forEachIndex); + }; +} forEach _effectBoolArray; + +//non-empty array - true effect +[true, _activeEffects] diff --git a/addons/common/functions/fnc_statusEffect_localEH.sqf b/addons/common/functions/fnc_statusEffect_localEH.sqf new file mode 100644 index 0000000000..5490029a3b --- /dev/null +++ b/addons/common/functions/fnc_statusEffect_localEH.sqf @@ -0,0 +1,36 @@ +/* + * Author: PabstMirror + * Handles locality switch, runs a respawn check and then reapplies all effect events. + * + * Arguments: + * 0: vehicle that it will be attached to (player or vehicle) + * + * Return Value: + * Nothing + * + * Example: + * [player, true] call ace_common_fnc_statusEffect_localEH + * + * Public: No + */ +// #define DEBUG_MODE_FULL +#include "script_component.hpp" + +params ["_object", "_isLocal"]; +TRACE_2("params",_object,_isLocal); + +//Only run this after the settings are initialized +//Need to wait for all EH to be installed (local event will happen between pre and post init) +if !(GVAR(settingsInitFinished)) exitWith { + TRACE_1("pushing to runAtSettingsInitialized", _this); + GVAR(runAtSettingsInitialized) pushBack [FUNC(statusEffect_localEH), _this]; +}; + +if (!_isLocal) exitWith {TRACE_1("object no longer local", _this)}; +if (isNull _object) exitWith {TRACE_1("object null", _this)}; + + //Reset any variables because of respawn +[_object, false] call FUNC(statusEffect_resetVariables); + +//Send all Variables to client +[_object, ""] call FUNC(statusEffect_sendEffects); diff --git a/addons/common/functions/fnc_statusEffect_resetVariables.sqf b/addons/common/functions/fnc_statusEffect_resetVariables.sqf new file mode 100644 index 0000000000..2a307c84e5 --- /dev/null +++ b/addons/common/functions/fnc_statusEffect_resetVariables.sqf @@ -0,0 +1,45 @@ +/* + * Author: PabstMirror + * Resets all effect numbers to 0 when an object respawns (but does not apply the effect event). + * + * Arguments: + * 0: vehicle that it will be attached to (player or vehicle) + * + * Return Value: + * Nothing + * + * Example: + * [player, true] call ace_common_fnc_statusEffect_resetVariables + * + * Public: No + */ +// #define DEBUG_MODE_FULL +#include "script_component.hpp" + +params [["_object", objNull, [objNull]], ["_setObjectRef", false, [false]]]; +TRACE_2("params",_object,_setObjectRef); + +if (isNull _object) exitWith {}; + +private _objectRef = _object getVariable QGVAR(statusEffect_object); +TRACE_2("testing",_object,_objectRef); + +// If nothing was ever set, or objects match, exit (always true unless respawned) +if (isNil "_objectRef") exitWith { + if (_setObjectRef) then { + _object setVariable [QGVAR(statusEffect_object), _object, true]; //explicitly set new object ref + }; +}; +if (_object == _objectRef) exitWith {}; + +//Mismatch, so if effect has ever been defined, reset to 0 +{ + private _effectVarName = format [QGVAR(effect_%1), _x]; + private _effectNumber = _object getVariable [_effectVarName, -1]; + if (_effectNumber != -1) then { + TRACE_2("forced reset defined array on object mismatch",_x,_effectNumber); + _object setVariable [_effectVarName, 0, true]; //This always resets to 0 (not -1/nil)! + }; +} forEach GVAR(statusEffect_Names); + +_object setVariable [QGVAR(statusEffect_object), _object, true]; diff --git a/addons/common/functions/fnc_statusEffect_respawnEH.sqf b/addons/common/functions/fnc_statusEffect_respawnEH.sqf new file mode 100644 index 0000000000..92717b68c7 --- /dev/null +++ b/addons/common/functions/fnc_statusEffect_respawnEH.sqf @@ -0,0 +1,36 @@ +/* + * Author: PabstMirror + * Handles the Respawn Event Handler to reset effects. + * + * Arguments: + * 0: vehicle that it will be attached to (player or vehicle) + * + * Return Value: + * Nothing + * + * Example: + * [player, objNull] call ace_common_fnc_statusEffect_respawnEH + * + * Public: No + */ +// #define DEBUG_MODE_FULL +#include "script_component.hpp" + +params ["_object"]; +TRACE_1("params",_object); + +//Only run this after the settings are initialized +//Need to wait for all EH to be installed (local event will happen between pre and post init) +if !(GVAR(settingsInitFinished)) exitWith { + TRACE_1("pushing to runAtSettingsInitialized", _this); + GVAR(runAtSettingsInitialized) pushBack [FUNC(statusEffect_respawnEH), _this]; +}; + +if (!local _object) exitWith {TRACE_1("object no longer local", _this)}; +if (isNull _object) exitWith {TRACE_1("object null", _this)}; + + //Reset any variables on "real" respawn +[_object, false] call FUNC(statusEffect_resetVariables); + +//Send all Variables to client +[_object, ""] call FUNC(statusEffect_sendEffects); diff --git a/addons/common/functions/fnc_statusEffect_sendEffects.sqf b/addons/common/functions/fnc_statusEffect_sendEffects.sqf new file mode 100644 index 0000000000..4291de1ad8 --- /dev/null +++ b/addons/common/functions/fnc_statusEffect_sendEffects.sqf @@ -0,0 +1,48 @@ +/* + * Author: PabstMirror + * Sends all status effects for an object (can be run on non-local objects) + * + * Arguments: + * 0: Object + * 1: Effect name (or "" or send all) + * + * Return Value: + * Nothing + * + * Example: + * [player, ""] call ace_common_fnc_statusEffect_sendEffects + * + * Public: No + */ +// #define DEBUG_MODE_FULL +#include "script_component.hpp" + +params [["_object", objNull, [objNull]], ["_effectName", "", [""]]]; +TRACE_2("params",_object,_effectName); + +if (isNull _object) exitWith {}; + +{ + if ((_effectName == "") || {_effectName == _x}) then { + private _effectVarName = format [QGVAR(effect_%1), _x]; + private _effectNumber = _object getVariable [_effectVarName, -1]; + + //We only do anything if the effect has been defined at some point in the game for this unit + TRACE_2("checking if event is nil",_x,_effectNumber); + if (_effectNumber != -1) then { + if (GVAR(statusEffect_isGlobal) select _forEachIndex) then { + TRACE_2("Sending Global Event", _object, _effectNumber); + [_x, [_object, _effectNumber]] call FUNC(globalEvent); + } else { + if (local _object) then { + //If local, send directly to bypass network delay of targetEvent call + TRACE_2("Sending Target Local Event", _object, _effectNumber); + [_x, [_object, _effectNumber]] call FUNC(localEvent); + } else { + TRACE_2("Sending Target Non-Local Event", _object, _effectNumber); + [_x, [_object], [_object, _effectNumber]] call FUNC(targetEvent); + }; + }; + }; + }; +} forEach GVAR(statusEffect_Names); diff --git a/addons/common/functions/fnc_statusEffect_set.sqf b/addons/common/functions/fnc_statusEffect_set.sqf new file mode 100644 index 0000000000..a0be8d8719 --- /dev/null +++ b/addons/common/functions/fnc_statusEffect_set.sqf @@ -0,0 +1,70 @@ +/* + * Author: PabstMirror + * Adds or removes an id to a status effect and will send an event to apply. + * + * Arguments: + * 0: vehicle that it will be attached to (player or vehicle) + * 1: Effect Name + * 2: Unique Reason ID + * 3: Is Set (true adds/false removes) + * + * Return Value: + * Nothing + * + * Example: + * [player, "setCaptive", "reason1", true] call ace_common_fnc_statusEffect_set + * + * Public: Yes + */ +// #define DEBUG_MODE_FULL +#include "script_component.hpp" + +params [["_object", objNull, [objNull]], ["_effectName", "", [""]], ["_ID", "", [""]], ["_set", true, [false]]]; +TRACE_4("params",_object,_effectName,_ID,_set); + +//Only run this after the settings are initialized +if !(GVAR(settingsInitFinished)) exitWith { + TRACE_1("pushing to runAtSettingsInitialized", _this); + GVAR(runAtSettingsInitialized) pushBack [FUNC(statusEffect_set), _this]; +}; + +if (isNull _object) exitWith {TRACE_1("null",_object);}; + +[_object, true] call FUNC(statusEffect_resetVariables); //Check for mismatch, and set object ref + +//check ID case and set globaly if not already set: +_ID = toLower _ID; +private _statusReasons = missionNamespace getVariable [(format [QGVAR(statusEffects_%1), _effectName]), []]; +private _statusIndex = _statusReasons find _ID; +if (_statusIndex == -1) then { + TRACE_2("ID not in global reasons, adding",_statusReasons,_ID); + _statusIndex = _statusReasons pushBack _ID; + missionNamespace setVariable [(format [QGVAR(statusEffects_%1), _effectName]), _statusReasons, true]; +}; + +private _effectVarName = format [QGVAR(effect_%1), _effectName]; +private _effectNumber = _object getVariable [_effectVarName, -1]; +TRACE_2("current",_effectVarName,_effectNumber); + +if ((_effectNumber == -1) && {!_set}) exitWith { + //Optimization for modules that always set an ID to false even if never set true + TRACE_2("Set False on nil array, exiting",_set,_effectNumber); +}; + +if (_effectNumber == -1) then {_effectNumber = 0}; //reset (-1/nil) to 0 + +//if no change: skip sending publicVar and events +private _effectBoolArray = [_effectNumber, count _statusReasons] call FUNC(binarizeNumber); +TRACE_2("bitArray",_statusIndex,_effectBoolArray); +if (_set isEqualTo (_effectBoolArray select _statusIndex)) exitWith { + TRACE_2("No Change, exiting",_set,_effectBoolArray select _statusIndex); +}; + +TRACE_2("Setting to new value",_set,_effectBoolArray select _statusIndex); +_effectBoolArray set [_statusIndex, _set]; +_effectNumber = _effectBoolArray call FUNC(toBitmask); //Convert array back to number + +TRACE_2("Saving globaly",_effectVarName,_effectNumber); +_object setVariable [_effectVarName, _effectNumber, true]; + +[_object, _effectName] call FUNC(statusEffect_sendEffects); diff --git a/addons/common/script_component.hpp b/addons/common/script_component.hpp index 7c266c169d..70bdff7ff3 100644 --- a/addons/common/script_component.hpp +++ b/addons/common/script_component.hpp @@ -2,6 +2,7 @@ #include "\z\ace\addons\main\script_mod.hpp" // #define DEBUG_MODE_FULL +// #define CBA_DEBUG_SYNCHRONOUS #ifdef DEBUG_ENABLED_COMMON #define DEBUG_MODE_FULL diff --git a/addons/dragging/functions/fnc_dropObject_carry.sqf b/addons/dragging/functions/fnc_dropObject_carry.sqf index c9c34c82a0..0896591755 100644 --- a/addons/dragging/functions/fnc_dropObject_carry.sqf +++ b/addons/dragging/functions/fnc_dropObject_carry.sqf @@ -48,7 +48,7 @@ _unit removeWeapon "ACE_FakePrimaryWeapon"; // reselect weapon and re-enable sprint _unit selectWeapon primaryWeapon _unit; -[_unit, "isDragging", false] call EFUNC(common,setforceWalkStatus); +[_unit, "forceWalk", "ACE_dragging", false] call EFUNC(common,statusEffect_set); // prevent object from flipping inside buildings if (_inBuilding) then { diff --git a/addons/dragging/functions/fnc_startCarry.sqf b/addons/dragging/functions/fnc_startCarry.sqf index 3b08de2c9d..0bef53e138 100644 --- a/addons/dragging/functions/fnc_startCarry.sqf +++ b/addons/dragging/functions/fnc_startCarry.sqf @@ -53,7 +53,7 @@ if (_target isKindOf "CAManBase") then { _unit action ["SwitchWeapon", _unit, _unit, 99]; [_unit, "AmovPercMstpSnonWnonDnon", 0] call EFUNC(common,doAnimation); - [_unit, "isDragging", true] call EFUNC(common,setforceWalkStatus); + [_unit, "forceWalk", "ACE_dragging", true] call EFUNC(common,statusEffect_set); }; diff --git a/addons/explosives/functions/fnc_setupExplosive.sqf b/addons/explosives/functions/fnc_setupExplosive.sqf index b104761fac..16e5ed6cbb 100644 --- a/addons/explosives/functions/fnc_setupExplosive.sqf +++ b/addons/explosives/functions/fnc_setupExplosive.sqf @@ -32,7 +32,7 @@ if (!isClass (configFile >> "CfgVehicles" >> _setupObjectClass)) exitWith {ERROR _p3dModel = getText (configFile >> "CfgVehicles" >> _setupObjectClass >> "model"); if (_p3dModel == "") exitWith {ERROR("No Model");}; //"" - will crash game! -[_unit, "ACE_Explosives", true] call EFUNC(common,setForceWalkStatus); +[_unit, "ACE_Explosives", true] call EFUNC(common,statusEffect_set); //Show mouse buttons: [localize LSTRING(PlaceAction), localize LSTRING(CancelAction), localize LSTRING(ScrollAction)] call EFUNC(interaction,showMouseHint); @@ -152,7 +152,7 @@ GVAR(TweakedAngle) = 0; [_pfID] call CBA_fnc_removePerFrameHandler; GVAR(pfeh_running) = false; - [_unit, "ACE_Explosives", false] call EFUNC(common,setForceWalkStatus); + [_unit, "forceWalk", "ACE_Explosives", false] call EFUNC(common,statusEffect_set); [] call EFUNC(interaction,hideMouseHint); [_unit, "DefaultAction", (_unit getVariable [QGVAR(placeActionEH), -1])] call EFUNC(common,removeActionEventHandler); [_unit, "zoomtemp", (_unit getVariable [QGVAR(cancelActionEH), -1])] call EFUNC(common,removeActionEventHandler); diff --git a/addons/frag/XEH_postInit.sqf b/addons/frag/XEH_postInit.sqf index af3464c2b6..f49e5d1e3e 100644 --- a/addons/frag/XEH_postInit.sqf +++ b/addons/frag/XEH_postInit.sqf @@ -9,4 +9,8 @@ if(isServer) then { [QGVAR(frag_eh), { _this call FUNC(frago); }] call EFUNC(common,addEventHandler); }; -[FUNC(masterPFH), 0, []] call CBA_fnc_addPerFrameHandler; \ No newline at end of file +[FUNC(masterPFH), 0, []] call CBA_fnc_addPerFrameHandler; + +//Cache for ammo type configs +GVAR(cacheRoundsTypesToTrack) = createLocation ["ACE_HashLocation", [-10000,-10000,-10000], 0, 0]; +GVAR(cacheRoundsTypesToTrack) setText QGVAR(cacheRoundsTypesToTrack); diff --git a/addons/frag/functions/fnc_fired.sqf b/addons/frag/functions/fnc_fired.sqf index 693b85eb3d..3e82544430 100644 --- a/addons/frag/functions/fnc_fired.sqf +++ b/addons/frag/functions/fnc_fired.sqf @@ -1,8 +1,56 @@ +/* + * Author: nou, jaynus, PabstMirror + * Called from FiredBIS event on AllVehicles + * If spall is not enabled (default), then cache and only track those that will actually trigger fragmentation. + * + * Arguments: + * 0: gun - Object the event handler is assigned to + * 4: type - Ammo used + * 6: round - Object of the projectile that was shot + * + * Return Value: + * Nothing + * + * Example: + * [clientFiredBIS-XEH] call ace_frag_fnc_fired + * + * Public: No + */ +// #define DEBUG_ENABLED_FRAG #include "script_component.hpp" -private["_gun", "_type", "_round"]; -_gun = _this select 0; -_type = _this select 4; -_round = _this select 6; +params ["_gun", "", "", "", "_type", "", "_round"]; -[_gun, _type, _round] call FUNC(addPfhRound); +private _shouldAdd = GVAR(cacheRoundsTypesToTrack) getVariable _type; +if (isNil "_shouldAdd") then { + TRACE_1("no cache for round",_type); + + if (!EGVAR(common,settingsInitFinished)) exitWith { + //Just incase fired event happens before settings init, don't want to set cache wrong if spall setting changes + TRACE_1("Settings not init yet - exit without setting cache",_type); + _shouldAdd = false; + }; + + if (GVAR(SpallEnabled)) exitWith { + //Always want to run whenever spall is enabled? + _shouldAdd = true; + TRACE_2("SettingCache[spallEnabled]",_type,_shouldAdd); + GVAR(cacheRoundsTypesToTrack) setVariable [_type, _shouldAdd]; + }; + + //Read configs and test if it would actually cause a frag, using same logic as FUNC(pfhRound) + private _skip = getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(skip)); + private _explosive = getNumber (configFile >> "CfgAmmo" >> _type >> "explosive"); + private _indirectRange = getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange"); + private _force = getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(force)); + private _fragPower = getNumber(configFile >> "CfgAmmo" >> _type >> "indirecthit")*(sqrt((getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange")))); + + _shouldAdd = (_skip == 0) && {(_force == 1) || {_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}}}; + TRACE_6("SettingCache[willFrag?]",_skip,_explosive,_indirectRange,_force,_fragPower,_shouldAdd); + GVAR(cacheRoundsTypesToTrack) setVariable [_type, _shouldAdd]; +}; + +if (_shouldAdd) then { + TRACE_3("Running Frag Tracking",_gun,_type,_round); + [_gun, _type, _round] call FUNC(addPfhRound); +}; diff --git a/addons/hearing/CfgWeapons.hpp b/addons/hearing/CfgWeapons.hpp index 7e1c932f62..af7b7d4cb3 100644 --- a/addons/hearing/CfgWeapons.hpp +++ b/addons/hearing/CfgWeapons.hpp @@ -18,36 +18,27 @@ class CfgWeapons { GVAR(protection) = 1; GVAR(lowerVolume) = 0.80; }; - class H_HelmetCrew_0: H_HelmetCrew_B {}; - class H_HelmetCrew_I: H_HelmetCrew_B {}; class H_CrewHelmetHeli_B: H_HelmetB { GVAR(protection) = 0.85; GVAR(lowerVolume) = 0.75; }; - class H_CrewHelmetHeli_O: H_CrewHelmetHeli_B {}; - class H_CrewHelmetHeli_I: H_CrewHelmetHeli_B {}; class H_PilotHelmetHeli_B: H_HelmetB { GVAR(protection) = 0.85; GVAR(lowerVolume) = 0.75; }; - class H_PilotHelmetHeli_O: H_PilotHelmetHeli_B {}; - class H_PilotHelmetHeli_I: H_PilotHelmetHeli_B {}; class H_PilotHelmetFighter_B: H_HelmetB { GVAR(protection) = 1; GVAR(lowerVolume) = 0.80; }; - class H_PilotHelmetFighter_O: H_PilotHelmetFighter_B {}; - class H_PilotHelmetFighter_I: H_PilotHelmetFighter_B {}; class HelmetBase; class H_Cap_headphones: HelmetBase { GVAR(protection) = 0.5; GVAR(lowerVolume) = 0.60; }; - class H_Cap_marshal: H_Cap_headphones {}; class H_HelmetB_light: H_HelmetB { GVAR(protection) = 0.8; diff --git a/addons/hearing/XEH_postInit.sqf b/addons/hearing/XEH_postInit.sqf index b8745acaaa..4ff2f84b6c 100644 --- a/addons/hearing/XEH_postInit.sqf +++ b/addons/hearing/XEH_postInit.sqf @@ -2,6 +2,9 @@ if (!hasInterface) exitWith {}; +GVAR(cacheAmmoLoudness) = createLocation ["ACE_HashLocation", [-10000,-10000,-10000], 0, 0]; +GVAR(cacheAmmoLoudness) setText QGVAR(cacheAmmoLoudness); + GVAR(deafnessDV) = 0; GVAR(deafnessPrior) = 0; GVAR(volume) = 1; diff --git a/addons/hearing/functions/fnc_earRinging.sqf b/addons/hearing/functions/fnc_earRinging.sqf index f4db19e6ea..cda5fa508e 100644 --- a/addons/hearing/functions/fnc_earRinging.sqf +++ b/addons/hearing/functions/fnc_earRinging.sqf @@ -28,11 +28,12 @@ if (_unit getVariable ["ACE_hasEarPlugsin", false]) then { //headgear hearing protection if(headgear _unit != "") then { - private ["_protection"]; - _protection = (getNumber (configFile >> "CfgWeapons" >> (headgear _unit) >> QGVAR(protection))) min 1; + private _protection = (getNumber (configFile >> "CfgWeapons" >> (headgear _unit) >> QGVAR(protection))) min 1; if(_protection > 0) then { _strength = _strength * (1 - _protection); }; }; +TRACE_2("adding",_strength,GVAR(deafnessDV)); + GVAR(deafnessDV) = GVAR(deafnessDV) + _strength; diff --git a/addons/hearing/functions/fnc_firedNear.sqf b/addons/hearing/functions/fnc_firedNear.sqf index 1ee84a2dc8..31f693bafd 100644 --- a/addons/hearing/functions/fnc_firedNear.sqf +++ b/addons/hearing/functions/fnc_firedNear.sqf @@ -32,31 +32,28 @@ if ((ACE_player != _object) && {(vehicle ACE_player) != _object}) exitWith {}; if (_weapon in ["Throw", "Put"]) exitWith {}; if (_distance > 50) exitWith {}; -private ["_silencer", "_audibleFireCoef", "_loudness", "_strength", "_vehAttenuation", "_magazine", "_muzzles", "_weaponMagazines", "_muzzleMagazines", "_ammoType", "_initSpeed", "_ammoConfig", "_caliber"]; +private _vehAttenuation = if ((ACE_player == (vehicle ACE_player)) || {isTurnedOut ACE_player}) then {1} else {GVAR(playerVehAttenuation)}; +private _distance = 1 max _distance; -_vehAttenuation = if ((ACE_player == (vehicle ACE_player)) || {isTurnedOut ACE_player}) then {1} else {GVAR(playerVehAttenuation)}; - -_distance = 1 max _distance; - -_silencer = switch (_weapon) do { +private _silencer = switch (_weapon) do { case (primaryWeapon _firer) : {(primaryWeaponItems _firer) select 0}; case (secondaryWeapon _firer) : {(secondaryWeaponItems _firer) select 0}; case (handgunWeapon _firer) : {(handgunItems _firer) select 0}; default {""}; }; -_audibleFireCoef = 1; +private _audibleFireCoef = 1; if (_silencer != "") then { _audibleFireCoef = getNumber (configFile >> "CfgWeapons" >> _silencer >> "ItemInfo" >> "AmmoCoef" >> "audibleFire"); }; -_weaponMagazines = missionNamespace getVariable [format[QEGVAR(common,weaponMagazines_%1),_weapon], []]; -if (count _weaponMagazines == 0) then { - _muzzles = getArray (configFile >> "CfgWeapons" >> _weapon >> "muzzles"); - _weaponMagazines = getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines"); +private _loudness = GVAR(cacheAmmoLoudness) getVariable (format ["%1%2",_weapon,_ammo]); +if (isNil "_loudness") then { + private _muzzles = getArray (configFile >> "CfgWeapons" >> _weapon >> "muzzles"); + private _weaponMagazines = getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines"); { if (_x != "this") then { - _muzzleMagazines = getArray (configFile >> "CfgWeapons" >> _weapon >> _x >> "magazines"); + private _muzzleMagazines = getArray (configFile >> "CfgWeapons" >> _weapon >> _x >> "magazines"); _weaponMagazines append _muzzleMagazines; }; } count _muzzles; @@ -64,34 +61,39 @@ if (count _weaponMagazines == 0) then { _ammoType = getText(configFile >> "CfgMagazines" >> _x >> "ammo"); _weaponMagazines set [_forEachIndex, [_x, _ammoType]]; } forEach _weaponMagazines; - missionNamespace setVariable [format[QEGVAR(common,weaponMagazines_%1),_weapon], _weaponMagazines]; -}; -_magazine = ""; -{ - _x params ["_magazineType", "_ammoType"]; - if (_ammoType == _ammo) exitWith { - _magazine = _magazineType; + private _magazine = ""; + { + _x params ["_magazineType", "_ammoType"]; + if (_ammoType == _ammo) exitWith { + _magazine = _magazineType; + }; + } count _weaponMagazines; + + if (_magazine == "") then { + _loudness = 0; + TRACE_2("No mag for Weapon/Ammo??",_weapon,_ammo); + } else { + private _initSpeed = getNumber(configFile >> "CfgMagazines" >> _magazine >> "initSpeed"); + private _caliber = getNumber (configFile >> "CfgAmmo" >> _ammo >> "ACE_caliber"); + _caliber = call { + if (_ammo isKindOf ["ShellBase", (configFile >> "CfgAmmo")]) exitWith { 80 }; + if (_ammo isKindOf ["RocketBase", (configFile >> "CfgAmmo")]) exitWith { 200 }; + if (_ammo isKindOf ["MissileBase", (configFile >> "CfgAmmo")]) exitWith { 600 }; + if (_ammo isKindOf ["SubmunitionBase", (configFile >> "CfgAmmo")]) exitWith { 80 }; + if (_caliber <= 0) then { 6.5 } else { _caliber }; + }; + + _loudness = (_caliber ^ 1.25 / 10) * (_initspeed / 1000) / 5; + TRACE_6("building cache",_weapon,_ammo,_magazine,_initSpeed,_caliber,_loudness); }; -} count _weaponMagazines; - -if (_magazine == "") exitWith {}; - -_initSpeed = getNumber(configFile >> "CfgMagazines" >> _magazine >> "initSpeed"); -_ammoConfig = (configFile >> "CfgAmmo" >> _ammo); -_caliber = getNumber(_ammoConfig >> "ACE_caliber"); -_caliber = call { - if (_ammo isKindOf ["ShellBase", (configFile >> "CfgAmmo")]) exitWith { 80 }; - if (_ammo isKindOf ["RocketBase", (configFile >> "CfgAmmo")]) exitWith { 200 }; - if (_ammo isKindOf ["MissileBase", (configFile >> "CfgAmmo")]) exitWith { 600 }; - if (_ammo isKindOf ["SubmunitionBase", (configFile >> "CfgAmmo")]) exitWith { 80 }; - if (_caliber <= 0) then { 6.5 } else { _caliber }; + GVAR(cacheAmmoLoudness) setVariable [(format ["%1%2",_weapon,_ammo]), _loudness]; }; -_loudness = (_caliber ^ 1.25 / 10) * (_initspeed / 1000) * _audibleFireCoef / 5; -_strength = _vehAttenuation * (_loudness - (_loudness / 50 * _distance)); // linear drop off -//systemChat format["%1 : %2", _strength, _initSpeed]; -//systemChat format["%1 : %2 : %3", _weapon, _magazine, _initSpeed]; +_loudness = _loudness * _audibleFireCoef; +private _strength = _vehAttenuation * (_loudness - (_loudness / 50 * _distance)); // linear drop off + +TRACE_1("result",_strength); if (_strength < 0.01) exitWith {}; diff --git a/addons/hearing/functions/fnc_updateVolume.sqf b/addons/hearing/functions/fnc_updateVolume.sqf index e36151aea4..5492dcd080 100644 --- a/addons/hearing/functions/fnc_updateVolume.sqf +++ b/addons/hearing/functions/fnc_updateVolume.sqf @@ -1,6 +1,6 @@ /* * Author: commy2 and esteldunedain and Ruthberg - * Updates and applys the current deafness. Called every 0.1 sec from a PFEH. + * Updates and applys the current deafness. Called every 1 sec from a PFEH. * * Arguments: * 0: Args @@ -19,7 +19,6 @@ //Only run if deafness or ear ringing is enabled: if ((!GVAR(enableCombatDeafness)) && GVAR(DisableEarRinging)) exitWith {}; -private["_volume", "_soundTransitionTime"]; (_this select 0) params ["_justUpdateVolume"]; @@ -71,7 +70,7 @@ if (!_justUpdateVolume) then { if ((missionNameSpace getVariable [QGVAR(disableVolumeUpdate), false]) || {!GVAR(enableCombatDeafness)}) exitWith {}; -_volume = GVAR(volume); +private _volume = GVAR(volume); // Earplugs reduce hearing 50% if ([ACE_player] call FUNC(hasEarPlugsIn)) then { @@ -92,7 +91,7 @@ if (ACE_player getVariable ["ACE_isUnconscious", false]) then { _volume = _volume min GVAR(UnconsciousnessVolume); }; -_soundTransitionTime = if (_justUpdateVolume) then {0.1} else {1}; +private _soundTransitionTime = if (_justUpdateVolume) then {0.1} else {1}; _soundTransitionTime fadeSound _volume; _soundTransitionTime fadeSpeech _volume; diff --git a/addons/interact_menu/XEH_clientInit.sqf b/addons/interact_menu/XEH_clientInit.sqf index f5e8a57db5..fe3b33feb5 100644 --- a/addons/interact_menu/XEH_clientInit.sqf +++ b/addons/interact_menu/XEH_clientInit.sqf @@ -79,8 +79,7 @@ GVAR(ParsedTextCached) = []; //Debug to help end users identify mods that break CBA's XEH [{ - private ["_badClassnames"]; - _badClassnames = []; + private _badClassnames = []; { //Only check Land objects (WeaponHolderSimulated show up in `vehicles` for some reason) if ((_x isKindOf "Land") && {(isNil (format [QGVAR(Act_%1), typeOf _x])) || {isNil (format [QGVAR(SelfAct_%1), typeOf _x])}}) then { diff --git a/addons/interact_menu/XEH_preInit.sqf b/addons/interact_menu/XEH_preInit.sqf index 73b543250e..92f6d61fde 100644 --- a/addons/interact_menu/XEH_preInit.sqf +++ b/addons/interact_menu/XEH_preInit.sqf @@ -74,11 +74,6 @@ GVAR(collectedActionPoints) = []; GVAR(foundActions) = []; GVAR(lastTimeSearchedActions) = -1000; - -// Init CAManBase menus -["CAManBase"] call FUNC(compileMenu); -["CAManBase"] call FUNC(compileMenuSelfAction); - // Init zeus menu [] call FUNC(compileMenuZeus); diff --git a/addons/interact_menu/functions/fnc_addActionToClass.sqf b/addons/interact_menu/functions/fnc_addActionToClass.sqf index f720903a6d..68efce4f2c 100644 --- a/addons/interact_menu/functions/fnc_addActionToClass.sqf +++ b/addons/interact_menu/functions/fnc_addActionToClass.sqf @@ -30,9 +30,8 @@ if (_typeNum == 0) then { [_objectType] call FUNC(compileMenuSelfAction); }; -private ["_varName","_actionTrees", "_parentNode"]; -_varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType]; -_actionTrees = missionNamespace getVariable [_varName, []]; +private _varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType]; +private _actionTrees = missionNamespace getVariable [_varName, []]; if((count _actionTrees) == 0) then { missionNamespace setVariable [_varName, _actionTrees]; }; @@ -41,7 +40,7 @@ if (_parentPath isEqualTo ["ACE_MainActions"]) then { [_objectType, _typeNum] call FUNC(addMainAction); }; -_parentNode = [_actionTrees, _parentPath] call FUNC(findActionNode); +private _parentNode = [_actionTrees, _parentPath] call FUNC(findActionNode); if (isNil {_parentNode}) exitWith { ERROR("Failed to add action"); ACE_LOGERROR_4("action (%1) to parent %2 on object %3 [%4]",(_action select 0),_parentPath,_objectType,_typeNum); diff --git a/addons/interact_menu/functions/fnc_addActionToObject.sqf b/addons/interact_menu/functions/fnc_addActionToObject.sqf index 8cd2270d48..31e15ae7aa 100644 --- a/addons/interact_menu/functions/fnc_addActionToObject.sqf +++ b/addons/interact_menu/functions/fnc_addActionToObject.sqf @@ -23,10 +23,10 @@ if (!params [["_object", objNull, [objNull]], ["_typeNum", 0, [0]], ["_parentPat ERROR("Bad Params"); }; -private ["_varName","_actionList"]; -_varName = [QGVAR(actions),QGVAR(selfActions)] select _typeNum; -_actionList = _object getVariable [_varName, []]; -if((count _actionList) == 0) then { +private _varName = [QGVAR(actions),QGVAR(selfActions)] select _typeNum; +private _actionList = _object getVariable [_varName, []]; + +if (_actionList isEqualTo []) then { _object setVariable [_varName, _actionList]; }; diff --git a/addons/interact_menu/functions/fnc_addMainAction.sqf b/addons/interact_menu/functions/fnc_addMainAction.sqf index cf2a3f51d4..161e12d6de 100644 --- a/addons/interact_menu/functions/fnc_addMainAction.sqf +++ b/addons/interact_menu/functions/fnc_addMainAction.sqf @@ -18,14 +18,12 @@ params ["_objectType", "_typeNum"]; -private["_actionTrees", "_mainAction", "_parentNode", "_varName"]; - -_varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType]; -_actionTrees = missionNamespace getVariable [_varName, []]; -_parentNode = [_actionTrees, ["ACE_MainActions"]] call FUNC(findActionNode); +private _varName = format [[QGVAR(Act_%1), QGVAR(SelfAct_%1)] select _typeNum, _objectType]; +private _actionTrees = missionNamespace getVariable [_varName, []]; +private _parentNode = [_actionTrees, ["ACE_MainActions"]] call FUNC(findActionNode); if (isNil {_parentNode}) then { TRACE_2("No Main Action on object", _objectType, _typeNum); - _mainAction = ["ACE_MainActions", localize ELSTRING(interaction,MainAction), "", {}, {true}] call FUNC(createAction); + private _mainAction = ["ACE_MainActions", localize ELSTRING(interaction,MainAction), "", {}, {true}] call FUNC(createAction); [_objectType, _typeNum, [], _mainAction] call EFUNC(interact_menu,addActionToClass); }; diff --git a/addons/interact_menu/functions/fnc_collectActiveActionTree.sqf b/addons/interact_menu/functions/fnc_collectActiveActionTree.sqf index 4da303f618..42fcf96cc7 100644 --- a/addons/interact_menu/functions/fnc_collectActiveActionTree.sqf +++ b/addons/interact_menu/functions/fnc_collectActiveActionTree.sqf @@ -6,6 +6,7 @@ * 0: Object * 1: Original action tree * 2: Parent path + * 3: Distance to base point (will be 0 for self/zeus/in-vehicle) * * Return value: * Active children @@ -14,13 +15,11 @@ */ #include "script_component.hpp" -params ["_object", "_origAction", "_parentPath"]; +params ["_object", "_origAction", "_parentPath", "_distanceToBasePoint"]; _origAction params ["_origActionData", "_origActionChildren"]; -private ["_target","_player","_fullPath","_activeChildren","_dynamicChildren","_action","_actionData","_x"]; - -_target = _object; -_player = ACE_player; +private _target = _object; +private _player = ACE_player; // Check if the function should be modified first if !((_origActionData select 10) isEqualTo {}) then { @@ -29,54 +28,62 @@ if !((_origActionData select 10) isEqualTo {}) then { [_target, ACE_player, _origActionData select 6, _origActionData] call (_origActionData select 10); }; +_origActionData params ["_actionName", "", "", "_statementCode", "_conditionCode", "_insertChildrenCode", "_customParams", "", "_distance"]; + // Return nothing if the action itself is not active -if !([_target, ACE_player, _origActionData select 6] call (_origActionData select 4)) exitWith { +if !([_target, ACE_player, _customParams] call _conditionCode) exitWith { [] }; -_fullPath = +_parentPath; -_fullPath pushBack (_origActionData select 0); -_activeChildren = []; +// Return nothing if the action is to far (including checking sub actions) [DISABLED FOR NOW ref #2196] +// if (_distanceToBasePoint > _distance) exitWith { + // [] +// }; + +private _fullPath = +_parentPath; +_fullPath pushBack _actionName; +private _activeChildren = []; // If there's a statement to dynamically insert children then execute it -if !({} isEqualTo (_origActionData select 5)) then { - _dynamicChildren = [_target, ACE_player, _origActionData select 6] call (_origActionData select 5); +if !({} isEqualTo _insertChildrenCode) then { + private _dynamicChildren = [_target, ACE_player, _customParams] call _insertChildrenCode; // Collect dynamic children class actions { - _action = [_x select 2, _x, _fullPath] call FUNC(collectActiveActionTree); + private _action = [_x select 2, _x, _fullPath, _distanceToBasePoint] call FUNC(collectActiveActionTree); if ((count _action) > 0) then { _activeChildren pushBack _action; }; - } forEach _dynamicChildren; + nil + } count _dynamicChildren; }; // Collect children class actions { - _action = [_object, _x, _fullPath] call FUNC(collectActiveActionTree); + private _action = [_object, _x, _fullPath, _distanceToBasePoint] call FUNC(collectActiveActionTree); if ((count _action) > 0) then { _activeChildren pushBack _action; }; -} forEach _origActionChildren; + nil +} count _origActionChildren; // Collect children object actions { - EXPLODE_2_PVT(_x,_actionData,_pPath); + _x params ["_actionData", "_pPath"]; // Check if the action is children of the original action - if (count _pPath == count _fullPath && - {_pPath isEqualTo _fullPath}) then { - - _action = [_object, [_actionData,[]], _fullPath] call FUNC(collectActiveActionTree); + if (_pPath isEqualTo _fullPath) then { + private _action = [_object, [_actionData,[]], _fullPath, _distanceToBasePoint] call FUNC(collectActiveActionTree); if ((count _action) > 0) then { _activeChildren pushBack _action; }; }; -} forEach GVAR(objectActionList); + nil +} count GVAR(objectActionList); // If the original action has no statement, and no children, don't display it -if ((count _activeChildren) == 0 && ((_origActionData select 3) isEqualTo {})) exitWith { +if ((_activeChildren isEqualTo []) && {_statementCode isEqualTo {}}) exitWith { // @todo: Account for showDisabled? [] }; diff --git a/addons/interact_menu/functions/fnc_compileMenu.sqf b/addons/interact_menu/functions/fnc_compileMenu.sqf index d84130e21c..02941626d1 100644 --- a/addons/interact_menu/functions/fnc_compileMenu.sqf +++ b/addons/interact_menu/functions/fnc_compileMenu.sqf @@ -14,34 +14,31 @@ params ["_target"]; -private ["_objectType","_actionsVarName","_isMan"]; -_objectType = _target; -_isMan = false; +private _objectType = _target; if (_target isEqualType objNull) then { _objectType = typeOf _target; - _isMan = _target isKindOf "CAManBase"; }; -_actionsVarName = format [QGVAR(Act_%1), _objectType]; +private _actionsVarName = format [QGVAR(Act_%1), _objectType]; // Exit if the action menu is already compiled for this class if !(isNil {missionNamespace getVariable [_actionsVarName, nil]}) exitWith {}; -private "_recurseFnc"; -_recurseFnc = { - private ["_actions", "_displayName", "_distance", "_icon", "_statement", "_position", "_condition", "_showDisabled", "_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_insertChildren", "_modifierFunction"]; - params ["_actionsCfg"]; - _actions = []; +private _recurseFnc = { + params ["_actionsCfg", "_parentDistance"]; + private _actions = []; { - _entryCfg = _x; + private _entryCfg = _x; if(isClass _entryCfg) then { - _displayName = getText (_entryCfg >> "displayName"); - _distance = getNumber (_entryCfg >> "distance"); - _icon = getText (_entryCfg >> "icon"); - _statement = compile (getText (_entryCfg >> "statement")); + private _displayName = getText (_entryCfg >> "displayName"); + private _distance = _parentDistance; + if (isNumber (_entryCfg >> "distance")) then {_distance = getNumber (_entryCfg >> "distance");}; + // if (_distance < _parentDistance) then {ACE_LOGWARNING_3("[%1] distance %2 less than parent %3", configName _entryCfg, _distance, _parentDistance);}; + private _icon = getText (_entryCfg >> "icon"); + private _statement = compile (getText (_entryCfg >> "statement")); // If the position entry is present, compile it - _position = getText (_entryCfg >> "position"); + private _position = getText (_entryCfg >> "position"); if (_position != "") then { _position = compile _position; } else { @@ -55,7 +52,7 @@ _recurseFnc = { }; }; - _condition = getText (_entryCfg >> "condition"); + private _condition = getText (_entryCfg >> "condition"); if (_condition == "") then {_condition = "true"}; // Add canInteract (including exceptions) and canInteractWith to condition @@ -63,13 +60,13 @@ _recurseFnc = { _condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, _target, %1)] call EFUNC(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")]; }; - _insertChildren = compile (getText (_entryCfg >> "insertChildren")); - _modifierFunction = compile (getText (_entryCfg >> "modifierFunction")); + private _insertChildren = compile (getText (_entryCfg >> "insertChildren")); + private _modifierFunction = compile (getText (_entryCfg >> "modifierFunction")); - _showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0; - _enableInside = (getNumber (_entryCfg >> "enableInside")) > 0; - _canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0; - _runOnHover = false; + private _showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0; + private _enableInside = (getNumber (_entryCfg >> "enableInside")) > 0; + private _canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0; + private _runOnHover = false; if (isText (_entryCfg >> "runOnHover")) then { _runOnHover = compile getText (_entryCfg >> "runOnHover"); } else { @@ -77,9 +74,9 @@ _recurseFnc = { }; _condition = compile _condition; - _children = [_entryCfg] call _recurseFnc; + private _children = [_entryCfg, _distance] call _recurseFnc; - _entry = [ + private _entry = [ [ configName _entryCfg, _displayName, @@ -97,19 +94,16 @@ _recurseFnc = { ]; _actions pushBack _entry; }; - } forEach (configProperties [_actionsCfg, "isClass _x", true]); + nil + } count (configProperties [_actionsCfg, "isClass _x", true]); _actions }; -private ["_actionsCfg","_actions"]; -_actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_Actions"; +private _actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_Actions"; + +TRACE_1("Building ACE_Actions",_objectType); +private _actions = [_actionsCfg, 0] call _recurseFnc; -// If the classname inherits from CAManBase, just copy it's menu without recompiling a new one -_actions = if (_isMan) then { - + (missionNamespace getVariable QGVAR(Act_CAManBase)) -} else { - [_actionsCfg] call _recurseFnc -}; missionNamespace setVariable [_actionsVarName, _actions]; /* @@ -125,7 +119,7 @@ missionNamespace setVariable [_actionsVarName, _actions]; [], {[0,0,0]}, 1, - [false,false,false] + [false,false,false,false,false] ], [children actions] ] diff --git a/addons/interact_menu/functions/fnc_compileMenuSelfAction.sqf b/addons/interact_menu/functions/fnc_compileMenuSelfAction.sqf index 123f83110d..de1364ee84 100644 --- a/addons/interact_menu/functions/fnc_compileMenuSelfAction.sqf +++ b/addons/interact_menu/functions/fnc_compileMenuSelfAction.sqf @@ -14,46 +14,42 @@ params ["_target"]; -private ["_objectType","_actionsVarName","_isMan"]; -_objectType = _target; -_isMan = false; +private _objectType = _target; if (_target isEqualType objNull) then { _objectType = typeOf _target; - _isMan = _target isKindOf "CAManBase"; }; -_actionsVarName = format [QGVAR(SelfAct_%1), _objectType]; +private _actionsVarName = format [QGVAR(SelfAct_%1), _objectType]; // Exit if the action menu is already compiled for this class if !(isNil {missionNamespace getVariable [_actionsVarName, nil]}) exitWith {}; -private "_recurseFnc"; -_recurseFnc = { - private ["_actions", "_displayName", "_icon", "_statement", "_condition", "_showDisabled", - "_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_insertChildren", "_modifierFunction"]; + +private _recurseFnc = { params ["_actionsCfg"]; - _actions = []; + + private _actions = []; { - _entryCfg = _x; + private _entryCfg = _x; if(isClass _entryCfg) then { - _displayName = getText (_entryCfg >> "displayName"); + private _displayName = getText (_entryCfg >> "displayName"); - _icon = getText (_entryCfg >> "icon"); - _statement = compile (getText (_entryCfg >> "statement")); + private _icon = getText (_entryCfg >> "icon"); + private _statement = compile (getText (_entryCfg >> "statement")); - _condition = getText (_entryCfg >> "condition"); + private _condition = getText (_entryCfg >> "condition"); if (_condition == "") then {_condition = "true"}; // Add canInteract (including exceptions) and canInteractWith to condition _condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, _target, %1)] call EFUNC(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")]; - _insertChildren = compile (getText (_entryCfg >> "insertChildren")); - _modifierFunction = compile (getText (_entryCfg >> "modifierFunction")); + private _insertChildren = compile (getText (_entryCfg >> "insertChildren")); + private _modifierFunction = compile (getText (_entryCfg >> "modifierFunction")); - _showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0; - _enableInside = (getNumber (_entryCfg >> "enableInside")) > 0; - _canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0; - _runOnHover = true; + private _showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0; + private _enableInside = (getNumber (_entryCfg >> "enableInside")) > 0; + private _canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0; + private _runOnHover = true; if (isText (_entryCfg >> "runOnHover")) then { _runOnHover = compile getText (_entryCfg >> "runOnHover"); } else { @@ -61,9 +57,9 @@ _recurseFnc = { }; _condition = compile _condition; - _children = [_entryCfg] call _recurseFnc; + private _children = [_entryCfg] call _recurseFnc; - _entry = [ + private _entry = [ [ configName _entryCfg, _displayName, @@ -81,16 +77,15 @@ _recurseFnc = { ]; _actions pushBack _entry; }; - } forEach (configProperties [_actionsCfg, "isClass _x", true]); + nil + } count (configProperties [_actionsCfg, "isClass _x", true]); _actions }; -private ["_actionsCfg","_actions"]; -_actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_SelfActions"; +private _actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_SelfActions"; -private ["_baseDisplayName", "_baseIcon"]; -_baseDisplayName = ""; -_baseIcon = ""; +private _baseDisplayName = ""; +private _baseIcon = ""; if (_objectType isKindOf "CAManBase") then { _baseDisplayName = localize LSTRING(SelfActionsRoot); _baseIcon = "\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa"; @@ -107,12 +102,9 @@ if (_objectType isKindOf "CAManBase") then { }; }; -// If the classname inherits from CAManBase, just copy it's menu without recompiling a new one -_actions = if (_isMan) then { - + (missionNamespace getVariable QGVAR(SelfAct_CAManBase)) -} else { - // Create a master action to base on self action - [ +TRACE_1("Building ACE_SelfActions",_objectType); +// Create a master action to base on self action +private _actions = [ [ [ "ACE_SelfActions", @@ -127,11 +119,10 @@ _actions = if (_isMan) then { {}, "Spine3", 10, - [false,true,false] + [false,true,false,false,false] ], [_actionsCfg] call _recurseFnc ] - ] -}; + ]; missionNamespace setVariable [_actionsVarName, _actions]; diff --git a/addons/interact_menu/functions/fnc_compileMenuZeus.sqf b/addons/interact_menu/functions/fnc_compileMenuZeus.sqf index ef7c36abc9..6026735154 100644 --- a/addons/interact_menu/functions/fnc_compileMenuZeus.sqf +++ b/addons/interact_menu/functions/fnc_compileMenuZeus.sqf @@ -15,41 +15,38 @@ // Exit if the action menu is already compiled for zeus if !(isNil {missionNamespace getVariable [QGVAR(ZeusActions), nil]}) exitWith {}; -private "_recurseFnc"; -_recurseFnc = { - private ["_actions", "_displayName", "_icon", "_statement", "_condition", "_showDisabled", - "_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_insertChildren", "_modifierFunction"]; +private _recurseFnc = { params ["_actionsCfg"]; - _actions = []; + private _actions = []; { - _entryCfg = _x; + private _entryCfg = _x; if(isClass _entryCfg) then { - _displayName = getText (_entryCfg >> "displayName"); + private _displayName = getText (_entryCfg >> "displayName"); - _icon = getText (_entryCfg >> "icon"); - _statement = compile (getText (_entryCfg >> "statement")); + private _icon = getText (_entryCfg >> "icon"); + private _statement = compile (getText (_entryCfg >> "statement")); - _condition = getText (_entryCfg >> "condition"); + private _condition = getText (_entryCfg >> "condition"); if (_condition == "") then {_condition = "true"}; - _insertChildren = compile (getText (_entryCfg >> "insertChildren")); - _modifierFunction = compile (getText (_entryCfg >> "modifierFunction")); + private _insertChildren = compile (getText (_entryCfg >> "insertChildren")); + private _modifierFunction = compile (getText (_entryCfg >> "modifierFunction")); - _showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0; - _enableInside = (getNumber (_entryCfg >> "enableInside")) > 0; - _canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0; - _runOnHover = true; + private _showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0; + private _enableInside = (getNumber (_entryCfg >> "enableInside")) > 0; + private _canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0; + private _runOnHover = true; if (isText (_entryCfg >> "runOnHover")) then { _runOnHover = compile getText (_entryCfg >> "runOnHover"); } else { _runOnHover = (getNumber (_entryCfg >> "runOnHover")) > 0; }; - _condition = compile _condition; - _children = [_entryCfg] call _recurseFnc; + private _condition = compile _condition; + private _children = [_entryCfg] call _recurseFnc; - _entry = [ + private _entry = [ [ configName _entryCfg, _displayName, @@ -60,7 +57,7 @@ _recurseFnc = { {}, [0,0,0], 10, //distace - [_showDisabled,_enableInside,_canCollapse,_runOnHover], + [_showDisabled,_enableInside,_canCollapse,_runOnHover,false], _modifierFunction ], _children @@ -71,8 +68,7 @@ _recurseFnc = { _actions }; -private ["_actionsCfg"]; -_actionsCfg = configFile >> "ACE_ZeusActions"; +private _actionsCfg = configFile >> "ACE_ZeusActions"; // Create a master action to base zeus actions on GVAR(ZeusActions) = [ @@ -87,7 +83,7 @@ GVAR(ZeusActions) = [ {}, {[0,0,0]}, 10, - [false,true,false] + [false,true,false,false,false] ], [_actionsCfg] call _recurseFnc ] diff --git a/addons/interact_menu/functions/fnc_createAction.sqf b/addons/interact_menu/functions/fnc_createAction.sqf index 0edef384d4..db31200c47 100644 --- a/addons/interact_menu/functions/fnc_createAction.sqf +++ b/addons/interact_menu/functions/fnc_createAction.sqf @@ -13,7 +13,7 @@ * 6: Action parameters (Optional) * 7: Position (Position array, Position code or Selection Name) , or (Optional) * 8: Distance (Optional) - * 9: Other parameters (Optional) + * 9: Other parameters [showDisabled,enableInside,canCollapse,runOnHover,doNotCheckLOS] (Optional) * 10: Modifier function (Optional) * * Return value: @@ -26,6 +26,8 @@ */ #include "script_component.hpp" +// IGNORE_PRIVATE_WARNING(_actionName,_displayName,_icon,_statement,_condition,_insertChildren,_customParams,_position,_distance,_params,_modifierFunction); + params [ "_actionName", "_displayName", @@ -41,16 +43,16 @@ params [ ]; _position = if (_position isEqualType "") then { - // If the action is set to a selection, create the suitable code - compile format ["_target selectionPosition '%1'", _position]; + // If the action is set to a selection, create the suitable code - IGNORE_PRIVATE_WARNING(_target); + compile format ["_target selectionPosition '%1'", _position]; +} else { + if (_position isEqualType []) then { + // If the action is set to a array position, create the suitable code + compile format ["%1", _position]; } else { - if (_position isEqualType []) then { - // If the action is set to a array position, create the suitable code - compile format ["%1", _position]; - } else { - _position; - }; + _position; }; +}; [ _actionName, @@ -58,7 +60,6 @@ _position = if (_position isEqualType "") then { _icon, _statement, _condition, - _insertChildren, _customParams, _position, diff --git a/addons/interact_menu/functions/fnc_ctrlSetParsedTextCached.sqf b/addons/interact_menu/functions/fnc_ctrlSetParsedTextCached.sqf index 334fc13f25..1c4e535d66 100644 --- a/addons/interact_menu/functions/fnc_ctrlSetParsedTextCached.sqf +++ b/addons/interact_menu/functions/fnc_ctrlSetParsedTextCached.sqf @@ -1,11 +1,24 @@ -// by commy2 +/* + * Author: commy2 + * Sets the controls structured text if it isn't already set. + * + * Argument: + * 0: Structured Text Ctrl + * 1: Index + * 2: Text + * + * Return value: + * None + * + * Public: No + */ #include "script_component.hpp" params ["_ctrl", "_index", "_text"]; //systemChat str (_text != ARR_SELECT(GVAR(ParsedTextCached),_index,"-1")); -if (_text != ARR_SELECT(GVAR(ParsedTextCached),_index,"-1")) then { +if (_text != (GVAR(ParsedTextCached) param [_index,"-1"])) then { GVAR(ParsedTextCached) set [_index, _text]; _ctrl ctrlSetStructuredText parseText _text; }; diff --git a/addons/interact_menu/functions/fnc_findActionNode.sqf b/addons/interact_menu/functions/fnc_findActionNode.sqf index 41ab658a62..edd0cace04 100644 --- a/addons/interact_menu/functions/fnc_findActionNode.sqf +++ b/addons/interact_menu/functions/fnc_findActionNode.sqf @@ -11,7 +11,7 @@ * Action node or if not found * * Example: - * [_actionTree, ["ACE_TapShoulderRight","VulcanPinchAction"]] call ace_interact_menu_fnc_findActionNode; + * [actionTree, ["ACE_TapShoulderRight","VulcanPinchAction"]] call ace_interact_menu_fnc_findActionNode; * * Public: No */ @@ -19,18 +19,16 @@ params ["_actionTreeList", "_parentPath"]; -private ["_parentNode", "_foundParentNode", "_fnc_findFolder", "_actionTree"]; - // Hack to make this work on the root node too -if (count _parentPath == 0) exitWith { +if (_parentPath isEqualTo []) exitWith { [[],_actionTreeList] }; // Search the class action trees and find where to insert the entry -_parentNode = [[],_actionTreeList]; -_foundParentNode = false; +private _parentNode = [[],_actionTreeList]; +private _foundParentNode = false; -_fnc_findFolder = { +private _fnc_findFolder = { params ["_parentPath", "_level", "_actionNode"]; { diff --git a/addons/interact_menu/functions/fnc_handlePlayerChanged.sqf b/addons/interact_menu/functions/fnc_handlePlayerChanged.sqf index a0962d7883..d8ad91c434 100644 --- a/addons/interact_menu/functions/fnc_handlePlayerChanged.sqf +++ b/addons/interact_menu/functions/fnc_handlePlayerChanged.sqf @@ -14,8 +14,7 @@ params ["_newUnit", "_oldUnit"]; // add to new unit -private "_ehid"; -_ehid = [_newUnit, "DefaultAction", {GVAR(openedMenuType) >= 0}, { +private _ehid = [_newUnit, "DefaultAction", {GVAR(openedMenuType) >= 0}, { if (!GVAR(actionOnKeyRelease) && GVAR(actionSelected)) then { [GVAR(openedMenuType),true] call FUNC(keyUp); }; diff --git a/addons/interact_menu/functions/fnc_isSubPath.sqf b/addons/interact_menu/functions/fnc_isSubPath.sqf index 0a02fe2ea7..53d88eb9d1 100644 --- a/addons/interact_menu/functions/fnc_isSubPath.sqf +++ b/addons/interact_menu/functions/fnc_isSubPath.sqf @@ -9,18 +9,20 @@ * Return value: * Bool * + * Example: + * [[["ACE_SelfActions", player],["ace_Gestures", player]], [["ACE_SelfActions", player]]] call ace_interact_menu_fnc_isSubPath + * * Public: No */ #include "script_component.hpp" params ["_longPath", "_shortPath"]; -private ["_isSubPath","_i"]; -_isSubPath = true; +private _isSubPath = true; if (count _shortPath > count _longPath) exitWith {false}; -for [{_i = 0},{_i < count _shortPath},{_i = _i + 1}] do { +for [{private _i = 0},{_i < count _shortPath},{_i = _i + 1}] do { if !((_longPath select _i) isEqualTo (_shortPath select _i)) exitWith { _isSubPath = false; }; diff --git a/addons/interact_menu/functions/fnc_keyDown.sqf b/addons/interact_menu/functions/fnc_keyDown.sqf index 56c0e6e19c..a8759a5007 100644 --- a/addons/interact_menu/functions/fnc_keyDown.sqf +++ b/addons/interact_menu/functions/fnc_keyDown.sqf @@ -65,7 +65,7 @@ if (GVAR(useCursorMenu)) then { // uiNamespace getVariable QGVAR(cursorMenuOpened); GVAR(cursorPos) = [0.5,0.5,0]; - _ctrl = (findDisplay 91919) ctrlCreate ["RscStructuredText", 9922]; + private _ctrl = (findDisplay 91919) ctrlCreate ["RscStructuredText", 9922]; _ctrl ctrlSetPosition [safeZoneX, safeZoneY, safeZoneW, safeZoneH]; _ctrl ctrlCommit 0; @@ -75,8 +75,7 @@ if (GVAR(useCursorMenu)) then { setMousePosition [0.5, 0.5]; }; -GVAR(selfMenuOffset) = ((positionCameraToWorld [0, 0, 2]) call EFUNC(common,positionToASL)) vectorDiff - ((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL)); +GVAR(selfMenuOffset) = (AGLtoASL (positionCameraToWorld [0, 0, 2])) vectorDiff (AGLtoASL (positionCameraToWorld [0, 0, 0])); if (GVAR(menuAnimationSpeed) > 0) then { //Auto expand the first level when self, mounted vehicle or zeus (skips the first animation as there is only one choice) diff --git a/addons/interact_menu/functions/fnc_keyUp.sqf b/addons/interact_menu/functions/fnc_keyUp.sqf index 86580afa67..b6eae6f527 100644 --- a/addons/interact_menu/functions/fnc_keyUp.sqf +++ b/addons/interact_menu/functions/fnc_keyUp.sqf @@ -24,9 +24,8 @@ if (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then { if(GVAR(actionSelected)) then { this = GVAR(selectedTarget); - private ["_player","_target","_actionData"]; - _player = ACE_Player; - _target = GVAR(selectedTarget); + private _player = ACE_Player; + private _target = GVAR(selectedTarget); // Clear the conditions caches ["clearConditionCaches", []] call EFUNC(common,localEvent); @@ -35,7 +34,7 @@ if(GVAR(actionSelected)) then { if (!(GVAR(actionOnKeyRelease)) && !_calledByClicking) exitWith {}; // Check the action conditions - _actionData = GVAR(selectedAction) select 0; + private _actionData = GVAR(selectedAction) select 0; if ([_target, _player, _actionData select 6] call (_actionData select 4)) then { // Call the statement [_target, _player, _actionData select 6] call (_actionData select 3); diff --git a/addons/interact_menu/functions/fnc_render.sqf b/addons/interact_menu/functions/fnc_render.sqf index 1f7cf8140b..7ca243817c 100644 --- a/addons/interact_menu/functions/fnc_render.sqf +++ b/addons/interact_menu/functions/fnc_render.sqf @@ -8,8 +8,12 @@ * Return value: * None * + * Example: + * [] call ace_interact_menu_fnc_render + * * Public: No */ +// #define ENABLE_PERFORMANCE_COUNTERS #include "script_component.hpp" BEGIN_COUNTER(fnc_render); @@ -42,7 +46,7 @@ if (GVAR(openedMenuType) >= 0) then { }; } forEach GVAR(currentOptions); - if(_closestSelection == -1) exitWith {}; + if (_closestSelection == -1) exitWith {END_COUNTER(fnc_renderMenuOpen);}; private _closest = GVAR(currentOptions) select _closestSelection; _closest params ["_action", "_sPos", "_hoverPath"]; diff --git a/addons/interact_menu/functions/fnc_renderActionPoints.sqf b/addons/interact_menu/functions/fnc_renderActionPoints.sqf index c5b2c887ce..1d42f38c6c 100644 --- a/addons/interact_menu/functions/fnc_renderActionPoints.sqf +++ b/addons/interact_menu/functions/fnc_renderActionPoints.sqf @@ -14,56 +14,57 @@ GVAR(currentOptions) = []; -private ["_player","_numInteractObjects","_numInteractions","_actionsVarName","_classActions","_target","_player","_action","_cameraPos","_cameraDir", "_lambda", "_nearestObjects", "_pos", "_virtualPoint", "_wavesAtOrigin", "_wavesAtVirtualPoint"]; -_player = ACE_player; +private _player = ACE_player; -_cameraPos = (positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL); -_cameraDir = ((positionCameraToWorld [0, 0, 1]) call EFUNC(common,positionToASL)) vectorDiff _cameraPos; +private _cameraPosASL = AGLtoASL (positionCameraToWorld [0, 0, 0]); +private _cameraDir = (AGLtoASL (positionCameraToWorld [0, 0, 1])) vectorDiff _cameraPosASL; -_fnc_renderNearbyActions = { +private _fnc_renderNearbyActions = { // Render all nearby interaction menus #define MAXINTERACTOBJECTS 3 GVAR(foundActions) = []; GVAR(lastTimeSearchedActions) = ACE_diagTime; - _numInteractObjects = 0; - _nearestObjects = nearestObjects [ACE_player, ["All"], 13]; + private _numInteractObjects = 0; + private _nearestObjects = nearestObjects [ACE_player, ["All"], 13]; { - _target = _x; + private _target = _x; // Quick oclussion test. Skip objects more than 1 m behind the camera plane - _lambda = ((getPosASL _x) vectorDiff _cameraPos) vectorDotProduct _cameraDir; + private _lambda = ((getPosASL _x) vectorDiff _cameraPosASL) vectorDotProduct _cameraDir; if ((_lambda > -1) && {!isObjectHidden _target}) then { - _numInteractions = 0; + private _numInteractions = 0; // Prevent interacting with yourself or your own vehicle if (_target != ACE_player && {_target != vehicle ACE_player}) then { // Iterate through object actions, find base level actions and render them if appropiate - _actionsVarName = format [QGVAR(Act_%1), typeOf _target]; GVAR(objectActionList) = _target getVariable [QGVAR(actions), []]; { // Only render them directly if they are base level actions - if (count (_x select 1) == 0) then { + if ((_x select 1) isEqualTo []) then { // Try to render the menu - _action = _x; + private _action = _x; if ([_target, _action] call FUNC(renderBaseMenu)) then { _numInteractions = _numInteractions + 1; GVAR(foundActions) pushBack [_target, _action, GVAR(objectActionList)]; }; }; - } forEach GVAR(objectActionList); + nil + } count GVAR(objectActionList); // Iterate through base level class actions and render them if appropiate - _classActions = missionNamespace getVariable [_actionsVarName, []]; + private _actionsVarName = format [QGVAR(Act_%1), typeOf _target]; + private _classActions = missionNamespace getVariable [_actionsVarName, []]; { - _action = _x; + private _action = _x; // Try to render the menu if ([_target, _action] call FUNC(renderBaseMenu)) then { _numInteractions = _numInteractions + 1; GVAR(foundActions) pushBack [_target, _action, GVAR(objectActionList)]; }; - } forEach _classActions; + nil + } count _classActions; // Limit the amount of objects the player can interact with if (_numInteractions > 0) then { @@ -73,44 +74,33 @@ _fnc_renderNearbyActions = { }; if (_numInteractObjects >= MAXINTERACTOBJECTS) exitWith {}; - } forEach _nearestObjects; + nil + } count _nearestObjects; }; -_fnc_renderLastFrameActions = { +private _fnc_renderLastFrameActions = { { _x params ["_target", "_action", "_objectActionList"]; GVAR(objectActionList) = _objectActionList; [_target, _action] call FUNC(renderBaseMenu); - } forEach GVAR(foundActions); + nil + } count GVAR(foundActions); }; -_fnc_renderSelfActions = { - _target = _this; +private _fnc_renderSelfActions = { + private _target = _this; - // Iterate through object actions, find base level actions and render them if appropiate - _actionsVarName = format [QGVAR(SelfAct_%1), typeOf _target]; + // Set object actions for collectActiveActionTree GVAR(objectActionList) = _target getVariable [QGVAR(selfActions), []]; - /* - { - _action = _x; - // Only render them directly if they are base level actions - if (count (_action select 7) == 1) then { - [_target, _action, 0, [180, 360]] call FUNC(renderMenu); - }; - } forEach GVAR(objectActionList); - */ // Iterate through base level class actions and render them if appropiate - _actionsVarName = format [QGVAR(SelfAct_%1), typeOf _target]; - _classActions = missionNamespace getVariable [_actionsVarName, []]; + private _actionsVarName = format [QGVAR(SelfAct_%1), typeOf _target]; + private _classActions = missionNamespace getVariable [_actionsVarName, []]; - _pos = if !(GVAR(useCursorMenu)) then { - _virtualPoint = (((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL)) vectorAdd GVAR(selfMenuOffset)) call EFUNC(common,ASLToPosition); - _wavesAtOrigin = [(positionCameraToWorld [0, 0, 0])] call EFUNC(common,waveHeightAt); - _wavesAtVirtualPoint = [_virtualPoint] call EFUNC(common,waveHeightAt); - _virtualPoint set [2, ((_virtualPoint select 2) - _wavesAtOrigin + _wavesAtVirtualPoint)]; - _virtualPoint + private _pos = if !(GVAR(useCursorMenu)) then { + //Convert to ASL, add offset and then convert back to AGL (handles waves when over water) + ASLtoAGL ((AGLtoASL (positionCameraToWorld [0, 0, 0])) vectorAdd GVAR(selfMenuOffset)); } else { [0.5, 0.5] }; @@ -118,14 +108,16 @@ _fnc_renderSelfActions = { { _action = _x; [_target, _action, _pos] call FUNC(renderBaseMenu); - } forEach _classActions; + nil + } count _classActions; }; -_fnc_renderZeusActions = { +private _fnc_renderZeusActions = { { - _action = _x; + private _action = _x; [_this, _action, [0.5, 0.5]] call FUNC(renderBaseMenu); - } forEach GVAR(ZeusActions); + nil + } count GVAR(ZeusActions); }; @@ -160,11 +152,10 @@ if (count GVAR(collectedActionPoints) > 1) then { // Order action points according to z GVAR(collectedActionPoints) sort true; - private ["_i","_j","_delta"]; - for [{_i = count GVAR(collectedActionPoints) - 1}, {_i > 0}, {_i = _i - 1}] do { - for [{_j = _i - 1}, {_j >= 0}, {_j = _j - 1}] do { + for [{private _i = count GVAR(collectedActionPoints) - 1}, {_i > 0}, {_i = _i - 1}] do { + for [{private _j = _i - 1}, {_j >= 0}, {_j = _j - 1}] do { // Check if action point _i is ocluded by _j - _delta = vectorNormalized ((GVAR(collectedActionPoints) select _i select 1) vectorDiff (GVAR(collectedActionPoints) select _j select 1)); + private _delta = vectorNormalized ((GVAR(collectedActionPoints) select _i select 1) vectorDiff (GVAR(collectedActionPoints) select _j select 1)); // If _i is inside a cone with 20º half angle with origin on _j if (_delta select 2 > 0.94) exitWith { @@ -178,4 +169,5 @@ if (count GVAR(collectedActionPoints) > 1) then { { _x params ["_z", "_sPos", "_activeActionTree"]; [[], _activeActionTree, _sPos, [180,360]] call FUNC(renderMenu); -} forEach GVAR(collectedActionPoints); + nil +} count GVAR(collectedActionPoints); diff --git a/addons/interact_menu/functions/fnc_renderBaseMenu.sqf b/addons/interact_menu/functions/fnc_renderBaseMenu.sqf index a5ccabf3bf..2bb2808b28 100644 --- a/addons/interact_menu/functions/fnc_renderBaseMenu.sqf +++ b/addons/interact_menu/functions/fnc_renderBaseMenu.sqf @@ -16,88 +16,83 @@ BEGIN_COUNTER(fnc_renderBaseMenu) -private ["_distance","_pos","_weaponDir","_ref","_sPos","_activeActionTree", "_line"]; - params ["_object", "_baseActionNode"]; _baseActionNode params ["_actionData"]; +_actionData params ["_actionName", "", "", "", "", "", "", "_positionCode", "_distance", "_params"]; -_distance = _actionData select 8; // Obtain a 3D position for the action -_pos = if((count _this) > 2) then { +private _pos = if((count _this) > 2) then { _this select 2 } else { // Setup scope variables for position code - private ["_target"]; - _target = _object; + private _target = _object; // Get action position - _object modelToWorldVisual (call (_actionData select 7)) + _object modelToWorldVisual (call _positionCode) }; // For non-self actions, exit if the action is too far away or ocluded -if (GVAR(openedMenuType) == 0 && (vehicle ACE_player == ACE_player) && (isNull curatorCamera) && +private _distanceToBasePoint = 0; //This will be 0 for self/zeus/in-vehicle (used later to check sub action distance) +if ((GVAR(openedMenuType) == 0) && {vehicle ACE_player == ACE_player} && {isNull curatorCamera} && { - private ["_headPos","_actualDistance"]; - _headPos = ACE_player modelToWorldVisual (ACE_player selectionPosition "pilot"); - _actualDistance = _headPos distance _pos; + private _headPos = ACE_player modelToWorldVisual (ACE_player selectionPosition "pilot"); + _distanceToBasePoint = _headPos distance _pos; - if (_actualDistance > _distance) exitWith {true}; + if (_distanceToBasePoint > _distance) exitWith {true}; - if ((_actualDistance > 1.5) && {!((_actionData select 9) select 4)}) exitWith { - // If distance to action is greater than 1.5 m, check LOS - _line = [_headPos call EFUNC(common,positionToASL), _pos call EFUNC(common,positionToASL), _object, ACE_player]; - lineIntersects _line + if ((_distanceToBasePoint > 1.5) && {!(_params select 4)}) exitWith { + // If distance to action is greater than 1.5 m and check isn't disabled in params, check LOS + lineIntersects [AGLtoASL _headPos, AGLtoASL _pos, _object, ACE_player] }; false }) exitWith {false}; // Exit if the action is behind you -_sPos = if (count _pos != 2) then { +private _sPos = if (count _pos != 2) then { worldToScreen _pos } else { _pos }; -if(count _sPos == 0) exitWith {false}; +if (_sPos isEqualTo []) exitWith {false}; // Exit if the action is off screen -if ((_sPos select 0) < safeZoneXAbs || (_sPos select 0) > safeZoneXAbs + safeZoneWAbs) exitWith {false}; -if ((_sPos select 1) < safeZoneY || (_sPos select 1) > safeZoneY + safeZoneH) exitWith {false}; +if ((_sPos select 0) < safeZoneXAbs || {(_sPos select 0) > safeZoneXAbs + safeZoneWAbs}) exitWith {false}; +if ((_sPos select 1) < safeZoneY || {(_sPos select 1) > safeZoneY + safeZoneH}) exitWith {false}; BEGIN_COUNTER(fnc_collectActiveActionTree) // Collect active tree -private "_uid"; -_uid = format [QGVAR(ATCache_%1), _actionData select 0]; -_activeActionTree = [ - [_object, _baseActionNode, []], +private _uid = format [QGVAR(ATCache_%1), _actionName]; +private _activeActionTree = [ + [_object, _baseActionNode, [], _distanceToBasePoint], DFUNC(collectActiveActionTree), _object, _uid, 1.0, "interactMenuClosed" ] call EFUNC(common,cachedCall); END_COUNTER(fnc_collectActiveActionTree) -/* +#ifdef DEBUG_MODE_EXTRA diag_log "Printing: _activeActionTree"; -_fnc_print = { - EXPLODE_2_PVT(_this,_level,_node); - EXPLODE_3_PVT(_node,_actionData,_children,_object); +[0, _activeActionTree] call { + params ["_level", "_node"]; + _node params ["_actionData", "_children", "_object"]; diag_log text format ["Level %1 -> %2 on %3", _level, _actionData select 0, _object]; { [_level + 1, _x] call _fnc_print; } forEach _children; }; -[0, _activeActionTree] call _fnc_print; -*/ +#endif + // Check if there's something left for rendering -if (count _activeActionTree == 0) exitWith {false}; +if (_activeActionTree isEqualTo []) exitWith {false}; BEGIN_COUNTER(fnc_renderMenus); -// IGNORE_PRIVATE_WARNING(_cameraPos,_cameraDir); +// IGNORE_PRIVATE_WARNING(_cameraPosASL,_cameraDir); if (count _pos > 2) then { - _sPos pushBack (((_pos call EFUNC(common,positionToASL)) vectorDiff _cameraPos) vectorDotProduct _cameraDir); + _sPos pushBack (((AGLtoASL _pos) vectorDiff _cameraPosASL) vectorDotProduct _cameraDir); } else { _sPos pushBack 0; }; diff --git a/addons/interact_menu/functions/fnc_renderIcon.sqf b/addons/interact_menu/functions/fnc_renderIcon.sqf index ab909964de..9ead5c65cf 100644 --- a/addons/interact_menu/functions/fnc_renderIcon.sqf +++ b/addons/interact_menu/functions/fnc_renderIcon.sqf @@ -15,21 +15,20 @@ */ #include "script_component.hpp" #define DEFAULT_ICON QUOTE(\z\ace\addons\interaction\ui\dot_ca.paa) -private ["_ctrl", "_pos", "_displayNum"]; params ["_text", "_icon", "_sPos", "_textSettings"]; -//systemChat format ["Icon %1 - %2,%3", _text, _sPos select 0, _sPos select 1]; +TRACE_2("Icon",_text,_sPos); if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then { - _displayNum = [[46, 12] select visibleMap,91919] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]); + private _displayNum = [[46, 12] select visibleMap,91919] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]); GVAR(iconCtrls) pushBack ((findDisplay _displayNum) ctrlCreate ["RscStructuredText", 54021+GVAR(iconCount)]); if (GVAR(useCursorMenu)) then { ((finddisplay _displayNum) displayctrl (54021+GVAR(iconCount))) ctrlAddEventHandler ["MouseMoving", DFUNC(handleMouseMovement)]; ((finddisplay _displayNum) displayctrl (54021+GVAR(iconCount))) ctrlAddEventHandler ["MouseButtonDown", DFUNC(handleMouseButtonDown)]; }; }; -_ctrl = GVAR(iconCtrls) select GVAR(iconCount); +private _ctrl = GVAR(iconCtrls) select GVAR(iconCount); if(_icon == "") then { _icon = DEFAULT_ICON; @@ -41,11 +40,10 @@ _text = if (GVAR(UseListMenu)) then { format ["
%3", _icon, _textSettings, "ace_break_line" callExtension _text]; }; -//_ctrl ctrlSetStructuredText parseText _text; [_ctrl, GVAR(iconCount), _text] call FUNC(ctrlSetParsedTextCached); GVAR(iconCount) = GVAR(iconCount) + 1; -_pos = if (GVAR(UseListMenu)) then { +private _pos = if (GVAR(UseListMenu)) then { [(_sPos select 0)-(0.0095*SafeZoneW), (_sPos select 1)-(0.0095*SafeZoneW), 0.20*SafeZoneW, 0.035*SafeZoneW] } else { [(_sPos select 0)-(0.0750*SafeZoneW), (_sPos select 1)-(0.0095*SafeZoneW), 0.15*SafeZoneW, 0.100*SafeZoneW] diff --git a/addons/interact_menu/functions/fnc_renderMenu.sqf b/addons/interact_menu/functions/fnc_renderMenu.sqf index 573845c08a..6abb980620 100644 --- a/addons/interact_menu/functions/fnc_renderMenu.sqf +++ b/addons/interact_menu/functions/fnc_renderMenu.sqf @@ -15,22 +15,20 @@ */ #include "script_component.hpp" -private ["_menuInSelectedPath", "_path", "_menuDepth", "_x", "_offset", "_newPos", "_forEachIndex", "_player", "_pos", "_target", "_textSettings"]; - params ["_parentPath", "_action", "_sPos", "_angles"]; _action params ["_actionData", "_activeChildren", "_actionObject"]; _angles params ["_centerAngle", "_maxAngleSpan"]; -_menuDepth = (count GVAR(menuDepthPath)); +private _menuDepth = (count GVAR(menuDepthPath)); //BEGIN_COUNTER(constructing_paths); // Store path to action -_path = +_parentPath; +private _path = +_parentPath; _path pushBack [_actionData select 0,_actionObject]; // Check if the menu is on the selected path -_menuInSelectedPath = true; +private _menuInSelectedPath = true; { if (_forEachIndex >= (count GVAR(menuDepthPath))) exitWith { _menuInSelectedPath = false; @@ -44,7 +42,7 @@ _menuInSelectedPath = true; //BEGIN_COUNTER(constructing_colors); //Get text color settings string -_textSettings = GVAR(colorSelectedSettings); +private _textSettings = GVAR(colorSelectedSettings); if(!_menuInSelectedPath) then { _textSettings = (GVAR(textSettingsMatrix) select (count _path)) select _menuDepth; }; @@ -68,13 +66,12 @@ if !(_menuInSelectedPath) exitWith {true}; //BEGIN_COUNTER(children); -private ["_numChildren","_angleSpan","_angle","_angleInterval","_scaleX", "_scaleY", "_offset", "_textSize"]; -_numChildren = count _activeChildren; -_angleSpan = _maxAngleSpan min (55 * ((_numChildren) - 1)); +private _numChildren = count _activeChildren; +private _angleSpan = _maxAngleSpan min (55 * ((_numChildren) - 1)); if (_angleSpan >= 305) then { _angleSpan = 360; }; -_angleInterval = 55; +private _angleInterval = 55; if (_angleSpan < 360) then { if (_numChildren > 1) then { _angleInterval = _angleSpan / (_numChildren - 1); @@ -87,15 +84,15 @@ if (_numChildren == 1) then { }; // Scale menu based on the amount of children -_scaleX = 1; -_scaleY = 1; +private _scaleX = 1; +private _scaleY = 1; if (GVAR(UseListMenu)) then { - _textSize = [0.75, 0.875, 1, 1.2, 1.4] select GVAR(textSize); + private _textSize = [0.75, 0.875, 1, 1.2, 1.4] select GVAR(textSize); _scaleX = _textSize * 0.17 * 1.1; _scaleY = 0.17 * 0.30 * 4/3; } else { - _textSize = if (GVAR(textSize) > 2) then {1.3} else {1}; + private _textSize = if (GVAR(textSize) > 2) then {1.3} else {1}; _scaleX = _textSize * 0.17 * (((0.8 * (0.46 / sin (0.5 * _angleInterval))) min 1.1) max 0.5); _scaleY = _textSize * 0.17 * 4/3 * (((0.8 * (0.46 / sin (0.5 * _angleInterval))) min 1.1) max 0.5); }; @@ -106,15 +103,13 @@ if (_menuInSelectedPath && {_menuDepth == count _path}) then { _scaleY = _scaleY * (0.3 + 0.7 * (((ACE_diagTime - GVAR(expandedTime)) * linearConversion [0, 2, GVAR(menuAnimationSpeed), 8, 16]) min 1)); }; -_target = _actionObject; -_player = ACE_player; +private _target = _actionObject; +private _player = ACE_player; //END_COUNTER(children); -_angle = _centerAngle - _angleSpan / 2; +private _angle = _centerAngle - _angleSpan / 2; { - //BEGIN_COUNTER(children); - private ["_offset","_newPos"]; - _newPos = if (GVAR(UseListMenu)) then { + private _newPos = if (GVAR(UseListMenu)) then { [(_sPos select 0) + _scaleX, (_sPos select 1) + _scaleY * (_forEachIndex - _numChildren/2 + 0.5)]; } else { @@ -122,8 +117,6 @@ _angle = _centerAngle - _angleSpan / 2; (_sPos select 1) + _scaleY * (sin _angle)]; }; - //drawLine3D [_pos, _newPos, [1,0,0,0.8]]; - //END_COUNTER(children); [_path, _x, _newPos, [_angle, 150]] call FUNC(renderMenu); _angle = _angle + _angleInterval; diff --git a/addons/interact_menu/functions/fnc_renderSelector.sqf b/addons/interact_menu/functions/fnc_renderSelector.sqf index 17ded20903..69f8a81b95 100644 --- a/addons/interact_menu/functions/fnc_renderSelector.sqf +++ b/addons/interact_menu/functions/fnc_renderSelector.sqf @@ -15,10 +15,8 @@ params ["_sPos", "_icon"]; -private ["_displayNum", "_ctrl", "_pos"]; - if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then { - _displayNum = [[46, 12] select visibleMap,91919] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]); + private _displayNum = [[46, 12] select visibleMap,91919] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]); GVAR(iconCtrls) pushBack ((findDisplay _displayNum) ctrlCreate ["RscStructuredText", 54021+GVAR(iconCount)]); if (GVAR(useCursorMenu)) then { ((finddisplay _displayNum) displayctrl (54021+GVAR(iconCount))) ctrlAddEventHandler ["MouseMoving", DFUNC(handleMouseMovement)]; @@ -26,9 +24,9 @@ if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then { }; }; -_ctrl = GVAR(iconCtrls) select GVAR(iconCount); +private _ctrl = GVAR(iconCtrls) select GVAR(iconCount); -_pos = if (GVAR(UseListMenu)) then { +private _pos = if (GVAR(UseListMenu)) then { [_ctrl, GVAR(iconCount), format ["", _icon]] call FUNC(ctrlSetParsedTextCached); [(_sPos select 0)-(0.014*SafeZoneW), (_sPos select 1)-(0.014*SafeZoneW), 0.05*SafeZoneW, 0.035*SafeZoneW] } else { diff --git a/addons/interact_menu/functions/fnc_setupTextColors.sqf b/addons/interact_menu/functions/fnc_setupTextColors.sqf index c23d68cfd3..cbdd56fb07 100644 --- a/addons/interact_menu/functions/fnc_setupTextColors.sqf +++ b/addons/interact_menu/functions/fnc_setupTextColors.sqf @@ -12,15 +12,13 @@ */ #include "script_component.hpp" -private ["_menuDepth", "_mixColor", "_pathCount", "_row", "_shadowColor", "_textColor", "_textSize", "_colorShadowMax", "_colorShadowMin", "_colorTextMax", "_colorTextMin", "_shadowSetting"]; - //Mixes 2 colors (number arrays) and makes a color string "#AARRGGBB" for structured text -_mixColor = { +private _mixColor = { params ["_color1", "_color2", "_ratio"]; - private ["_return", "_mix", "_index"]; - _return = ""; + + private _return = ""; for "_index" from 0 to 3 do { - _mix = linearConversion [0, 1, _ratio, (_color1 select _index), (_color2 select _index)]; + private _mix = linearConversion [0, 1, _ratio, (_color1 select _index), (_color2 select _index)]; if (_index != 3) then { _return = _return + ([255 * _mix] call EFUNC(common,toHex)); } else { @@ -30,15 +28,17 @@ _mixColor = { _return }; -_colorTextMin = missionNamespace getVariable [QGVAR(colorTextMin), [1,1,1,0.25]]; -_colorTextMax = missionNamespace getVariable [QGVAR(colorTextMax), [1,1,1,1]]; -_colorShadowMin = missionNamespace getVariable [QGVAR(colorShadowMin), [0,0,0,0.25]]; -_colorShadowMax = missionNamespace getVariable [QGVAR(colorShadowMax), [0,0,0,1]]; -_shadowSetting = missionNamespace getVariable [QGVAR(shadowSetting), 2]; -_textSize = missionNamespace getVariable [QGVAR(textSize), 2]; +private _colorTextMin = missionNamespace getVariable [QGVAR(colorTextMin), [1,1,1,0.25]]; +private _colorTextMax = missionNamespace getVariable [QGVAR(colorTextMax), [1,1,1,1]]; +private _colorShadowMin = missionNamespace getVariable [QGVAR(colorShadowMin), [0,0,0,0.25]]; +private _colorShadowMax = missionNamespace getVariable [QGVAR(colorShadowMax), [0,0,0,1]]; +private _shadowSetting = missionNamespace getVariable [QGVAR(shadowSetting), 2]; +private _textSize = missionNamespace getVariable [QGVAR(textSize), 2]; -_textColor = [_colorTextMin, _colorTextMax, 1] call _mixColor; -_shadowColor = [_colorShadowMin, _colorShadowMax, 1] call _mixColor; +TRACE_6("Building text matrix",_colorTextMin,_colorTextMax,_colorShadowMin,_colorShadowMax,_shadowSetting,_textSize); + +private _textColor = [_colorTextMin, _colorTextMax, 1] call _mixColor; +private _shadowColor = [_colorShadowMin, _colorShadowMax, 1] call _mixColor; _textSize = switch (_textSize) do { case (0): {0.4}; case (1): {0.6}; @@ -51,7 +51,7 @@ GVAR(colorSelectedSettings) = format ["color='%1' size='%2' shadow='%3' shadowCo GVAR(textSettingsMatrix) = []; for "_pathCount" from 0 to 15 do { - _row = []; + private _row = []; for "_menuDepth" from 0 to 15 do { if (_menuDepth > 0) then { _textColor = [_colorTextMin, _colorTextMax, (((_pathCount - 1) / _menuDepth) max 0.25)] call _mixColor; diff --git a/addons/interact_menu/functions/fnc_splitPath.sqf b/addons/interact_menu/functions/fnc_splitPath.sqf index 790ae83466..ba07dc1d9e 100644 --- a/addons/interact_menu/functions/fnc_splitPath.sqf +++ b/addons/interact_menu/functions/fnc_splitPath.sqf @@ -13,12 +13,11 @@ */ #include "script_component.hpp" -private ["_parentPath","_actionName", "_i"]; -_parentPath = []; -for [{_i = 0},{_i < (count _this) - 1},{_i = _i + 1}] do { +private _parentPath = []; +for [{private _i = 0},{_i < (count _this) - 1},{_i = _i + 1}] do { _parentPath pushBack (_this select _i); }; -_actionName = if (count _this > 0) then { +private _actionName = if (count _this > 0) then { _this select ((count _this) - 1); } else { "" diff --git a/addons/interact_menu/functions/fnc_userActions_addHouseActions.sqf b/addons/interact_menu/functions/fnc_userActions_addHouseActions.sqf index 98abfdccd1..a83ff46bba 100644 --- a/addons/interact_menu/functions/fnc_userActions_addHouseActions.sqf +++ b/addons/interact_menu/functions/fnc_userActions_addHouseActions.sqf @@ -1,7 +1,7 @@ /* * Author: PabstMirror * Scans for nearby "Static" objects (buildings) and adds the UserActions to them. - * Called when interact_menu starts rendering (from "interact_keyDown" event) + * Called when interact_menu starts rendering (from "interactMenuOpened" event) * * Arguments: * 0: Interact Menu Type (0 - world, 1 - self) @@ -10,9 +10,9 @@ * Nothing * * Example: - * [0] call ace_interact_menu_fnc_addHouseActions + * [0] call ace_interact_menu_fnc_userActions_addHouseActions * - * Public: Yes + * Public: No */ #include "script_component.hpp" @@ -26,7 +26,6 @@ if (_interactionType != 0) exitWith {}; if ((vehicle ACE_player) != ACE_player) exitWith {}; [{ - private ["_nearBuidlings", "_typeOfHouse", "_houseBeingScaned", "_actionSet", "_memPoints", "_memPointsActions", "_helperPos", "_helperObject"]; params ["_args", "_pfID"]; _args params ["_setPosition", "_addedHelpers", "_housesScaned", "_housesToScanForActions"]; @@ -54,33 +53,34 @@ if ((vehicle ACE_player) != ACE_player) exitWith {}; //If player moved >2 meters from last pos, then rescan if (((getPosASL ace_player) distance _setPosition) < 2) exitWith {}; - _nearBuidlings = nearestObjects [ace_player, ["Static"], 30]; + private _nearBuidlings = nearestObjects [ace_player, ["Static"], 30]; { - _typeOfHouse = typeOf _x; + private _typeOfHouse = typeOf _x; if (((count (configFile >> "CfgVehicles" >> _typeOfHouse >> "UserActions")) == 0) && {(count (getArray (configFile >> "CfgVehicles" >> _typeOfHouse >> "ladders"))) == 0}) then { _housesScaned pushBack _x; } else { _housesToScanForActions pushBack _x; }; - } forEach (_nearBuidlings - _housesScaned); + nil + } count (_nearBuidlings - _housesScaned); _args set [0, (getPosASL ace_player)]; } else { _houseBeingScaned = _housesToScanForActions deleteAt 0; - _typeOfHouse = typeOf _houseBeingScaned; + private _typeOfHouse = typeOf _houseBeingScaned; //Skip this house for now if we are outside of it's radius //(we have to scan far out for the big houses, but we don't want to waste time adding actions on every little shack) if ((_houseBeingScaned != cursorTarget) && {((ACE_player distance _houseBeingScaned) - ((sizeOf _typeOfHouse) / 2)) > 4}) exitWith {}; _housesScaned pushBack _houseBeingScaned; - _actionSet = [_typeOfHouse] call FUNC(userActions_getHouseActions); + private _actionSet = [_typeOfHouse] call FUNC(userActions_getHouseActions); _actionSet params ["_memPoints", "_memPointsActions"]; // systemChat format ["Add Actions for [%1] (count %2) @ %3", _typeOfHouse, (count _memPoints), diag_tickTime]; { - _helperPos = (_houseBeingScaned modelToWorld (_houseBeingScaned selectionPosition _x)) call EFUNC(common,positionToASL); - _helperObject = "ACE_LogicDummy" createVehicleLocal _helperPos; + private _helperPos = AGLtoASL (_houseBeingScaned modelToWorld (_houseBeingScaned selectionPosition _x)); + private _helperObject = "ACE_LogicDummy" createVehicleLocal _helperPos; _addedHelpers pushBack _helperObject; _helperObject setVariable [QGVAR(building), _houseBeingScaned]; _helperObject setPosASL _helperPos; @@ -88,7 +88,8 @@ if ((vehicle ACE_player) != ACE_player) exitWith {}; { [_helperObject, 0, [], _x] call EFUNC(interact_menu,addActionToObject); - } forEach (_memPointsActions select _forEachIndex); + nil + } count (_memPointsActions select _forEachIndex); } forEach _memPoints; }; diff --git a/addons/interact_menu/functions/fnc_userActions_getHouseActions.sqf b/addons/interact_menu/functions/fnc_userActions_getHouseActions.sqf index dee82fd939..c513805d10 100644 --- a/addons/interact_menu/functions/fnc_userActions_getHouseActions.sqf +++ b/addons/interact_menu/functions/fnc_userActions_getHouseActions.sqf @@ -8,22 +8,23 @@ * Return Value: * [[Array of MemPoints], [Array Of Actions]] * - * Public: Yes + * Example: + * ["Land_i_House_Big_01_V1_F"] call ace_interact_menu_fnc_userActions_getHouseActions + * + * Public: No */ #include "script_component.hpp" params ["_typeOfBuilding"]; -private["_action", "_actionDisplayName", "_actionDisplayNameDefault", "_actionMaxDistance", "_actionOffset", "_actionPath", "_actionPosition", "_building", "_configPath", "_endIndex", "_iconImage", "_index", "_ladders", "_memPointIndex", "_memPoints", "_memPointsActions", "_startIndex"]; - -_searchIndex = GVAR(cachedBuildingTypes) find _typeOfBuilding; +private _searchIndex = GVAR(cachedBuildingTypes) find _typeOfBuilding; if (_searchIndex != -1) exitWith {GVAR(cachedBuildingActionPairs) select _searchIndex}; -_memPoints = []; -_memPointsActions = []; +private _memPoints = []; +private _memPointsActions = []; //Get the offset for a memory point: -_fnc_getMemPointOffset = { +private _fnc_getMemPointOffset = { params ["_memoryPoint"]; _memPointIndex = _memPoints find _memoryPoint; _actionOffset = [0,0,0]; @@ -37,13 +38,13 @@ _fnc_getMemPointOffset = { }; // Add UserActions for the building: -_fnc_userAction_Statement = { +private _fnc_userAction_Statement = { params ["_target", "_player", "_variable"]; _variable params ["_actionStatement", "_actionCondition"]; this = _target getVariable [QGVAR(building), objNull]; call _actionStatement; }; -_fnc_userAction_Condition = { +private _fnc_userAction_Condition = { params ["_target", "_player", "_variable"]; _variable params ["_actionStatement", "_actionCondition"]; this = _target getVariable [QGVAR(building), objNull]; @@ -51,16 +52,16 @@ _fnc_userAction_Condition = { call _actionCondition; }; -_configPath = configFile >> "CfgVehicles" >> _typeOfBuilding >> "UserActions"; +private _configPath = configFile >> "CfgVehicles" >> _typeOfBuilding >> "UserActions"; for "_index" from 0 to ((count _configPath) - 1) do { - _actionPath = _configPath select _index; + private _actionPath = _configPath select _index; - _actionDisplayName = getText (_actionPath >> "displayName"); - _actionDisplayNameDefault = getText (_actionPath >> "displayNameDefault"); - _actionPosition = getText (_actionPath >> "position"); - _actionCondition = getText (_actionPath >> "condition"); - _actionStatement = getText (_actionPath >> "statement"); - _actionMaxDistance = getNumber (_actionPath >> "radius"); + private _actionDisplayName = getText (_actionPath >> "displayName"); + private _actionDisplayNameDefault = getText (_actionPath >> "displayNameDefault"); + private _actionPosition = getText (_actionPath >> "position"); + private _actionCondition = getText (_actionPath >> "condition"); + private _actionStatement = getText (_actionPath >> "statement"); + private _actionMaxDistance = getNumber (_actionPath >> "radius"); if (_actionDisplayName == "") then {_actionDisplayName = (configName _x);}; if (_actionPosition == "") then {ERROR("Bad Position");}; @@ -70,53 +71,52 @@ for "_index" from 0 to ((count _configPath) - 1) do { _actionStatement = compile _actionStatement; _actionCondition = compile _actionCondition; _actionMaxDistance = _actionMaxDistance + 0.1; //increase range slightly - _iconImage = ""; //extension ~4x as fast: - _iconImage = "ace_parse_imagepath" callExtension _actionDisplayNameDefault; + private _iconImage = "ace_parse_imagepath" callExtension _actionDisplayNameDefault; - _actionOffset = [_actionPosition] call _fnc_getMemPointOffset; - _memPointIndex = _memPoints find _actionPosition; + private _actionOffset = [_actionPosition] call _fnc_getMemPointOffset; + private _memPointIndex = _memPoints find _actionPosition; _action = [(configName _actionPath), _actionDisplayName, _iconImage, _fnc_userAction_Statement, _fnc_userAction_Condition, {}, [_actionStatement, _actionCondition], _actionOffset, _actionMaxDistance, [false,false,false,false,true]] call EFUNC(interact_menu,createAction); (_memPointsActions select _memPointIndex) pushBack _action; }; // Add Ladder Actions for the building: -_fnc_ladder_ladderUp = { +private _fnc_ladder_ladderUp = { params ["_target", "_player", "_variable"]; _variable params ["_ladderIndex"]; - _building = _target getVariable [QGVAR(building), objNull]; + private _building = _target getVariable [QGVAR(building), objNull]; TRACE_3("Ladder Action - UP",_player,_building,_ladderIndex); _player action ["LadderUp", _building, _ladderIndex, 0]; }; -_fnc_ladder_ladderDown = { +private _fnc_ladder_ladderDown = { params ["_target", "_player", "_variable"]; _variable params ["_ladderIndex"]; - _building = _target getVariable [QGVAR(building), objNull]; + private _building = _target getVariable [QGVAR(building), objNull]; TRACE_3("Ladder Action - Down",_player,_building,_ladderIndex); _player action ["LadderDown", _building, _ladderIndex, 1]; }; -_fnc_ladder_conditional = { +private _fnc_ladder_conditional = { params ["_target", "_player"]; //(Check distance < 2) and (Don't show actions if on a ladder) ((_target distance _player) < 2) && {((getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState _player) >> "onLadder")) == 0)} }; -_ladders = getArray (configFile >> "CfgVehicles" >> _typeOfBuilding >> "ladders"); +private _ladders = getArray (configFile >> "CfgVehicles" >> _typeOfBuilding >> "ladders"); { _x params ["_ladderBottomMemPoint", "_ladderTopMemPoint"]; - _actionMaxDistance = 3; //interact_menu will check head -> target's offset; leave this high and do a precice distance check in condition + private _actionMaxDistance = 3; //interact_menu will check head -> target's offset; leave this high and do a precice distance check in condition - _actionDisplayName = localize "str_action_ladderup"; - _iconImage = "\A3\ui_f\data\igui\cfg\actions\ladderup_ca.paa"; + private _actionDisplayName = localize "str_action_ladderup"; + private _iconImage = "\A3\ui_f\data\igui\cfg\actions\ladderup_ca.paa"; //Ladder Up Action: - _actionOffset = [_ladderBottomMemPoint] call _fnc_getMemPointOffset; + private _actionOffset = [_ladderBottomMemPoint] call _fnc_getMemPointOffset; _actionOffset = _actionOffset vectorAdd [0,0,1]; - _memPointIndex = _memPoints find _ladderBottomMemPoint; - _action = [format ["LadderUp_%1", _forEachIndex], _actionDisplayName, _iconImage, _fnc_ladder_ladderUp, _fnc_ladder_conditional, {}, [_forEachIndex], _actionOffset, _actionMaxDistance, [false,false,false,false,true]] call EFUNC(interact_menu,createAction); + private _memPointIndex = _memPoints find _ladderBottomMemPoint; + private _action = [format ["LadderUp_%1", _forEachIndex], _actionDisplayName, _iconImage, _fnc_ladder_ladderUp, _fnc_ladder_conditional, {}, [_forEachIndex], _actionOffset, _actionMaxDistance, [false,false,false,false,true]] call EFUNC(interact_menu,createAction); (_memPointsActions select _memPointIndex) pushBack _action; _actionDisplayName = localize "str_action_ladderdown"; diff --git a/addons/interact_menu/script_component.hpp b/addons/interact_menu/script_component.hpp index 3117065ca2..7b1ab461ca 100644 --- a/addons/interact_menu/script_component.hpp +++ b/addons/interact_menu/script_component.hpp @@ -12,5 +12,3 @@ #endif #include "\z\ace\addons\main\script_macros.hpp" - -#define ENABLE_PERFORMANCE_COUNTERS diff --git a/addons/medical/XEH_respawn.sqf b/addons/medical/XEH_respawn.sqf index 438e7396cc..7d48672972 100644 --- a/addons/medical/XEH_respawn.sqf +++ b/addons/medical/XEH_respawn.sqf @@ -7,7 +7,7 @@ params ["_unit"]; // Reset captive status for respawning unit if (!(_unit getVariable ["ACE_isUnconscious", false])) then { - [_unit, QGVAR(unconscious), false] call EFUNC(common,setCaptivityStatus); + [_unit, "setCaptive", QGVAR(unconscious), false] call EFUNC(common,statusEffect_set); }; // Remove maximum unconsciousness time handler diff --git a/addons/medical/functions/fnc_setUnconscious.sqf b/addons/medical/functions/fnc_setUnconscious.sqf index 910745d7bb..7cfc6f55b4 100644 --- a/addons/medical/functions/fnc_setUnconscious.sqf +++ b/addons/medical/functions/fnc_setUnconscious.sqf @@ -95,7 +95,7 @@ if (GVAR(moveUnitsFromGroupOnUnconscious)) then { [_unit, true, "ACE_isUnconscious", side group _unit] call EFUNC(common,switchToGroupSide); }; -[_unit, QGVAR(unconscious), true] call EFUNC(common,setCaptivityStatus); +[_unit, "setCaptive", QGVAR(unconscious), true] call EFUNC(common,statusEffect_set); _anim = [_unit] call EFUNC(common,getDeathAnim); [_unit, _anim, 1, true] call EFUNC(common,doAnimation); [{ diff --git a/addons/medical/functions/fnc_unconsciousPFH.sqf b/addons/medical/functions/fnc_unconsciousPFH.sqf index 2922cae465..e78c80f3ec 100644 --- a/addons/medical/functions/fnc_unconsciousPFH.sqf +++ b/addons/medical/functions/fnc_unconsciousPFH.sqf @@ -33,7 +33,7 @@ if (!alive _unit) exitWith { if (GVAR(moveUnitsFromGroupOnUnconscious)) then { [_unit, false, "ACE_isUnconscious", side group _unit] call EFUNC(common,switchToGroupSide); }; - [_unit, QGVAR(unconscious), false] call EFUNC(common,setCaptivityStatus); + [_unit, "setCaptive", QGVAR(unconscious), false] call EFUNC(common,statusEffect_set); [_unit, false] call EFUNC(common,disableAI); //_unit setUnitPos _originalPos; _unit setUnconscious false; @@ -102,7 +102,7 @@ if !(_unit getVariable ["ACE_isUnconscious",false]) exitWith { }; if (!_hasMovedOut) then { // Reset the unit back to the previous captive state. - [_unit, QGVAR(unconscious), false] call EFUNC(common,setCaptivityStatus); + [_unit, "setCaptive", QGVAR(unconscious), false] call EFUNC(common,statusEffect_set); // Swhich the unit back to its original group //Unconscious units shouldn't be put in another group #527: diff --git a/addons/rearm/functions/fnc_dropAmmo.sqf b/addons/rearm/functions/fnc_dropAmmo.sqf index 8fc9ba4945..dff8463e27 100644 --- a/addons/rearm/functions/fnc_dropAmmo.sqf +++ b/addons/rearm/functions/fnc_dropAmmo.sqf @@ -36,7 +36,7 @@ if (_actionID != -1) then { _unit removeAction _actionID; _unit setVariable [QGVAR(ReleaseActionID), nil]; }; -[_unit, QGVAR(vehRearm), false] call EFUNC(common,setForceWalkStatus); +[_unit, "forceWalk", QGVAR(vehRearm), false] call EFUNC(common,statusEffect_set); if (_unholster) then { REARM_UNHOLSTER_WEAPON diff --git a/addons/rearm/functions/fnc_grabAmmo.sqf b/addons/rearm/functions/fnc_grabAmmo.sqf index 9b09d1282d..0b62cb69d5 100644 --- a/addons/rearm/functions/fnc_grabAmmo.sqf +++ b/addons/rearm/functions/fnc_grabAmmo.sqf @@ -19,7 +19,7 @@ params ["_dummy", "_unit"]; REARM_HOLSTER_WEAPON -[_unit, QGVAR(vehRearm), true] call EFUNC(common,setForceWalkStatus); +[_unit, "forceWalk", QGVAR(vehRearm), true] call EFUNC(common,statusEffect_set); [ 5, diff --git a/addons/rearm/functions/fnc_takeSuccess.sqf b/addons/rearm/functions/fnc_takeSuccess.sqf index 952cfdee08..3ced9a729a 100644 --- a/addons/rearm/functions/fnc_takeSuccess.sqf +++ b/addons/rearm/functions/fnc_takeSuccess.sqf @@ -22,7 +22,7 @@ private ["_ammo", "_dummyName", "_dummy", "_actionID"]; params ["_args"]; _args params ["_unit", "_magazineClass", "_target"]; // _target is for future possible finite ammo -[_unit, QGVAR(vehRearm), true] call EFUNC(common,setForceWalkStatus); +[_unit, "forceWalk", QGVAR(vehRearm), true] call EFUNC(common,statusEffect_set); _dummy = [_unit, _magazineClass] call FUNC(createDummy); [_dummy, _unit] call FUNC(pickUpAmmo); diff --git a/addons/refuel/XEH_respawn.sqf b/addons/refuel/XEH_respawn.sqf index 39225f2521..87b8db3514 100644 --- a/addons/refuel/XEH_respawn.sqf +++ b/addons/refuel/XEH_respawn.sqf @@ -6,6 +6,6 @@ _unit = _this select 0; if !(local _unit) exitWith {}; -[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); +[_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set); _unit setVariable [QGVAR(selectedWeaponOnRefuel), nil]; _unit setVariable [QGVAR(isRefueling), false]; diff --git a/addons/refuel/functions/fnc_connectNozzleAction.sqf b/addons/refuel/functions/fnc_connectNozzleAction.sqf index 42190aacc6..1e5c199a22 100644 --- a/addons/refuel/functions/fnc_connectNozzleAction.sqf +++ b/addons/refuel/functions/fnc_connectNozzleAction.sqf @@ -80,7 +80,7 @@ _endPosTestOffset set [2, (_startingOffset select 2)]; _args params ["_unit", "_nozzle", "_target", "_endPosTestOffset"]; _unit setVariable [QGVAR(nozzle), nil]; _unit setVariable [QGVAR(isRefueling), false]; - [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); + [_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set); REFUEL_UNHOLSTER_WEAPON _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1]; if (_actionID != -1) then { diff --git a/addons/refuel/functions/fnc_handleUnconscious.sqf b/addons/refuel/functions/fnc_handleUnconscious.sqf index 6a6e561230..d3927aca09 100644 --- a/addons/refuel/functions/fnc_handleUnconscious.sqf +++ b/addons/refuel/functions/fnc_handleUnconscious.sqf @@ -22,7 +22,7 @@ if (!local _unit || {!_isUnconscious}) exitWith {}; private "_nozzle"; -[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); +[_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set); _nozzle = _unit getVariable [QGVAR(nozzle), objNull]; if !(isNull _nozzle) then { [_unit, _nozzle] call FUNC(dropNozzle); diff --git a/addons/refuel/functions/fnc_returnNozzle.sqf b/addons/refuel/functions/fnc_returnNozzle.sqf index d3fca33021..0cbb56967c 100644 --- a/addons/refuel/functions/fnc_returnNozzle.sqf +++ b/addons/refuel/functions/fnc_returnNozzle.sqf @@ -33,7 +33,7 @@ if (isNull _nozzle || {_source != _target}) exitWith {false}; _args params ["_unit", "_nozzle", "_target"]; _unit setVariable [QGVAR(nozzle), nil]; detach _nozzle; - [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); + [_unit, "ACE_refuel", false] call EFUNC(common,statusEffect_set); REFUEL_UNHOLSTER_WEAPON _unit setVariable [QGVAR(isRefueling), false]; _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1]; diff --git a/addons/refuel/functions/fnc_takeNozzle.sqf b/addons/refuel/functions/fnc_takeNozzle.sqf index 3c52748efc..aeff3c833d 100644 --- a/addons/refuel/functions/fnc_takeNozzle.sqf +++ b/addons/refuel/functions/fnc_takeNozzle.sqf @@ -21,7 +21,7 @@ private ["_endPosOffset"], params ["_unit", "_target", ["_nozzle", objNull]]; -[_unit, QGVAR(vehAttach), true] call EFUNC(common,setForceWalkStatus); +[_unit, "forceWalk", "ACE_refuel", true] call EFUNC(common,statusEffect_set); REFUEL_HOLSTER_WEAPON @@ -70,7 +70,7 @@ if (isNull _nozzle) then { // func is called on fuel truck }; _actionID = _unit addAction [ format ["%1", localize ELSTRING(dragging,Drop)], - '_unit = _this select 0; _nozzle = _unit getVariable QGVAR(nozzle); [_unit, _nozzle] call FUNC(dropNozzle); [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); REFUEL_UNHOLSTER_WEAPON', + '_unit = _this select 0; _nozzle = _unit getVariable QGVAR(nozzle); [_unit, _nozzle] call FUNC(dropNozzle); [_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set); REFUEL_UNHOLSTER_WEAPON', nil, 20, false, @@ -107,7 +107,7 @@ if (isNull _nozzle) then { // func is called on fuel truck }; _actionID = _unit addAction [ format ["%1", localize ELSTRING(dragging,Drop)], - '_unit = _this select 0; _nozzle = _unit getVariable QGVAR(nozzle); [_unit, _nozzle] call FUNC(dropNozzle); [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); REFUEL_UNHOLSTER_WEAPON', + '_unit = _this select 0; _nozzle = _unit getVariable QGVAR(nozzle); [_unit, _nozzle] call FUNC(dropNozzle); [_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set); REFUEL_UNHOLSTER_WEAPON', nil, 20, false, @@ -138,7 +138,7 @@ if !(_nozzle getVariable [QGVAR(jerryCan), false]) then { [_unit, _nozzle] call FUNC(dropNozzle); REFUEL_UNHOLSTER_WEAPON - [_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus); + [_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set); [LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured); }; [_pfID] call cba_fnc_removePerFrameHandler; diff --git a/addons/sandbag/functions/fnc_deploy.sqf b/addons/sandbag/functions/fnc_deploy.sqf index de5bd9458e..1a539929ff 100644 --- a/addons/sandbag/functions/fnc_deploy.sqf +++ b/addons/sandbag/functions/fnc_deploy.sqf @@ -18,7 +18,7 @@ params ["_unit"]; // prevent the placing unit from running -[_unit, "ACE_Sandbag", true] call EFUNC(common,setForceWalkStatus); +[_unit, "forceWalk", "ACE_Sandbag", true] call EFUNC(common,statusEffect_set); // create the sandbag private "_sandBag"; diff --git a/addons/sandbag/functions/fnc_deployCancel.sqf b/addons/sandbag/functions/fnc_deployCancel.sqf index 9186ddbf57..bb9d691fa9 100644 --- a/addons/sandbag/functions/fnc_deployCancel.sqf +++ b/addons/sandbag/functions/fnc_deployCancel.sqf @@ -18,7 +18,7 @@ params ["_unit"]; // enable running again -[_unit, "ACE_Sandbag", false] call EFUNC(common,setForceWalkStatus); +[_unit, "forceWalk", "ACE_Sandbag", false] call EFUNC(common,statusEffect_set); // delete placement dummy deleteVehicle GVAR(sandBag); diff --git a/addons/sandbag/functions/fnc_deployConfirm.sqf b/addons/sandbag/functions/fnc_deployConfirm.sqf index 62848dd0cd..8c789fd124 100644 --- a/addons/sandbag/functions/fnc_deployConfirm.sqf +++ b/addons/sandbag/functions/fnc_deployConfirm.sqf @@ -18,7 +18,7 @@ params ["_unit"]; // enable running again -[_unit, "ACE_Sandbag", false] call EFUNC(common,setForceWalkStatus); +[_unit, "forceWalk", "ACE_Sandbag", false] call EFUNC(common,statusEffect_set); // remove sandbag from inventory _unit removeItem "ACE_Sandbag_empty"; diff --git a/addons/spectator/functions/fnc_stageSpectator.sqf b/addons/spectator/functions/fnc_stageSpectator.sqf index 87b2faffa8..926ac008dc 100644 --- a/addons/spectator/functions/fnc_stageSpectator.sqf +++ b/addons/spectator/functions/fnc_stageSpectator.sqf @@ -66,3 +66,13 @@ if !(_set isEqualTo (GETVAR(_unit,GVAR(isStaged),false))) then { ["spectatorStaged",[_set]] call EFUNC(common,localEvent); }; + +//BandAid for #2677 - if player in unitList weird before being staged, weird things can happen +if ((player in GVAR(unitList)) || {ACE_player in GVAR(unitList)}) then { + [] call FUNC(updateUnits); //update list now + if (!(isNull (findDisplay 12249))) then {//If display is open now, close it and restart + ACE_LOGWARNING("Player in unitList, call ace_spectator_fnc_stageSpectator before ace_spectator_fnc_setSpectator"); + ["fixWeirdList", true] call FUNC(interrupt); + [{["fixWeirdList", false] call FUNC(interrupt);}, []] call EFUNC(common,execNextFrame); + }; +}; diff --git a/addons/switchunits/functions/fnc_initPlayer.sqf b/addons/switchunits/functions/fnc_initPlayer.sqf index 87873c349f..7b0c8f2603 100644 --- a/addons/switchunits/functions/fnc_initPlayer.sqf +++ b/addons/switchunits/functions/fnc_initPlayer.sqf @@ -39,7 +39,7 @@ if (vehicle _playerUnit == _playerUnit) then { _playerUnit linkItem "ItemMap"; removeUniform _playerUnit; - [_playerUnit, "ACE_SwitchUnits", true] call EFUNC(common,setForceWalkStatus); + [_playerUnit, "forceWalk", "ACE_SwitchUnits", true] call EFUNC(common,statusEffect_set); [_playerUnit, _sides] call FUNC(addMapFunction); }; diff --git a/addons/tacticalladder/functions/fnc_cancelTLdeploy.sqf b/addons/tacticalladder/functions/fnc_cancelTLdeploy.sqf index c134df31d1..940b2b612a 100644 --- a/addons/tacticalladder/functions/fnc_cancelTLdeploy.sqf +++ b/addons/tacticalladder/functions/fnc_cancelTLdeploy.sqf @@ -21,7 +21,7 @@ params ["_unit", "_ladder"]; // enable running again -[_unit, "ACE_Ladder", false] call EFUNC(common,setForceWalkStatus); +[_unit, "forceWalk", "ACE_Ladder", false] call EFUNC(common,statusEffect_set); detach _ladder; diff --git a/addons/tacticalladder/functions/fnc_confirmTLdeploy.sqf b/addons/tacticalladder/functions/fnc_confirmTLdeploy.sqf index 0094e460dc..9d5783b327 100644 --- a/addons/tacticalladder/functions/fnc_confirmTLdeploy.sqf +++ b/addons/tacticalladder/functions/fnc_confirmTLdeploy.sqf @@ -19,7 +19,7 @@ params ["_unit", "_ladder"]; // enable running again -[_unit, "ACE_Ladder", false] call EFUNC(common,setForceWalkStatus); +[_unit, "forceWalk", "ACE_Ladder", false] call EFUNC(common,statusEffect_set); private ["_pos1", "_pos2"]; diff --git a/addons/tacticalladder/functions/fnc_positionTL.sqf b/addons/tacticalladder/functions/fnc_positionTL.sqf index 1e7f0db209..629159db75 100644 --- a/addons/tacticalladder/functions/fnc_positionTL.sqf +++ b/addons/tacticalladder/functions/fnc_positionTL.sqf @@ -21,7 +21,7 @@ params ["_unit", "_ladder"]; // prevent the placing unit from running -[_unit, "ACE_Ladder", true] call EFUNC(common,setForceWalkStatus); +[_unit, "forceWalk", "ACE_Ladder", true] call EFUNC(common,statusEffect_set); { _ladder animate [_x, 0]; diff --git a/addons/weather/CfgVehicles.hpp b/addons/weather/CfgVehicles.hpp index f37a62449a..f98a1e50f5 100644 --- a/addons/weather/CfgVehicles.hpp +++ b/addons/weather/CfgVehicles.hpp @@ -53,4 +53,4 @@ class CfgVehicles { description = CSTRING(Module_Description); }; }; -}; \ No newline at end of file +}; diff --git a/addons/weather/CfgWorlds.hpp b/addons/weather/CfgWorlds.hpp index 1391468fd9..dd0a616272 100644 --- a/addons/weather/CfgWorlds.hpp +++ b/addons/weather/CfgWorlds.hpp @@ -48,4 +48,4 @@ class CfgWorlds { {0.08, 0.38, 0.06, 0.04, 0.19, 0.03, 0.02, 0.02}, // November {0.06, 0.37, 0.05, 0.03, 0.18, 0.04, 0.02, 0.02}};// December }; -}; \ No newline at end of file +}; diff --git a/addons/weather/RscTitles.hpp b/addons/weather/RscTitles.hpp index aedebdabfc..d89c8d0671 100644 --- a/addons/weather/RscTitles.hpp +++ b/addons/weather/RscTitles.hpp @@ -1,17 +1,13 @@ -class RscTitles -{ - class RscWindIntuitive - { +class RscTitles { + class RscWindIntuitive { idd=-1; onLoad="with uiNameSpace do { RscWindIntuitive = _this select 0 };"; movingEnable=0; duration=60; fadeIn="false"; fadeOut="false"; - class controls - { - class RscWindIntuitive - { + class controls { + class RscWindIntuitive { idc=132948; type=0; style=48; @@ -28,4 +24,4 @@ class RscTitles }; }; }; -}; \ No newline at end of file +}; diff --git a/addons/weather/UI/wind0.paa b/addons/weather/UI/wind0.paa deleted file mode 100644 index c049caf47e..0000000000 Binary files a/addons/weather/UI/wind0.paa and /dev/null differ diff --git a/addons/weather/UI/wind1.paa b/addons/weather/UI/wind1.paa deleted file mode 100644 index 47d996fe67..0000000000 Binary files a/addons/weather/UI/wind1.paa and /dev/null differ diff --git a/addons/weather/UI/wind10.paa b/addons/weather/UI/wind10.paa deleted file mode 100644 index a9bcd49c1b..0000000000 Binary files a/addons/weather/UI/wind10.paa and /dev/null differ diff --git a/addons/weather/UI/wind11.paa b/addons/weather/UI/wind11.paa deleted file mode 100644 index 469cdedada..0000000000 Binary files a/addons/weather/UI/wind11.paa and /dev/null differ diff --git a/addons/weather/UI/wind2.paa b/addons/weather/UI/wind2.paa deleted file mode 100644 index 585944af45..0000000000 Binary files a/addons/weather/UI/wind2.paa and /dev/null differ diff --git a/addons/weather/UI/wind3.paa b/addons/weather/UI/wind3.paa deleted file mode 100644 index 16b823a9f3..0000000000 Binary files a/addons/weather/UI/wind3.paa and /dev/null differ diff --git a/addons/weather/UI/wind4.paa b/addons/weather/UI/wind4.paa deleted file mode 100644 index a5bd119889..0000000000 Binary files a/addons/weather/UI/wind4.paa and /dev/null differ diff --git a/addons/weather/UI/wind5.paa b/addons/weather/UI/wind5.paa deleted file mode 100644 index 43398e2960..0000000000 Binary files a/addons/weather/UI/wind5.paa and /dev/null differ diff --git a/addons/weather/UI/wind6.paa b/addons/weather/UI/wind6.paa deleted file mode 100644 index 3bd9a9c676..0000000000 Binary files a/addons/weather/UI/wind6.paa and /dev/null differ diff --git a/addons/weather/UI/wind7.paa b/addons/weather/UI/wind7.paa deleted file mode 100644 index a7bb1d5942..0000000000 Binary files a/addons/weather/UI/wind7.paa and /dev/null differ diff --git a/addons/weather/UI/wind8.paa b/addons/weather/UI/wind8.paa deleted file mode 100644 index e51ad530c5..0000000000 Binary files a/addons/weather/UI/wind8.paa and /dev/null differ diff --git a/addons/weather/UI/wind9.paa b/addons/weather/UI/wind9.paa deleted file mode 100644 index 016ca49f7c..0000000000 Binary files a/addons/weather/UI/wind9.paa and /dev/null differ diff --git a/addons/weather/UI/wind_arrow_ca.paa b/addons/weather/UI/wind_arrow_ca.paa new file mode 100644 index 0000000000..7554936ba1 Binary files /dev/null and b/addons/weather/UI/wind_arrow_ca.paa differ diff --git a/addons/weather/UI/wind_dot_ca.paa b/addons/weather/UI/wind_dot_ca.paa new file mode 100644 index 0000000000..8286ffab2d Binary files /dev/null and b/addons/weather/UI/wind_dot_ca.paa differ diff --git a/addons/weather/UI/wind12.paa b/addons/weather/UI/wind_noneCircle_ca.paa similarity index 100% rename from addons/weather/UI/wind12.paa rename to addons/weather/UI/wind_noneCircle_ca.paa diff --git a/addons/weather/XEH_postInit.sqf b/addons/weather/XEH_postInit.sqf index c6f779358f..a19e000332 100644 --- a/addons/weather/XEH_postInit.sqf +++ b/addons/weather/XEH_postInit.sqf @@ -14,6 +14,7 @@ GVAR(ACE_rain) = rain; "ACE_RAIN_PARAMS" addPublicVariableEventHandler { GVAR(rain_period_start_time) = ACE_time; }; "ACE_MISC_PARAMS" addPublicVariableEventHandler { if (!isServer) then { + TRACE_1("MISC PARAMS PVEH",ACE_MISC_PARAMS); if (GVAR(syncMisc)) then { 30 setLightnings (ACE_MISC_PARAMS select 0); 30 setRainbow (ACE_MISC_PARAMS select 1); @@ -27,10 +28,11 @@ GVAR(ACE_rain) = rain; }; }; +GVAR(WindInfo) = false; ["ACE3 Common", QGVAR(WindInfoKey), localize LSTRING(WindInfoKey), { // Conditions: canInteract - if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; + if !([ACE_player, ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false}; // Statement [] call FUNC(displayWindInfo); @@ -40,12 +42,40 @@ GVAR(ACE_rain) = rain; simulWeatherSync; -[FUNC(updateTemperature), 20, []] call CBA_fnc_addPerFrameHandler; -[FUNC(updateHumidity), 20, []] call CBA_fnc_addPerFrameHandler; -[FUNC(updateWind), 1, []] call CBA_fnc_addPerFrameHandler; -[FUNC(updateRain), 2, []] call CBA_fnc_addPerFrameHandler; -[{ + + + +["SettingsInitialized",{ + TRACE_1("SettingsInitialized",GVAR(syncRain)); + + //Create a 0 sec delay PFEH to update rain every frame: if (GVAR(syncRain)) then { - 0 setRain GVAR(ACE_rain); + [{ + 0 setRain GVAR(ACE_rain); + }, 0, []] call CBA_fnc_addPerFrameHandler; }; -}, 0, []] call CBA_fnc_addPerFrameHandler; \ No newline at end of file + + //Create a 1 sec delay PFEH to update wind/rain/temp/humidity: + + //If we don't sync rain, set next time to infinity + GVAR(nextUpdateRain) = if (GVAR(syncRain)) then {0} else {1e99}; + GVAR(nextUpdateTempAndHumidity) = 0; + [{ + BEGIN_COUNTER(weatherPFEH); + + [] call FUNC(updateWind); //Every 1 second + + if (ACE_time >= GVAR(nextUpdateRain)) then { + [] call FUNC(updateRain); //Every 2 seconds + GVAR(nextUpdateRain) = 2 + ACE_time; + }; + if (ACE_time >= GVAR(nextUpdateTempAndHumidity)) then { + [] call FUNC(updateTemperature); //Every 20 seconds + [] call FUNC(updateHumidity); //Every 20 seconds + GVAR(nextUpdateTempAndHumidity) = 20 + ACE_time; + }; + + END_COUNTER(weatherPFEH); + }, 1, []] call CBA_fnc_addPerFrameHandler; + +}] call EFUNC(common,addEventHandler); diff --git a/addons/weather/XEH_postServerInit.sqf b/addons/weather/XEH_postServerInit.sqf index aa733afa5d..f7b830b11d 100644 --- a/addons/weather/XEH_postServerInit.sqf +++ b/addons/weather/XEH_postServerInit.sqf @@ -9,4 +9,10 @@ GVAR(rain_current_range) = -1+(random 2); // Wind call FUNC(initWind); -[FUNC(serverController), GVAR(serverUpdateInterval)] call CBA_fnc_addPerFrameHandler; +["SettingsInitialized", { + TRACE_2("SettingsInitialized",GVAR(enableServerController),GVAR(serverUpdateInterval)); + + if (GVAR(enableServerController)) then { + [FUNC(serverController), GVAR(serverUpdateInterval)] call CBA_fnc_addPerFrameHandler; + }; +}] call EFUNC(common,addEventHandler); diff --git a/addons/weather/functions/fnc_calculateAirDensity.sqf b/addons/weather/functions/fnc_calculateAirDensity.sqf index f3de65f99d..bda8410ddd 100644 --- a/addons/weather/functions/fnc_calculateAirDensity.sqf +++ b/addons/weather/functions/fnc_calculateAirDensity.sqf @@ -1,18 +1,19 @@ /* * Author: Ruthberg - * * Calculates the air density * * Arguments: - * 0: temperature - degrees celcius + * 0: temperature - degrees celsius * 1: pressure - hPa * 2: relativeHumidity - value between 0.0 and 1.0 * * Return Value: * density of air - kg * m^(-3) * - * Return value: - * None + * Example: + * [0, 1020, 0.5] call ace_weather_fnc_calculateAirDensity + * + * Public: No */ #include "script_component.hpp" @@ -21,11 +22,10 @@ params ["_temperature", "_pressure", "_relativeHumidity"]; _pressure = _pressure * 100; // hPa to Pa if (_relativeHumidity > 0) then { - private ["_pSat", "_vaporPressure", "_partialPressure"]; // Saturation vapor pressure calculated according to: http://wahiduddin.net/calc/density_algorithms.htm - _pSat = 6.1078 * 10 ^ ((7.5 * _temperature) / (_temperature + 237.3)); - _vaporPressure = _relativeHumidity * _pSat; - _partialPressure = _pressure - _vaporPressure; + private _pSat = 6.1078 * 10 ^ ((7.5 * _temperature) / (_temperature + 237.3)); + private _vaporPressure = _relativeHumidity * _pSat; + private _partialPressure = _pressure - _vaporPressure; (_partialPressure * DRY_AIR_MOLAR_MASS + _vaporPressure * WATER_VAPOR_MOLAR_MASS) / (UNIVERSAL_GAS_CONSTANT * KELVIN(_temperature)) } else { diff --git a/addons/weather/functions/fnc_calculateBarometricPressure.sqf b/addons/weather/functions/fnc_calculateBarometricPressure.sqf index 134a741127..29b8fa7877 100644 --- a/addons/weather/functions/fnc_calculateBarometricPressure.sqf +++ b/addons/weather/functions/fnc_calculateBarometricPressure.sqf @@ -1,6 +1,5 @@ /* * Author: Ruthberg - * * Calculates the barometric pressure based on altitude and weather * * Arguments: @@ -9,8 +8,10 @@ * Return Value: * barometric pressure - hPA * - * Return value: - * None + * Example: + * 0 call ace_weather_fnc_calculateBarometricPressure + * + * Public: No */ #include "script_component.hpp" diff --git a/addons/weather/functions/fnc_calculateDensityAltitude.sqf b/addons/weather/functions/fnc_calculateDensityAltitude.sqf index 97889e2499..8dea9849b1 100644 --- a/addons/weather/functions/fnc_calculateDensityAltitude.sqf +++ b/addons/weather/functions/fnc_calculateDensityAltitude.sqf @@ -1,6 +1,5 @@ /* * Author: Ruthberg - * * Calculates density altitude for a given air density * * Arguments: @@ -9,8 +8,10 @@ * Return Value: * density altitude - m * - * Return value: - * None + * Example: + * 1.225 call ace_weather_fnc_calculateDensityAltitude + * + * Public: No */ #include "script_component.hpp" diff --git a/addons/weather/functions/fnc_calculateDewPoint.sqf b/addons/weather/functions/fnc_calculateDewPoint.sqf index cbfc606054..81db9565dc 100644 --- a/addons/weather/functions/fnc_calculateDewPoint.sqf +++ b/addons/weather/functions/fnc_calculateDewPoint.sqf @@ -1,17 +1,18 @@ /* * Author: Ruthberg - * * Calculates dew point based on temperature and relative humidity * * Arguments: - * 0: temperature - degrees celcius - * 2: relativeHumidity - value between 0.0 and 1.0 + * 0: temperature - degrees celsius + * 1: relativeHumidity - value between 0.0 and 1.0 * * Return Value: * dew point * - * Return value: - * None + * Example: + * [32, 0.4] call ace_weather_fnc_calculateDewPoint + * + * Public: No */ #include "script_component.hpp" @@ -24,7 +25,6 @@ if (_rh == 0) exitWith { CELSIUS(0) }; // Source: https://en.wikipedia.org/wiki/Dew_point -private ["_gamma"]; -_gamma = ln(_rh) + (__b * _t) / (__c + _t); +private _gamma = ln(_rh) + (__b * _t) / (__c + _t); (__c * _gamma) / (__b - _gamma) diff --git a/addons/weather/functions/fnc_calculateHeatIndex.sqf b/addons/weather/functions/fnc_calculateHeatIndex.sqf index 057c13d7ad..a4626128de 100644 --- a/addons/weather/functions/fnc_calculateHeatIndex.sqf +++ b/addons/weather/functions/fnc_calculateHeatIndex.sqf @@ -1,17 +1,18 @@ /* * Author: Ruthberg - * * Calculates heat index based on temperature and relative humidity * * Arguments: - * 0: temperature - degrees celcius + * 0: temperature - degrees celsius * 1: relativeHumidity - value between 0.0 and 1.0 * * Return Value: * heat index * - * Return value: - * None + * Example: + * [36, 0.75] call ace_weather_fnc_calculateHeatIndex + * + * Public: No */ #include "script_component.hpp" diff --git a/addons/weather/functions/fnc_calculateRoughnessLength.sqf b/addons/weather/functions/fnc_calculateRoughnessLength.sqf index 4fd0d18fb3..423f3fc3d6 100644 --- a/addons/weather/functions/fnc_calculateRoughnessLength.sqf +++ b/addons/weather/functions/fnc_calculateRoughnessLength.sqf @@ -1,6 +1,5 @@ /* * Author: Ruthberg - * * Calculates the terrain roughness length at a given world position * * Arguments: @@ -9,19 +8,20 @@ * Return Value: * roughness length * + * Example: + * (getPosASL player) call ace_weather_fnc_calculateRoughnessLength + * * Public: No */ #include "script_component.hpp" -private ["_roughness_lengths", "_windSource", "_nearBuildings", "_isWater"]; - // Source: http://es.ucsc.edu/~jnoble/wind/extrap/index.html -_roughness_lengths = [0.0002, 0.0005, 0.0024, 0.03, 0.055, 0.1, 0.2, 0.4, 0.8, 1.6]; +#define ROUGHNESS_LENGTHS [0.0002, 0.0005, 0.0024, 0.03, 0.055, 0.1, 0.2, 0.4, 0.8, 1.6] -_windSource = _this vectorDiff ((vectorNormalized ACE_wind) vectorMultiply 25); +private _windSource = _this vectorDiff ((vectorNormalized ACE_wind) vectorMultiply 25); -_nearBuildings = count (_windSource nearObjects ["Building", 50]); -_isWater = surfaceIsWater _windSource; +private _nearBuildings = count (_windSource nearObjects ["Building", 50]); +private _isWater = surfaceIsWater _windSource; if (_nearBuildings == 0 && _isWater) exitWith { 0.0005 @@ -31,4 +31,4 @@ if (_nearBuildings >= 10) exitWith { 1.6 }; -_roughness_lengths select (2 + (_nearBuildings min 6)) +ROUGHNESS_LENGTHS select (2 + (_nearBuildings min 6)) diff --git a/addons/weather/functions/fnc_calculateSpeedOfSound.sqf b/addons/weather/functions/fnc_calculateSpeedOfSound.sqf index 322ba75ac5..f645ba2368 100644 --- a/addons/weather/functions/fnc_calculateSpeedOfSound.sqf +++ b/addons/weather/functions/fnc_calculateSpeedOfSound.sqf @@ -1,16 +1,17 @@ /* * Author: Ruthberg - * * Calculates the speed of sound for a given temperature * * Arguments: - * temperature - degrees celcius + * temperature - degrees celsius * * Return Value: * speed of sound - m/s * - * Return value: - * None + * Example: + * 0 call ace_weather_fnc_calculateSpeedOfSound + * + * Public: No */ #include "script_component.hpp" diff --git a/addons/weather/functions/fnc_calculateTemperatureAtHeight.sqf b/addons/weather/functions/fnc_calculateTemperatureAtHeight.sqf index 5e02795d59..e33b8213eb 100644 --- a/addons/weather/functions/fnc_calculateTemperatureAtHeight.sqf +++ b/addons/weather/functions/fnc_calculateTemperatureAtHeight.sqf @@ -1,6 +1,5 @@ /* * Author: Ruthberg - * * Calculates the temperature based on altitude and weather * * Arguments: @@ -9,8 +8,10 @@ * Return Value: * temperature - degrees celsius * - * Return value: - * None + * Example: + * 500 call ace_weather_fnc_calculateTemperatureAtHeight + * + * Public: No */ #include "script_component.hpp" diff --git a/addons/weather/functions/fnc_calculateWetBulb.sqf b/addons/weather/functions/fnc_calculateWetBulb.sqf index 94e96cd11b..a8a58b0dc3 100644 --- a/addons/weather/functions/fnc_calculateWetBulb.sqf +++ b/addons/weather/functions/fnc_calculateWetBulb.sqf @@ -1,36 +1,35 @@ /* * Author: Ruthberg - * * Calculates wet bulb based on temperature and relative humidity * * Arguments: - * 0: temperature - degrees celcius + * 0: temperature - degrees celsius * 1: pressure - hPa * 2: relativeHumidity - value between 0.0 and 1.0 * * Return Value: * wet bulb * - * Return value: - * None + * Example: + * [0, 1020, 0.5] call ace_weather_fnc_calculateWetBulb + * + * Public: No */ #include "script_component.hpp" -private ["_es", "_e", "_eDiff", "_eGuessPrev", "_cTempDelta", "_twGuess", "_eguess"]; - params ["_temperature", "_pressure", "_relativeHumidity"]; // Source: http://cosmoquest.org/forum/showthread.php?155366-Calculating-Wet-Bulb-Temperature-from-RH-amp-Dry-Bulb -_es = 6.112 * exp((17.67 * _temperature) / (_temperature + 243.5)); -_e = _es * _relativeHumidity; -_eDiff = _es - _e; -_eGuessPrev = _es; -_cTempDelta = 3.3145; -_twGuess = _temperature; +private _es = 6.112 * exp((17.67 * _temperature) / (_temperature + 243.5)); +private _e = _es * _relativeHumidity; +private _eDiff = _es - _e; +private _eGuessPrev = _es; +private _cTempDelta = 3.3145; +private _twGuess = _temperature; for "_j" from 1 to 50 do { _twGuess = _twGuess - _cTempDelta; - _eguess = 6.112 * exp((17.67 * _twGuess) / (_twGuess + 243.5)); + private _eguess = 6.112 * exp((17.67 * _twGuess) / (_twGuess + 243.5)); _eguess = _eguess - (_pressure * (_temperature - _twGuess) * 0.00066 * (1 + (0.00115 * _twGuess))); _eDiff = _eguess - _e; if (abs(_eDiff) <= 0.001) exitWith {}; diff --git a/addons/weather/functions/fnc_calculateWindChill.sqf b/addons/weather/functions/fnc_calculateWindChill.sqf index ee3a20283b..0e17d53377 100644 --- a/addons/weather/functions/fnc_calculateWindChill.sqf +++ b/addons/weather/functions/fnc_calculateWindChill.sqf @@ -1,15 +1,17 @@ /* * Author: Ruthberg - * * Calculates wind chill based on temperature and wind speed * * Arguments: - * 0: temperature - degrees celcius + * 0: temperature - degrees celsius * 1: wind speed - m/s * * Return Value: * wind chill * + * Example: + * [0, 10] call ace_weather_fnc_calculateWindChill + * * Public: No */ #include "script_component.hpp" diff --git a/addons/weather/functions/fnc_calculateWindSpeed.sqf b/addons/weather/functions/fnc_calculateWindSpeed.sqf index 87c6c49d42..206bc1d298 100644 --- a/addons/weather/functions/fnc_calculateWindSpeed.sqf +++ b/addons/weather/functions/fnc_calculateWindSpeed.sqf @@ -1,43 +1,42 @@ /* * Author: Ruthberg - * * Calculates the true wind speed at a given world position * * Arguments: * 0: world position - posASL - * 1: Account for wind gradient + * 1: Account for wind gradient (used in advanced ballistics) * 2: Account for terrain * 3: Account for obstacles * * Return Value: * wind speed - m/s * + * Example: + * [eyePos ACE_player, true, true, true] call ace_weather_fnc_calculateWindSpeed; + * * Public: No */ #include "script_component.hpp" -private ["_fnc_polar2vect", "_windSpeed", "_windDir", "_windDirAdjusted", "_height", "_newWindSpeed", "_windSource", "_roughnessLength"]; - params ["_position", "_windGradientEnabled", "_terrainEffectEnabled", "_obstacleEffectEnabled"]; -_fnc_polar2vect = { - private ["_mag2D"]; - params ["_x", "_y", "_z"]; - _mag2D = _x * cos(_z); - [_mag2D * sin(_y), _mag2D * cos(_y), _x * sin(_z)]; +private _fnc_polar2vect = { + params ["_mag","_dir","_elev"]; + private _mag2D = _mag * cos(_elev); + [_mag2D * sin(_dir), _mag2D * cos(_dir), _mag * sin(_elev)]; }; -_windSpeed = vectorMagnitude ACE_wind; -_windDir = (ACE_wind select 0) atan2 (ACE_wind select 1); -_windDirAdjusted = _windDir + 180; +private _windSpeed = vectorMagnitude ACE_wind; +private _windDir = (ACE_wind select 0) atan2 (ACE_wind select 1); +private _windDirAdjusted = _windDir + 180; // Wind gradient if (_windGradientEnabled) then { if (_windSpeed > 0.05) then { - _height = (ASLToATL _position) select 2; + private _height = (ASLToATL _position) select 2; _height = 0 max _height min 20; if (_height < 20) then { - _roughnessLength = _position call FUNC(calculateRoughnessLength); + private _roughnessLength = _position call FUNC(calculateRoughnessLength); _windSpeed = _windSpeed * abs(ln(_height / _roughnessLength) / ln(20 / _roughnessLength)); }; }; @@ -46,9 +45,9 @@ if (_windGradientEnabled) then { // Terrain effect on wind if (_terrainEffectEnabled) then { if (_windSpeed > 0.05) then { - _newWindSpeed = 0; + private _newWindSpeed = 0; { - _windSource = [100, _windDirAdjusted, _x] call _fnc_polar2vect; + private _windSource = [100, _windDirAdjusted, _x] call _fnc_polar2vect; if (!(terrainIntersectASL [_position, _position vectorAdd _windSource])) exitWith { _newWindSpeed = cos(_x * 9) * _windSpeed; }; @@ -60,6 +59,7 @@ if (_terrainEffectEnabled) then { if (!(terrainIntersectASL [_position, _position vectorAdd _windSource])) exitWith { _newWindSpeed = cos(_x * 9) * _windSpeed; }; + nil } count [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; _windSpeed = _newWindSpeed; }; @@ -68,9 +68,9 @@ if (_terrainEffectEnabled) then { // Obstacle effect on wind if (_obstacleEffectEnabled) then { if (_windSpeed > 0.05) then { - _newWindSpeed = 0; + private _newWindSpeed = 0; { - _windSource = [20, _windDirAdjusted, _x] call _fnc_polar2vect; + private _windSource = [20, _windDirAdjusted, _x] call _fnc_polar2vect; if (!(lineIntersects [_position, _position vectorAdd _windSource])) exitWith { _newWindSpeed = cos(_x * 2) * _windSpeed; }; @@ -82,6 +82,7 @@ if (_obstacleEffectEnabled) then { if (!(lineIntersects [_position, _position vectorAdd _windSource])) exitWith { _newWindSpeed = cos(_x * 2) * _windSpeed; }; + nil } count [0, 5, 10, 15, 20, 25, 30, 35, 40, 45]; _windSpeed = _newWindSpeed; }; diff --git a/addons/weather/functions/fnc_displayWindInfo.sqf b/addons/weather/functions/fnc_displayWindInfo.sqf index 98d9026c1c..f81384c1b0 100644 --- a/addons/weather/functions/fnc_displayWindInfo.sqf +++ b/addons/weather/functions/fnc_displayWindInfo.sqf @@ -1,6 +1,5 @@ /* * Author: Ruthberg - * * Displays a wind info (colored arrow) in the top left corner of the screen * * Argument: @@ -8,6 +7,11 @@ * * Return value: * None + * + * Example: + * [] call ace_weather_fnc_displayWindInfo + * + * Public: No */ #include "script_component.hpp" @@ -16,64 +20,87 @@ if (GVAR(WindInfo)) exitWith { GVAR(WindInfo) = false; - 0 cutText ["", "PLAIN"]; + (["RscWindIntuitive"] call BIS_fnc_rscLayer) cutText ["", "PLAIN"]; true }; -if (underwater ACE_player) exitWith { false }; -if (vehicle ACE_player != ACE_player) exitWith { false }; -2 cutText ["", "PLAIN"]; EGVAR(advanced_ballistics,Protractor) = false; 1 cutText ["", "PLAIN"]; GVAR(WindInfo) = true; -[{ - private ["_windSpeed", "_windDir", "_playerDir", "_windIndex", "_windColor"]; - if !(GVAR(WindInfo) && !(underwater ACE_player) && vehicle ACE_player == ACE_player) exitWith { +TRACE_1("Starting Wind Info PFEH", GVAR(WindInfo)); + +[{ + disableSerialization; + params ["", "_pfID"]; + + if ((!GVAR(WindInfo)) || {!([ACE_player, ACE_player, []] call EFUNC(common,canInteractWith))}) exitWith { + TRACE_1("Ending Wind Info PFEH", GVAR(WindInfo)); GVAR(WindInfo) = false; - 0 cutText ["", "PLAIN"]; - [_this select 1] call CBA_fnc_removePerFrameHandler; + (["RscWindIntuitive"] call BIS_fnc_rscLayer) cutText ["", "PLAIN"]; + [_pfID] call CBA_fnc_removePerFrameHandler; }; - _windIndex = 12; - _windColor = [1, 1, 1, 1]; - _windSpeed = if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then { + //Keeps the display open: + (["RscWindIntuitive"] call BIS_fnc_rscLayer) cutRsc ["RscWindIntuitive", "PLAIN", 1, false]; + + private _windSpeed = if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then { // With wind gradient [eyePos ACE_player, true, true, true] call FUNC(calculateWindSpeed); } else { // Without wind gradient [eyePos ACE_player, false, true, true] call FUNC(calculateWindSpeed); }; - - if (_windSpeed > 0.2) then { - _playerDir = (ACE_player call CBA_fnc_headDir) select 0; - _windDir = (ACE_wind select 0) atan2 (ACE_wind select 1); - _windIndex = round(((_playerDir - _windDir + 360) % 360) / 30); - _windIndex = _windIndex % 12; - }; + + + private _playerDir = (ACE_player call CBA_fnc_headDir) select 0; + private _windDir = (ACE_wind select 0) atan2 (ACE_wind select 1); + _windDir = 30 * (round(((_windDir - _playerDir + 360) % 360) / 30)); // Color Codes from https://en.wikipedia.org/wiki/Beaufort_scale#Modern_scale - if (_windSpeed > 0.3) then { _windColor = [0.796, 1, 1, 1]; }; - if (_windSpeed > 1.5) then { _windColor = [0.596, 0.996, 0.796, 1]; }; - if (_windSpeed > 3.3) then { _windColor = [0.596, 0.996, 0.596, 1]; }; - if (_windSpeed > 5.4) then { _windColor = [0.6, 0.996, 0.4, 1]; }; - if (_windSpeed > 7.9) then { _windColor = [0.6, 0.996, 0.047, 1]; }; - if (_windSpeed > 10.7) then { _windColor = [0.8, 0.996, 0.059, 1]; }; - if (_windSpeed > 13.8) then { _windColor = [1, 0.996, 0.067, 1]; }; - if (_windSpeed > 17.1) then { _windColor = [1, 0.796, 0.051, 1]; }; - if (_windSpeed > 20.7) then { _windColor = [1, 0.596, 0.039, 1]; }; - if (_windSpeed > 24.4) then { _windColor = [1, 0.404, 0.031, 1]; }; - if (_windSpeed > 28.4) then { _windColor = [1, 0.22, 0.027, 1]; }; - if (_windSpeed > 32.6) then { _windColor = [1, 0.078, 0.027, 1]; }; + private _beaufortNumber = 0; + private _windColor = [1, 1, 1, 1]; + if (_windSpeed > 0.3) then { _windColor = [0.796, 1, 1, 1]; _beaufortNumber = 1; }; + if (_windSpeed > 1.5) then { _windColor = [0.596, 0.996, 0.796, 1]; _beaufortNumber = 2; }; + if (_windSpeed > 3.3) then { _windColor = [0.596, 0.996, 0.596, 1]; _beaufortNumber = 3; }; + if (_windSpeed > 5.4) then { _windColor = [0.6, 0.996, 0.4, 1]; _beaufortNumber = 4; }; + if (_windSpeed > 7.9) then { _windColor = [0.6, 0.996, 0.047, 1]; _beaufortNumber = 5; }; + if (_windSpeed > 10.7) then { _windColor = [0.8, 0.996, 0.059, 1]; _beaufortNumber = 6; }; + if (_windSpeed > 13.8) then { _windColor = [1, 0.996, 0.067, 1]; _beaufortNumber = 7; }; + if (_windSpeed > 17.1) then { _windColor = [1, 0.796, 0.051, 1]; _beaufortNumber = 8; }; + if (_windSpeed > 20.7) then { _windColor = [1, 0.596, 0.039, 1]; _beaufortNumber = 9; }; + if (_windSpeed > 24.4) then { _windColor = [1, 0.404, 0.031, 1]; _beaufortNumber = 10; }; + if (_windSpeed > 28.4) then { _windColor = [1, 0.22, 0.027, 1]; _beaufortNumber = 11; }; + if (_windSpeed > 32.6) then { _windColor = [1, 0.078, 0.027, 1]; _beaufortNumber = 12; }; - 0 cutRsc ["RscWindIntuitive", "PLAIN", 1, false]; - __ctrl ctrlSetScale 0.75; + TRACE_3("update display",_beaufortNumber,_windDir,_windSpeed); + __ctrl ctrlSetTextColor _windColor; + if (_beaufortNumber > 0) then { + __ctrl ctrlSetText QUOTE(PATHTOF(UI\wind_arrow_ca.paa)); + __ctrl ctrlSetAngle [_windDir, 0.5, 0.5]; + } else { + __ctrl ctrlSetText QUOTE(PATHTOF(UI\wind_noneCircle_ca.paa)); + }; __ctrl ctrlCommit 0; - __ctrl ctrlSetText format[QUOTE(PATHTOF(UI\wind%1.paa)), _windIndex]; - __ctrl ctrlSetTextColor _windColor; + //Update the beaufort balls: + (ctrlPosition __ctrl) params ["_ctrlX", "_ctrlY", "_ctrlWidth", "_ctrlHeight"]; + private _centerX = _ctrlX + _ctrlWidth / 2; + private _centerY = _ctrlY + _ctrlHeight / 2; + private _ballHeight = _ctrlHeight / 17; + private _ballWidth = _ballHeight * 3/4; + + for "_index" from 0 to (_beaufortNumber - 1) do { + private _ball = __dsp ctrlCreate ["RscPicture", _index]; + _ball ctrlSetText QUOTE(PATHTOF(UI\wind_dot_ca.paa)); + _ball ctrlSetTextColor [1,1,1,1]; + private _ballCenterX = _centerX - (_ballWidth / 2) + ((sin _windDir) * 0.013333) * (_index - 4.9) + ((cos _windDir) * 0.0125); + private _ballCenterY = _centerY - (_ballHeight / 2) - ((1 * cos _windDir) * 4/3*0.013333) * (_index - 4.9) + ((sin _windDir) * 0.0125); + _ball ctrlSetPosition [_ballCenterX, _ballCenterY, _ballWidth, _ballHeight]; + _ball ctrlCommit 0; + }; }, 0.5, []] call CBA_fnc_addPerFrameHandler; diff --git a/addons/weather/functions/fnc_getMapData.sqf b/addons/weather/functions/fnc_getMapData.sqf index 2e39f80764..b344ad2bdf 100644 --- a/addons/weather/functions/fnc_getMapData.sqf +++ b/addons/weather/functions/fnc_getMapData.sqf @@ -1,6 +1,5 @@ /* * Author: Ruthberg, esteldunedain - * * Get the weather data for the current map * * Argument: @@ -8,6 +7,11 @@ * * Return value: * None + * + * Example: + * [] call ace_weather_fnc_getMapData + * + * Public: No */ #include "script_component.hpp" @@ -207,4 +211,4 @@ GVAR(TempNight) = [-4, -3, 0, 4, 9, 12, 14, 14, 10, 6, 2, -2]; GVAR(Humidity) = [82, 80, 78, 70, 71, 72, 70, 73, 78, 80, 83, 82]; GVAR(currentTemperature) = 20; -GVAR(currentHumidity) = 0.5; \ No newline at end of file +GVAR(currentHumidity) = 0.5; diff --git a/addons/weather/functions/fnc_getWind.sqf b/addons/weather/functions/fnc_getWind.sqf index 7e133896a6..c9ccd43ff9 100644 --- a/addons/weather/functions/fnc_getWind.sqf +++ b/addons/weather/functions/fnc_getWind.sqf @@ -1,6 +1,5 @@ /* * Author: ACE2 Team, Ruthberg - * * Calculate current wind locally from the data broadcasted by the server * * Argument: @@ -8,17 +7,21 @@ * * Return value: * Wind + * + * Example: + * [] call ace_weather_fnc_getWind + * + * Public: No */ #include "script_component.hpp" -private ["_periodPercent", "_periodPosition"]; - if (isNil "ACE_WIND_PARAMS") exitWith { [0, 0, 0] }; ACE_WIND_PARAMS params ["_dir", "_dirChange", "_spd", "_spdChange", "_period"]; +//Wind _dir is the "source" of the wind [eg: "northerly wind": _dir = 0 -> wind = [0,-1,0];] -_periodPosition = (ACE_time - GVAR(wind_period_start_time)) min _period; -_periodPercent = _periodPosition / _period; +private _periodPosition = (ACE_time - GVAR(wind_period_start_time)) min _period; +private _periodPercent = _periodPosition / _period; _spd = _spd + _spdChange * _periodPercent; _dir = _dir + _dirChange * _periodPercent; diff --git a/addons/weather/functions/fnc_initModuleSettings.sqf b/addons/weather/functions/fnc_initModuleSettings.sqf index 034612ab58..f1e9c1d6fc 100644 --- a/addons/weather/functions/fnc_initModuleSettings.sqf +++ b/addons/weather/functions/fnc_initModuleSettings.sqf @@ -10,6 +10,9 @@ * Return Value: * None * + * Example: + * [module, [], true] call ace_weather_fnc_initModuleSettings + * * Public: No */ diff --git a/addons/weather/functions/fnc_initWind.sqf b/addons/weather/functions/fnc_initWind.sqf index 10b22efa2a..4c88f59f95 100644 --- a/addons/weather/functions/fnc_initWind.sqf +++ b/addons/weather/functions/fnc_initWind.sqf @@ -1,6 +1,5 @@ /* * Author: Ruthberg - * * Inits the wind variables on mission start * * Argument: @@ -8,28 +7,32 @@ * * Return value: * None + * + * Example: + * [] call ace_weather_fnc_initWind + * + * Public: No */ #include "script_component.hpp" -private ["_sum", "_rand", "_csum", "_index", "_month", "_windDirectionProbabilities"]; -_month = date select 1; -_windDirectionProbabilities = GVAR(WindDirectionProbabilities) select (_month - 1); +private _month = date select 1; +private _windDirectionProbabilities = GVAR(WindDirectionProbabilities) select (_month - 1); ACE_wind = [0, 0, 0]; GVAR(wind_direction_reference) = random 360; -_sum = 0; +private _sum = 0; for "_i" from 0 to 7 do { _sum = _sum + (_windDirectionProbabilities select _i); }; -_rand = random _sum; -_csum = [0, 0, 0, 0, 0, 0, 0, 0]; +private _rand = random _sum; +private _csum = [0, 0, 0, 0, 0, 0, 0, 0]; for "_i" from 0 to 7 do { for "_j" from 0 to _i do { _csum set [_i, (_csum select _i) + (_windDirectionProbabilities select _j)]; }; }; -_index = 0; +private _index = 0; for "_i" from 0 to 7 do { if (_rand > (_csum select _i)) then { _index = _index + 1; diff --git a/addons/weather/functions/fnc_serverController.sqf b/addons/weather/functions/fnc_serverController.sqf index 2cbdeb581e..9791049914 100644 --- a/addons/weather/functions/fnc_serverController.sqf +++ b/addons/weather/functions/fnc_serverController.sqf @@ -1,6 +1,5 @@ /* * Author: Ruthberg - * * Gather weather parameters and broadcast them to the clients * * Argument: @@ -8,11 +7,14 @@ * * Return value: * None + * + * Example: + * [] call ace_weather_fnc_serverController + * + * Public: No */ #include "script_component.hpp" -if (!GVAR(enableServerController)) exitWith {}; - if (GVAR(useACEWeather)) then { // Use location based real world weather data [] call FUNC(updateAceWeather); @@ -23,7 +25,9 @@ if (GVAR(useACEWeather)) then { publicVariable "ACE_RAIN_PARAMS"; }; if (GVAR(syncWind)) then { - ACE_WIND_PARAMS = [wind call CBA_fnc_vectDir, 0, vectorMagnitude wind, 0, GVAR(serverUpdateInterval)]; + //Wind _dir is the "source" of the wind [eg: "northerly wind": _dir = 0 -> wind = [0,-1,0];] + private _windDir = ((((wind select 0) atan2 (wind select 1)) + 180) % 360); + ACE_WIND_PARAMS = [_windDir, 0, vectorMagnitude wind, 0, GVAR(serverUpdateInterval)]; publicVariable "ACE_WIND_PARAMS"; }; if (GVAR(syncMisc)) then { diff --git a/addons/weather/functions/fnc_updateAceWeather.sqf b/addons/weather/functions/fnc_updateAceWeather.sqf index 029e1eb89b..2eb264d91b 100644 --- a/addons/weather/functions/fnc_updateAceWeather.sqf +++ b/addons/weather/functions/fnc_updateAceWeather.sqf @@ -1,6 +1,5 @@ /* * Author: ACE2 Team, esteldunedain, ruthberg - * * Updates the wind and rain evolution on the server. Broadcasts the current and next values to the clients * * Argument: @@ -8,40 +7,44 @@ * * Return value: * None + * + * Example: + * [] call ace_weather_fnc_updateAceWeather + * + * Public: No */ #include "script_component.hpp" -private ["_overcastMultiplier", "_lastRain", "_rainOverCast", "_transitionTime", "_windDirectionVariance", "_windSpeed", "_windSpeedChange", "_windMaxDiff", "_windMinDiff", "_windDirection", "_windDirectionChange", "_ratioMin", "_ratioMax"]; - -_overcastMultiplier = 1 max (2* overcast) min 2; // 0 (@ overcast 0), 2 (@ overcast 1) +private _overcastMultiplier = 1 max (2* overcast) min 2; // 0 (@ overcast 0), 2 (@ overcast 1) // Rain simulation -if (GVAR(syncRain) && GVAR(rain_period_count) > GVAR(rain_next_period)) then { +if (GVAR(syncRain) && {GVAR(rain_period_count) > GVAR(rain_next_period)}) then { GVAR(rain_next_period) = ceil((1 + (random 10)) / _overcastMultiplier); GVAR(rain_period_count) = 0; - - _lastRain = GVAR(current_rain); - + + private _lastRain = GVAR(current_rain); + private _rainOverCast = 0; + if (overcast >= 0.7) then { _rainOverCast = (overcast - 0.7) / 0.3; if (GVAR(current_rain) == 0) then { // Initialize rain with a random strength depending on the current overcast value GVAR(current_rain) = -0.25 + (random 0.75) + (random 0.5) * _rainOverCast; }; - + GVAR(current_rain) = GVAR(current_rain) + GVAR(current_rain) * ((_rainOverCast * _overcastMultiplier) / 8) * GVAR(rain_current_range); GVAR(current_rain) = 0 max GVAR(current_rain) min 1; - + GVAR(rain_current_range) = -1 + (random 2); } else { _rainOverCast = 1; - + GVAR(current_rain) = 0; }; - - _transitionTime = 1 + (_rainOverCast * 5) + (random (_rainOverCast * 20)); - + + private _transitionTime = 1 + (_rainOverCast * 5) + (random (_rainOverCast * 20)); + ACE_RAIN_PARAMS = [_lastRain, GVAR(current_rain), _transitionTime]; TRACE_4("",_lastRain,_rainOverCast,_transitionTime,overcast); @@ -50,47 +53,47 @@ if (GVAR(syncRain) && GVAR(rain_period_count) > GVAR(rain_next_period)) then { }; // Wind simulation -if (GVAR(syncWind) && GVAR(wind_period_count) > GVAR(wind_next_period)) then { - +if (GVAR(syncWind) && {GVAR(wind_period_count) > GVAR(wind_next_period)}) then { + GVAR(wind_next_period) = ceil((2 + (random 5)) / _overcastMultiplier); GVAR(wind_period_count) = 0; - - _windDirectionVariance = (90 - (random 180)) * (overcast ^ 2); - _windDirection = (360 + GVAR(wind_direction_reference) + _windDirectionVariance) % 360; - _windDirectionChange = _windDirection - GVAR(current_wind_direction); + + private _windDirectionVariance = (90 - (random 180)) * (overcast ^ 2); + private _windDirection = (360 + GVAR(wind_direction_reference) + _windDirectionVariance) % 360; + private _windDirectionChange = _windDirection - GVAR(current_wind_direction); if (_windDirectionChange > 180) then { _windDirectionChange = _windDirectionChange - 360; }; if (_windDirectionChange < -180) then { _windDirectionChange = 360 + _windDirectionChange; }; - - _windMaxDiff = GVAR(mean_wind_speed) - GVAR(max_wind_speed); - _windMinDiff = GVAR(min_wind_speed) - GVAR(mean_wind_speed); - - _ratioMax = (random 1) ^ 2; - _ratioMin = (random 1) ^ 2; - - _windSpeed = GVAR(current_wind_speed); - _windSpeedChange = 0; + + private _windMaxDiff = GVAR(mean_wind_speed) - GVAR(max_wind_speed); + private _windMinDiff = GVAR(min_wind_speed) - GVAR(mean_wind_speed); + + private _ratioMax = (random 1) ^ 2; + private _ratioMin = (random 1) ^ 2; + + private _windSpeed = GVAR(current_wind_speed); + private _windSpeedChange = 0; if ((random 1) < (0.3 max overcast)) then { _windSpeed = GVAR(mean_wind_speed) + _windMaxDiff * _ratioMax + _windMinDiff * _ratioMin; _windSpeedChange = _windSpeed - GVAR(current_wind_speed); }; - - _transitionTime = GVAR(wind_next_period) * GVAR(serverUpdateInterval); - + + private _transitionTime = GVAR(wind_next_period) * GVAR(serverUpdateInterval); + TRACE_5("dirCur/dirNew/spdCur/spdNew/period",GVAR(current_wind_direction),_windDirection,GVAR(current_wind_speed),_windSpeed,_transitionTime); - + ACE_WIND_PARAMS = [GVAR(current_wind_direction), - _windDirectionChange, - GVAR(current_wind_speed), - _windSpeedChange, - _transitionTime]; - + _windDirectionChange, + GVAR(current_wind_speed), + _windSpeedChange, + _transitionTime]; + GVAR(current_wind_direction) = _windDirection; GVAR(current_wind_speed) = _windSpeed; - + GVAR(wind_period_start_time) = ACE_time; publicVariable "ACE_WIND_PARAMS"; }; @@ -102,4 +105,4 @@ if (GVAR(syncMisc)) then { }; GVAR(rain_period_count) = GVAR(rain_period_count) + 1; -GVAR(wind_period_count) = GVAR(wind_period_count) + 1; \ No newline at end of file +GVAR(wind_period_count) = GVAR(wind_period_count) + 1; diff --git a/addons/weather/functions/fnc_updateHumidity.sqf b/addons/weather/functions/fnc_updateHumidity.sqf index df6e64df5d..3ea28d6a44 100644 --- a/addons/weather/functions/fnc_updateHumidity.sqf +++ b/addons/weather/functions/fnc_updateHumidity.sqf @@ -1,27 +1,30 @@ /* * Author: ACE2 Team - * - * Updates GVAR(currentHumidity) based on + * Updates GVAR(currentHumidity) * * Argument: * Nothing * * Return value: * Nothing + * + * Example: + * [] call ace_weather_fnc_updateHumidity + * + * Public: No */ #include "script_component.hpp" -private ["_month", "_avgTemperature", "_pS1", "_pS2"]; -_month = date select 1; +private _month = date select 1; GVAR(currentHumidity) = (GVAR(Humidity) select (_month - 1)) / 100; -if (rain > 0 && overcast > 0.7) then { +if ((rain > 0) && {overcast > 0.7}) then { GVAR(currentHumidity) = 1; } else { - _avgTemperature = ((GVAR(TempDay) select (_month - 1)) + (GVAR(TempNight) select (_month - 1))) / 2; - _pS1 = 6.112 * exp((17.62 * _avgTemperature) / (243.12 + _avgTemperature)); - _PS2 = 6.112 * exp((17.62 * GVAR(currentTemperature)) / (243.12 + GVAR(currentTemperature))); + private _avgTemperature = ((GVAR(TempDay) select (_month - 1)) + (GVAR(TempNight) select (_month - 1))) / 2; + private _pS1 = 6.112 * exp((17.62 * _avgTemperature) / (243.12 + _avgTemperature)); + private _PS2 = 6.112 * exp((17.62 * GVAR(currentTemperature)) / (243.12 + GVAR(currentTemperature))); GVAR(currentHumidity) = GVAR(currentHumidity) * _PS1 / _PS2; GVAR(currentHumidity) = GVAR(currentHumidity) + GVAR(humidityShift); diff --git a/addons/weather/functions/fnc_updateRain.sqf b/addons/weather/functions/fnc_updateRain.sqf index 6c4c829747..8fa18500e8 100644 --- a/addons/weather/functions/fnc_updateRain.sqf +++ b/addons/weather/functions/fnc_updateRain.sqf @@ -1,6 +1,5 @@ /* * Author: ACE2 Team, Ruthberg - * * Updates rain based on ACE_RAIN_PARAMS * * Argument: @@ -8,17 +7,21 @@ * * Return value: * Nothing + * + * Example: + * [] call ace_weather_fnc_updateRain + * + * Public: No */ #include "script_component.hpp" -if (!GVAR(syncRain)) exitWith {}; - if (!isNil "ACE_RAIN_PARAMS") then { ACE_RAIN_PARAMS params ["_oldRain", "_newRain", "_period"]; - private ["_periodPosition", "_periodPercent"]; - _periodPosition = (ACE_time - GVAR(rain_period_start_time)) min _period; - _periodPercent = (_periodPosition / _period) min 1; + private _periodPosition = (ACE_time - GVAR(rain_period_start_time)) min _period; + private _periodPercent = (_periodPosition / _period) min 1; - GVAR(ACE_Rain) = (_oldRain + (_newRain - _oldRain) * _periodPercent); + GVAR(ACE_Rain) = linearConversion [GVAR(rain_period_start_time), (GVAR(rain_period_start_time) + _period), ACE_time, _oldRain, _newRain]; + + TRACE_3("Update Rain",rain,ACE_RAIN_PARAMS,GVAR(ACE_Rain)); }; diff --git a/addons/weather/functions/fnc_updateTemperature.sqf b/addons/weather/functions/fnc_updateTemperature.sqf index 82f126e33f..9ff11859f4 100644 --- a/addons/weather/functions/fnc_updateTemperature.sqf +++ b/addons/weather/functions/fnc_updateTemperature.sqf @@ -1,6 +1,5 @@ /* * Author: ACE2 Team - * * Updates GVAR(currentTemperature) based on the map data * * Argument: @@ -8,14 +7,18 @@ * * Return value: * Nothing + * + * Example: + * [] call ace_weather_fnc_updateTemperature + * + * Public: No */ #include "script_component.hpp" -private ["_time", "_month", "_timeRatio"]; -_time = daytime; -_month = date select 1; +private _time = daytime; +private _month = date select 1; -_timeRatio = abs(_time - 12) / 12; +private _timeRatio = abs(_time - 12) / 12; GVAR(currentTemperature) = (GVAR(TempDay) select (_month - 1)) * (1 - _timeRatio) + (GVAR(TempNight) select (_month - 1)) * _timeRatio; GVAR(currentTemperature) = GVAR(currentTemperature) + GVAR(temperatureShift) - GVAR(badWeatherShift) * overcast; diff --git a/addons/weather/functions/fnc_updateWind.sqf b/addons/weather/functions/fnc_updateWind.sqf index b362458fdb..75724e3674 100644 --- a/addons/weather/functions/fnc_updateWind.sqf +++ b/addons/weather/functions/fnc_updateWind.sqf @@ -1,6 +1,5 @@ /* * Author: ACE2 Team, Ruthberg - * * Updates wind, gusts and waves based on ACE_wind * * Argument: @@ -8,19 +7,22 @@ * * Return value: * Nothing + * + * Example: + * [] call ace_weather_fnc_updateWind + * + * Public: No */ #include "script_component.hpp" if (!GVAR(syncWind)) exitWith { ACE_wind = wind }; -private ["_newWaves"]; - ACE_wind = [] call FUNC(getWind); setWind [ACE_wind select 0, ACE_wind select 1, true]; 2 setGusts 0; // Set waves: 0 when no wind, 1 when wind >= 16 m/s -_newWaves = ((vectorMagnitude ACE_wind) / 16.0) min 1.0; +private _newWaves = ((vectorMagnitude ACE_wind) / 16.0) min 1.0; if (abs(_newWaves - waves) > 0.1) then { 1 setWaves _newWaves; }; diff --git a/addons/weather/script_component.hpp b/addons/weather/script_component.hpp index 2a6aeb0393..c2df236d53 100644 --- a/addons/weather/script_component.hpp +++ b/addons/weather/script_component.hpp @@ -1,6 +1,9 @@ #define COMPONENT weather #include "\z\ace\addons\main\script_mod.hpp" -//#define DEBUG_ENABLED_WEATHER + +// #define DEBUG_MODE_FULL +// #define ENABLE_PERFORMANCE_COUNTERS + #ifdef DEBUG_ENABLED_WEATHER #define DEBUG_MODE_FULL #endif