From fef7441f13784abece188ae98826a5359c87b026 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 5 Jun 2016 21:39:03 +0200 Subject: [PATCH 01/54] Add Advanced Throwing --- addons/advancedthrowing/$PBOPREFIX$ | 1 + addons/advancedthrowing/ACE_Settings.hpp | 26 +++++ addons/advancedthrowing/CfgEventHandlers.hpp | 17 ++++ addons/advancedthrowing/CfgVehicles.hpp | 35 +++++++ addons/advancedthrowing/README.md | 11 +++ addons/advancedthrowing/XEH_PREP.hpp | 14 +++ .../advancedthrowing/XEH_postInitClient.sqf | 31 ++++++ addons/advancedthrowing/XEH_preInit.sqf | 20 ++++ addons/advancedthrowing/XEH_preStart.sqf | 3 + addons/advancedthrowing/config.cpp | 18 ++++ .../functions/fnc_canPrepare.sqf | 22 +++++ .../functions/fnc_canThrow.sqf | 32 +++++++ .../functions/fnc_drawArc.sqf | 84 +++++++++++++++++ .../functions/fnc_drawThrowable.sqf | 94 +++++++++++++++++++ .../functions/fnc_exitThrowMode.sqf | 49 ++++++++++ .../functions/fnc_getMuzzle.sqf | 25 +++++ .../functions/fnc_moduleInit.sqf | 31 ++++++ .../functions/fnc_onKeyDown.sqf | 50 ++++++++++ .../functions/fnc_onMouseButtonDown.sqf | 53 +++++++++++ .../functions/fnc_onMouseScroll.sqf | 46 +++++++++ .../functions/fnc_prepare.sqf | 57 +++++++++++ .../advancedthrowing/functions/fnc_prime.sqf | 43 +++++++++ .../advancedthrowing/functions/fnc_throw.sqf | 57 +++++++++++ .../functions/fnc_throwFiredXEH.sqf | 28 ++++++ .../functions/script_component.hpp | 1 + addons/advancedthrowing/script_component.hpp | 29 ++++++ addons/advancedthrowing/stringtable.xml | 47 ++++++++++ addons/optics/functions/fnc_handleFired.sqf | 2 + addons/weaponselect/XEH_postInit.sqf | 4 - 29 files changed, 926 insertions(+), 4 deletions(-) create mode 100644 addons/advancedthrowing/$PBOPREFIX$ create mode 100644 addons/advancedthrowing/ACE_Settings.hpp create mode 100644 addons/advancedthrowing/CfgEventHandlers.hpp create mode 100644 addons/advancedthrowing/CfgVehicles.hpp create mode 100644 addons/advancedthrowing/README.md create mode 100644 addons/advancedthrowing/XEH_PREP.hpp create mode 100644 addons/advancedthrowing/XEH_postInitClient.sqf create mode 100644 addons/advancedthrowing/XEH_preInit.sqf create mode 100644 addons/advancedthrowing/XEH_preStart.sqf create mode 100644 addons/advancedthrowing/config.cpp create mode 100644 addons/advancedthrowing/functions/fnc_canPrepare.sqf create mode 100644 addons/advancedthrowing/functions/fnc_canThrow.sqf create mode 100644 addons/advancedthrowing/functions/fnc_drawArc.sqf create mode 100644 addons/advancedthrowing/functions/fnc_drawThrowable.sqf create mode 100644 addons/advancedthrowing/functions/fnc_exitThrowMode.sqf create mode 100644 addons/advancedthrowing/functions/fnc_getMuzzle.sqf create mode 100644 addons/advancedthrowing/functions/fnc_moduleInit.sqf create mode 100644 addons/advancedthrowing/functions/fnc_onKeyDown.sqf create mode 100644 addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf create mode 100644 addons/advancedthrowing/functions/fnc_onMouseScroll.sqf create mode 100644 addons/advancedthrowing/functions/fnc_prepare.sqf create mode 100644 addons/advancedthrowing/functions/fnc_prime.sqf create mode 100644 addons/advancedthrowing/functions/fnc_throw.sqf create mode 100644 addons/advancedthrowing/functions/fnc_throwFiredXEH.sqf create mode 100644 addons/advancedthrowing/functions/script_component.hpp create mode 100644 addons/advancedthrowing/script_component.hpp create mode 100644 addons/advancedthrowing/stringtable.xml diff --git a/addons/advancedthrowing/$PBOPREFIX$ b/addons/advancedthrowing/$PBOPREFIX$ new file mode 100644 index 00000000000..efcf4f0c262 --- /dev/null +++ b/addons/advancedthrowing/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\advancedthrowing diff --git a/addons/advancedthrowing/ACE_Settings.hpp b/addons/advancedthrowing/ACE_Settings.hpp new file mode 100644 index 00000000000..5b6ca38ced0 --- /dev/null +++ b/addons/advancedthrowing/ACE_Settings.hpp @@ -0,0 +1,26 @@ +class ACE_Settings { + class GVAR(enabled) { + category = CSTRING(Category); + displayName = CSTRING(Enable_DisplayName); + description = CSTRING(Enable_Description); + typeName = "BOOL"; + value = 1; + isClientSettable = 1; + }; + class GVAR(showThrowArc) { + category = CSTRING(Category); + displayName = CSTRING(ShowThrowArc_DisplayName); + description = CSTRING(ShowThrowArc_Description); + typeName = "BOOL"; + value = 1; + isClientSettable = 1; + }; + class GVAR(showMouseControls) { + category = CSTRING(Category); + displayName = CSTRING(ShowMouseControls_DisplayName); + description = CSTRING(ShowMouseControls_Description); + typeName = "BOOL"; + value = 1; + isClientSettable = 1; + }; +}; diff --git a/addons/advancedthrowing/CfgEventHandlers.hpp b/addons/advancedthrowing/CfgEventHandlers.hpp new file mode 100644 index 00000000000..9426fa861ec --- /dev/null +++ b/addons/advancedthrowing/CfgEventHandlers.hpp @@ -0,0 +1,17 @@ +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preStart)); + }; +}; + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + clientInit = QUOTE(call COMPILE_FILE(XEH_postInitClient)); + }; +}; diff --git a/addons/advancedthrowing/CfgVehicles.hpp b/addons/advancedthrowing/CfgVehicles.hpp new file mode 100644 index 00000000000..77a68362cbd --- /dev/null +++ b/addons/advancedthrowing/CfgVehicles.hpp @@ -0,0 +1,35 @@ +class CfgVehicles { + class ACE_Module; + class GVAR(Module): ACE_Module { + author = ECSTRING(common,ACETeam); + category = "ACE"; + displayName = CSTRING(Category); + function = QFUNC(moduleInit); + scope = 2; + isGlobal = 1; + //icon = PATHTOF(UI\Icon_Module_AdvancedThrowing_ca.paa);//@todo + class Arguments { + class Enabled { + displayName = CSTRING(EnableThrowingSystem_DisplayName); + description = CSTRING(EnableThrowingSystem_Description); + typeName = "BOOL"; + defaultValue = 1; + }; + class ShowThrowArc { + displayName = CSTRING(ShowThrowArc_DisplayName); + description = CSTRING(ShowThrowArc_Description); + typeName = "BOOL"; + defaultValue = 1; + }; + class ShowMouseControls { + displayName = CSTRING(ShowMouseControls_DisplayName); + description = CSTRING(ShowMouseControls_Description); + typeName = "BOOL"; + defaultValue = 1; + }; + }; + class ModuleDescription { + description = CSTRING(Module_Description); + }; + }; +}; diff --git a/addons/advancedthrowing/README.md b/addons/advancedthrowing/README.md new file mode 100644 index 00000000000..3e6ac7f063f --- /dev/null +++ b/addons/advancedthrowing/README.md @@ -0,0 +1,11 @@ +ace_advancedthrowing +=================== + +Integrates advanced throwing by [Dslyecxi](https://github.com/dslyecxi). + + +## Maintainers + +The people responsible for merging changes to this component or answering potential questions. + +- [Jonpas](https://github.com/jonpas) diff --git a/addons/advancedthrowing/XEH_PREP.hpp b/addons/advancedthrowing/XEH_PREP.hpp new file mode 100644 index 00000000000..83bb5ddc995 --- /dev/null +++ b/addons/advancedthrowing/XEH_PREP.hpp @@ -0,0 +1,14 @@ +PREP(canPrepare); +PREP(canThrow); +PREP(drawArc); +PREP(drawThrowable); +PREP(exitThrowMode); +PREP(getMuzzle); +PREP(moduleInit); +PREP(onKeyDown); +PREP(onMouseButtonDown); +PREP(onMouseScroll); +PREP(prepare); +PREP(prime); +PREP(throw); +PREP(throwFiredXEH); diff --git a/addons/advancedthrowing/XEH_postInitClient.sqf b/addons/advancedthrowing/XEH_postInitClient.sqf new file mode 100644 index 00000000000..10493cb9418 --- /dev/null +++ b/addons/advancedthrowing/XEH_postInitClient.sqf @@ -0,0 +1,31 @@ +#include "script_component.hpp" + +// Exit on HC +if (!hasInterface) exitWith {}; + + +// Add keybinds +["ACE3 Weapons", QGVAR(prepare), localize LSTRING(Prepare), { + // Condition + if (!([ACE_player] call FUNC(canPrepare))) exitWith {false}; + + // Statement + [ACE_player] call FUNC(prepare); + true +}, +{false}, +[34, [true, false, false]], false] call CBA_fnc_addKeybind; // Shift + G + + +// Event handlers +["playerChanged", { + [_this select 1, "Player changed"] call FUNC(exitThrowMode); +}] call EFUNC(common,addEventhandler); + +[QGVAR(throwFiredXEH), {_this call FUNC(throwFiredXEH)}] call EFUNC(common,addEventHandler); + + +// Display handlers +["KeyDown", {_this call FUNC(onKeyDown)}] call CBA_fnc_addDisplayHandler; +["MouseButtonDown", {_this call FUNC(onMouseButtonDown)}] call CBA_fnc_addDisplayHandler; +["MouseZChanged", {_this call FUNC(onMouseScroll)}] call CBA_fnc_addDisplayHandler; diff --git a/addons/advancedthrowing/XEH_preInit.sqf b/addons/advancedthrowing/XEH_preInit.sqf new file mode 100644 index 00000000000..8ee6ee34e13 --- /dev/null +++ b/addons/advancedthrowing/XEH_preInit.sqf @@ -0,0 +1,20 @@ +#include "script_component.hpp" + +ADDON = false; + +#include "XEH_PREP.hpp" + +GVAR(inHand) = false; +GVAR(primed) = false; + +GVAR(activeThrowable) = objNull; + +GVAR(throwType) = "normal"; +GVAR(throwSpeed) = 18; + +GVAR(extendedDrop) = false; +GVAR(extendedDropDistance) = 0.2; + +GVAR(dropCookedCounter) = 0; + +ADDON = true; diff --git a/addons/advancedthrowing/XEH_preStart.sqf b/addons/advancedthrowing/XEH_preStart.sqf new file mode 100644 index 00000000000..022888575ed --- /dev/null +++ b/addons/advancedthrowing/XEH_preStart.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" + +#include "XEH_PREP.hpp" diff --git a/addons/advancedthrowing/config.cpp b/addons/advancedthrowing/config.cpp new file mode 100644 index 00000000000..2c5accf8231 --- /dev/null +++ b/addons/advancedthrowing/config.cpp @@ -0,0 +1,18 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common", "ace_weaponselect"}; + author = ECSTRING(common,ACETeam) + authors[] = {"Jonpas", "Dslyecxi", "Zapat"}; + url = ECSTRING(main,URL); + VERSION_CONFIG; + }; +}; + +#include "ACE_Settings.hpp" +#include "CfgEventHandlers.hpp" +#include "CfgVehicles.hpp" diff --git a/addons/advancedthrowing/functions/fnc_canPrepare.sqf b/addons/advancedthrowing/functions/fnc_canPrepare.sqf new file mode 100644 index 00000000000..78fc0e5240e --- /dev/null +++ b/addons/advancedthrowing/functions/fnc_canPrepare.sqf @@ -0,0 +1,22 @@ +/* + * Author: Jonpas + * Checks if a throwable can be prepared. + * + * Arguments: + * 0: Unit + * + * Return Value: + * Can Prepare + * + * Example: + * [unit] call ace_advancedthrowing_fnc_canPrepare + * + * Public: No + */ +#include "script_component.hpp" + +if (!GVAR(enabled) || {call EFUNC(common,isFeatureCameraActive)}) exitWith {false}; + +params ["_unit"]; + +[_unit, objNull, ["isNotInside", "isNotSitting", "isNotOnLadder"]] call EFUNC(common,canInteractWith) diff --git a/addons/advancedthrowing/functions/fnc_canThrow.sqf b/addons/advancedthrowing/functions/fnc_canThrow.sqf new file mode 100644 index 00000000000..5d45795b4c1 --- /dev/null +++ b/addons/advancedthrowing/functions/fnc_canThrow.sqf @@ -0,0 +1,32 @@ +/* + * Author: Jonpas + * Checks if a throwable can be thrown. + * + * Arguments: + * 0: Unit + * + * Return Value: + * Can Throw + * + * Example: + * [unit] call ace_advancedthrowing_fnc_canThrow + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit"]; + +// Disable throwing from non FFV seats due to surface detection issues +if (!GVAR(inHand) || {!(_unit call CBA_fnc_canUseWeapon)}) exitWith {false}; + +if (vehicle _unit != _unit) exitWith { + private _startPos = eyePos _unit; + private _aimLinePos = AGLToASL (positionCameraToWorld [0, 0, 1]); + private _intersections = lineIntersectsSurfaces [_startPos, _aimLinePos, _unit, objNull, false]; + //TRACE_1("Intersections",_intersections); + + (_intersections select {(vehicle _unit) in (_x select 3)}) isEqualTo [] +}; + +true diff --git a/addons/advancedthrowing/functions/fnc_drawArc.sqf b/addons/advancedthrowing/functions/fnc_drawArc.sqf new file mode 100644 index 00000000000..79bef45182a --- /dev/null +++ b/addons/advancedthrowing/functions/fnc_drawArc.sqf @@ -0,0 +1,84 @@ +/* + * Author: Zapat, Dslyecxi, Jonpas + * Draws throw arc. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * call ace_advancedthrowing_fnc_drawArc + * + * Public: No + */ +#include "script_component.hpp" + +// Disable drawing when intersecting with the vehicle, it looks ugly +if (!([ACE_player] call FUNC(canThrow))) exitWith { + drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_0_ca.paa", [1, 0, 0, 1], positionCameraToWorld [0, 0, 1], 2, 2, 0, "", 2]; +}; + +if (isNull GVAR(activeThrowable)) exitWith {}; + +private _direction = THROWSTYLE_NORMAL_DIR; +private _velocity = GVAR(throwSpeed); + +if (GVAR(throwType) == "high") then { + _direction = THROWSTYLE_HIGH_DIR; + _velocity = THROWSTYLE_HIGH_VEL; +}; + +if (GVAR(extendedDrop)) then { + _direction = THROWSTYLE_EXTENDED_DIR; + _velocity = THROWSTYLE_EXTENDED_VEL; +}; + +private _viewStart = AGLToASL (positionCameraToWorld [0, 0, 0]); +private _viewEnd = AGLToASL (positionCameraToWorld _direction); + +private _initialVelocity = (vectorNormalized (_viewEnd vectorDiff _viewStart)) vectorMultiply (_velocity / 1.8); +private _prevTrajASL = getPosASLVisual GVAR(activeThrowable); + +private _pathData = []; + +for "_i" from 0.05 to 1.45 step 0.1 do { + private _newTrajASL = _prevTrajASL vectorAdd (_initialVelocity vectorMultiply _i) vectorAdd ([0, 0, -4.9] vectorMultiply (_i * _i)); + private _cross = 0; + + if (_newTrajASL distance (getPosASL ACE_player) <= 20) then { + if ((ASLToATL _newTrajASL) select 2 <= 0) then { + _cross = 1 + } else { + // Even vanilla throwables go through glass, only "GEOM" LOD will stop it but that will also stop it when there is glass in a window + if (lineIntersects [_prevTrajASL, _newTrajASL]) then { + _cross = 2; + }; + }; + + private _iDim = linearConversion [20, 0, _newTrajASL distance (getPosASL ACE_player), 0.3, 2.5, true]; + private _alpha = linearConversion [20, 0, _newTrajASL distance (getPosASL ACE_player), 0.05, 0.7, true]; + private _movePerc = linearConversion [3, 0, vectorMagnitude (velocity ACE_player), 0, 1, true]; + _alpha = _alpha * _movePerc; + + private _col = [ [1, 1, 1, _alpha], [0, 1, 0, _alpha], [1, 0, 0, _alpha] ] select _cross; + + if (_cross != 2 && lineIntersects [eyePos ACE_player, _newTrajASL]) then { + _col set [3, 0.1] + }; + + _pathData pushBack [_col, ASLToAGL _newTrajASL, _iDim]; + }; + + if (_cross > 0) exitWith {}; + + _prevTrajASL = _newTrajASL; +}; + +reverse _pathData; +// To get the sort order correct from our POV, particularly when using outlined dots +{ + _x params ["_col", "_newTrajAGL", "_iDim"]; + drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_1_ca.paa", _col, _newTrajAGL, _iDim, _iDim, 0, "", 2]; +} forEach _pathData; diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf new file mode 100644 index 00000000000..a8defc82cda --- /dev/null +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -0,0 +1,94 @@ +/* + * Author: Dslyecxi, Jonpas + * Handles drawing the currently selected or cooked throwable. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * call ace_advancedthrowing_fnc_drawThrowable + * + * Public: No + */ +#include "script_component.hpp" + +if (dialog || {!GVAR(inHand)} || {!([ACE_player] call FUNC(canPrepare))}) exitWith { + [ACE_player, "In dialog or no throwable in hand or cannot prepare throwable"] call FUNC(exitThrowMode); +}; + +private _throwable = currentThrowable ACE_player; +private _throwableMag = _throwable select 0; + +// Handle cooking last throwable in inventory +if (GVAR(primed)) then { + _throwableMag = typeOf GVAR(activeThrowable); +} else { + // Some throwables have different classname for magazine and ammo + // Check only CfgMagazines one for correct value only when not primed to assure correct magazine is used + GVAR(throwSpeed) = getNumber (configFile >> "CfgMagazines" >> _throwableMag >> "initSpeed"); +}; + +// Inventory check +if ((count _throwable < 1 && !GVAR(primed)) || {_throwableMag == ""}) exitWith { + [ACE_player, "No valid throwables"] call FUNC(exitThrowMode); +}; + +private _throwableType = getText (configFile >> "CfgMagazines" >> _throwableMag >> "ammo"); + +if (!([ACE_player] call FUNC(canThrow)) && {!GVAR(primed)}) exitWith { + if (!isNull GVAR(activeThrowable)) then { + deleteVehicle GVAR(activeThrowable); + }; +}; + +if (isNull GVAR(activeThrowable) || {(_throwableType != typeOf GVAR(activeThrowable)) && {!GVAR(primed)}}) then { + if (!isNull GVAR(activeThrowable)) then { + deleteVehicle GVAR(activeThrowable); + }; + GVAR(activeThrowable) = _throwableType createVehicleLocal (getPosWorld ACE_player); + GVAR(activeThrowable) enableSimulation false; +}; + + +// Set position +private _leanCoef = (ACE_player selectionPosition "head") select 0; +_leanCoef = _leanCoef - 0.15; // Counter the base offset +if (abs _leanCoef < 0.15 || {vehicle ACE_player != ACE_player}) then { + _leanCoef = 0; +}; + +private _cameraOffset = [_leanCoef, 0, 0.3]; +private _xAdjustBonus = [0, -0.075] select (GVAR(throwType) == "high"); +private _yAdjustBonus = [0, 0.1] select (GVAR(throwType) == "high"); + +_cameraOffset = _cameraOffset vectorAdd CAMERA_ADJUST vectorAdd [_xAdjustBonus, _yAdjustBonus, 0]; +private _posFin = (eyePos ACE_player) vectorAdd (positionCameraToWorld _cameraOffset) vectorDiff (positionCameraToWorld [0, 0, 0]); + +// Orient it nicely, point towards player +GVAR(activeThrowable) setDir ((getDir ACE_player) + 90); + +private _pitch = [-30, -90] select (GVAR(throwType) == "high"); +[GVAR(activeThrowable), _pitch, 0] call BIS_fnc_setPitchBank; + + +if (GVAR(extendedDrop)) then { + _posFin = (eyePos ACE_player) vectorAdd (positionCameraToWorld [_leanCoef, 0, GVAR(extendedDropDistance)]) vectorDiff (positionCameraToWorld [0, 0, 0]); + private _posView = AGLtoASL (positionCameraToWorld [0, 0, 0]); + + // Even vanilla throwables go through glass, only "GEOM" LOD will stop it but that will also stop it when there is glass in a window + if (lineIntersects [_posView, _posFin]) then { + GVAR(extendedDropDistance) = (GVAR(extendedDropDistance) - 0.10) max 0.2; + }; + + GVAR(activeThrowable) setPosASL _posFin; +} else { + if (vehicle ACE_player == ACE_player) then { + GVAR(activeThrowable) setPosASL _posFin; + } else { + //@todo make it work while moving properly + GVAR(activeThrowable) setPosASL _posFin; + }; +}; diff --git a/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf b/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf new file mode 100644 index 00000000000..79ab9ee9818 --- /dev/null +++ b/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf @@ -0,0 +1,49 @@ +/* + * Author: Dslyecxi, Jonpas + * Exits throw mode. + * + * Arguments: + * 0: Unit + * 1: Reason + * + * Return Value: + * None + * + * Example: + * [unit, "reason"] call ace_advancedthrowing_fnc_exitThrowMode + * + * Public: No + */ +#include "script_component.hpp" + +if (!GVAR(inHand)) exitWith {}; + +params ["_unit", "_reason"]; + +TRACE_1("Exit Throw Mode",_reason); +#ifdef DEBUG_MODE_FULL + systemChat format ["Exit Throw Mode: %1", _reason]; +#endif + +if (!GVAR(primed)) then { + deleteVehicle GVAR(activeThrowable); +}; + +GVAR(activeThrowable) = objNull; +GVAR(inHand) = false; +GVAR(primed) = false; +GVAR(dropCookedCounter) = 0; +GVAR(extendedDrop) = false; +GVAR(throwType) = "normal"; + +// Remove controls hint (check if ever enabled is inside the function) +call EFUNC(interaction,hideMouseHint); + +// Remove throw action +[_unit, "DefaultAction", _unit getVariable [QGVAR(throwAction), -1]] call EFUNC(common,removeActionEventHandler); + +// Remove throw arc draw +if (!isNil QGVAR(draw3DHandle)) then { + removeMissionEventHandler ["Draw3D", GVAR(draw3DHandle)]; + GVAR(draw3DHandle) = nil; +}; diff --git a/addons/advancedthrowing/functions/fnc_getMuzzle.sqf b/addons/advancedthrowing/functions/fnc_getMuzzle.sqf new file mode 100644 index 00000000000..7724e48ed47 --- /dev/null +++ b/addons/advancedthrowing/functions/fnc_getMuzzle.sqf @@ -0,0 +1,25 @@ +/* + * Author: PabstMirror + * Retrieve muzzle name from config. + * + * Arguments: + * 0: Magazine Classname + * + * Return Value: + * None + * + * Example: + * "magazine" call ace_advancedthrowing_fnc_getMuzzle + * + * Public: No + */ +#include "script_component.hpp" + +params ["_magazineClassname"]; + +_magazineClassname = toLower _magazineClassname; +private _throwMuzzles = getArray (configFile >> "CfgWeapons" >> "Throw" >> "muzzles"); + +_throwMuzzles = _throwMuzzles select {_magazineClassname in ((getArray (configFile >> "CfgWeapons" >> "Throw" >> _x >> "magazines")) apply {toLower _x})}; + +[_throwMuzzles select 0, ""] select (_throwMuzzles isEqualTo []) diff --git a/addons/advancedthrowing/functions/fnc_moduleInit.sqf b/addons/advancedthrowing/functions/fnc_moduleInit.sqf new file mode 100644 index 00000000000..1d179d30006 --- /dev/null +++ b/addons/advancedthrowing/functions/fnc_moduleInit.sqf @@ -0,0 +1,31 @@ +/* + * Author: Jonpas + * Initializes the Advanced Throwing module. + * + * Arguments: + * 0: Logic + * 1: Synchronized Units + * 2: Module Activated + * + * Return Value: + * None + * + * Example: + * [logic, [unit1, unit2], true] call ace_advancedthrowing_fnc_moduleInit + * + * Public: + * No + */ +#include "script_component.hpp" + +if (!isServer) exitWith {}; + +params ["_logic", "_units", "_activated"]; + +if (!_activated) exitWith {}; + +[_logic, QGVAR(enabled), "Enabled"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(showThrowArc), "ShowThrowArc"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(showMouseControls), "ShowMouseControls"] call EFUNC(common,readSettingFromModule); + +ACE_LOGINFO_1("Advanced Throwing Module Initialized. Enabled: %1",GVAR(enabled)); diff --git a/addons/advancedthrowing/functions/fnc_onKeyDown.sqf b/addons/advancedthrowing/functions/fnc_onKeyDown.sqf new file mode 100644 index 00000000000..f77c036c5e9 --- /dev/null +++ b/addons/advancedthrowing/functions/fnc_onKeyDown.sqf @@ -0,0 +1,50 @@ +/* + * Author: Dslyecxi, Jonpas + * Key down event. + * + * Arguments: + * 0: Control + * 1: Key + * 2: Shift + * 3: Ctrl + * 4: Alt + * + * Return Value: + * None + * + * Example: + * [control, 5, false, true, false] call ace_advancedthrowing_fnc_onKeyDown + * + * Public: No + */ +#include "script_component.hpp" + +if (!GVAR(inHand)) exitWith {false}; + +params ["", "_key", "_shift", "_ctrl", "_alt"]; + +// Extend arm drop mode (only on foot) - check _key to prevent some key weirdness and allow nice changing while moving +if (_ctrl && _key == 29) then { + GVAR(extendedDrop) = [true, false] select GVAR(extendedDrop); +}; + +// Exit if any of the action keys is pressed +{ + if (_key in _x) exitWith { + [ACE_player, "Pressed a key that cycles us out of throwables"] call FUNC(exitThrowMode); + }; +} forEach [ + actionKeys "ReloadMagazine", + actionKeys "Handgun", + actionKeys "Binoculars", + actionKeys "SwitchWeapon", + actionKeys "Optics", + actionKeys "NextWeapon", + actionKeys "PrevWeapon", + actionKeys "OpticsTemp", + actionKeys "SwitchPrimary", + actionKeys "SwitchHandgun", + actionKeys "SwitchSecondary" +]; + +false diff --git a/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf b/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf new file mode 100644 index 00000000000..4c3712e638c --- /dev/null +++ b/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf @@ -0,0 +1,53 @@ +/* + * Author: Dslyecxi, Jonpas + * Mouse button down event. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ace_advancedthrowing_fnc_onMouseButtonDown + * + * Public: No + */ +#include "script_component.hpp" + +if (!GVAR(inHand)) exitWith {}; + +params ["", "_key"]; + +// Left mouse button +// "DefaultAction" doesn't get executed when in driver seat +if (_key == 0) exitWith { + if (!isNull GVAR(activeThrowable)) then { + if (ACE_player call CBA_fnc_canUseWeapon) then { + if !(weaponLowered ACE_player) then { + [ACE_player] call FUNC(throw); + }; + } else { + [ACE_player] call FUNC(throw); + }; + }; +}; + +// Right mouse button +if (_key == 1) exitWith { + if (GVAR(primed)) then { + GVAR(dropCookedCounter) = GVAR(dropCookedCounter) + 1; + + if (GVAR(dropCookedCounter) >= 2) then { + [ACE_player, "Dropping cooked throwable"] call FUNC(exitThrowMode); + }; + } else { + [ACE_player, "Storing throwable"] call FUNC(exitThrowMode); + }; +}; + +// Middle mouse button +if (_key == 2 && {!GVAR(primed)}) exitWith { + [ACE_player] call FUNC(prime); + [LSTRING(Primed)] call EFUNC(common,displayTextStructured); +}; diff --git a/addons/advancedthrowing/functions/fnc_onMouseScroll.sqf b/addons/advancedthrowing/functions/fnc_onMouseScroll.sqf new file mode 100644 index 00000000000..bc35c685136 --- /dev/null +++ b/addons/advancedthrowing/functions/fnc_onMouseScroll.sqf @@ -0,0 +1,46 @@ +/* + * Author: Dslyecxi, Jonpas + * Mouse scroll wheel changed event. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ace_advancedthrowing_fnc_onMouseScroll + * + * Public: No + */ +#include "script_component.hpp" + +if (!GVAR(inHand)) exitWith {}; + +params ["", "_amount"]; + +if (GVAR(extendedDrop)) then { + if (_amount < 0) then { + // Move closer + GVAR(extendedDropDistance) = (GVAR(extendedDropDistance) - 0.1) max 0.2; + } else { + // Move further + GVAR(extendedDropDistance) = (GVAR(extendedDropDistance) + 0.1) min 1; + }; + + // Limit distance in vehicle + if (vehicle ACE_player != ACE_player) then { + GVAR(extendedDropDistance) = GVAR(extendedDropDistance) min 0.5; + }; +} else { + if (_amount < 0) then { + if (GVAR(throwType) == "high") then { + GVAR(throwType) = "normal"; + }; + } else { + if (GVAR(throwType) == "normal") then { + GVAR(throwType) = "high"; + }; + }; + TRACE_2("Change Throw Type",_amount,GVAR(throwType)); +}; diff --git a/addons/advancedthrowing/functions/fnc_prepare.sqf b/addons/advancedthrowing/functions/fnc_prepare.sqf new file mode 100644 index 00000000000..fa641282b53 --- /dev/null +++ b/addons/advancedthrowing/functions/fnc_prepare.sqf @@ -0,0 +1,57 @@ +/* + * Author: Dslyecxi, Jonpas + * Prepares throwable or selects the next. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [unit] call ace_advancedthrowing_fnc_prepare + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit"]; + +// Select next throwable if one already in hand +if (GVAR(inHand)) exitWith { + if (!GVAR(primed)) then { + [_unit] call EFUNC(weaponselect,selectNextGrenade); + }; +}; + +// Try selecting next throwable if none currently selected +if ((currentThrowable _unit) select 0 == "" && {!([_unit] call EFUNC(weaponselect,selectNextGrenade))}) exitWith { + [_unit, "No valid throwables"] call FUNC(exitThrowMode); +}; + + +GVAR(inHand) = true; + +// Add controls hint if enabled +if (GVAR(showMouseControls)) then { + [ + localize LSTRING(Throw), + format ["%1 / %2", localize ELSTRING(common,Cancel), localize LSTRING(DropCooked)], + format ["%1 / %2", localize LSTRING(ChangeMode), localize LSTRING(Cook)] + ] call EFUNC(interaction,showMouseHint); +}; + +// Add throw action to suppress weapon firing (not possible to suppress mouseButtonDown event) +_unit setVariable [QGVAR(throwAction), [ + _unit, "DefaultAction", + {true}, + {true} +] call EFUNC(common,addActionEventHandler)]; + +// Draw throwable and throw arc if enabled +GVAR(draw3DHandle) = addMissionEventHandler ["Draw3D", { + call FUNC(drawThrowable); + if (GVAR(showThrowArc)) then { + call FUNC(drawArc); + }; +}]; diff --git a/addons/advancedthrowing/functions/fnc_prime.sqf b/addons/advancedthrowing/functions/fnc_prime.sqf new file mode 100644 index 00000000000..c2e341805c0 --- /dev/null +++ b/addons/advancedthrowing/functions/fnc_prime.sqf @@ -0,0 +1,43 @@ +/* + * Author: Dslyecxi, Jonpas + * Primes the throwable, creates global throwable vehicle and throws Fired XEH. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [unit] call ace_advancedthrowing_fnc_prime + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit"]; + +GVAR(primed) = true; + +// Remove item before cooking to prevent weaponselect showing more throwables than there actually are in inventory +private _throwableMag = (currentThrowable _unit) select 0; +_unit removeItem _throwableMag; + +private _throwableType = getText (configFile >> "CfgMagazines" >> _throwableMag >> "ammo"); +private _muzzle = _throwableMag call FUNC(getMuzzle); + +// Create actual throwable globally +private _activeThrowableOld = GVAR(activeThrowable); +GVAR(activeThrowable) = createVehicle [_throwableType, _activeThrowableOld, [], 0, "CAN_COLLIDE"]; +deleteVehicle _activeThrowableOld; + +// Throw Fired XEH +[QGVAR(throwFiredXEH), [ + _unit, // unit + "Throw", // weapon + _muzzle, // muzzle + _muzzle, // mode + _throwableType, // ammo + _throwableMag, // magazine + GVAR(activeThrowable) // projectile +]] call EFUNC(common,globalEvent); diff --git a/addons/advancedthrowing/functions/fnc_throw.sqf b/addons/advancedthrowing/functions/fnc_throw.sqf new file mode 100644 index 00000000000..796ab03c11f --- /dev/null +++ b/addons/advancedthrowing/functions/fnc_throw.sqf @@ -0,0 +1,57 @@ +/* + * Author: Dslyecxi, Jonpas + * Throw selected throwable. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * unit call ace_advancedthrowing_fnc_throw + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit"]; + +_unit playAction "ThrowGrenade"; + +[{ + params ["_unit"]; + + // Prime the throwable if it hasn't been cooking already + if (!GVAR(primed)) then { + [_unit] call FUNC(prime); + }; + + // Launch actual throwable + private _direction = [THROWSTYLE_NORMAL_DIR, THROWSTYLE_HIGH_DIR] select (GVAR(throwType) == "high"); + private _velocity = [GVAR(throwSpeed), THROWSTYLE_HIGH_VEL] select (GVAR(throwType) == "high"); + private _vup = [THROWSTYLE_NORMAL_VECTORUP, THROWSTYLE_HIGH_VECTORUP] select (GVAR(throwType) == "high"); + + if (GVAR(extendedDrop)) then { + _direction = THROWSTYLE_EXTENDED_DIR; + _velocity = THROWSTYLE_EXTENDED_VEL; + }; + + private _p2 = (eyePos _unit) vectorAdd (positionCameraToWorld _direction) vectorDiff (positionCameraToWorld [0, 0, 0]); + private _p1 = AGLtoASL (GVAR(activeThrowable) modelToWorldVisual [0, 0, 0]); + + private _newVelocity = (_p1 vectorFromTo _p2) vectorMultiply _velocity; + + // Adjust for throwing from inside vehicles, where we have a vehicle-based velocity that can't be compensated for by a human + if (vehicle _unit != _unit) then { + _newVelocity = _newVelocity vectorAdd (velocity (vehicle _unit)); + }; + + // Drop if unit dies during throw process + if (alive _unit) then { + GVAR(activeThrowable) setVectorUp _vup; // This was null at start sometimes + GVAR(activeThrowable) setVelocity _newVelocity; + }; + + [_unit, "Completed a throw fully"] call FUNC(exitThrowMode); +}, _unit, 0.3] call CBA_fnc_waitAndExecute; diff --git a/addons/advancedthrowing/functions/fnc_throwFiredXEH.sqf b/addons/advancedthrowing/functions/fnc_throwFiredXEH.sqf new file mode 100644 index 00000000000..cb996e53e81 --- /dev/null +++ b/addons/advancedthrowing/functions/fnc_throwFiredXEH.sqf @@ -0,0 +1,28 @@ +/* + * Author: CBA Team + * Throws Fired XEH. + * + * Arguments: + * 0: unit - Object the event handler is assigned to + * 1: weapon - Fired weapon + * 2: muzzle - Muzzle that was used + * 3: mode - Current mode of the fired weapon + * 4: ammo - Ammo used + * 5: magazine - magazine name which was used + * 6: projectile - Object of the projectile that was shot + * + * Return Value: + * None + * + * Example: + * [unit, "weapon", "muzle", "mode", "ammo", "magazine", projectile] call ace_advancedthrowing_fnc_throwFiredXEH + * + * Public: No + */ +#include "script_component.hpp" + +TRACE_1("Fired",_this); + +{ + _this call _x; +} forEach ((_this select 0) getVariable "cba_xeh_fired"); diff --git a/addons/advancedthrowing/functions/script_component.hpp b/addons/advancedthrowing/functions/script_component.hpp new file mode 100644 index 00000000000..2a1ff8773c8 --- /dev/null +++ b/addons/advancedthrowing/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\advancedthrowing\script_component.hpp" diff --git a/addons/advancedthrowing/script_component.hpp b/addons/advancedthrowing/script_component.hpp new file mode 100644 index 00000000000..f7ae966afde --- /dev/null +++ b/addons/advancedthrowing/script_component.hpp @@ -0,0 +1,29 @@ +#define COMPONENT advancedthrowing +#include "\z\ace\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define CBA_DEBUG_SYNCHRONOUS +// #define ENABLE_PERFORMANCE_COUNTERS + +#ifdef DEBUG_ENABLED_ADVANCEDTHROWING + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_ADVANCEDTHROWING + #define DEBUG_SETTINGS DEBUG_SETTINGS_ADVANCEDTHROWING +#endif + +#include "\z\ace\addons\main\script_macros.hpp" + + +#define THROWSTYLE_NORMAL_DIR [0, 70, 500] +#define THROWSTYLE_NORMAL_VECTORUP [0, 1, 1] +#define THROWSTYLE_HIGH_DIR [0, 200, 500] +#define THROWSTYLE_HIGH_VEL 8 +#define THROWSTYLE_HIGH_VECTORUP [1, 0, 0] +#define THROWSTYLE_EXTENDED_DIR [0, 200, 500] +#define THROWSTYLE_EXTENDED_VEL 3 + +#define CAMERA_OFFSET [0, 0, 0.3] +#define CAMERA_ADJUST [-0.05, -0.12, -0.03] diff --git a/addons/advancedthrowing/stringtable.xml b/addons/advancedthrowing/stringtable.xml new file mode 100644 index 00000000000..70e01ce4272 --- /dev/null +++ b/addons/advancedthrowing/stringtable.xml @@ -0,0 +1,47 @@ + + + + + Advanced Throwing + + + Allows changing advanced throwing behaviour. + + + Enable Advanced Throwing + + + Enables advanced throwing system. + + + Show Throw Arc + + + Enables visualization of the throw arc (where throwable will fly). + + + Show Throwing Mouse Controls + + + Enables visual cues for mouse controls when throwable is prepared. + + + Throwable Primed + + + Prepare/Change Throwable + + + Throw + + + (x2) Drop Cooked + + + (Scroll) Change Mode + + + (Click) Cook + + + diff --git a/addons/optics/functions/fnc_handleFired.sqf b/addons/optics/functions/fnc_handleFired.sqf index 299b2c30f40..f7c4fd1ae85 100644 --- a/addons/optics/functions/fnc_handleFired.sqf +++ b/addons/optics/functions/fnc_handleFired.sqf @@ -15,6 +15,8 @@ //IGNORE_PRIVATE_WARNING ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle", "_gunner", "_turret"]; TRACE_10("firedEH:",_unit, _weapon, _muzzle, _mode, _ammo, _magazine, _projectile, _vehicle, _gunner, _turret); +disableSerialization; + // check if compatible scope is used private "_display"; _display = uiNamespace getVariable [QGVAR(RscWeaponInfo2D), displayNull]; diff --git a/addons/weaponselect/XEH_postInit.sqf b/addons/weaponselect/XEH_postInit.sqf index 2e03982fecc..c324d129ae1 100644 --- a/addons/weaponselect/XEH_postInit.sqf +++ b/addons/weaponselect/XEH_postInit.sqf @@ -72,8 +72,6 @@ if (!hasInterface) exitWith {}; ["ACE3 Weapons", QGVAR(SelectGrenadeFrag), localize LSTRING(SelectGrenadeFrag), { // Conditions: canInteract if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false}; - // Conditions: specific - if !([ACE_player] call CBA_fnc_canUseWeapon) exitWith {false}; // Statement [ACE_player, 1] call FUNC(selectNextGrenade); @@ -85,8 +83,6 @@ if (!hasInterface) exitWith {}; ["ACE3 Weapons", QGVAR(SelectGrenadeOther), localize LSTRING(SelectGrenadeOther), { // Conditions: canInteract if !([ACE_player, ACE_player, ["isNotInside", "isNotEscorting"]] call EFUNC(common,canInteractWith)) exitWith {false}; - // Conditions: specific - if !([ACE_player] call CBA_fnc_canUseWeapon) exitWith {false}; // Statement [ACE_player, 2] call FUNC(selectNextGrenade); From 504118ae375db7a855daee5100c652e7aefd68bb Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 5 Jun 2016 22:37:32 +0200 Subject: [PATCH 02/54] Move canUseWeapon check to canPrepare, Remove redundand other checks --- addons/advancedthrowing/functions/fnc_canPrepare.sqf | 7 ++++--- addons/advancedthrowing/functions/fnc_canThrow.sqf | 3 +-- .../advancedthrowing/functions/fnc_onMouseButtonDown.sqf | 6 +----- addons/advancedthrowing/script_component.hpp | 4 ++-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_canPrepare.sqf b/addons/advancedthrowing/functions/fnc_canPrepare.sqf index 78fc0e5240e..641069e0916 100644 --- a/addons/advancedthrowing/functions/fnc_canPrepare.sqf +++ b/addons/advancedthrowing/functions/fnc_canPrepare.sqf @@ -15,8 +15,9 @@ */ #include "script_component.hpp" -if (!GVAR(enabled) || {call EFUNC(common,isFeatureCameraActive)}) exitWith {false}; - params ["_unit"]; -[_unit, objNull, ["isNotInside", "isNotSitting", "isNotOnLadder"]] call EFUNC(common,canInteractWith) +GVAR(enabled) && +{!(call EFUNC(common,isFeatureCameraActive))} && +{[_unit, objNull, ["isNotInside", "isNotSitting", "isNotOnLadder"]] call EFUNC(common,canInteractWith)} && +{_unit call CBA_fnc_canUseWeapon} // Disable in non-FFV seats due to surface detection issues diff --git a/addons/advancedthrowing/functions/fnc_canThrow.sqf b/addons/advancedthrowing/functions/fnc_canThrow.sqf index 5d45795b4c1..4800d6d063b 100644 --- a/addons/advancedthrowing/functions/fnc_canThrow.sqf +++ b/addons/advancedthrowing/functions/fnc_canThrow.sqf @@ -17,8 +17,7 @@ params ["_unit"]; -// Disable throwing from non FFV seats due to surface detection issues -if (!GVAR(inHand) || {!(_unit call CBA_fnc_canUseWeapon)}) exitWith {false}; +if (!GVAR(inHand)) exitWith {false}; if (vehicle _unit != _unit) exitWith { private _startPos = eyePos _unit; diff --git a/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf b/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf index 4c3712e638c..573eebe774c 100644 --- a/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf +++ b/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf @@ -23,11 +23,7 @@ params ["", "_key"]; // "DefaultAction" doesn't get executed when in driver seat if (_key == 0) exitWith { if (!isNull GVAR(activeThrowable)) then { - if (ACE_player call CBA_fnc_canUseWeapon) then { - if !(weaponLowered ACE_player) then { - [ACE_player] call FUNC(throw); - }; - } else { + if !(weaponLowered ACE_player) then { [ACE_player] call FUNC(throw); }; }; diff --git a/addons/advancedthrowing/script_component.hpp b/addons/advancedthrowing/script_component.hpp index f7ae966afde..c4694b0f63d 100644 --- a/addons/advancedthrowing/script_component.hpp +++ b/addons/advancedthrowing/script_component.hpp @@ -1,8 +1,8 @@ #define COMPONENT advancedthrowing #include "\z\ace\addons\main\script_mod.hpp" -// #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE +#define DEBUG_MODE_FULL +#define DISABLE_COMPILE_CACHE // #define CBA_DEBUG_SYNCHRONOUS // #define ENABLE_PERFORMANCE_COUNTERS From ff3d3926efd490c0621696491c63a88f63a5192c Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 5 Jun 2016 22:49:42 +0200 Subject: [PATCH 03/54] Improve and consolidate rendering maths --- .../functions/fnc_drawArc.sqf | 9 ++----- .../functions/fnc_drawThrowable.sqf | 27 ++++++++++--------- addons/advancedthrowing/script_component.hpp | 3 --- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_drawArc.sqf b/addons/advancedthrowing/functions/fnc_drawArc.sqf index 79bef45182a..065e5015525 100644 --- a/addons/advancedthrowing/functions/fnc_drawArc.sqf +++ b/addons/advancedthrowing/functions/fnc_drawArc.sqf @@ -22,13 +22,8 @@ if (!([ACE_player] call FUNC(canThrow))) exitWith { if (isNull GVAR(activeThrowable)) exitWith {}; -private _direction = THROWSTYLE_NORMAL_DIR; -private _velocity = GVAR(throwSpeed); - -if (GVAR(throwType) == "high") then { - _direction = THROWSTYLE_HIGH_DIR; - _velocity = THROWSTYLE_HIGH_VEL; -}; +private _direction = [THROWSTYLE_NORMAL_DIR, THROWSTYLE_HIGH_DIR] select (GVAR(throwType) == "high"); +private _velocity = [GVAR(throwSpeed), THROWSTYLE_HIGH_VEL] select (GVAR(throwType) == "high"); if (GVAR(extendedDrop)) then { _direction = THROWSTYLE_EXTENDED_DIR; diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index a8defc82cda..d731b11c12f 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -60,12 +60,9 @@ if (abs _leanCoef < 0.15 || {vehicle ACE_player != ACE_player}) then { _leanCoef = 0; }; -private _cameraOffset = [_leanCoef, 0, 0.3]; -private _xAdjustBonus = [0, -0.075] select (GVAR(throwType) == "high"); -private _yAdjustBonus = [0, 0.1] select (GVAR(throwType) == "high"); - -_cameraOffset = _cameraOffset vectorAdd CAMERA_ADJUST vectorAdd [_xAdjustBonus, _yAdjustBonus, 0]; -private _posFin = (eyePos ACE_player) vectorAdd (positionCameraToWorld _cameraOffset) vectorDiff (positionCameraToWorld [0, 0, 0]); +private _eyePos = eyePos ACE_player; +private _posCameraWorld = positionCameraToWorld [0, 0, 0]; +private _posFin = [0, 0, 0]; // Orient it nicely, point towards player GVAR(activeThrowable) setDir ((getDir ACE_player) + 90); @@ -75,20 +72,24 @@ private _pitch = [-30, -90] select (GVAR(throwType) == "high"); if (GVAR(extendedDrop)) then { - _posFin = (eyePos ACE_player) vectorAdd (positionCameraToWorld [_leanCoef, 0, GVAR(extendedDropDistance)]) vectorDiff (positionCameraToWorld [0, 0, 0]); - private _posView = AGLtoASL (positionCameraToWorld [0, 0, 0]); + _posFin = _eyePos vectorAdd (positionCameraToWorld [_leanCoef, 0, GVAR(extendedDropDistance)]); // Even vanilla throwables go through glass, only "GEOM" LOD will stop it but that will also stop it when there is glass in a window - if (lineIntersects [_posView, _posFin]) then { + if (lineIntersects [AGLtoASL _posCameraWorld, _posFin vectorDiff _posCameraWorld]) then { GVAR(extendedDropDistance) = (GVAR(extendedDropDistance) - 0.10) max 0.2; }; - - GVAR(activeThrowable) setPosASL _posFin; } else { if (vehicle ACE_player == ACE_player) then { - GVAR(activeThrowable) setPosASL _posFin; + private _cameraOffset = [_leanCoef, 0, 0.3]; + private _xAdjustBonus = [0, -0.075] select (GVAR(throwType) == "high"); + private _yAdjustBonus = [0, 0.1] select (GVAR(throwType) == "high"); + + _cameraOffset = _cameraOffset vectorAdd [-0.05, -0.12, -0.03] vectorAdd [_xAdjustBonus, _yAdjustBonus, 0]; + _posFin = _eyePos vectorAdd (positionCameraToWorld _cameraOffset); } else { //@todo make it work while moving properly - GVAR(activeThrowable) setPosASL _posFin; + }; }; + +GVAR(activeThrowable) setPosASL (_posFin vectorDiff _posCameraWorld); diff --git a/addons/advancedthrowing/script_component.hpp b/addons/advancedthrowing/script_component.hpp index c4694b0f63d..0b3ff0ce110 100644 --- a/addons/advancedthrowing/script_component.hpp +++ b/addons/advancedthrowing/script_component.hpp @@ -24,6 +24,3 @@ #define THROWSTYLE_HIGH_VECTORUP [1, 0, 0] #define THROWSTYLE_EXTENDED_DIR [0, 200, 500] #define THROWSTYLE_EXTENDED_VEL 3 - -#define CAMERA_OFFSET [0, 0, 0.3] -#define CAMERA_ADJUST [-0.05, -0.12, -0.03] From f0e9f74e020d1d1932c7057a930e04b7792cef77 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 5 Jun 2016 23:35:27 +0200 Subject: [PATCH 04/54] Minor cleanup and optimizations --- addons/advancedthrowing/XEH_preInit.sqf | 10 ++++----- .../functions/fnc_drawThrowable.sqf | 21 ++++++++----------- .../functions/fnc_exitThrowMode.sqf | 7 +++---- .../functions/fnc_onMouseButtonDown.sqf | 6 ++---- .../functions/fnc_prepare.sqf | 4 +--- 5 files changed, 19 insertions(+), 29 deletions(-) diff --git a/addons/advancedthrowing/XEH_preInit.sqf b/addons/advancedthrowing/XEH_preInit.sqf index 8ee6ee34e13..55619c8fcf6 100644 --- a/addons/advancedthrowing/XEH_preInit.sqf +++ b/addons/advancedthrowing/XEH_preInit.sqf @@ -4,17 +4,15 @@ ADDON = false; #include "XEH_PREP.hpp" +// Trackers GVAR(inHand) = false; GVAR(primed) = false; - GVAR(activeThrowable) = objNull; - GVAR(throwType) = "normal"; -GVAR(throwSpeed) = 18; - GVAR(extendedDrop) = false; -GVAR(extendedDropDistance) = 0.2; - GVAR(dropCookedCounter) = 0; +// Defaults +GVAR(extendedDropDistance) = 0.2; + ADDON = true; diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index d731b11c12f..b9221cecfea 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -54,15 +54,13 @@ if (isNull GVAR(activeThrowable) || {(_throwableType != typeOf GVAR(activeThrowa // Set position -private _leanCoef = (ACE_player selectionPosition "head") select 0; -_leanCoef = _leanCoef - 0.15; // Counter the base offset +private _leanCoef = ((ACE_player selectionPosition "head") select 0) - 0.15; // 0.15 counters the base offset if (abs _leanCoef < 0.15 || {vehicle ACE_player != ACE_player}) then { _leanCoef = 0; }; -private _eyePos = eyePos ACE_player; private _posCameraWorld = positionCameraToWorld [0, 0, 0]; -private _posFin = [0, 0, 0]; +private _posFin = eyePos ACE_player; // Orient it nicely, point towards player GVAR(activeThrowable) setDir ((getDir ACE_player) + 90); @@ -72,23 +70,22 @@ private _pitch = [-30, -90] select (GVAR(throwType) == "high"); if (GVAR(extendedDrop)) then { - _posFin = _eyePos vectorAdd (positionCameraToWorld [_leanCoef, 0, GVAR(extendedDropDistance)]); + _posFin = _posFin vectorAdd (positionCameraToWorld [_leanCoef, 0, GVAR(extendedDropDistance)]); // Even vanilla throwables go through glass, only "GEOM" LOD will stop it but that will also stop it when there is glass in a window if (lineIntersects [AGLtoASL _posCameraWorld, _posFin vectorDiff _posCameraWorld]) then { GVAR(extendedDropDistance) = (GVAR(extendedDropDistance) - 0.10) max 0.2; }; } else { - if (vehicle ACE_player == ACE_player) then { - private _cameraOffset = [_leanCoef, 0, 0.3]; - private _xAdjustBonus = [0, -0.075] select (GVAR(throwType) == "high"); - private _yAdjustBonus = [0, 0.1] select (GVAR(throwType) == "high"); + private _xAdjustBonus = [0, -0.075] select (GVAR(throwType) == "high"); + private _yAdjustBonus = [0, 0.1] select (GVAR(throwType) == "high"); + private _cameraOffset = [_leanCoef, 0, 0.3] vectorAdd [-0.05, -0.12, -0.03] vectorAdd [_xAdjustBonus, _yAdjustBonus, 0]; - _cameraOffset = _cameraOffset vectorAdd [-0.05, -0.12, -0.03] vectorAdd [_xAdjustBonus, _yAdjustBonus, 0]; - _posFin = _eyePos vectorAdd (positionCameraToWorld _cameraOffset); + if (vehicle ACE_player == ACE_player) then { + _posFin = _posFin vectorAdd (positionCameraToWorld _cameraOffset); } else { //@todo make it work while moving properly - + _posFin = _posFin vectorAdd (positionCameraToWorld _cameraOffset); }; }; diff --git a/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf b/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf index 79ab9ee9818..9e2815be533 100644 --- a/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf +++ b/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf @@ -20,7 +20,6 @@ if (!GVAR(inHand)) exitWith {}; params ["_unit", "_reason"]; -TRACE_1("Exit Throw Mode",_reason); #ifdef DEBUG_MODE_FULL systemChat format ["Exit Throw Mode: %1", _reason]; #endif @@ -29,12 +28,12 @@ if (!GVAR(primed)) then { deleteVehicle GVAR(activeThrowable); }; -GVAR(activeThrowable) = objNull; GVAR(inHand) = false; GVAR(primed) = false; -GVAR(dropCookedCounter) = 0; -GVAR(extendedDrop) = false; +GVAR(activeThrowable) = objNull; GVAR(throwType) = "normal"; +GVAR(extendedDrop) = false; +GVAR(dropCookedCounter) = 0; // Remove controls hint (check if ever enabled is inside the function) call EFUNC(interaction,hideMouseHint); diff --git a/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf b/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf index 573eebe774c..b2d2027d552 100644 --- a/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf +++ b/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf @@ -22,10 +22,8 @@ params ["", "_key"]; // Left mouse button // "DefaultAction" doesn't get executed when in driver seat if (_key == 0) exitWith { - if (!isNull GVAR(activeThrowable)) then { - if !(weaponLowered ACE_player) then { - [ACE_player] call FUNC(throw); - }; + if (!isNull GVAR(activeThrowable) && !(weaponLowered ACE_player)) then { + [ACE_player] call FUNC(throw); }; }; diff --git a/addons/advancedthrowing/functions/fnc_prepare.sqf b/addons/advancedthrowing/functions/fnc_prepare.sqf index fa641282b53..6211ca103c0 100644 --- a/addons/advancedthrowing/functions/fnc_prepare.sqf +++ b/addons/advancedthrowing/functions/fnc_prepare.sqf @@ -43,9 +43,7 @@ if (GVAR(showMouseControls)) then { // Add throw action to suppress weapon firing (not possible to suppress mouseButtonDown event) _unit setVariable [QGVAR(throwAction), [ - _unit, "DefaultAction", - {true}, - {true} + _unit, "DefaultAction", {true}, {true} ] call EFUNC(common,addActionEventHandler)]; // Draw throwable and throw arc if enabled From c7a0d261b0cf2a7bcccb39adba7f6165bf2d3c52 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 5 Jun 2016 23:38:43 +0200 Subject: [PATCH 05/54] Cleanup 2 more defines --- addons/advancedthrowing/functions/fnc_throw.sqf | 2 +- addons/advancedthrowing/script_component.hpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_throw.sqf b/addons/advancedthrowing/functions/fnc_throw.sqf index 796ab03c11f..79ecff62388 100644 --- a/addons/advancedthrowing/functions/fnc_throw.sqf +++ b/addons/advancedthrowing/functions/fnc_throw.sqf @@ -30,7 +30,7 @@ _unit playAction "ThrowGrenade"; // Launch actual throwable private _direction = [THROWSTYLE_NORMAL_DIR, THROWSTYLE_HIGH_DIR] select (GVAR(throwType) == "high"); private _velocity = [GVAR(throwSpeed), THROWSTYLE_HIGH_VEL] select (GVAR(throwType) == "high"); - private _vup = [THROWSTYLE_NORMAL_VECTORUP, THROWSTYLE_HIGH_VECTORUP] select (GVAR(throwType) == "high"); + private _vup = [[0, 1, 1], [1, 0, 0]] select (GVAR(throwType) == "high"); if (GVAR(extendedDrop)) then { _direction = THROWSTYLE_EXTENDED_DIR; diff --git a/addons/advancedthrowing/script_component.hpp b/addons/advancedthrowing/script_component.hpp index 0b3ff0ce110..bc53b8c527e 100644 --- a/addons/advancedthrowing/script_component.hpp +++ b/addons/advancedthrowing/script_component.hpp @@ -18,9 +18,7 @@ #define THROWSTYLE_NORMAL_DIR [0, 70, 500] -#define THROWSTYLE_NORMAL_VECTORUP [0, 1, 1] #define THROWSTYLE_HIGH_DIR [0, 200, 500] #define THROWSTYLE_HIGH_VEL 8 -#define THROWSTYLE_HIGH_VECTORUP [1, 0, 0] #define THROWSTYLE_EXTENDED_DIR [0, 200, 500] #define THROWSTYLE_EXTENDED_VEL 3 From c8b7492166aeabff4a90c08999b9ac69c4c66d41 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 6 Jun 2016 00:12:16 +0200 Subject: [PATCH 06/54] Use getPosASLVisual, Reset throwType when switching to drop mode --- addons/advancedthrowing/functions/fnc_drawArc.sqf | 8 ++++---- addons/advancedthrowing/functions/fnc_onKeyDown.sqf | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_drawArc.sqf b/addons/advancedthrowing/functions/fnc_drawArc.sqf index 065e5015525..02b923da907 100644 --- a/addons/advancedthrowing/functions/fnc_drawArc.sqf +++ b/addons/advancedthrowing/functions/fnc_drawArc.sqf @@ -15,7 +15,7 @@ */ #include "script_component.hpp" -// Disable drawing when intersecting with the vehicle, it looks ugly +// Disable drawing when intersecting with the vehicle if (!([ACE_player] call FUNC(canThrow))) exitWith { drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_0_ca.paa", [1, 0, 0, 1], positionCameraToWorld [0, 0, 1], 2, 2, 0, "", 2]; }; @@ -42,7 +42,7 @@ for "_i" from 0.05 to 1.45 step 0.1 do { private _newTrajASL = _prevTrajASL vectorAdd (_initialVelocity vectorMultiply _i) vectorAdd ([0, 0, -4.9] vectorMultiply (_i * _i)); private _cross = 0; - if (_newTrajASL distance (getPosASL ACE_player) <= 20) then { + if (_newTrajASL distance (getPosASLVisual ACE_player) <= 20) then { if ((ASLToATL _newTrajASL) select 2 <= 0) then { _cross = 1 } else { @@ -52,8 +52,8 @@ for "_i" from 0.05 to 1.45 step 0.1 do { }; }; - private _iDim = linearConversion [20, 0, _newTrajASL distance (getPosASL ACE_player), 0.3, 2.5, true]; - private _alpha = linearConversion [20, 0, _newTrajASL distance (getPosASL ACE_player), 0.05, 0.7, true]; + private _iDim = linearConversion [20, 0, _newTrajASL distance (getPosASLVisual ACE_player), 0.3, 2.5, true]; + private _alpha = linearConversion [20, 0, _newTrajASL distance (getPosASLVisual ACE_player), 0.05, 0.7, true]; private _movePerc = linearConversion [3, 0, vectorMagnitude (velocity ACE_player), 0, 1, true]; _alpha = _alpha * _movePerc; diff --git a/addons/advancedthrowing/functions/fnc_onKeyDown.sqf b/addons/advancedthrowing/functions/fnc_onKeyDown.sqf index f77c036c5e9..678f4930f41 100644 --- a/addons/advancedthrowing/functions/fnc_onKeyDown.sqf +++ b/addons/advancedthrowing/functions/fnc_onKeyDown.sqf @@ -26,6 +26,7 @@ params ["", "_key", "_shift", "_ctrl", "_alt"]; // Extend arm drop mode (only on foot) - check _key to prevent some key weirdness and allow nice changing while moving if (_ctrl && _key == 29) then { GVAR(extendedDrop) = [true, false] select GVAR(extendedDrop); + GVAR(throwType) = "normal"; }; // Exit if any of the action keys is pressed From b3a21eee795729270c8a88c6fe0eee5ea834334a Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 6 Jun 2016 04:09:55 +0200 Subject: [PATCH 07/54] Fix rendering in moving vehicle --- addons/advancedthrowing/XEH_preInit.sqf | 1 + .../functions/fnc_drawThrowable.sqf | 20 +++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/addons/advancedthrowing/XEH_preInit.sqf b/addons/advancedthrowing/XEH_preInit.sqf index 55619c8fcf6..f54ea746f5f 100644 --- a/addons/advancedthrowing/XEH_preInit.sqf +++ b/addons/advancedthrowing/XEH_preInit.sqf @@ -14,5 +14,6 @@ GVAR(dropCookedCounter) = 0; // Defaults GVAR(extendedDropDistance) = 0.2; +GVAR(lastTickTime) = 0; ADDON = true; diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index b9221cecfea..0d3cc89937f 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -54,16 +54,18 @@ if (isNull GVAR(activeThrowable) || {(_throwableType != typeOf GVAR(activeThrowa // Set position -private _leanCoef = ((ACE_player selectionPosition "head") select 0) - 0.15; // 0.15 counters the base offset +private _posHeadRel = ACE_player selectionPosition "head"; + +private _leanCoef = (_posHeadRel select 0) - 0.15; // 0.15 counters the base offset if (abs _leanCoef < 0.15 || {vehicle ACE_player != ACE_player}) then { _leanCoef = 0; }; private _posCameraWorld = positionCameraToWorld [0, 0, 0]; -private _posFin = eyePos ACE_player; +private _posFin = AGLToASL (ACE_player modelToWorldVisual (_posHeadRel vectorAdd [-0.03, 0.01, 0.15])); // Orient it nicely, point towards player -GVAR(activeThrowable) setDir ((getDir ACE_player) + 90); +GVAR(activeThrowable) setDir ((getDirVisual ACE_player) + 90); private _pitch = [-30, -90] select (GVAR(throwType) == "high"); [GVAR(activeThrowable), _pitch, 0] call BIS_fnc_setPitchBank; @@ -81,11 +83,13 @@ if (GVAR(extendedDrop)) then { private _yAdjustBonus = [0, 0.1] select (GVAR(throwType) == "high"); private _cameraOffset = [_leanCoef, 0, 0.3] vectorAdd [-0.05, -0.12, -0.03] vectorAdd [_xAdjustBonus, _yAdjustBonus, 0]; - if (vehicle ACE_player == ACE_player) then { - _posFin = _posFin vectorAdd (positionCameraToWorld _cameraOffset); - } else { - //@todo make it work while moving properly - _posFin = _posFin vectorAdd (positionCameraToWorld _cameraOffset); + _posFin = _posFin vectorAdd (positionCameraToWorld _cameraOffset); + + if (vehicle ACE_player != ACE_player) then { + // Counteract vehicle velocity including acceleration + private _vectorDiff = (velocity (vehicle ACE_player)) vectorMultiply (time - GVAR(lastTickTime) + 0.01); + _posFin = _posFin vectorAdd _vectorDiff; + GVAR(lastTickTime) = time; }; }; From 6ab8f46c0f05919bd5ed6c240f91fd186e955566 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 6 Jun 2016 04:53:40 +0200 Subject: [PATCH 08/54] Fix throw orientation being different than holding orientation --- addons/advancedthrowing/functions/fnc_drawThrowable.sqf | 3 ++- addons/advancedthrowing/functions/fnc_throw.sqf | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index 0d3cc89937f..e8e0f8369db 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -62,7 +62,8 @@ if (abs _leanCoef < 0.15 || {vehicle ACE_player != ACE_player}) then { }; private _posCameraWorld = positionCameraToWorld [0, 0, 0]; -private _posFin = AGLToASL (ACE_player modelToWorldVisual (_posHeadRel vectorAdd [-0.03, 0.01, 0.15])); +_posHeadRel = _posHeadRel vectorAdd [-0.03, 0.01, 0.15]; // Bring closer to eyePos value +private _posFin = AGLToASL (ACE_player modelToWorldVisual _posHeadRel); // Orient it nicely, point towards player GVAR(activeThrowable) setDir ((getDirVisual ACE_player) + 90); diff --git a/addons/advancedthrowing/functions/fnc_throw.sqf b/addons/advancedthrowing/functions/fnc_throw.sqf index 79ecff62388..3c4135d27a6 100644 --- a/addons/advancedthrowing/functions/fnc_throw.sqf +++ b/addons/advancedthrowing/functions/fnc_throw.sqf @@ -30,7 +30,7 @@ _unit playAction "ThrowGrenade"; // Launch actual throwable private _direction = [THROWSTYLE_NORMAL_DIR, THROWSTYLE_HIGH_DIR] select (GVAR(throwType) == "high"); private _velocity = [GVAR(throwSpeed), THROWSTYLE_HIGH_VEL] select (GVAR(throwType) == "high"); - private _vup = [[0, 1, 1], [1, 0, 0]] select (GVAR(throwType) == "high"); + private _pitch = [-30, -90] select (GVAR(throwType) == "high"); if (GVAR(extendedDrop)) then { _direction = THROWSTYLE_EXTENDED_DIR; @@ -49,7 +49,10 @@ _unit playAction "ThrowGrenade"; // Drop if unit dies during throw process if (alive _unit) then { - GVAR(activeThrowable) setVectorUp _vup; // This was null at start sometimes + // This has to be set again for some reason + GVAR(activeThrowable) setDir ((getDirVisual ACE_player) + 90); + [GVAR(activeThrowable), _pitch, 0] call BIS_fnc_setPitchBank; + GVAR(activeThrowable) setVelocity _newVelocity; }; From 8c8d1487fb2bee50f657152d3a6e1ed75c0bd78a Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 6 Jun 2016 13:13:39 +0200 Subject: [PATCH 09/54] Prime before throw animation and delay, Remove therefore redundant pitch-bank set --- addons/advancedthrowing/functions/fnc_throw.sqf | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_throw.sqf b/addons/advancedthrowing/functions/fnc_throw.sqf index 3c4135d27a6..5d8d693a98e 100644 --- a/addons/advancedthrowing/functions/fnc_throw.sqf +++ b/addons/advancedthrowing/functions/fnc_throw.sqf @@ -17,20 +17,20 @@ params ["_unit"]; +// Prime the throwable if it hasn't been cooking already +// Next to proper simulation this also has to happen before delay for orientation of the throwable to be set +if (!GVAR(primed)) then { + [_unit] call FUNC(prime); +}; + _unit playAction "ThrowGrenade"; [{ params ["_unit"]; - // Prime the throwable if it hasn't been cooking already - if (!GVAR(primed)) then { - [_unit] call FUNC(prime); - }; - // Launch actual throwable private _direction = [THROWSTYLE_NORMAL_DIR, THROWSTYLE_HIGH_DIR] select (GVAR(throwType) == "high"); private _velocity = [GVAR(throwSpeed), THROWSTYLE_HIGH_VEL] select (GVAR(throwType) == "high"); - private _pitch = [-30, -90] select (GVAR(throwType) == "high"); if (GVAR(extendedDrop)) then { _direction = THROWSTYLE_EXTENDED_DIR; @@ -49,10 +49,6 @@ _unit playAction "ThrowGrenade"; // Drop if unit dies during throw process if (alive _unit) then { - // This has to be set again for some reason - GVAR(activeThrowable) setDir ((getDirVisual ACE_player) + 90); - [GVAR(activeThrowable), _pitch, 0] call BIS_fnc_setPitchBank; - GVAR(activeThrowable) setVelocity _newVelocity; }; From c1cce58cdb7d3e06a51577861d4db257592d1dc2 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 6 Jun 2016 14:50:56 +0200 Subject: [PATCH 10/54] Add ability to pick up primed throwables --- addons/advancedthrowing/CfgVehicles.hpp | 24 ++++++++ addons/advancedthrowing/XEH_PREP.hpp | 2 + .../advancedthrowing/XEH_postInitClient.sqf | 14 +++++ .../functions/fnc_interactEH.sqf | 60 +++++++++++++++++++ .../advancedthrowing/functions/fnc_pickUp.sqf | 27 +++++++++ addons/advancedthrowing/stringtable.xml | 3 + 6 files changed, 130 insertions(+) create mode 100644 addons/advancedthrowing/functions/fnc_interactEH.sqf create mode 100644 addons/advancedthrowing/functions/fnc_pickUp.sqf diff --git a/addons/advancedthrowing/CfgVehicles.hpp b/addons/advancedthrowing/CfgVehicles.hpp index 77a68362cbd..5f0bc68d048 100644 --- a/addons/advancedthrowing/CfgVehicles.hpp +++ b/addons/advancedthrowing/CfgVehicles.hpp @@ -1,3 +1,5 @@ +class CBA_Extended_EventHandlers; + class CfgVehicles { class ACE_Module; class GVAR(Module): ACE_Module { @@ -32,4 +34,26 @@ class CfgVehicles { description = CSTRING(Module_Description); }; }; + + + class Items_base_F; + class GVAR(pickUpHelper): Items_base_F { + author = ECSTRING(common,Author); + displayName = "ACE Throwable Pick Up Helper"; + model = "\a3\weapons_f\dummyweapon.p3d"; + scope = 1; + + class ACE_Actions { + class GVAR(pickUp) { + displayName = CSTRING(PickUp); + distance = 1; + condition = QUOTE(_player call FUNC(canPrepare)); + statement = QUOTE(_this call FUNC(pickUp)); + }; + }; + + class EventHandlers { + class CBA_Extended_EventHandlers: CBA_Extended_EventHandlers {}; + }; + }; }; diff --git a/addons/advancedthrowing/XEH_PREP.hpp b/addons/advancedthrowing/XEH_PREP.hpp index 83bb5ddc995..2e75be63ec8 100644 --- a/addons/advancedthrowing/XEH_PREP.hpp +++ b/addons/advancedthrowing/XEH_PREP.hpp @@ -4,10 +4,12 @@ PREP(drawArc); PREP(drawThrowable); PREP(exitThrowMode); PREP(getMuzzle); +PREP(interactEH); PREP(moduleInit); PREP(onKeyDown); PREP(onMouseButtonDown); PREP(onMouseScroll); +PREP(pickUp); PREP(prepare); PREP(prime); PREP(throw); diff --git a/addons/advancedthrowing/XEH_postInitClient.sqf b/addons/advancedthrowing/XEH_postInitClient.sqf index 10493cb9418..8d26e983475 100644 --- a/addons/advancedthrowing/XEH_postInitClient.sqf +++ b/addons/advancedthrowing/XEH_postInitClient.sqf @@ -22,6 +22,20 @@ if (!hasInterface) exitWith {}; [_this select 1, "Player changed"] call FUNC(exitThrowMode); }] call EFUNC(common,addEventhandler); +["interactMenuOpened", { + // Exit if advanced throwing is disabled (pick up only supports advanced throwing) + if (!GVAR(enabled)) exitWith {}; + + if (GVAR(inHand)) then { + [ACE_player, "Interact menu opened"] call FUNC(exitThrowMode); + } else { + // Show pick up actions on CfgAmmo's + _this call FUNC(interactEH); + }; +}] call EFUNC(common,addEventHandler); + + +// Fired XEH [QGVAR(throwFiredXEH), {_this call FUNC(throwFiredXEH)}] call EFUNC(common,addEventHandler); diff --git a/addons/advancedthrowing/functions/fnc_interactEH.sqf b/addons/advancedthrowing/functions/fnc_interactEH.sqf new file mode 100644 index 00000000000..f97cfc43c00 --- /dev/null +++ b/addons/advancedthrowing/functions/fnc_interactEH.sqf @@ -0,0 +1,60 @@ +/* + * Author: PabstMirror, Jonpas + * When interact_menu starts rendering (from "interact_keyDown" event). + * Add pick up helpers to all nearby grenades. + * + * Arguments: + * 0: Interaction Menu Type (0 - world, 1 - self) + * + * Return Value: + * Nothing + * + * Example: + * [0] call ace_advancedthrowing_fnc_interactEH + * + * Public: No + */ +#include "script_component.hpp" + +params ["_interactionType"]; + +// Ignore self-interaction menu and when in vehicle +if (_interactionType != 0 || {vehicle ACE_player != ACE_player}) exitWith {}; + +[{ + params ["_args", "_idPFH"]; + _args params ["_setPosition", "_addedPickUpHelpers", "_throwablesHelped"]; + + if (!EGVAR(interact_menu,keyDown)) then { + TRACE_1("Cleaning Pick Up Helpers",count _addedPickUpHelpers); + {deleteVehicle _x} forEach _addedPickUpHelpers; + [_idPFH] call CBA_fnc_removePerFrameHandler; + } else { + // Prevent rare error when ending mission with interact key down + if (isNull ace_player) exitWith {}; + + //If player moved >5 meters from last pos, then rescan + if ((getPosASL ace_player) distance _setPosition > 5) then { + { + if ((_x distance ACE_player < 15) && {!(_x in _throwablesHelped)} && {!GVAR(inHand)}) then { + private _pickUpHelper = QGVAR(pickUpHelper) createVehicleLocal (getPos _x); + + private _config = configFile >> "CfgAmmo" >> typeOf _x; + + private _pickUpPosition = getArray (_config >> QGVAR(pickUpPosition)); + if (_pickUpPosition isEqualTo []) then { + _pickUpPosition = [0, 0, 0]; + }; + + TRACE_3("Made PickUp Helper",_x,typeOf _x,_pickUpPosition); + + _pickUpHelper attachTo [_x, _pickUpPosition]; + _pickUpHelper setVariable [QGVAR(throwable), _x]; + _addedPickUpHelpers pushBack _pickUpHelper; + _throwablesHelped pushBack _x; + }; + } forEach (ACE_player nearObjects ["GrenadeHand", 5]); + _args set [0, getPosASL ACE_player]; + }; + }; +}, 0.5, [(getPosASL ACE_player) vectorAdd [-100,0,0], [], []]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/advancedthrowing/functions/fnc_pickUp.sqf b/addons/advancedthrowing/functions/fnc_pickUp.sqf new file mode 100644 index 00000000000..b627af38bc6 --- /dev/null +++ b/addons/advancedthrowing/functions/fnc_pickUp.sqf @@ -0,0 +1,27 @@ +/* + * Author: Jonpas + * Picks up a throwable from the ground. + * + * Arguments: + * 0: Pick Up Helper + * 1: Unit + * + * Return Value: + * None + * + * Example: + * [unit, throwable] call ace_advancedthrowing_fnc_pickUp + * + * Public: No + */ +#include "script_component.hpp" + +params ["_helper", "_unit"]; + +GVAR(activeThrowable) = _helper getVariable [QGVAR(throwable), objNull]; + +if (isNull GVAR(activeThrowable)) exitWith {}; + +GVAR(primed) = true; + +_unit call FUNC(prepare) diff --git a/addons/advancedthrowing/stringtable.xml b/addons/advancedthrowing/stringtable.xml index 70e01ce4272..eb81162e495 100644 --- a/addons/advancedthrowing/stringtable.xml +++ b/addons/advancedthrowing/stringtable.xml @@ -43,5 +43,8 @@ (Click) Cook + + Pick Up + From 02c43ce6b3fe8fd5a7d89fecdd36cd7e860172ea Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 6 Jun 2016 14:55:39 +0200 Subject: [PATCH 11/54] Remove unused config entry - not necessary as all throwables are rather small --- addons/advancedthrowing/functions/fnc_interactEH.sqf | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_interactEH.sqf b/addons/advancedthrowing/functions/fnc_interactEH.sqf index f97cfc43c00..e0139c83b14 100644 --- a/addons/advancedthrowing/functions/fnc_interactEH.sqf +++ b/addons/advancedthrowing/functions/fnc_interactEH.sqf @@ -33,7 +33,7 @@ if (_interactionType != 0 || {vehicle ACE_player != ACE_player}) exitWith {}; // Prevent rare error when ending mission with interact key down if (isNull ace_player) exitWith {}; - //If player moved >5 meters from last pos, then rescan + // Player moved >5 meters from last pos, rescan if ((getPosASL ace_player) distance _setPosition > 5) then { { if ((_x distance ACE_player < 15) && {!(_x in _throwablesHelped)} && {!GVAR(inHand)}) then { @@ -41,14 +41,9 @@ if (_interactionType != 0 || {vehicle ACE_player != ACE_player}) exitWith {}; private _config = configFile >> "CfgAmmo" >> typeOf _x; - private _pickUpPosition = getArray (_config >> QGVAR(pickUpPosition)); - if (_pickUpPosition isEqualTo []) then { - _pickUpPosition = [0, 0, 0]; - }; + TRACE_3("Made PickUp Helper",_x,typeOf _x); - TRACE_3("Made PickUp Helper",_x,typeOf _x,_pickUpPosition); - - _pickUpHelper attachTo [_x, _pickUpPosition]; + _pickUpHelper attachTo [_x, [0, 0, 0]]; _pickUpHelper setVariable [QGVAR(throwable), _x]; _addedPickUpHelpers pushBack _pickUpHelper; _throwablesHelped pushBack _x; From 3a3a388135d59a949ce6dcbd19ab688cdf084d19 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 6 Jun 2016 15:40:00 +0200 Subject: [PATCH 12/54] Improve mouse controls hint for different states --- addons/advancedthrowing/XEH_PREP.hpp | 1 + .../functions/fnc_onKeyDown.sqf | 3 ++ .../functions/fnc_prepare.sqf | 10 ++---- .../advancedthrowing/functions/fnc_prime.sqf | 3 ++ .../functions/fnc_updateControlsHint.sqf | 31 +++++++++++++++++++ addons/advancedthrowing/stringtable.xml | 3 ++ 6 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 addons/advancedthrowing/functions/fnc_updateControlsHint.sqf diff --git a/addons/advancedthrowing/XEH_PREP.hpp b/addons/advancedthrowing/XEH_PREP.hpp index 2e75be63ec8..c34eb9b9aac 100644 --- a/addons/advancedthrowing/XEH_PREP.hpp +++ b/addons/advancedthrowing/XEH_PREP.hpp @@ -14,3 +14,4 @@ PREP(prepare); PREP(prime); PREP(throw); PREP(throwFiredXEH); +PREP(updateControlsHint); diff --git a/addons/advancedthrowing/functions/fnc_onKeyDown.sqf b/addons/advancedthrowing/functions/fnc_onKeyDown.sqf index 678f4930f41..6ba2a00deb1 100644 --- a/addons/advancedthrowing/functions/fnc_onKeyDown.sqf +++ b/addons/advancedthrowing/functions/fnc_onKeyDown.sqf @@ -27,6 +27,9 @@ params ["", "_key", "_shift", "_ctrl", "_alt"]; if (_ctrl && _key == 29) then { GVAR(extendedDrop) = [true, false] select GVAR(extendedDrop); GVAR(throwType) = "normal"; + + // Change controls hint for MMB + call FUNC(updateControlsHint); }; // Exit if any of the action keys is pressed diff --git a/addons/advancedthrowing/functions/fnc_prepare.sqf b/addons/advancedthrowing/functions/fnc_prepare.sqf index 6211ca103c0..ef6adcb1dfb 100644 --- a/addons/advancedthrowing/functions/fnc_prepare.sqf +++ b/addons/advancedthrowing/functions/fnc_prepare.sqf @@ -32,14 +32,8 @@ if ((currentThrowable _unit) select 0 == "" && {!([_unit] call EFUNC(weaponselec GVAR(inHand) = true; -// Add controls hint if enabled -if (GVAR(showMouseControls)) then { - [ - localize LSTRING(Throw), - format ["%1 / %2", localize ELSTRING(common,Cancel), localize LSTRING(DropCooked)], - format ["%1 / %2", localize LSTRING(ChangeMode), localize LSTRING(Cook)] - ] call EFUNC(interaction,showMouseHint); -}; +// Add controls hint +call FUNC(updateControlsHint); // Add throw action to suppress weapon firing (not possible to suppress mouseButtonDown event) _unit setVariable [QGVAR(throwAction), [ diff --git a/addons/advancedthrowing/functions/fnc_prime.sqf b/addons/advancedthrowing/functions/fnc_prime.sqf index c2e341805c0..b75bca4cf72 100644 --- a/addons/advancedthrowing/functions/fnc_prime.sqf +++ b/addons/advancedthrowing/functions/fnc_prime.sqf @@ -41,3 +41,6 @@ deleteVehicle _activeThrowableOld; _throwableMag, // magazine GVAR(activeThrowable) // projectile ]] call EFUNC(common,globalEvent); + +// Change controls hint for RMB +call FUNC(updateControlsHint); diff --git a/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf b/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf new file mode 100644 index 00000000000..ddd15e3f21f --- /dev/null +++ b/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf @@ -0,0 +1,31 @@ + /* + * Author: Jonpas + * Updates controls hints based on current state. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * call ace_advancedthrowing_fnc_updateControlsHint + * + * Public: No + */ +#include "script_component.hpp" + +if (!GVAR(showMouseControls)) exitWith {}; + +private _rmb = [localize ELSTRING(common,Cancel), localize LSTRING(DropCooked)] select (GVAR(primed)); + +private _mmb = [localize LSTRING(ChangeMode), localize LSTRING(Extend)] select GVAR(extendedDrop); +if (!GVAR(primed)) then { + [_mmb, localize LSTRING(Cook)] joinString " / "; +}; + +[ + localize LSTRING(Throw), + _rmb, + _mmb +] call EFUNC(interaction,showMouseHint); diff --git a/addons/advancedthrowing/stringtable.xml b/addons/advancedthrowing/stringtable.xml index eb81162e495..359f3390a70 100644 --- a/addons/advancedthrowing/stringtable.xml +++ b/addons/advancedthrowing/stringtable.xml @@ -40,6 +40,9 @@ (Scroll) Change Mode + + (Scroll) Extend + (Click) Cook From 390d377e88a71ef294ff97681c6631e45cae4484 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 6 Jun 2016 16:00:06 +0200 Subject: [PATCH 13/54] Improve primed hint --- .../functions/fnc_onMouseButtonDown.sqf | 3 +-- addons/advancedthrowing/functions/fnc_prime.sqf | 15 ++++++++++++--- addons/advancedthrowing/stringtable.xml | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf b/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf index b2d2027d552..973f12d3449 100644 --- a/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf +++ b/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf @@ -42,6 +42,5 @@ if (_key == 1) exitWith { // Middle mouse button if (_key == 2 && {!GVAR(primed)}) exitWith { - [ACE_player] call FUNC(prime); - [LSTRING(Primed)] call EFUNC(common,displayTextStructured); + [ACE_player, true] call FUNC(prime); }; diff --git a/addons/advancedthrowing/functions/fnc_prime.sqf b/addons/advancedthrowing/functions/fnc_prime.sqf index b75bca4cf72..388b10f899d 100644 --- a/addons/advancedthrowing/functions/fnc_prime.sqf +++ b/addons/advancedthrowing/functions/fnc_prime.sqf @@ -4,6 +4,7 @@ * * Arguments: * 0: Unit + * 1: Show Hint (default: false) * * Return Value: * None @@ -15,7 +16,7 @@ */ #include "script_component.hpp" -params ["_unit"]; +params ["_unit", ["_showHint", false]]; GVAR(primed) = true; @@ -42,5 +43,13 @@ deleteVehicle _activeThrowableOld; GVAR(activeThrowable) // projectile ]] call EFUNC(common,globalEvent); -// Change controls hint for RMB -call FUNC(updateControlsHint); +if (_showHint) then { + // Show primed hint + private _displayNameShort = getText (configFile >> "CfgMagazines" >> _throwableMag >> "displayNameShort"); + private _picture = getText (configFile >> "CfgMagazines" >> _throwableMag >> "picture"); + + [[_displayNameShort, localize LSTRING(Primed)] joinString " ", _picture] call EFUNC(common,displayTextPicture); + + // Change controls hint for RMB + call FUNC(updateControlsHint); +}; diff --git a/addons/advancedthrowing/stringtable.xml b/addons/advancedthrowing/stringtable.xml index 359f3390a70..1f396c990d5 100644 --- a/addons/advancedthrowing/stringtable.xml +++ b/addons/advancedthrowing/stringtable.xml @@ -26,7 +26,7 @@ Enables visual cues for mouse controls when throwable is prepared. - Throwable Primed + Primed Prepare/Change Throwable From 6af7b99789f00d5db9e8fa828ba7749c69d96af1 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 6 Jun 2016 17:23:04 +0200 Subject: [PATCH 14/54] Fix missing semicolon in CfgPatches --- addons/advancedthrowing/config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/advancedthrowing/config.cpp b/addons/advancedthrowing/config.cpp index 2c5accf8231..b7710563490 100644 --- a/addons/advancedthrowing/config.cpp +++ b/addons/advancedthrowing/config.cpp @@ -6,7 +6,7 @@ class CfgPatches { weapons[] = {}; requiredVersion = REQUIRED_VERSION; requiredAddons[] = {"ace_common", "ace_weaponselect"}; - author = ECSTRING(common,ACETeam) + author = ECSTRING(common,ACETeam); authors[] = {"Jonpas", "Dslyecxi", "Zapat"}; url = ECSTRING(main,URL); VERSION_CONFIG; From e506d4a8a08c2c9e4d302aebaa180fcc2c5a0b3d Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 7 Jun 2016 01:06:06 +0200 Subject: [PATCH 15/54] Change pick up distance to 1.5m to allow picking up while standing with weapon on back, Add icon to pick up action, Use better icon for blocked throw --- addons/advancedthrowing/CfgVehicles.hpp | 3 ++- addons/advancedthrowing/functions/fnc_drawArc.sqf | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/advancedthrowing/CfgVehicles.hpp b/addons/advancedthrowing/CfgVehicles.hpp index 5f0bc68d048..e65e3c981cf 100644 --- a/addons/advancedthrowing/CfgVehicles.hpp +++ b/addons/advancedthrowing/CfgVehicles.hpp @@ -46,9 +46,10 @@ class CfgVehicles { class ACE_Actions { class GVAR(pickUp) { displayName = CSTRING(PickUp); - distance = 1; condition = QUOTE(_player call FUNC(canPrepare)); statement = QUOTE(_this call FUNC(pickUp)); + distance = 1.5; + icon = "\a3\ui_f\data\igui\cfg\actions\obsolete\ui_action_takemine_ca.paa"; }; }; diff --git a/addons/advancedthrowing/functions/fnc_drawArc.sqf b/addons/advancedthrowing/functions/fnc_drawArc.sqf index 02b923da907..2d67333e29b 100644 --- a/addons/advancedthrowing/functions/fnc_drawArc.sqf +++ b/addons/advancedthrowing/functions/fnc_drawArc.sqf @@ -17,7 +17,7 @@ // Disable drawing when intersecting with the vehicle if (!([ACE_player] call FUNC(canThrow))) exitWith { - drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_0_ca.paa", [1, 0, 0, 1], positionCameraToWorld [0, 0, 1], 2, 2, 0, "", 2]; + drawIcon3D ["\a3\ui_f\data\igui\cfg\actions\obsolete\ui_action_cancel_manualfire_ca.paa", [1, 0, 0, 1], positionCameraToWorld [0, 0, 1], 1, 1, 0, "", 1]; }; if (isNull GVAR(activeThrowable)) exitWith {}; From edffec93c02e1935e95d78d0138eda373c51326b Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 7 Jun 2016 01:13:00 +0200 Subject: [PATCH 16/54] Fix inventory check on prepare --- addons/advancedthrowing/functions/fnc_drawThrowable.sqf | 2 +- addons/advancedthrowing/functions/fnc_prepare.sqf | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index e8e0f8369db..133e0838121 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -32,7 +32,7 @@ if (GVAR(primed)) then { }; // Inventory check -if ((count _throwable < 1 && !GVAR(primed)) || {_throwableMag == ""}) exitWith { +if (_throwable isEqualTo [] && {!GVAR(primed)}) exitWith { [ACE_player, "No valid throwables"] call FUNC(exitThrowMode); }; diff --git a/addons/advancedthrowing/functions/fnc_prepare.sqf b/addons/advancedthrowing/functions/fnc_prepare.sqf index ef6adcb1dfb..91399ff7078 100644 --- a/addons/advancedthrowing/functions/fnc_prepare.sqf +++ b/addons/advancedthrowing/functions/fnc_prepare.sqf @@ -25,9 +25,7 @@ if (GVAR(inHand)) exitWith { }; // Try selecting next throwable if none currently selected -if ((currentThrowable _unit) select 0 == "" && {!([_unit] call EFUNC(weaponselect,selectNextGrenade))}) exitWith { - [_unit, "No valid throwables"] call FUNC(exitThrowMode); -}; +if ((currentThrowable _unit) isEqualTo [] && {!([_unit] call EFUNC(weaponselect,selectNextGrenade))}) exitWith {}; GVAR(inHand) = true; From df2e42c0f945703fe96599f73d36084506b6315d Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 7 Jun 2016 01:18:36 +0200 Subject: [PATCH 17/54] Fix Cook control hint, Remove 2xRMB control - same can be achieved with drop mode --- addons/advancedthrowing/XEH_preInit.sqf | 1 - addons/advancedthrowing/functions/fnc_exitThrowMode.sqf | 1 - .../advancedthrowing/functions/fnc_onMouseButtonDown.sqf | 8 +------- .../advancedthrowing/functions/fnc_updateControlsHint.sqf | 7 +++---- addons/advancedthrowing/stringtable.xml | 3 --- 5 files changed, 4 insertions(+), 16 deletions(-) diff --git a/addons/advancedthrowing/XEH_preInit.sqf b/addons/advancedthrowing/XEH_preInit.sqf index f54ea746f5f..6e429194cce 100644 --- a/addons/advancedthrowing/XEH_preInit.sqf +++ b/addons/advancedthrowing/XEH_preInit.sqf @@ -10,7 +10,6 @@ GVAR(primed) = false; GVAR(activeThrowable) = objNull; GVAR(throwType) = "normal"; GVAR(extendedDrop) = false; -GVAR(dropCookedCounter) = 0; // Defaults GVAR(extendedDropDistance) = 0.2; diff --git a/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf b/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf index 9e2815be533..2554225cf09 100644 --- a/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf +++ b/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf @@ -33,7 +33,6 @@ GVAR(primed) = false; GVAR(activeThrowable) = objNull; GVAR(throwType) = "normal"; GVAR(extendedDrop) = false; -GVAR(dropCookedCounter) = 0; // Remove controls hint (check if ever enabled is inside the function) call EFUNC(interaction,hideMouseHint); diff --git a/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf b/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf index 973f12d3449..dea2f3acd0d 100644 --- a/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf +++ b/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf @@ -29,13 +29,7 @@ if (_key == 0) exitWith { // Right mouse button if (_key == 1) exitWith { - if (GVAR(primed)) then { - GVAR(dropCookedCounter) = GVAR(dropCookedCounter) + 1; - - if (GVAR(dropCookedCounter) >= 2) then { - [ACE_player, "Dropping cooked throwable"] call FUNC(exitThrowMode); - }; - } else { + if (!GVAR(primed)) then { [ACE_player, "Storing throwable"] call FUNC(exitThrowMode); }; }; diff --git a/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf b/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf index ddd15e3f21f..158ca50ff43 100644 --- a/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf +++ b/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf @@ -17,15 +17,14 @@ if (!GVAR(showMouseControls)) exitWith {}; -private _rmb = [localize ELSTRING(common,Cancel), localize LSTRING(DropCooked)] select (GVAR(primed)); - private _mmb = [localize LSTRING(ChangeMode), localize LSTRING(Extend)] select GVAR(extendedDrop); + if (!GVAR(primed)) then { - [_mmb, localize LSTRING(Cook)] joinString " / "; + _mmb = [_mmb, localize LSTRING(Cook)] joinString " / "; }; [ localize LSTRING(Throw), - _rmb, + [localize ELSTRING(common,Cancel), ""] select (GVAR(primed)), _mmb ] call EFUNC(interaction,showMouseHint); diff --git a/addons/advancedthrowing/stringtable.xml b/addons/advancedthrowing/stringtable.xml index 1f396c990d5..b0d8479be06 100644 --- a/addons/advancedthrowing/stringtable.xml +++ b/addons/advancedthrowing/stringtable.xml @@ -34,9 +34,6 @@ Throw - - (x2) Drop Cooked - (Scroll) Change Mode From 00865b6322ec64d1fb182d250115213cdbb6caf4 Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 7 Jun 2016 01:27:10 +0200 Subject: [PATCH 18/54] Possibly fix locality issue with picking up --- addons/advancedthrowing/functions/fnc_pickUp.sqf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/advancedthrowing/functions/fnc_pickUp.sqf b/addons/advancedthrowing/functions/fnc_pickUp.sqf index b627af38bc6..26c2cf8961b 100644 --- a/addons/advancedthrowing/functions/fnc_pickUp.sqf +++ b/addons/advancedthrowing/functions/fnc_pickUp.sqf @@ -22,6 +22,10 @@ GVAR(activeThrowable) = _helper getVariable [QGVAR(throwable), objNull]; if (isNull GVAR(activeThrowable)) exitWith {}; -GVAR(primed) = true; +// Change locality for manipulation (some commands require local object, such as setVelocity) +if (!local GVAR(activeThrowable)) then { + ["setOwner", [GVAR(activeThrowable), clientOwner]] call EFUNC(common,serverEvent); +}; +GVAR(primed) = true; _unit call FUNC(prepare) From 88fca3fe5f7f48e36051f05d31b83fade81271ed Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 7 Jun 2016 01:37:57 +0200 Subject: [PATCH 19/54] Allow throwing with weapon lowered/on back/no weapon when not in vehicle --- .../functions/fnc_onMouseButtonDown.sqf | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf b/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf index dea2f3acd0d..6c4caa7d7a4 100644 --- a/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf +++ b/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf @@ -20,10 +20,14 @@ if (!GVAR(inHand)) exitWith {}; params ["", "_key"]; // Left mouse button -// "DefaultAction" doesn't get executed when in driver seat +// "DefaultAction" doesn't get executed when in driver seat or in FFV seat with weapon lowered if (_key == 0) exitWith { - if (!isNull GVAR(activeThrowable) && !(weaponLowered ACE_player)) then { - [ACE_player] call FUNC(throw); + if (!isNull GVAR(activeThrowable)) then { + // Look gets automatically pointed at weapon direction on first LMB press when in FFV seat, require weapon to be up if in vehicle + private _inVehicle = vehicle ACE_player != ACE_player; + if (!_inVehicle || {_inVehicle && {!weaponLowered ACE_player}}) then { + [ACE_player] call FUNC(throw); + }; }; }; From 432d77029868ee3c35a0af6cc56a2d278d7f6e73 Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 7 Jun 2016 01:58:34 +0200 Subject: [PATCH 20/54] Make drop mode bindable (hold and toggle), Cleanup dropMode variables --- .../advancedthrowing/XEH_postInitClient.sqf | 35 +++++++++++++++++-- addons/advancedthrowing/XEH_preInit.sqf | 4 +-- .../functions/fnc_drawArc.sqf | 8 ++--- .../functions/fnc_drawThrowable.sqf | 6 ++-- .../functions/fnc_exitThrowMode.sqf | 2 +- .../functions/fnc_onKeyDown.sqf | 9 ----- .../functions/fnc_onMouseScroll.sqf | 8 ++--- .../advancedthrowing/functions/fnc_throw.sqf | 8 ++--- .../functions/fnc_updateControlsHint.sqf | 2 +- addons/advancedthrowing/script_component.hpp | 3 +- addons/advancedthrowing/stringtable.xml | 16 ++++++--- 11 files changed, 59 insertions(+), 42 deletions(-) diff --git a/addons/advancedthrowing/XEH_postInitClient.sqf b/addons/advancedthrowing/XEH_postInitClient.sqf index 8d26e983475..f1fd172b225 100644 --- a/addons/advancedthrowing/XEH_postInitClient.sqf +++ b/addons/advancedthrowing/XEH_postInitClient.sqf @@ -11,10 +11,39 @@ if (!hasInterface) exitWith {}; // Statement [ACE_player] call FUNC(prepare); + + true +}, {false}, [34, [true, false, false]], false] call CBA_fnc_addKeybind; // Shift + G + +["ACE3 Weapons", QGVAR(dropModeToggle), localize LSTRING(DropModeToggle), { + // Condition + if (!GVAR(inHand)) exitWith {false}; + + // Statement + GVAR(dropMode) = [true, false] select GVAR(dropMode); + GVAR(throwType) = "normal"; // Reset for consistency when opening + call FUNC(updateControlsHint); // Change controls hint for MMB + true +}, {false}, [34, [false, true, false]], false] call CBA_fnc_addKeybind; // Ctrl + G + +["ACE3 Weapons", QGVAR(dropModeHold), localize LSTRING(DropModeHold), { + // Condition + if (!GVAR(inHand)) exitWith {false}; + + // Statement + GVAR(dropMode) = true; + GVAR(throwType) = "normal"; // Reset for consistency when opening + call FUNC(updateControlsHint); // Change controls hint for MMB + true +}, { + // Condition + if (!GVAR(inHand)) exitWith {false}; + + // Statement + GVAR(dropMode) = false; + call FUNC(updateControlsHint); // Change controls hint for MMB true -}, -{false}, -[34, [true, false, false]], false] call CBA_fnc_addKeybind; // Shift + G +}, [0, [false, false, false]], false] call CBA_fnc_addKeybind; // Empty // Event handlers diff --git a/addons/advancedthrowing/XEH_preInit.sqf b/addons/advancedthrowing/XEH_preInit.sqf index 6e429194cce..81a5c994ae6 100644 --- a/addons/advancedthrowing/XEH_preInit.sqf +++ b/addons/advancedthrowing/XEH_preInit.sqf @@ -9,10 +9,10 @@ GVAR(inHand) = false; GVAR(primed) = false; GVAR(activeThrowable) = objNull; GVAR(throwType) = "normal"; -GVAR(extendedDrop) = false; +GVAR(dropMode) = false; // Defaults -GVAR(extendedDropDistance) = 0.2; +GVAR(dropDistance) = 0.2; GVAR(lastTickTime) = 0; ADDON = true; diff --git a/addons/advancedthrowing/functions/fnc_drawArc.sqf b/addons/advancedthrowing/functions/fnc_drawArc.sqf index 2d67333e29b..7f484f2e304 100644 --- a/addons/advancedthrowing/functions/fnc_drawArc.sqf +++ b/addons/advancedthrowing/functions/fnc_drawArc.sqf @@ -22,13 +22,9 @@ if (!([ACE_player] call FUNC(canThrow))) exitWith { if (isNull GVAR(activeThrowable)) exitWith {}; -private _direction = [THROWSTYLE_NORMAL_DIR, THROWSTYLE_HIGH_DIR] select (GVAR(throwType) == "high"); +private _direction = [THROWSTYLE_NORMAL_DIR, THROWSTYLE_HIGH_DIR] select (GVAR(throwType) == "high" || {GVAR(dropMode)}); private _velocity = [GVAR(throwSpeed), THROWSTYLE_HIGH_VEL] select (GVAR(throwType) == "high"); - -if (GVAR(extendedDrop)) then { - _direction = THROWSTYLE_EXTENDED_DIR; - _velocity = THROWSTYLE_EXTENDED_VEL; -}; +_velocity = [_velocity, THROWSTYLE_DROP_VEL] select GVAR(dropMode); private _viewStart = AGLToASL (positionCameraToWorld [0, 0, 0]); private _viewEnd = AGLToASL (positionCameraToWorld _direction); diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index 133e0838121..d53b762f603 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -72,12 +72,12 @@ private _pitch = [-30, -90] select (GVAR(throwType) == "high"); [GVAR(activeThrowable), _pitch, 0] call BIS_fnc_setPitchBank; -if (GVAR(extendedDrop)) then { - _posFin = _posFin vectorAdd (positionCameraToWorld [_leanCoef, 0, GVAR(extendedDropDistance)]); +if (GVAR(dropMode)) then { + _posFin = _posFin vectorAdd (positionCameraToWorld [_leanCoef, 0, GVAR(dropDistance)]); // Even vanilla throwables go through glass, only "GEOM" LOD will stop it but that will also stop it when there is glass in a window if (lineIntersects [AGLtoASL _posCameraWorld, _posFin vectorDiff _posCameraWorld]) then { - GVAR(extendedDropDistance) = (GVAR(extendedDropDistance) - 0.10) max 0.2; + GVAR(dropDistance) = (GVAR(dropDistance) - 0.10) max 0.2; }; } else { private _xAdjustBonus = [0, -0.075] select (GVAR(throwType) == "high"); diff --git a/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf b/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf index 2554225cf09..e5466a12291 100644 --- a/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf +++ b/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf @@ -32,7 +32,7 @@ GVAR(inHand) = false; GVAR(primed) = false; GVAR(activeThrowable) = objNull; GVAR(throwType) = "normal"; -GVAR(extendedDrop) = false; +GVAR(dropMode) = false; // Remove controls hint (check if ever enabled is inside the function) call EFUNC(interaction,hideMouseHint); diff --git a/addons/advancedthrowing/functions/fnc_onKeyDown.sqf b/addons/advancedthrowing/functions/fnc_onKeyDown.sqf index 6ba2a00deb1..e0ba32e822f 100644 --- a/addons/advancedthrowing/functions/fnc_onKeyDown.sqf +++ b/addons/advancedthrowing/functions/fnc_onKeyDown.sqf @@ -23,15 +23,6 @@ if (!GVAR(inHand)) exitWith {false}; params ["", "_key", "_shift", "_ctrl", "_alt"]; -// Extend arm drop mode (only on foot) - check _key to prevent some key weirdness and allow nice changing while moving -if (_ctrl && _key == 29) then { - GVAR(extendedDrop) = [true, false] select GVAR(extendedDrop); - GVAR(throwType) = "normal"; - - // Change controls hint for MMB - call FUNC(updateControlsHint); -}; - // Exit if any of the action keys is pressed { if (_key in _x) exitWith { diff --git a/addons/advancedthrowing/functions/fnc_onMouseScroll.sqf b/addons/advancedthrowing/functions/fnc_onMouseScroll.sqf index bc35c685136..ecceec697fe 100644 --- a/addons/advancedthrowing/functions/fnc_onMouseScroll.sqf +++ b/addons/advancedthrowing/functions/fnc_onMouseScroll.sqf @@ -19,18 +19,18 @@ if (!GVAR(inHand)) exitWith {}; params ["", "_amount"]; -if (GVAR(extendedDrop)) then { +if (GVAR(dropMode)) then { if (_amount < 0) then { // Move closer - GVAR(extendedDropDistance) = (GVAR(extendedDropDistance) - 0.1) max 0.2; + GVAR(dropDistance) = (GVAR(dropDistance) - 0.1) max 0.2; } else { // Move further - GVAR(extendedDropDistance) = (GVAR(extendedDropDistance) + 0.1) min 1; + GVAR(dropDistance) = (GVAR(dropDistance) + 0.1) min 1; }; // Limit distance in vehicle if (vehicle ACE_player != ACE_player) then { - GVAR(extendedDropDistance) = GVAR(extendedDropDistance) min 0.5; + GVAR(dropDistance) = GVAR(dropDistance) min 0.5; }; } else { if (_amount < 0) then { diff --git a/addons/advancedthrowing/functions/fnc_throw.sqf b/addons/advancedthrowing/functions/fnc_throw.sqf index 5d8d693a98e..c11d7e9160f 100644 --- a/addons/advancedthrowing/functions/fnc_throw.sqf +++ b/addons/advancedthrowing/functions/fnc_throw.sqf @@ -29,13 +29,9 @@ _unit playAction "ThrowGrenade"; params ["_unit"]; // Launch actual throwable - private _direction = [THROWSTYLE_NORMAL_DIR, THROWSTYLE_HIGH_DIR] select (GVAR(throwType) == "high"); + private _direction = [THROWSTYLE_NORMAL_DIR, THROWSTYLE_HIGH_DIR] select (GVAR(throwType) == "high" || {GVAR(dropMode)}); private _velocity = [GVAR(throwSpeed), THROWSTYLE_HIGH_VEL] select (GVAR(throwType) == "high"); - - if (GVAR(extendedDrop)) then { - _direction = THROWSTYLE_EXTENDED_DIR; - _velocity = THROWSTYLE_EXTENDED_VEL; - }; + _velocity = [_velocity, THROWSTYLE_DROP_VEL] select GVAR(dropMode); private _p2 = (eyePos _unit) vectorAdd (positionCameraToWorld _direction) vectorDiff (positionCameraToWorld [0, 0, 0]); private _p1 = AGLtoASL (GVAR(activeThrowable) modelToWorldVisual [0, 0, 0]); diff --git a/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf b/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf index 158ca50ff43..acecc109007 100644 --- a/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf +++ b/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf @@ -17,7 +17,7 @@ if (!GVAR(showMouseControls)) exitWith {}; -private _mmb = [localize LSTRING(ChangeMode), localize LSTRING(Extend)] select GVAR(extendedDrop); +private _mmb = [localize LSTRING(ChangeMode), localize LSTRING(Extend)] select GVAR(dropMode); if (!GVAR(primed)) then { _mmb = [_mmb, localize LSTRING(Cook)] joinString " / "; diff --git a/addons/advancedthrowing/script_component.hpp b/addons/advancedthrowing/script_component.hpp index bc53b8c527e..66a055ec543 100644 --- a/addons/advancedthrowing/script_component.hpp +++ b/addons/advancedthrowing/script_component.hpp @@ -20,5 +20,4 @@ #define THROWSTYLE_NORMAL_DIR [0, 70, 500] #define THROWSTYLE_HIGH_DIR [0, 200, 500] #define THROWSTYLE_HIGH_VEL 8 -#define THROWSTYLE_EXTENDED_DIR [0, 200, 500] -#define THROWSTYLE_EXTENDED_VEL 3 +#define THROWSTYLE_DROP_VEL 3 diff --git a/addons/advancedthrowing/stringtable.xml b/addons/advancedthrowing/stringtable.xml index b0d8479be06..e2aee68033c 100644 --- a/addons/advancedthrowing/stringtable.xml +++ b/addons/advancedthrowing/stringtable.xml @@ -25,13 +25,19 @@ Enables visual cues for mouse controls when throwable is prepared. - - Primed - - + Prepare/Change Throwable - + + Throwable Drop Mode (Hold) + + + Throwable Drop Mode (Toggle) + + + Primed + + Throw From 1c95c883e0d9d2fe93970d826c9be413320e21fa Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 7 Jun 2016 02:10:14 +0200 Subject: [PATCH 21/54] Fix animation changing position in some stances, Stop drawing arc and doing rendering magic while throw is happening --- .../advancedthrowing/functions/fnc_throw.sqf | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_throw.sqf b/addons/advancedthrowing/functions/fnc_throw.sqf index c11d7e9160f..02fb1063ffd 100644 --- a/addons/advancedthrowing/functions/fnc_throw.sqf +++ b/addons/advancedthrowing/functions/fnc_throw.sqf @@ -25,16 +25,20 @@ if (!GVAR(primed)) then { _unit playAction "ThrowGrenade"; +// Pass position to reset later because animation may change it in certain stances [{ - params ["_unit"]; + params ["_unit", "_activeThrowable", "_posThrown", "_throwType", "_throwSpeed", "_dropMode"]; + + // Reset position in case animation changed it + _activeThrowable setPosASL _posThrown; // Launch actual throwable - private _direction = [THROWSTYLE_NORMAL_DIR, THROWSTYLE_HIGH_DIR] select (GVAR(throwType) == "high" || {GVAR(dropMode)}); - private _velocity = [GVAR(throwSpeed), THROWSTYLE_HIGH_VEL] select (GVAR(throwType) == "high"); - _velocity = [_velocity, THROWSTYLE_DROP_VEL] select GVAR(dropMode); + private _direction = [THROWSTYLE_NORMAL_DIR, THROWSTYLE_HIGH_DIR] select (_throwType == "high" || {_dropMode}); + private _velocity = [_throwSpeed, THROWSTYLE_HIGH_VEL] select (_throwType == "high"); + _velocity = [_velocity, THROWSTYLE_DROP_VEL] select _dropMode; private _p2 = (eyePos _unit) vectorAdd (positionCameraToWorld _direction) vectorDiff (positionCameraToWorld [0, 0, 0]); - private _p1 = AGLtoASL (GVAR(activeThrowable) modelToWorldVisual [0, 0, 0]); + private _p1 = AGLtoASL (_activeThrowable modelToWorldVisual [0, 0, 0]); private _newVelocity = (_p1 vectorFromTo _p2) vectorMultiply _velocity; @@ -45,8 +49,9 @@ _unit playAction "ThrowGrenade"; // Drop if unit dies during throw process if (alive _unit) then { - GVAR(activeThrowable) setVelocity _newVelocity; + _activeThrowable setVelocity _newVelocity; }; +}, [_unit, GVAR(activeThrowable), getPosASLVisual GVAR(activeThrowable), GVAR(throwType), GVAR(throwSpeed), GVAR(dropMode)], 0.3] call CBA_fnc_waitAndExecute; - [_unit, "Completed a throw fully"] call FUNC(exitThrowMode); -}, _unit, 0.3] call CBA_fnc_waitAndExecute; +// Stop rendering arc and doing rendering magic while throw is happening +[_unit, "Completed a throw fully"] call FUNC(exitThrowMode); From f1a453314f59ca03dfc528a1258135ae2921d7be Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 7 Jun 2016 19:51:02 +0200 Subject: [PATCH 22/54] Fix support for picking up attached throwables, Fix IR Grenades not being pick uppable, Improve interactEH performance a bit --- addons/advancedthrowing/ACE_Settings.hpp | 16 ++++++ addons/advancedthrowing/CfgVehicles.hpp | 2 +- .../advancedthrowing/XEH_postInitClient.sqf | 4 +- .../functions/fnc_interactEH.sqf | 54 +++++++++---------- .../advancedthrowing/functions/fnc_pickUp.sqf | 8 +++ addons/advancedthrowing/stringtable.xml | 12 +++++ 6 files changed, 67 insertions(+), 29 deletions(-) diff --git a/addons/advancedthrowing/ACE_Settings.hpp b/addons/advancedthrowing/ACE_Settings.hpp index 5b6ca38ced0..db8991b8fc7 100644 --- a/addons/advancedthrowing/ACE_Settings.hpp +++ b/addons/advancedthrowing/ACE_Settings.hpp @@ -23,4 +23,20 @@ class ACE_Settings { value = 1; isClientSettable = 1; }; + class GVAR(enablePickUp) { + category = CSTRING(Category); + displayName = CSTRING(EnablePickUp_DisplayName); + description = CSTRING(EnablePickUp_Description); + typeName = "BOOL"; + value = 1; + isClientSettable = 1; + }; + class GVAR(enablePickUpAttached) { + category = CSTRING(Category); + displayName = CSTRING(EnablePickUpAttached_DisplayName); + description = CSTRING(EnablePickUpAttached_Description); + typeName = "BOOL"; + value = 1; + isClientSettable = 1; + }; }; diff --git a/addons/advancedthrowing/CfgVehicles.hpp b/addons/advancedthrowing/CfgVehicles.hpp index e65e3c981cf..4ed6676458f 100644 --- a/addons/advancedthrowing/CfgVehicles.hpp +++ b/addons/advancedthrowing/CfgVehicles.hpp @@ -48,7 +48,7 @@ class CfgVehicles { displayName = CSTRING(PickUp); condition = QUOTE(_player call FUNC(canPrepare)); statement = QUOTE(_this call FUNC(pickUp)); - distance = 1.5; + distance = 1.8; // Requires >1.7 to work when standing with weapon on back icon = "\a3\ui_f\data\igui\cfg\actions\obsolete\ui_action_takemine_ca.paa"; }; }; diff --git a/addons/advancedthrowing/XEH_postInitClient.sqf b/addons/advancedthrowing/XEH_postInitClient.sqf index f1fd172b225..6a2d9be13f5 100644 --- a/addons/advancedthrowing/XEH_postInitClient.sqf +++ b/addons/advancedthrowing/XEH_postInitClient.sqf @@ -59,7 +59,9 @@ if (!hasInterface) exitWith {}; [ACE_player, "Interact menu opened"] call FUNC(exitThrowMode); } else { // Show pick up actions on CfgAmmo's - _this call FUNC(interactEH); + if (GVAR(enablePickUp)) then { + _this call FUNC(interactEH); + }; }; }] call EFUNC(common,addEventHandler); diff --git a/addons/advancedthrowing/functions/fnc_interactEH.sqf b/addons/advancedthrowing/functions/fnc_interactEH.sqf index e0139c83b14..0382563316f 100644 --- a/addons/advancedthrowing/functions/fnc_interactEH.sqf +++ b/addons/advancedthrowing/functions/fnc_interactEH.sqf @@ -25,31 +25,31 @@ if (_interactionType != 0 || {vehicle ACE_player != ACE_player}) exitWith {}; params ["_args", "_idPFH"]; _args params ["_setPosition", "_addedPickUpHelpers", "_throwablesHelped"]; - if (!EGVAR(interact_menu,keyDown)) then { - TRACE_1("Cleaning Pick Up Helpers",count _addedPickUpHelpers); - {deleteVehicle _x} forEach _addedPickUpHelpers; - [_idPFH] call CBA_fnc_removePerFrameHandler; - } else { - // Prevent rare error when ending mission with interact key down - if (isNull ace_player) exitWith {}; - - // Player moved >5 meters from last pos, rescan - if ((getPosASL ace_player) distance _setPosition > 5) then { - { - if ((_x distance ACE_player < 15) && {!(_x in _throwablesHelped)} && {!GVAR(inHand)}) then { - private _pickUpHelper = QGVAR(pickUpHelper) createVehicleLocal (getPos _x); - - private _config = configFile >> "CfgAmmo" >> typeOf _x; - - TRACE_3("Made PickUp Helper",_x,typeOf _x); - - _pickUpHelper attachTo [_x, [0, 0, 0]]; - _pickUpHelper setVariable [QGVAR(throwable), _x]; - _addedPickUpHelpers pushBack _pickUpHelper; - _throwablesHelped pushBack _x; - }; - } forEach (ACE_player nearObjects ["GrenadeHand", 5]); - _args set [0, getPosASL ACE_player]; - }; - }; + if (EGVAR(interact_menu,keyDown)) then { + // Prevent rare error when ending mission with interact key down + if (isNull ACE_player) exitWith {}; + + // Player moved >5 meters from last pos, rescan + if ((getPosASL ACE_player) distance _setPosition > 5 && {!GVAR(inHand)}) then { + { + if (_x distance ACE_player > 5 || {_x in _throwablesHelped}) exitWith {}; + + if (!GVAR(enablePickUpAttached) && {!isNull (attachedTo _x)}) exitWith {}; + + private _pickUpHelper = QGVAR(pickUpHelper) createVehicleLocal (getPos _x); + + TRACE_3("Made PickUp Helper",_x,typeOf _x); + + _pickUpHelper attachTo [_x, [0, 0, 0]]; + _pickUpHelper setVariable [QGVAR(throwable), _x]; + _addedPickUpHelpers pushBack _pickUpHelper; + _throwablesHelped pushBack _x; + } forEach ((ACE_player nearObjects ["GrenadeHand", 5]) + (ACE_player nearObjects ["GrenadeCore", 5])); + _args set [0, getPosASL ACE_player]; + }; + } else { + TRACE_1("Cleaning Pick Up Helpers",count _addedPickUpHelpers); + {deleteVehicle _x} forEach _addedPickUpHelpers; + [_idPFH] call CBA_fnc_removePerFrameHandler; + }; }, 0.5, [(getPosASL ACE_player) vectorAdd [-100,0,0], [], []]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/advancedthrowing/functions/fnc_pickUp.sqf b/addons/advancedthrowing/functions/fnc_pickUp.sqf index 26c2cf8961b..50b64907c85 100644 --- a/addons/advancedthrowing/functions/fnc_pickUp.sqf +++ b/addons/advancedthrowing/functions/fnc_pickUp.sqf @@ -22,6 +22,14 @@ GVAR(activeThrowable) = _helper getVariable [QGVAR(throwable), objNull]; if (isNull GVAR(activeThrowable)) exitWith {}; +// Detach if attached (to vehicle for example or another player) +if (!isNull (attachedTo GVAR(activeThrowable))) then { + detach GVAR(activeThrowable); + + // Fix throw speed in some cases after detaching + GVAR(throwSpeed) = getNumber (configFile >> "CfgMagazines" >> typeOf GVAR(activeThrowable) >> "initSpeed"); +}; + // Change locality for manipulation (some commands require local object, such as setVelocity) if (!local GVAR(activeThrowable)) then { ["setOwner", [GVAR(activeThrowable), clientOwner]] call EFUNC(common,serverEvent); diff --git a/addons/advancedthrowing/stringtable.xml b/addons/advancedthrowing/stringtable.xml index e2aee68033c..2c6544cb9a8 100644 --- a/addons/advancedthrowing/stringtable.xml +++ b/addons/advancedthrowing/stringtable.xml @@ -25,6 +25,18 @@ Enables visual cues for mouse controls when throwable is prepared. + + Enable Throwables Pick Up + + + Enables ability to pick up throwables from the ground. + + + Enable Attached Throwables Pick Up + + + Enables ability to pick up throwables from attached objects. + Prepare/Change Throwable From f8a18041f3431d9f657c6b8acaba8fbd7d7c4d77 Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 7 Jun 2016 20:32:02 +0200 Subject: [PATCH 23/54] Improve arc precision, Change high throw velocity to use throwSpeed --- addons/advancedthrowing/functions/fnc_drawArc.sqf | 4 ++-- addons/advancedthrowing/functions/fnc_interactEH.sqf | 3 +-- addons/advancedthrowing/functions/fnc_throw.sqf | 2 +- addons/advancedthrowing/script_component.hpp | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_drawArc.sqf b/addons/advancedthrowing/functions/fnc_drawArc.sqf index 7f484f2e304..3e6c30e1895 100644 --- a/addons/advancedthrowing/functions/fnc_drawArc.sqf +++ b/addons/advancedthrowing/functions/fnc_drawArc.sqf @@ -23,7 +23,7 @@ if (!([ACE_player] call FUNC(canThrow))) exitWith { if (isNull GVAR(activeThrowable)) exitWith {}; private _direction = [THROWSTYLE_NORMAL_DIR, THROWSTYLE_HIGH_DIR] select (GVAR(throwType) == "high" || {GVAR(dropMode)}); -private _velocity = [GVAR(throwSpeed), THROWSTYLE_HIGH_VEL] select (GVAR(throwType) == "high"); +private _velocity = [GVAR(throwSpeed), GVAR(throwSpeed) / THROWSTYLE_HIGH_VEL_COEF] select (GVAR(throwType) == "high"); _velocity = [_velocity, THROWSTYLE_DROP_VEL] select GVAR(dropMode); private _viewStart = AGLToASL (positionCameraToWorld [0, 0, 0]); @@ -35,7 +35,7 @@ private _prevTrajASL = getPosASLVisual GVAR(activeThrowable); private _pathData = []; for "_i" from 0.05 to 1.45 step 0.1 do { - private _newTrajASL = _prevTrajASL vectorAdd (_initialVelocity vectorMultiply _i) vectorAdd ([0, 0, -4.9] vectorMultiply (_i * _i)); + private _newTrajASL = _prevTrajASL vectorAdd (_initialVelocity vectorMultiply _i) vectorAdd ([0, 0, -4.12] vectorMultiply (_i * _i)); private _cross = 0; if (_newTrajASL distance (getPosASLVisual ACE_player) <= 20) then { diff --git a/addons/advancedthrowing/functions/fnc_interactEH.sqf b/addons/advancedthrowing/functions/fnc_interactEH.sqf index 0382563316f..05bf072ab63 100644 --- a/addons/advancedthrowing/functions/fnc_interactEH.sqf +++ b/addons/advancedthrowing/functions/fnc_interactEH.sqf @@ -32,8 +32,7 @@ if (_interactionType != 0 || {vehicle ACE_player != ACE_player}) exitWith {}; // Player moved >5 meters from last pos, rescan if ((getPosASL ACE_player) distance _setPosition > 5 && {!GVAR(inHand)}) then { { - if (_x distance ACE_player > 5 || {_x in _throwablesHelped}) exitWith {}; - + if (_x distance ACE_player > 5 || {_x in _throwablesHelped}) exitWith {}; if (!GVAR(enablePickUpAttached) && {!isNull (attachedTo _x)}) exitWith {}; private _pickUpHelper = QGVAR(pickUpHelper) createVehicleLocal (getPos _x); diff --git a/addons/advancedthrowing/functions/fnc_throw.sqf b/addons/advancedthrowing/functions/fnc_throw.sqf index 02fb1063ffd..946a77c19d7 100644 --- a/addons/advancedthrowing/functions/fnc_throw.sqf +++ b/addons/advancedthrowing/functions/fnc_throw.sqf @@ -34,7 +34,7 @@ _unit playAction "ThrowGrenade"; // Launch actual throwable private _direction = [THROWSTYLE_NORMAL_DIR, THROWSTYLE_HIGH_DIR] select (_throwType == "high" || {_dropMode}); - private _velocity = [_throwSpeed, THROWSTYLE_HIGH_VEL] select (_throwType == "high"); + private _velocity = [_throwSpeed, _throwSpeed / THROWSTYLE_HIGH_VEL_COEF] select (_throwType == "high"); _velocity = [_velocity, THROWSTYLE_DROP_VEL] select _dropMode; private _p2 = (eyePos _unit) vectorAdd (positionCameraToWorld _direction) vectorDiff (positionCameraToWorld [0, 0, 0]); diff --git a/addons/advancedthrowing/script_component.hpp b/addons/advancedthrowing/script_component.hpp index 66a055ec543..15f9ea34c70 100644 --- a/addons/advancedthrowing/script_component.hpp +++ b/addons/advancedthrowing/script_component.hpp @@ -19,5 +19,5 @@ #define THROWSTYLE_NORMAL_DIR [0, 70, 500] #define THROWSTYLE_HIGH_DIR [0, 200, 500] -#define THROWSTYLE_HIGH_VEL 8 -#define THROWSTYLE_DROP_VEL 3 +#define THROWSTYLE_HIGH_VEL_COEF 2 +#define THROWSTYLE_DROP_VEL 2 From a14ad25dcea54534a4dac19b7e0460c94c6e0a04 Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 7 Jun 2016 20:43:06 +0200 Subject: [PATCH 24/54] Add thrown and picked up listenable events, Change throwFiredXEH to CBA event --- addons/advancedthrowing/XEH_postInitClient.sqf | 2 +- addons/advancedthrowing/functions/fnc_pickUp.sqf | 6 +++++- addons/advancedthrowing/functions/fnc_prime.sqf | 2 +- addons/advancedthrowing/functions/fnc_throw.sqf | 3 +++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/advancedthrowing/XEH_postInitClient.sqf b/addons/advancedthrowing/XEH_postInitClient.sqf index 6a2d9be13f5..f0c644c1434 100644 --- a/addons/advancedthrowing/XEH_postInitClient.sqf +++ b/addons/advancedthrowing/XEH_postInitClient.sqf @@ -67,7 +67,7 @@ if (!hasInterface) exitWith {}; // Fired XEH -[QGVAR(throwFiredXEH), {_this call FUNC(throwFiredXEH)}] call EFUNC(common,addEventHandler); +[QGVAR(throwFiredXEH), FUNC(throwFiredXEH)] call CBA_fnc_addEventHandler; // Display handlers diff --git a/addons/advancedthrowing/functions/fnc_pickUp.sqf b/addons/advancedthrowing/functions/fnc_pickUp.sqf index 50b64907c85..a96c0c0a911 100644 --- a/addons/advancedthrowing/functions/fnc_pickUp.sqf +++ b/addons/advancedthrowing/functions/fnc_pickUp.sqf @@ -23,7 +23,8 @@ GVAR(activeThrowable) = _helper getVariable [QGVAR(throwable), objNull]; if (isNull GVAR(activeThrowable)) exitWith {}; // Detach if attached (to vehicle for example or another player) -if (!isNull (attachedTo GVAR(activeThrowable))) then { +private _attachedTo = attachedTo GVAR(activeThrowable); +if (!isNull _attachedTo) then { detach GVAR(activeThrowable); // Fix throw speed in some cases after detaching @@ -35,5 +36,8 @@ if (!local GVAR(activeThrowable)) then { ["setOwner", [GVAR(activeThrowable), clientOwner]] call EFUNC(common,serverEvent); }; +// Invoke listenable event +["ace_throwablePickedUp", [GVAR(activeThrowable), _unit, _attachedTo]] call CBA_fnc_localEvent; + GVAR(primed) = true; _unit call FUNC(prepare) diff --git a/addons/advancedthrowing/functions/fnc_prime.sqf b/addons/advancedthrowing/functions/fnc_prime.sqf index 388b10f899d..3e9ee24737a 100644 --- a/addons/advancedthrowing/functions/fnc_prime.sqf +++ b/addons/advancedthrowing/functions/fnc_prime.sqf @@ -41,7 +41,7 @@ deleteVehicle _activeThrowableOld; _throwableType, // ammo _throwableMag, // magazine GVAR(activeThrowable) // projectile -]] call EFUNC(common,globalEvent); +]] call CBA_fnc_globalEvent; if (_showHint) then { // Show primed hint diff --git a/addons/advancedthrowing/functions/fnc_throw.sqf b/addons/advancedthrowing/functions/fnc_throw.sqf index 946a77c19d7..4f03c4034be 100644 --- a/addons/advancedthrowing/functions/fnc_throw.sqf +++ b/addons/advancedthrowing/functions/fnc_throw.sqf @@ -51,6 +51,9 @@ _unit playAction "ThrowGrenade"; if (alive _unit) then { _activeThrowable setVelocity _newVelocity; }; + + // Invoke listenable event + ["ace_throwableThrown", [_unit, _activeThrowable]] call CBA_fnc_localEvent; }, [_unit, GVAR(activeThrowable), getPosASLVisual GVAR(activeThrowable), GVAR(throwType), GVAR(throwSpeed), GVAR(dropMode)], 0.3] call CBA_fnc_waitAndExecute; // Stop rendering arc and doing rendering magic while throw is happening From d719414cd656f7792e6bf1c1d23fd9ca922fee82 Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 7 Jun 2016 22:36:58 +0200 Subject: [PATCH 25/54] Improve pick up interaction rendering, Fix pickup helper positioning --- addons/advancedthrowing/XEH_PREP.hpp | 2 +- .../advancedthrowing/XEH_postInitClient.sqf | 8 ++- .../functions/fnc_interactEH.sqf | 54 ---------------- .../functions/fnc_renderPickUpInteraction.sqf | 61 +++++++++++++++++++ 4 files changed, 67 insertions(+), 58 deletions(-) delete mode 100644 addons/advancedthrowing/functions/fnc_interactEH.sqf create mode 100644 addons/advancedthrowing/functions/fnc_renderPickUpInteraction.sqf diff --git a/addons/advancedthrowing/XEH_PREP.hpp b/addons/advancedthrowing/XEH_PREP.hpp index c34eb9b9aac..abd49514ae8 100644 --- a/addons/advancedthrowing/XEH_PREP.hpp +++ b/addons/advancedthrowing/XEH_PREP.hpp @@ -4,7 +4,6 @@ PREP(drawArc); PREP(drawThrowable); PREP(exitThrowMode); PREP(getMuzzle); -PREP(interactEH); PREP(moduleInit); PREP(onKeyDown); PREP(onMouseButtonDown); @@ -12,6 +11,7 @@ PREP(onMouseScroll); PREP(pickUp); PREP(prepare); PREP(prime); +PREP(renderPickUpInteraction); PREP(throw); PREP(throwFiredXEH); PREP(updateControlsHint); diff --git a/addons/advancedthrowing/XEH_postInitClient.sqf b/addons/advancedthrowing/XEH_postInitClient.sqf index f0c644c1434..6ffbc758d02 100644 --- a/addons/advancedthrowing/XEH_postInitClient.sqf +++ b/addons/advancedthrowing/XEH_postInitClient.sqf @@ -58,9 +58,11 @@ if (!hasInterface) exitWith {}; if (GVAR(inHand)) then { [ACE_player, "Interact menu opened"] call FUNC(exitThrowMode); } else { - // Show pick up actions on CfgAmmo's - if (GVAR(enablePickUp)) then { - _this call FUNC(interactEH); + params ["_interactionType"]; + // Ignore self-interaction menu, when in vehicle and when pick up is disabled + if (GVAR(enablePickUp) && {_interactionType == 0} && {vehicle ACE_player == ACE_player}) then { + // Show pick up actions on CfgAmmo's + call FUNC(renderPickUpInteraction); }; }; }] call EFUNC(common,addEventHandler); diff --git a/addons/advancedthrowing/functions/fnc_interactEH.sqf b/addons/advancedthrowing/functions/fnc_interactEH.sqf deleted file mode 100644 index 05bf072ab63..00000000000 --- a/addons/advancedthrowing/functions/fnc_interactEH.sqf +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Author: PabstMirror, Jonpas - * When interact_menu starts rendering (from "interact_keyDown" event). - * Add pick up helpers to all nearby grenades. - * - * Arguments: - * 0: Interaction Menu Type (0 - world, 1 - self) - * - * Return Value: - * Nothing - * - * Example: - * [0] call ace_advancedthrowing_fnc_interactEH - * - * Public: No - */ -#include "script_component.hpp" - -params ["_interactionType"]; - -// Ignore self-interaction menu and when in vehicle -if (_interactionType != 0 || {vehicle ACE_player != ACE_player}) exitWith {}; - -[{ - params ["_args", "_idPFH"]; - _args params ["_setPosition", "_addedPickUpHelpers", "_throwablesHelped"]; - - if (EGVAR(interact_menu,keyDown)) then { - // Prevent rare error when ending mission with interact key down - if (isNull ACE_player) exitWith {}; - - // Player moved >5 meters from last pos, rescan - if ((getPosASL ACE_player) distance _setPosition > 5 && {!GVAR(inHand)}) then { - { - if (_x distance ACE_player > 5 || {_x in _throwablesHelped}) exitWith {}; - if (!GVAR(enablePickUpAttached) && {!isNull (attachedTo _x)}) exitWith {}; - - private _pickUpHelper = QGVAR(pickUpHelper) createVehicleLocal (getPos _x); - - TRACE_3("Made PickUp Helper",_x,typeOf _x); - - _pickUpHelper attachTo [_x, [0, 0, 0]]; - _pickUpHelper setVariable [QGVAR(throwable), _x]; - _addedPickUpHelpers pushBack _pickUpHelper; - _throwablesHelped pushBack _x; - } forEach ((ACE_player nearObjects ["GrenadeHand", 5]) + (ACE_player nearObjects ["GrenadeCore", 5])); - _args set [0, getPosASL ACE_player]; - }; - } else { - TRACE_1("Cleaning Pick Up Helpers",count _addedPickUpHelpers); - {deleteVehicle _x} forEach _addedPickUpHelpers; - [_idPFH] call CBA_fnc_removePerFrameHandler; - }; -}, 0.5, [(getPosASL ACE_player) vectorAdd [-100,0,0], [], []]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/advancedthrowing/functions/fnc_renderPickUpInteraction.sqf b/addons/advancedthrowing/functions/fnc_renderPickUpInteraction.sqf new file mode 100644 index 00000000000..5e12543981b --- /dev/null +++ b/addons/advancedthrowing/functions/fnc_renderPickUpInteraction.sqf @@ -0,0 +1,61 @@ +/* + * Author: PabstMirror, Jonpas + * When interact_menu starts rendering (from "interact_keyDown" event). + * Add pick up helpers to all nearby throwables and keep setting them to their position (setVariable and attachTo does not work on CfgAmmo). + * + * Arguments: + * None + * + * Return Value: + * Nothing + * + * Example: + * call ace_advancedthrowing_fnc_renderPickUpInteraction + * + * Public: No + */ +#include "script_component.hpp" + +[{ + params ["_args", "_idPFH"]; + _args params ["_setPosition", "_addedPickUpHelpers", "_throwablesHelped", "_nearThrowables"]; + + // isNull is necessarry to prevent rare error when ending mission with interact key down + if (EGVAR(interact_menu,keyDown) && {!isNull ACE_player}) then { + // Rescan when player moved >5 meters from last pos, nearObjects is costly + if ((getPosASL ACE_player) distance _setPosition > 5) then { + // IR throwbles inherit from GrenadeCore, others from GrenadeHand + _nearThrowables = ACE_player nearObjects ["GrenadeHand", 10]; + _nearThrowables append (ACE_player nearObjects ["GrenadeCore", 10]); + + { + if (_x in _throwablesHelped) exitWith {}; + + TRACE_2("Making PickUp Helper",_x,typeOf _x); + private _pickUpHelper = QGVAR(pickUpHelper) createVehicleLocal (getPosASL _x); + + _pickUpHelper attachTo [_x, [0, 0, 0]]; + _pickUpHelper setVariable [QGVAR(throwable), _x]; + + _addedPickUpHelpers pushBack _pickUpHelper; + _throwablesHelped pushBack _x; + true + } count _nearThrowables; + + _args set [0, getPosASL ACE_player]; + _args set [3, _nearThrowables]; + }; + + { + if (!GVAR(enablePickUpAttached) && {!isNull (attachedTo _x)}) exitWith {}; + + // Only handling with attachTo works nicely + _x attachTo [_x getVariable [QGVAR(throwable), objNull], [0, 0, 0]]; + true + } count _addedPickUpHelpers; + } else { + TRACE_1("Cleaning Pick Up Helpers",count _addedPickUpHelpers); + {deleteVehicle _x} count _addedPickUpHelpers; + [_idPFH] call CBA_fnc_removePerFrameHandler; + }; +}, 0, [(getPosASL ACE_player) vectorAdd [-100, 0, 0], [], [], []]] call CBA_fnc_addPerFrameHandler; From 87fe2aaa3d16841c428731840e1c3ac47bf3d459 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 12 Jun 2016 14:20:31 +0200 Subject: [PATCH 26/54] Convert GVARs to setVariable (respawn and player change compatibility) --- .../advancedthrowing/XEH_postInitClient.sqf | 20 ++++--- addons/advancedthrowing/XEH_preInit.sqf | 11 ---- .../functions/fnc_canThrow.sqf | 2 +- .../functions/fnc_drawArc.sqf | 16 ++++-- .../functions/fnc_drawThrowable.sqf | 55 +++++++++++-------- .../functions/fnc_exitThrowMode.sqf | 20 ++++--- .../functions/fnc_onKeyDown.sqf | 2 +- .../functions/fnc_onMouseButtonDown.sqf | 10 ++-- .../functions/fnc_onMouseScroll.sqf | 22 ++++---- .../advancedthrowing/functions/fnc_pickUp.sqf | 23 ++++---- .../functions/fnc_prepare.sqf | 6 +- .../advancedthrowing/functions/fnc_prime.sqf | 9 +-- .../advancedthrowing/functions/fnc_throw.sqf | 11 +++- .../functions/fnc_updateControlsHint.sqf | 8 ++- addons/advancedthrowing/script_component.hpp | 4 ++ 15 files changed, 123 insertions(+), 96 deletions(-) diff --git a/addons/advancedthrowing/XEH_postInitClient.sqf b/addons/advancedthrowing/XEH_postInitClient.sqf index 6ffbc758d02..8a2200487c7 100644 --- a/addons/advancedthrowing/XEH_postInitClient.sqf +++ b/addons/advancedthrowing/XEH_postInitClient.sqf @@ -17,30 +17,32 @@ if (!hasInterface) exitWith {}; ["ACE3 Weapons", QGVAR(dropModeToggle), localize LSTRING(DropModeToggle), { // Condition - if (!GVAR(inHand)) exitWith {false}; + if !(ACE_player getVariable [QGVAR(inHand), false]) exitWith {false}; // Statement - GVAR(dropMode) = [true, false] select GVAR(dropMode); - GVAR(throwType) = "normal"; // Reset for consistency when opening + private _currentDropMode = ACE_player getVariable [QGVAR(dropMode), false]; + ACE_player setVariable [QGVAR(dropMode), !_currentDropMode]; + + ACE_player setVariable [QGVAR(throwType), THROW_TYPE_DEFAULT]; // Reset for consistency when opening call FUNC(updateControlsHint); // Change controls hint for MMB true }, {false}, [34, [false, true, false]], false] call CBA_fnc_addKeybind; // Ctrl + G ["ACE3 Weapons", QGVAR(dropModeHold), localize LSTRING(DropModeHold), { // Condition - if (!GVAR(inHand)) exitWith {false}; + if !(ACE_player getVariable [QGVAR(inHand), false]) exitWith {false}; // Statement - GVAR(dropMode) = true; - GVAR(throwType) = "normal"; // Reset for consistency when opening + ACE_player setVariable [QGVAR(dropMode), true]; + ACE_player setVariable [QGVAR(throwType), THROW_TYPE_DEFAULT]; // Reset for consistency when opening call FUNC(updateControlsHint); // Change controls hint for MMB true }, { // Condition - if (!GVAR(inHand)) exitWith {false}; + if !(ACE_player getVariable [QGVAR(inHand), false]) exitWith {false}; // Statement - GVAR(dropMode) = false; + ACE_player setVariable [QGVAR(dropMode), false]; call FUNC(updateControlsHint); // Change controls hint for MMB true }, [0, [false, false, false]], false] call CBA_fnc_addKeybind; // Empty @@ -55,7 +57,7 @@ if (!hasInterface) exitWith {}; // Exit if advanced throwing is disabled (pick up only supports advanced throwing) if (!GVAR(enabled)) exitWith {}; - if (GVAR(inHand)) then { + if (ACE_player getVariable [QGVAR(inHand), false]) then { [ACE_player, "Interact menu opened"] call FUNC(exitThrowMode); } else { params ["_interactionType"]; diff --git a/addons/advancedthrowing/XEH_preInit.sqf b/addons/advancedthrowing/XEH_preInit.sqf index 81a5c994ae6..a7feade1c39 100644 --- a/addons/advancedthrowing/XEH_preInit.sqf +++ b/addons/advancedthrowing/XEH_preInit.sqf @@ -4,15 +4,4 @@ ADDON = false; #include "XEH_PREP.hpp" -// Trackers -GVAR(inHand) = false; -GVAR(primed) = false; -GVAR(activeThrowable) = objNull; -GVAR(throwType) = "normal"; -GVAR(dropMode) = false; - -// Defaults -GVAR(dropDistance) = 0.2; -GVAR(lastTickTime) = 0; - ADDON = true; diff --git a/addons/advancedthrowing/functions/fnc_canThrow.sqf b/addons/advancedthrowing/functions/fnc_canThrow.sqf index 4800d6d063b..c0e742546d9 100644 --- a/addons/advancedthrowing/functions/fnc_canThrow.sqf +++ b/addons/advancedthrowing/functions/fnc_canThrow.sqf @@ -17,7 +17,7 @@ params ["_unit"]; -if (!GVAR(inHand)) exitWith {false}; +if !(_unit getVariable [QGVAR(inHand), false]) exitWith {false}; if (vehicle _unit != _unit) exitWith { private _startPos = eyePos _unit; diff --git a/addons/advancedthrowing/functions/fnc_drawArc.sqf b/addons/advancedthrowing/functions/fnc_drawArc.sqf index 3e6c30e1895..d138eb91758 100644 --- a/addons/advancedthrowing/functions/fnc_drawArc.sqf +++ b/addons/advancedthrowing/functions/fnc_drawArc.sqf @@ -20,17 +20,23 @@ if (!([ACE_player] call FUNC(canThrow))) exitWith { drawIcon3D ["\a3\ui_f\data\igui\cfg\actions\obsolete\ui_action_cancel_manualfire_ca.paa", [1, 0, 0, 1], positionCameraToWorld [0, 0, 1], 1, 1, 0, "", 1]; }; -if (isNull GVAR(activeThrowable)) exitWith {}; +private _activeThrowable = ACE_player getVariable [QGVAR(activeThrowable), objNull]; -private _direction = [THROWSTYLE_NORMAL_DIR, THROWSTYLE_HIGH_DIR] select (GVAR(throwType) == "high" || {GVAR(dropMode)}); -private _velocity = [GVAR(throwSpeed), GVAR(throwSpeed) / THROWSTYLE_HIGH_VEL_COEF] select (GVAR(throwType) == "high"); -_velocity = [_velocity, THROWSTYLE_DROP_VEL] select GVAR(dropMode); +if (isNull _activeThrowable) exitWith {}; + +private _dropMode = ACE_player getVariable [QGVAR(dropMode), false]; +private _throwType = ACE_player getVariable [QGVAR(throwType), THROW_TYPE_DEFAULT]; +private _throwSpeed = ACE_player getVariable [QGVAR(throwSpeed), THROW_SPEED_DEFAULT]; + +private _direction = [THROWSTYLE_NORMAL_DIR, THROWSTYLE_HIGH_DIR] select (_throwType == "high" || {_dropMode}); +private _velocity = [_throwSpeed, _throwSpeed / THROWSTYLE_HIGH_VEL_COEF] select (_throwType == "high"); +_velocity = [_velocity, THROWSTYLE_DROP_VEL] select _dropMode; private _viewStart = AGLToASL (positionCameraToWorld [0, 0, 0]); private _viewEnd = AGLToASL (positionCameraToWorld _direction); private _initialVelocity = (vectorNormalized (_viewEnd vectorDiff _viewStart)) vectorMultiply (_velocity / 1.8); -private _prevTrajASL = getPosASLVisual GVAR(activeThrowable); +private _prevTrajASL = getPosASLVisual _activeThrowable; private _pathData = []; diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index d53b762f603..34d118e3b41 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -15,41 +15,46 @@ */ #include "script_component.hpp" -if (dialog || {!GVAR(inHand)} || {!([ACE_player] call FUNC(canPrepare))}) exitWith { +if (dialog || {!(ACE_player getVariable [QGVAR(inHand), false])} || {!([ACE_player] call FUNC(canPrepare))}) exitWith { [ACE_player, "In dialog or no throwable in hand or cannot prepare throwable"] call FUNC(exitThrowMode); }; private _throwable = currentThrowable ACE_player; private _throwableMag = _throwable select 0; +private _primed = ACE_player getVariable [QGVAR(primed), false]; +private _activeThrowable = ACE_player getVariable [QGVAR(activeThrowable), objNull]; // Handle cooking last throwable in inventory -if (GVAR(primed)) then { - _throwableMag = typeOf GVAR(activeThrowable); +if (_primed) then { + _throwableMag = typeOf _activeThrowable; } else { // Some throwables have different classname for magazine and ammo // Check only CfgMagazines one for correct value only when not primed to assure correct magazine is used - GVAR(throwSpeed) = getNumber (configFile >> "CfgMagazines" >> _throwableMag >> "initSpeed"); + _throwSpeed = getNumber (configFile >> "CfgMagazines" >> _throwableMag >> "initSpeed"); + ACE_player setVariable [QGVAR(throwSpeed), _throwSpeed]; }; // Inventory check -if (_throwable isEqualTo [] && {!GVAR(primed)}) exitWith { +if (_throwable isEqualTo [] && {!_primed}) exitWith { [ACE_player, "No valid throwables"] call FUNC(exitThrowMode); }; private _throwableType = getText (configFile >> "CfgMagazines" >> _throwableMag >> "ammo"); -if (!([ACE_player] call FUNC(canThrow)) && {!GVAR(primed)}) exitWith { - if (!isNull GVAR(activeThrowable)) then { - deleteVehicle GVAR(activeThrowable); +if (!([ACE_player] call FUNC(canThrow)) && {!_primed}) exitWith { + if (!isNull _activeThrowable) then { + deleteVehicle _activeThrowable; + ACE_player setVariable [QGVAR(activeThrowable), objNull]; }; }; -if (isNull GVAR(activeThrowable) || {(_throwableType != typeOf GVAR(activeThrowable)) && {!GVAR(primed)}}) then { - if (!isNull GVAR(activeThrowable)) then { - deleteVehicle GVAR(activeThrowable); +if (isNull _activeThrowable || {(_throwableType != typeOf _activeThrowable) && {!_primed}}) then { + if (!isNull _activeThrowable) then { + deleteVehicle _activeThrowable; }; - GVAR(activeThrowable) = _throwableType createVehicleLocal (getPosWorld ACE_player); - GVAR(activeThrowable) enableSimulation false; + _activeThrowable = _throwableType createVehicleLocal (getPosWorld ACE_player); + _activeThrowable enableSimulation false; + ACE_player setVariable [QGVAR(activeThrowable), _activeThrowable]; }; @@ -65,33 +70,35 @@ private _posCameraWorld = positionCameraToWorld [0, 0, 0]; _posHeadRel = _posHeadRel vectorAdd [-0.03, 0.01, 0.15]; // Bring closer to eyePos value private _posFin = AGLToASL (ACE_player modelToWorldVisual _posHeadRel); +private _throwType = ACE_player getVariable [QGVAR(throwType), THROW_TYPE_DEFAULT]; + // Orient it nicely, point towards player -GVAR(activeThrowable) setDir ((getDirVisual ACE_player) + 90); +_activeThrowable setDir ((getDirVisual ACE_player) + 90); -private _pitch = [-30, -90] select (GVAR(throwType) == "high"); -[GVAR(activeThrowable), _pitch, 0] call BIS_fnc_setPitchBank; +private _pitch = [-30, -90] select (_throwType == "high"); +[_activeThrowable, _pitch, 0] call BIS_fnc_setPitchBank; -if (GVAR(dropMode)) then { - _posFin = _posFin vectorAdd (positionCameraToWorld [_leanCoef, 0, GVAR(dropDistance)]); +if (ACE_player getVariable [QGVAR(dropMode), false]) then { + _posFin = _posFin vectorAdd (positionCameraToWorld [_leanCoef, 0, ACE_player getVariable [QGVAR(dropDistance), DROP_DISTANCE_DEFAULT]]); // Even vanilla throwables go through glass, only "GEOM" LOD will stop it but that will also stop it when there is glass in a window if (lineIntersects [AGLtoASL _posCameraWorld, _posFin vectorDiff _posCameraWorld]) then { - GVAR(dropDistance) = (GVAR(dropDistance) - 0.10) max 0.2; + ACE_player setVariable [QGVAR(dropDistance), (ACE_player getVariable [QGVAR(dropDistance), DROP_DISTANCE_DEFAULT] - 0.1) max DROP_DISTANCE_DEFAULT] }; } else { - private _xAdjustBonus = [0, -0.075] select (GVAR(throwType) == "high"); - private _yAdjustBonus = [0, 0.1] select (GVAR(throwType) == "high"); + private _xAdjustBonus = [0, -0.075] select (_throwType == "high"); + private _yAdjustBonus = [0, 0.1] select (_throwType == "high"); private _cameraOffset = [_leanCoef, 0, 0.3] vectorAdd [-0.05, -0.12, -0.03] vectorAdd [_xAdjustBonus, _yAdjustBonus, 0]; _posFin = _posFin vectorAdd (positionCameraToWorld _cameraOffset); if (vehicle ACE_player != ACE_player) then { // Counteract vehicle velocity including acceleration - private _vectorDiff = (velocity (vehicle ACE_player)) vectorMultiply (time - GVAR(lastTickTime) + 0.01); + private _vectorDiff = (velocity (vehicle ACE_player)) vectorMultiply (time - (ACE_player getVariable [QGVAR(lastTick), time]) + 0.01); _posFin = _posFin vectorAdd _vectorDiff; - GVAR(lastTickTime) = time; + ACE_player setVariable [QGVAR(lastTick), time]; }; }; -GVAR(activeThrowable) setPosASL (_posFin vectorDiff _posCameraWorld); +_activeThrowable setPosASL (_posFin vectorDiff _posCameraWorld); diff --git a/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf b/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf index e5466a12291..94f4e0c5113 100644 --- a/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf +++ b/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf @@ -16,23 +16,25 @@ */ #include "script_component.hpp" -if (!GVAR(inHand)) exitWith {}; - params ["_unit", "_reason"]; +if !(_unit getVariable [QGVAR(inHand), false]) exitWith {}; + #ifdef DEBUG_MODE_FULL systemChat format ["Exit Throw Mode: %1", _reason]; #endif -if (!GVAR(primed)) then { - deleteVehicle GVAR(activeThrowable); +if (!(_unit getVariable [QGVAR(dropMode), false])) then { + deleteVehicle (_unit setVariable [QGVAR(activeThrowable), objNull]); }; -GVAR(inHand) = false; -GVAR(primed) = false; -GVAR(activeThrowable) = objNull; -GVAR(throwType) = "normal"; -GVAR(dropMode) = false; +_unit setVariable [QGVAR(inHand), false]; +_unit setVariable [QGVAR(primed), false]; +_unit setVariable [QGVAR(activeThrowable), objNull]; +_unit setVariable [QGVAR(throwType), THROW_TYPE_DEFAULT]; +_unit setVariable [QGVAR(throwSpeed), THROW_SPEED_DEFAULT]; +_unit setVariable [QGVAR(dropMode), false]; +_unit setVariable [QGVAR(dropDistance), DROP_DISTANCE_DEFAULT]; // Remove controls hint (check if ever enabled is inside the function) call EFUNC(interaction,hideMouseHint); diff --git a/addons/advancedthrowing/functions/fnc_onKeyDown.sqf b/addons/advancedthrowing/functions/fnc_onKeyDown.sqf index e0ba32e822f..81aabb5c5b9 100644 --- a/addons/advancedthrowing/functions/fnc_onKeyDown.sqf +++ b/addons/advancedthrowing/functions/fnc_onKeyDown.sqf @@ -19,7 +19,7 @@ */ #include "script_component.hpp" -if (!GVAR(inHand)) exitWith {false}; +if !(ACE_player getVariable [QGVAR(inHand), false]) exitWith {false}; params ["", "_key", "_shift", "_ctrl", "_alt"]; diff --git a/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf b/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf index 6c4caa7d7a4..b999fc287a9 100644 --- a/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf +++ b/addons/advancedthrowing/functions/fnc_onMouseButtonDown.sqf @@ -15,14 +15,14 @@ */ #include "script_component.hpp" -if (!GVAR(inHand)) exitWith {}; +if !(ACE_player getVariable [QGVAR(inHand), false]) exitWith {}; params ["", "_key"]; // Left mouse button // "DefaultAction" doesn't get executed when in driver seat or in FFV seat with weapon lowered if (_key == 0) exitWith { - if (!isNull GVAR(activeThrowable)) then { + if (!isNull (ACE_player getVariable [QGVAR(activeThrowable), objNull])) then { // Look gets automatically pointed at weapon direction on first LMB press when in FFV seat, require weapon to be up if in vehicle private _inVehicle = vehicle ACE_player != ACE_player; if (!_inVehicle || {_inVehicle && {!weaponLowered ACE_player}}) then { @@ -31,14 +31,16 @@ if (_key == 0) exitWith { }; }; +private _primed = ACE_player getVariable [QGVAR(primed), false]; + // Right mouse button if (_key == 1) exitWith { - if (!GVAR(primed)) then { + if (!_primed) then { [ACE_player, "Storing throwable"] call FUNC(exitThrowMode); }; }; // Middle mouse button -if (_key == 2 && {!GVAR(primed)}) exitWith { +if (_key == 2 && {!_primed}) exitWith { [ACE_player, true] call FUNC(prime); }; diff --git a/addons/advancedthrowing/functions/fnc_onMouseScroll.sqf b/addons/advancedthrowing/functions/fnc_onMouseScroll.sqf index ecceec697fe..1a15a07f760 100644 --- a/addons/advancedthrowing/functions/fnc_onMouseScroll.sqf +++ b/addons/advancedthrowing/functions/fnc_onMouseScroll.sqf @@ -15,32 +15,34 @@ */ #include "script_component.hpp" -if (!GVAR(inHand)) exitWith {}; +if !(ACE_player getVariable [QGVAR(inHand), false]) exitWith {}; params ["", "_amount"]; -if (GVAR(dropMode)) then { +if (ACE_player getVariable [QGVAR(dropMode), false]) then { + private _dropDistance = ACE_player getVariable [QGVAR(dropDistance), DROP_DISTANCE_DEFAULT]; if (_amount < 0) then { // Move closer - GVAR(dropDistance) = (GVAR(dropDistance) - 0.1) max 0.2; + ACE_player setVariable [QGVAR(dropDistance), (_dropDistance - 0.1) max DROP_DISTANCE_DEFAULT]; } else { // Move further - GVAR(dropDistance) = (GVAR(dropDistance) + 0.1) min 1; + ACE_player setVariable [QGVAR(dropDistance), (_dropDistance + 0.1) min 1]; }; // Limit distance in vehicle if (vehicle ACE_player != ACE_player) then { - GVAR(dropDistance) = GVAR(dropDistance) min 0.5; + ACE_player setVariable [QGVAR(dropDistance), (ACE_player getVariable [QGVAR(dropDistance), DROP_DISTANCE_DEFAULT]) min 0.5]; }; } else { + private _throwType = ACE_player getVariable [QGVAR(throwType), THROW_TYPE_DEFAULT]; if (_amount < 0) then { - if (GVAR(throwType) == "high") then { - GVAR(throwType) = "normal"; + if (_throwType == "high") then { + ACE_player setVariable [QGVAR(throwType), THROW_TYPE_DEFAULT]; }; } else { - if (GVAR(throwType) == "normal") then { - GVAR(throwType) = "high"; + if (_throwType == "normal") then { + ACE_player setVariable [QGVAR(throwType), "high"]; }; }; - TRACE_2("Change Throw Type",_amount,GVAR(throwType)); + TRACE_2("Change Throw Type",_amount,ACE_player getVariable QGVAR(throwType)); }; diff --git a/addons/advancedthrowing/functions/fnc_pickUp.sqf b/addons/advancedthrowing/functions/fnc_pickUp.sqf index a96c0c0a911..5de21393af8 100644 --- a/addons/advancedthrowing/functions/fnc_pickUp.sqf +++ b/addons/advancedthrowing/functions/fnc_pickUp.sqf @@ -18,26 +18,29 @@ params ["_helper", "_unit"]; -GVAR(activeThrowable) = _helper getVariable [QGVAR(throwable), objNull]; +_activeThrowable = _helper getVariable [QGVAR(throwable), objNull]; -if (isNull GVAR(activeThrowable)) exitWith {}; +if (isNull _activeThrowable) exitWith {}; // Detach if attached (to vehicle for example or another player) -private _attachedTo = attachedTo GVAR(activeThrowable); +private _attachedTo = attachedTo _activeThrowable; if (!isNull _attachedTo) then { - detach GVAR(activeThrowable); + detach _activeThrowable; // Fix throw speed in some cases after detaching - GVAR(throwSpeed) = getNumber (configFile >> "CfgMagazines" >> typeOf GVAR(activeThrowable) >> "initSpeed"); + private _throwSpeed = getNumber (configFile >> "CfgMagazines" >> typeOf _activeThrowable >> "initSpeed"); + _unit setVariable [QGVAR(throwSpeed), _throwSpeed]; }; // Change locality for manipulation (some commands require local object, such as setVelocity) -if (!local GVAR(activeThrowable)) then { - ["setOwner", [GVAR(activeThrowable), clientOwner]] call EFUNC(common,serverEvent); +if (!local _activeThrowable) then { + ["setOwner", [_activeThrowable, clientOwner]] call EFUNC(common,serverEvent); }; // Invoke listenable event -["ace_throwablePickedUp", [GVAR(activeThrowable), _unit, _attachedTo]] call CBA_fnc_localEvent; +["ace_throwablePickedUp", [_activeThrowable, _unit, _attachedTo]] call CBA_fnc_localEvent; -GVAR(primed) = true; -_unit call FUNC(prepare) +_unit setVariable [QGVAR(primed), true]; +_unit setVariable [QGVAR(activeThrowable), _activeThrowable]; + +_unit call FUNC(prepare); diff --git a/addons/advancedthrowing/functions/fnc_prepare.sqf b/addons/advancedthrowing/functions/fnc_prepare.sqf index 91399ff7078..a840088095b 100644 --- a/addons/advancedthrowing/functions/fnc_prepare.sqf +++ b/addons/advancedthrowing/functions/fnc_prepare.sqf @@ -18,8 +18,8 @@ params ["_unit"]; // Select next throwable if one already in hand -if (GVAR(inHand)) exitWith { - if (!GVAR(primed)) then { +if (_unit getVariable [QGVAR(inHand), false]) exitWith { + if (!(_unit getVariable [QGVAR(primed), false])) then { [_unit] call EFUNC(weaponselect,selectNextGrenade); }; }; @@ -28,7 +28,7 @@ if (GVAR(inHand)) exitWith { if ((currentThrowable _unit) isEqualTo [] && {!([_unit] call EFUNC(weaponselect,selectNextGrenade))}) exitWith {}; -GVAR(inHand) = true; +_unit setVariable [QGVAR(inHand), true]; // Add controls hint call FUNC(updateControlsHint); diff --git a/addons/advancedthrowing/functions/fnc_prime.sqf b/addons/advancedthrowing/functions/fnc_prime.sqf index 3e9ee24737a..ad5a6e3e11c 100644 --- a/addons/advancedthrowing/functions/fnc_prime.sqf +++ b/addons/advancedthrowing/functions/fnc_prime.sqf @@ -18,7 +18,7 @@ params ["_unit", ["_showHint", false]]; -GVAR(primed) = true; +_unit setVariable [QGVAR(primed), true]; // Remove item before cooking to prevent weaponselect showing more throwables than there actually are in inventory private _throwableMag = (currentThrowable _unit) select 0; @@ -28,8 +28,9 @@ private _throwableType = getText (configFile >> "CfgMagazines" >> _throwableMag private _muzzle = _throwableMag call FUNC(getMuzzle); // Create actual throwable globally -private _activeThrowableOld = GVAR(activeThrowable); -GVAR(activeThrowable) = createVehicle [_throwableType, _activeThrowableOld, [], 0, "CAN_COLLIDE"]; +private _activeThrowableOld = _unit getVariable [QGVAR(activeThrowable), objNull]; +private _activeThrowable = createVehicle [_throwableType, _activeThrowableOld, [], 0, "CAN_COLLIDE"]; +_unit setVariable [QGVAR(activeThrowable), _activeThrowable]; deleteVehicle _activeThrowableOld; // Throw Fired XEH @@ -40,7 +41,7 @@ deleteVehicle _activeThrowableOld; _muzzle, // mode _throwableType, // ammo _throwableMag, // magazine - GVAR(activeThrowable) // projectile + _activeThrowable // projectile ]] call CBA_fnc_globalEvent; if (_showHint) then { diff --git a/addons/advancedthrowing/functions/fnc_throw.sqf b/addons/advancedthrowing/functions/fnc_throw.sqf index 4f03c4034be..d1bb8e6b2db 100644 --- a/addons/advancedthrowing/functions/fnc_throw.sqf +++ b/addons/advancedthrowing/functions/fnc_throw.sqf @@ -19,7 +19,7 @@ params ["_unit"]; // Prime the throwable if it hasn't been cooking already // Next to proper simulation this also has to happen before delay for orientation of the throwable to be set -if (!GVAR(primed)) then { +if (!(_unit getVariable [QGVAR(primed), false])) then { [_unit] call FUNC(prime); }; @@ -54,7 +54,14 @@ _unit playAction "ThrowGrenade"; // Invoke listenable event ["ace_throwableThrown", [_unit, _activeThrowable]] call CBA_fnc_localEvent; -}, [_unit, GVAR(activeThrowable), getPosASLVisual GVAR(activeThrowable), GVAR(throwType), GVAR(throwSpeed), GVAR(dropMode)], 0.3] call CBA_fnc_waitAndExecute; +}, [ + _unit, + _unit getVariable [QGVAR(activeThrowable), objNull], + getPosASLVisual (_unit getVariable [QGVAR(activeThrowable), objNull]), + _unit getVariable [QGVAR(throwType), THROW_TYPE_DEFAULT], + _unit getVariable [QGVAR(throwSpeed), THROW_SPEED_DEFAULT], + _unit getVariable [QGVAR(dropMode), false] +], 0.3] call CBA_fnc_waitAndExecute; // Stop rendering arc and doing rendering magic while throw is happening [_unit, "Completed a throw fully"] call FUNC(exitThrowMode); diff --git a/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf b/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf index acecc109007..fbe3c4c082e 100644 --- a/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf +++ b/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf @@ -17,14 +17,16 @@ if (!GVAR(showMouseControls)) exitWith {}; -private _mmb = [localize LSTRING(ChangeMode), localize LSTRING(Extend)] select GVAR(dropMode); +private _primed = ACE_player getVariable [QGVAR(primed), false]; -if (!GVAR(primed)) then { +private _mmb = [localize LSTRING(ChangeMode), localize LSTRING(Extend)] select (ACE_player getVariable [QGVAR(dropMode), false]); + +if (!_primed) then { _mmb = [_mmb, localize LSTRING(Cook)] joinString " / "; }; [ localize LSTRING(Throw), - [localize ELSTRING(common,Cancel), ""] select (GVAR(primed)), + [localize ELSTRING(common,Cancel), ""] select _primed, _mmb ] call EFUNC(interaction,showMouseHint); diff --git a/addons/advancedthrowing/script_component.hpp b/addons/advancedthrowing/script_component.hpp index 15f9ea34c70..15aff444676 100644 --- a/addons/advancedthrowing/script_component.hpp +++ b/addons/advancedthrowing/script_component.hpp @@ -21,3 +21,7 @@ #define THROWSTYLE_HIGH_DIR [0, 200, 500] #define THROWSTYLE_HIGH_VEL_COEF 2 #define THROWSTYLE_DROP_VEL 2 + +#define THROW_TYPE_DEFAULT "normal" +#define THROW_SPEED_DEFAULT 14 +#define DROP_DISTANCE_DEFAULT 0.2 From 95d39c2b6222153f11a79939ca7b97aebcf839d9 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 12 Jun 2016 14:36:07 +0200 Subject: [PATCH 27/54] Fix throwing --- addons/advancedthrowing/functions/fnc_drawArc.sqf | 2 +- addons/advancedthrowing/functions/fnc_drawThrowable.sqf | 4 ++-- addons/advancedthrowing/functions/fnc_exitThrowMode.sqf | 4 ++-- addons/advancedthrowing/functions/fnc_prepare.sqf | 4 +--- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_drawArc.sqf b/addons/advancedthrowing/functions/fnc_drawArc.sqf index d138eb91758..c3ca9f312e9 100644 --- a/addons/advancedthrowing/functions/fnc_drawArc.sqf +++ b/addons/advancedthrowing/functions/fnc_drawArc.sqf @@ -16,7 +16,7 @@ #include "script_component.hpp" // Disable drawing when intersecting with the vehicle -if (!([ACE_player] call FUNC(canThrow))) exitWith { +if !([ACE_player] call FUNC(canThrow)) exitWith { drawIcon3D ["\a3\ui_f\data\igui\cfg\actions\obsolete\ui_action_cancel_manualfire_ca.paa", [1, 0, 0, 1], positionCameraToWorld [0, 0, 1], 1, 1, 0, "", 1]; }; diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index 34d118e3b41..78d5111bf43 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -41,10 +41,10 @@ if (_throwable isEqualTo [] && {!_primed}) exitWith { private _throwableType = getText (configFile >> "CfgMagazines" >> _throwableMag >> "ammo"); -if (!([ACE_player] call FUNC(canThrow)) && {!_primed}) exitWith { +if !([ACE_player] call FUNC(canThrow) && {!_primed}) exitWith { if (!isNull _activeThrowable) then { deleteVehicle _activeThrowable; - ACE_player setVariable [QGVAR(activeThrowable), objNull]; + //ACE_player setVariable [QGVAR(activeThrowable), objNull]; }; }; diff --git a/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf b/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf index 94f4e0c5113..13c3a333221 100644 --- a/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf +++ b/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf @@ -24,8 +24,8 @@ if !(_unit getVariable [QGVAR(inHand), false]) exitWith {}; systemChat format ["Exit Throw Mode: %1", _reason]; #endif -if (!(_unit getVariable [QGVAR(dropMode), false])) then { - deleteVehicle (_unit setVariable [QGVAR(activeThrowable), objNull]); +if !(_unit getVariable [QGVAR(primed), false]) then { + deleteVehicle (_unit getVariable [QGVAR(activeThrowable), objNull]); }; _unit setVariable [QGVAR(inHand), false]; diff --git a/addons/advancedthrowing/functions/fnc_prepare.sqf b/addons/advancedthrowing/functions/fnc_prepare.sqf index a840088095b..3022fa71789 100644 --- a/addons/advancedthrowing/functions/fnc_prepare.sqf +++ b/addons/advancedthrowing/functions/fnc_prepare.sqf @@ -34,9 +34,7 @@ _unit setVariable [QGVAR(inHand), true]; call FUNC(updateControlsHint); // Add throw action to suppress weapon firing (not possible to suppress mouseButtonDown event) -_unit setVariable [QGVAR(throwAction), [ - _unit, "DefaultAction", {true}, {true} -] call EFUNC(common,addActionEventHandler)]; +_unit setVariable [QGVAR(throwAction), [_unit, "DefaultAction", {true}, {true}] call EFUNC(common,addActionEventHandler)]; // Draw throwable and throw arc if enabled GVAR(draw3DHandle) = addMissionEventHandler ["Draw3D", { From ff9cc397940b4a034ba361bb042dd26bcc01037f Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 12 Jun 2016 14:37:40 +0200 Subject: [PATCH 28/54] Convert the rest of events to CBA events --- addons/advancedthrowing/XEH_postInitClient.sqf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/advancedthrowing/XEH_postInitClient.sqf b/addons/advancedthrowing/XEH_postInitClient.sqf index 8a2200487c7..af7a5a58d58 100644 --- a/addons/advancedthrowing/XEH_postInitClient.sqf +++ b/addons/advancedthrowing/XEH_postInitClient.sqf @@ -49,11 +49,11 @@ if (!hasInterface) exitWith {}; // Event handlers -["playerChanged", { +["ace_playerChanged", { [_this select 1, "Player changed"] call FUNC(exitThrowMode); -}] call EFUNC(common,addEventhandler); +}] call CBA_fnc_addEventhandler; -["interactMenuOpened", { +["ace_interactMenuOpened", { // Exit if advanced throwing is disabled (pick up only supports advanced throwing) if (!GVAR(enabled)) exitWith {}; @@ -67,7 +67,7 @@ if (!hasInterface) exitWith {}; call FUNC(renderPickUpInteraction); }; }; -}] call EFUNC(common,addEventHandler); +}] call CBA_fnc_addEventHandler; // Fired XEH From 3748d1abb86a5b620db27944f456e2b0d272bbd3 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 12 Jun 2016 14:48:29 +0200 Subject: [PATCH 29/54] Add module icon and rest of settings to module --- addons/advancedthrowing/CfgVehicles.hpp | 26 +++++++++++++----- .../UI/Icon_Module_AdvancedThrowing_ca.paa | Bin 0 -> 5625 bytes .../functions/fnc_moduleInit.sqf | 8 ++++-- addons/advancedthrowing/stringtable.xml | 20 +++++++------- .../Icon_Module_AdvancedThrowing_ca.png | Bin 0 -> 3767 bytes extras/assets/icons/Icons_Modules.psd | Bin 2371272 -> 2384184 bytes 6 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 addons/advancedthrowing/UI/Icon_Module_AdvancedThrowing_ca.paa create mode 100644 extras/assets/icons/Icon_Module_png/Icon_Module_AdvancedThrowing_ca.png diff --git a/addons/advancedthrowing/CfgVehicles.hpp b/addons/advancedthrowing/CfgVehicles.hpp index 4ed6676458f..af63f7caf99 100644 --- a/addons/advancedthrowing/CfgVehicles.hpp +++ b/addons/advancedthrowing/CfgVehicles.hpp @@ -9,26 +9,38 @@ class CfgVehicles { function = QFUNC(moduleInit); scope = 2; isGlobal = 1; - //icon = PATHTOF(UI\Icon_Module_AdvancedThrowing_ca.paa);//@todo + icon = QPATHTOF(UI\Icon_Module_AdvancedThrowing_ca.paa); class Arguments { - class Enabled { - displayName = CSTRING(EnableThrowingSystem_DisplayName); - description = CSTRING(EnableThrowingSystem_Description); + class enabled { + displayName = CSTRING(Enable_DisplayName); + description = CSTRING(Enable_Description); typeName = "BOOL"; defaultValue = 1; }; - class ShowThrowArc { + class showThrowArc { displayName = CSTRING(ShowThrowArc_DisplayName); description = CSTRING(ShowThrowArc_Description); typeName = "BOOL"; defaultValue = 1; }; - class ShowMouseControls { + class showMouseControls { displayName = CSTRING(ShowMouseControls_DisplayName); description = CSTRING(ShowMouseControls_Description); typeName = "BOOL"; defaultValue = 1; }; + class enablePickUp { + displayName = CSTRING(EnablePickUp_DisplayName); + description = CSTRING(EnablePickUp_Description); + typeName = "BOOL"; + defaultValue = 1; + }; + class enablePickUpAttached { + displayName = CSTRING(EnablePickUpAttached_DisplayName); + description = CSTRING(EnablePickUpAttached_Description); + typeName = "BOOL"; + defaultValue = 1; + }; }; class ModuleDescription { description = CSTRING(Module_Description); @@ -48,7 +60,7 @@ class CfgVehicles { displayName = CSTRING(PickUp); condition = QUOTE(_player call FUNC(canPrepare)); statement = QUOTE(_this call FUNC(pickUp)); - distance = 1.8; // Requires >1.7 to work when standing with weapon on back + distance = 1.8; // Requires >1.7 to work when standing with weapon on back icon = "\a3\ui_f\data\igui\cfg\actions\obsolete\ui_action_takemine_ca.paa"; }; }; diff --git a/addons/advancedthrowing/UI/Icon_Module_AdvancedThrowing_ca.paa b/addons/advancedthrowing/UI/Icon_Module_AdvancedThrowing_ca.paa new file mode 100644 index 0000000000000000000000000000000000000000..1161b964c78875a9baf5f8e6ff1bb9bb3aa297ba GIT binary patch literal 5625 zcmd^@4@?_X7{EVD_Xiy-&Ot<^Eu#`MNrnqqbdvQ5OIgE^xS3@J$t*(_LJFHPiw!Dk zbH9Gy`~JM|yZ7#H6)G<;eWUyYHn{?Y)JzZ8y3UN5Y%2rJ^h{`JTC&rO)Kc%>{kt$iVRq4~;LcZ?91H88pwAdBXQnxw8Jyg{BXnu$js;KM0>kb3uaQ z^-%tkkRIqh?x(DbXSvxl7Hu7VvV+yT-fw9PG>x+O5BW|u1X^dpH2z*cJQ@%$c_}}) z-);+7=a~N6etkp0G8(1&fN}xuT)FGP?VlVw+k4E;`ZsIL7mSWKv+Fg>e+F%Lrrt*L zL0P0?@%w|UAv9w~sd4?GKZ22HeEgOk=lrG4bk=XnU2ir2`VpaSMmU&5^Ua@gPgi?R zvHq|Q0^S=siCFA!W5^vbI3izDt{7N-8qJ4$Dd$z-#ZY#=srg@N@|%MFwqoHBtKY4` zKZDW32N`F-=?RZ^*D>z+(wTle^Hr`tHyRtk2za~YJ-ERfQ*0X-8ERSEDj&mvCk;7c zAirXZ5tiLX1Ha~(k(Bi#33A;OyR5}Qvd3!P|Q%_R8!f-KOKm6kbdH zlYF3kp6TQGJ591>hvOZmyu$13v4Z3AH7jG_%`W*er5vBkYxG8${bYHfe@QO8?G)pS z^Mh}pDz{)~@$HyI9=p)SwpBiibYKmcS-zwg@7J))NX@?5GNJ!%AnW1wYH=SUxB=SBrlVkRJ&|^@i~5_(EYy3u51gfp>R=sj-DIVF z1um2oo!fgCWwrd&OJ+g8fqU^LtVh0Z={^_O-rHg?x!zNRHa9So3nLbWavzHTxO(RUm%J$axX6RfTNS4ez<; z=)88sOxeggdh&#q3MpfKL!fE{3ybr%rhv7UwH@a@qQRUO*MDA%+m!8YoENvLOkX)o zyT9G(TXpf5N;=*!>#V%cT>1cIrM{S^Y#G|xR$rShTqWw_G!=Z6c4Fv`2xF!GT3Ab7 zi%t~o&)er~e1#6{;x@nfY)Klc=10)yI^6d$3(MZ$o$G(DhIOA7uc&xFx%c`uKVI-c JCN(2P`!`BRG8F&- literal 0 HcmV?d00001 diff --git a/addons/advancedthrowing/functions/fnc_moduleInit.sqf b/addons/advancedthrowing/functions/fnc_moduleInit.sqf index 1d179d30006..d20dd621925 100644 --- a/addons/advancedthrowing/functions/fnc_moduleInit.sqf +++ b/addons/advancedthrowing/functions/fnc_moduleInit.sqf @@ -24,8 +24,10 @@ params ["_logic", "_units", "_activated"]; if (!_activated) exitWith {}; -[_logic, QGVAR(enabled), "Enabled"] call EFUNC(common,readSettingFromModule); -[_logic, QGVAR(showThrowArc), "ShowThrowArc"] call EFUNC(common,readSettingFromModule); -[_logic, QGVAR(showMouseControls), "ShowMouseControls"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(enabled), "enabled"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(showThrowArc), "showThrowArc"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(showMouseControls), "showMouseControls"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(enablePickUp), "enablePickUp"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(enablePickUpAttached), "enablePickUpAttached"] call EFUNC(common,readSettingFromModule); ACE_LOGINFO_1("Advanced Throwing Module Initialized. Enabled: %1",GVAR(enabled)); diff --git a/addons/advancedthrowing/stringtable.xml b/addons/advancedthrowing/stringtable.xml index 2c6544cb9a8..1f9ba3e81da 100644 --- a/addons/advancedthrowing/stringtable.xml +++ b/addons/advancedthrowing/stringtable.xml @@ -1,28 +1,28 @@ - + Advanced Throwing - + Allows changing advanced throwing behaviour. - + Enable Advanced Throwing - + Enables advanced throwing system. - + Show Throw Arc - + Enables visualization of the throw arc (where throwable will fly). - + Show Throwing Mouse Controls - + Enables visual cues for mouse controls when throwable is prepared. @@ -52,13 +52,13 @@ Throw - + (Scroll) Change Mode (Scroll) Extend - + (Click) Cook diff --git a/extras/assets/icons/Icon_Module_png/Icon_Module_AdvancedThrowing_ca.png b/extras/assets/icons/Icon_Module_png/Icon_Module_AdvancedThrowing_ca.png new file mode 100644 index 0000000000000000000000000000000000000000..0750276965fe46d4895420d518f0cfdf09212f7b GIT binary patch literal 3767 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 literal 0 HcmV?d00001 diff --git a/extras/assets/icons/Icons_Modules.psd b/extras/assets/icons/Icons_Modules.psd index 0da44ea68106022ee9fa90f40c6db5af943219c0..c31d8590067e56002be65fd24c72b524afe4a775 100644 GIT binary patch delta 15572 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 KvR)FS-~R=O!T}lp delta 5203 zcmd5;dsI}_8bAB+6hwgm3(*S(_*jX|it?CeEqiL`B(yq0>I9sk)!^&;HVXFR3o?x)7*#eMO~J z=-;n%U$L_6#`zZiz3E%2;L5L8{g`k1VROdl-4=CkJJqc)ZrZ!2fAgq?CAB@TeBU)# zr|+SOX{x?hFPd05eSf?r!`NU_4Na~u9e((8XD>}09rCLl&Kgt=#Q*2QX8ENrO_^U8 zzed%*c&+$YVPAF5_}9Ziw$1u+sG=w)H`}0Ayqs}Wz4#*aL*0wlD!vzPJyw!*QnkR- zYf|D|(llF~G_~rj%`KCs>>l&C6TJuJKh&2TAB?7n&&xdw%l)313r!fa-t0GwUfMIA zCTi63=A(C1@|$brhf{{BMR%#e)44_cjl=RO10{6zgM(2%#XVhTO*u4Cd2X9&Jx$Dx z`SM0P#Hgs1ci;CI)aKXDs-TIc*pT5;nmAsxIz=xZUaeLQY}{`g_$KzyaN6pW;ryIq zG_fW8+u6OJ^sAZ!hr>?LgoBbMLVqbS%`-<18f)4Hp;w)j@2wxS-fs-JVeEfXr5DhI zbJ=Wtz0s7mntP$Rd)LQgxr6u57+>^yFy(wajY?Zd5xjq)&5pf$xSMD`DtNBtz zGfmj5fBLj~*w^oBDQ?crtIe8{UQn~D(JS?CUt(Uab8)<0a3=9qyLiWEEpdyQv$y(p zroLOYF+rCv-|^v!PO?(mef70{&i5Lx&k!hV#w|#n5kwR9!ST)R=k63JVxz8Z&t3V6 z%JU0beQ83PVfLblNBcXJ#=ui4>S=NFZ!I-0Y@mrd@*e#e8=4q@!wB%2`D`Gp}poy&EE%L78%73k~hEqRNB=sCQ^5j@T9D3W? z1VN7&#v~C5#M(oV$n}X>lBbPDy&j1S%4KaHmaHUwj3mc8rn8c?*eP#3+QQirsPk5! zZG6|?xeg(aU6tQ;`*H1XCDJ8w_N(A)QbhN%TDEM2rl(ThyMS}Qs|@dp;p~qXs(gT> z7BSQ*gUdMgB`R|p@>Uiaz95-7w$v!&Oe;C(LuTwTnj32}k1dTrb69t)GtNhd+wN8$ zGnZ0XAeP)3LODH;yzzR=5&AL=E9COFCIWq;`I5K7(`=BKi}(hX*&=R{t^3UBux8Xq zib5P}Khh{=@?|>k`Mzb?Ze!348)hM`4LI5raVoSL81|m$IQD}v7-pA&sH?>&3SW0a z_q>=vZCj}`p=i1JP*_oD7FtK;FGf39*Fh$PHku33R?H+kyo6s;+jXjIDH_LDY~UYN zES|Ou?Xq~H%mSab%zme2rB53RL&-WKymkfJW5urf9@ehn_oPk7R4LAU9d%kTZnX_g zT7$U4Q@gS5>oT;2-BGn4CEATVacBbC%ngXZrOEs*s#lraO_X{ar>Z&wXQra<+~A$K zD~(UBE@1QzN#~hGRADU?*u!)r<>)FrDFe;p8aEkwbS6)4VYW-3IWpG)9G->NuF!s2YE|{P7?ArS^w;RTV9rx1;7$u1+WI#0BixH0CoU-z-WL2U<_a^ zz!BgCa0Uo)mX*sLF%=Nwt)RM1$U1Bc@mC)^f`3TjS5Lutax(QrjJM$bHC`h*xxhr; zq^x7To#mGa^P?q(=mCHcpnaAt`Lj;=M7{)ey$0Gq7`WAU1H}LsVyN9rzhR`+#rU*D z7tzgGorI1aWVnxrUPeVNp&4D9u=)F3yf)l+L>h zk2VjK1{eX_XW5cJ>x56_+sLjLl+FXC8D}?q8vsLG%iIr2b1hJsvAXg=X~ycz1Em@3 VQ64DGSeiUgnz794!b7vq{{TD+b#?#% From 1629915cf74466e1de374b62d800d0454e96aa60 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 12 Jun 2016 15:02:00 +0200 Subject: [PATCH 30/54] Fix priming --- addons/advancedthrowing/functions/fnc_drawThrowable.sqf | 3 +-- addons/advancedthrowing/functions/fnc_prime.sqf | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index 78d5111bf43..bdc31263f05 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -41,10 +41,9 @@ if (_throwable isEqualTo [] && {!_primed}) exitWith { private _throwableType = getText (configFile >> "CfgMagazines" >> _throwableMag >> "ammo"); -if !([ACE_player] call FUNC(canThrow) && {!_primed}) exitWith { +if (!([ACE_player] call FUNC(canThrow)) && {!_primed}) exitWith { if (!isNull _activeThrowable) then { deleteVehicle _activeThrowable; - //ACE_player setVariable [QGVAR(activeThrowable), objNull]; }; }; diff --git a/addons/advancedthrowing/functions/fnc_prime.sqf b/addons/advancedthrowing/functions/fnc_prime.sqf index ad5a6e3e11c..1ae9504625b 100644 --- a/addons/advancedthrowing/functions/fnc_prime.sqf +++ b/addons/advancedthrowing/functions/fnc_prime.sqf @@ -28,7 +28,7 @@ private _throwableType = getText (configFile >> "CfgMagazines" >> _throwableMag private _muzzle = _throwableMag call FUNC(getMuzzle); // Create actual throwable globally -private _activeThrowableOld = _unit getVariable [QGVAR(activeThrowable), objNull]; +private _activeThrowableOld = _unit getVariable [QGVAR(activeThrowable), objNull]; private _activeThrowable = createVehicle [_throwableType, _activeThrowableOld, [], 0, "CAN_COLLIDE"]; _unit setVariable [QGVAR(activeThrowable), _activeThrowable]; deleteVehicle _activeThrowableOld; From 98aa9c6dc883dee7b8b0fe7bc114fecf366447c6 Mon Sep 17 00:00:00 2001 From: jonpas Date: Thu, 30 Jun 2016 22:01:33 +0200 Subject: [PATCH 31/54] Fix #3939 --- addons/advancedthrowing/functions/fnc_drawArc.sqf | 1 + addons/advancedthrowing/functions/fnc_drawThrowable.sqf | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/addons/advancedthrowing/functions/fnc_drawArc.sqf b/addons/advancedthrowing/functions/fnc_drawArc.sqf index c3ca9f312e9..cb1517f825c 100644 --- a/addons/advancedthrowing/functions/fnc_drawArc.sqf +++ b/addons/advancedthrowing/functions/fnc_drawArc.sqf @@ -22,6 +22,7 @@ if !([ACE_player] call FUNC(canThrow)) exitWith { private _activeThrowable = ACE_player getVariable [QGVAR(activeThrowable), objNull]; +// Exit during switches and similar where object can be null for a very short amount of time if (isNull _activeThrowable) exitWith {}; private _dropMode = ACE_player getVariable [QGVAR(dropMode), false]; diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index bdc31263f05..06a0755d86b 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -56,6 +56,10 @@ if (isNull _activeThrowable || {(_throwableType != typeOf _activeThrowable) && { ACE_player setVariable [QGVAR(activeThrowable), _activeThrowable]; }; +// Exit in case of explosion in hand +if (isNull _activeThrowable) exitWith { + [ACE_player, "No active throwable (explosion in hand)"] call FUNC(exitThrowMode); +}; // Set position private _posHeadRel = ACE_player selectionPosition "head"; From 415fd7526ff19144f76ae79962fd7d6d04ea26dc Mon Sep 17 00:00:00 2001 From: jonpas Date: Fri, 15 Jul 2016 18:14:49 +0200 Subject: [PATCH 32/54] CRLF snuck in --- .../functions/fnc_renderPickUpInteraction.sqf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_renderPickUpInteraction.sqf b/addons/advancedthrowing/functions/fnc_renderPickUpInteraction.sqf index 5e12543981b..e19c4a81db2 100644 --- a/addons/advancedthrowing/functions/fnc_renderPickUpInteraction.sqf +++ b/addons/advancedthrowing/functions/fnc_renderPickUpInteraction.sqf @@ -53,9 +53,9 @@ _x attachTo [_x getVariable [QGVAR(throwable), objNull], [0, 0, 0]]; true } count _addedPickUpHelpers; - } else { - TRACE_1("Cleaning Pick Up Helpers",count _addedPickUpHelpers); + } else { + TRACE_1("Cleaning Pick Up Helpers",count _addedPickUpHelpers); {deleteVehicle _x} count _addedPickUpHelpers; - [_idPFH] call CBA_fnc_removePerFrameHandler; - }; + [_idPFH] call CBA_fnc_removePerFrameHandler; + }; }, 0, [(getPosASL ACE_player) vectorAdd [-100, 0, 0], [], [], []]] call CBA_fnc_addPerFrameHandler; From 4962f9913c4620257998c133a9f38070882024a8 Mon Sep 17 00:00:00 2001 From: jonpas Date: Fri, 15 Jul 2016 18:17:16 +0200 Subject: [PATCH 33/54] Use common,doGesture --- addons/advancedthrowing/functions/fnc_throw.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/advancedthrowing/functions/fnc_throw.sqf b/addons/advancedthrowing/functions/fnc_throw.sqf index d1bb8e6b2db..c7ef32928b7 100644 --- a/addons/advancedthrowing/functions/fnc_throw.sqf +++ b/addons/advancedthrowing/functions/fnc_throw.sqf @@ -23,7 +23,7 @@ if (!(_unit getVariable [QGVAR(primed), false])) then { [_unit] call FUNC(prime); }; -_unit playAction "ThrowGrenade"; +[_unit, "ThrowGrenade"] call EFUNC(common,doGesture); // Pass position to reset later because animation may change it in certain stances [{ From 6e0cb232f1a01b1a45c8cb27b8af48b2a3962b57 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sat, 23 Jul 2016 05:02:23 +0200 Subject: [PATCH 34/54] Add beautified component name --- addons/advancedthrowing/config.cpp | 1 + addons/advancedthrowing/script_component.hpp | 1 + 2 files changed, 2 insertions(+) diff --git a/addons/advancedthrowing/config.cpp b/addons/advancedthrowing/config.cpp index b7710563490..021a57bea65 100644 --- a/addons/advancedthrowing/config.cpp +++ b/addons/advancedthrowing/config.cpp @@ -2,6 +2,7 @@ class CfgPatches { class ADDON { + name = COMPONENT_NAME; units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; diff --git a/addons/advancedthrowing/script_component.hpp b/addons/advancedthrowing/script_component.hpp index 15aff444676..8bc84b76fc8 100644 --- a/addons/advancedthrowing/script_component.hpp +++ b/addons/advancedthrowing/script_component.hpp @@ -1,4 +1,5 @@ #define COMPONENT advancedthrowing +#define COMPONENT_BEAUTIFIED Advanced Throwing #include "\z\ace\addons\main\script_mod.hpp" #define DEBUG_MODE_FULL From 155472407c89556cbc25b3883548f228a3f1a515 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sat, 23 Jul 2016 05:10:46 +0200 Subject: [PATCH 35/54] Prevent leaning with lowered weapon, Disable debug --- addons/advancedthrowing/functions/fnc_drawThrowable.sqf | 3 ++- addons/advancedthrowing/script_component.hpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index 06a0755d86b..50f0be3878e 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -65,7 +65,8 @@ if (isNull _activeThrowable) exitWith { private _posHeadRel = ACE_player selectionPosition "head"; private _leanCoef = (_posHeadRel select 0) - 0.15; // 0.15 counters the base offset -if (abs _leanCoef < 0.15 || {vehicle ACE_player != ACE_player}) then { +// Don't take leaning into account when weapon is lowered due to jiggling when walking side-ways (bandaid) +if (abs _leanCoef < 0.15 || {vehicle ACE_player != ACE_player} || {weaponLowered ACE_player}) then { _leanCoef = 0; }; diff --git a/addons/advancedthrowing/script_component.hpp b/addons/advancedthrowing/script_component.hpp index 8bc84b76fc8..5b9906ead07 100644 --- a/addons/advancedthrowing/script_component.hpp +++ b/addons/advancedthrowing/script_component.hpp @@ -2,8 +2,8 @@ #define COMPONENT_BEAUTIFIED Advanced Throwing #include "\z\ace\addons\main\script_mod.hpp" -#define DEBUG_MODE_FULL -#define DISABLE_COMPILE_CACHE +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE // #define CBA_DEBUG_SYNCHRONOUS // #define ENABLE_PERFORMANCE_COUNTERS From dd52f6116e69295a0b628830e6967043d380a834 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 24 Jul 2016 00:19:53 +0200 Subject: [PATCH 36/54] Reduce throwing speed when throwing over shoulder and to sides --- .../functions/fnc_drawThrowable.sqf | 28 ++++++++++++++----- .../advancedthrowing/functions/fnc_pickUp.sqf | 4 --- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index 50f0be3878e..667237c3e06 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -1,5 +1,5 @@ /* - * Author: Dslyecxi, Jonpas + * Author: Dslyecxi, Jonpas, SilentSpike * Handles drawing the currently selected or cooked throwable. * * Arguments: @@ -24,14 +24,28 @@ private _throwableMag = _throwable select 0; private _primed = ACE_player getVariable [QGVAR(primed), false]; private _activeThrowable = ACE_player getVariable [QGVAR(activeThrowable), objNull]; +// Some throwables have different classname for magazine and ammo +// Primed magazine may be different, read speed before checking primed magazine! +private _throwSpeed = getNumber (configFile >> "CfgMagazines" >> _throwableMag >> "initSpeed"); + +// Reduce power of throw over shoulder and to sides +private _unitDirVisual = getDirVisual ACE_player; +private _cameraDir = getCameraViewDirection ACE_player; +_cameraDir = (_cameraDir select 0) atan2 (_cameraDir select 1); + +private _phi = abs (_cameraDir - _unitDirVisual) % 360; +_phi = [_phi, 360 - _phi] select (_phi > 180); + +private _power = linearConversion [0, 180, _phi - 30, 1, 0.3, true]; +ACE_player setVariable [QGVAR(throwSpeed), _throwSpeed * _power]; + +#ifdef DEBUG_MODE_FULL +hintSilent format ["Heading: %1\nPower: %2\nSpeed: %3", _phi, _power, _throwSpeed * _power]; +#endif + // Handle cooking last throwable in inventory if (_primed) then { _throwableMag = typeOf _activeThrowable; -} else { - // Some throwables have different classname for magazine and ammo - // Check only CfgMagazines one for correct value only when not primed to assure correct magazine is used - _throwSpeed = getNumber (configFile >> "CfgMagazines" >> _throwableMag >> "initSpeed"); - ACE_player setVariable [QGVAR(throwSpeed), _throwSpeed]; }; // Inventory check @@ -77,7 +91,7 @@ private _posFin = AGLToASL (ACE_player modelToWorldVisual _posHeadRel); private _throwType = ACE_player getVariable [QGVAR(throwType), THROW_TYPE_DEFAULT]; // Orient it nicely, point towards player -_activeThrowable setDir ((getDirVisual ACE_player) + 90); +_activeThrowable setDir (_unitDirVisual + 90); private _pitch = [-30, -90] select (_throwType == "high"); [_activeThrowable, _pitch, 0] call BIS_fnc_setPitchBank; diff --git a/addons/advancedthrowing/functions/fnc_pickUp.sqf b/addons/advancedthrowing/functions/fnc_pickUp.sqf index 5de21393af8..3206e778216 100644 --- a/addons/advancedthrowing/functions/fnc_pickUp.sqf +++ b/addons/advancedthrowing/functions/fnc_pickUp.sqf @@ -26,10 +26,6 @@ if (isNull _activeThrowable) exitWith {}; private _attachedTo = attachedTo _activeThrowable; if (!isNull _attachedTo) then { detach _activeThrowable; - - // Fix throw speed in some cases after detaching - private _throwSpeed = getNumber (configFile >> "CfgMagazines" >> typeOf _activeThrowable >> "initSpeed"); - _unit setVariable [QGVAR(throwSpeed), _throwSpeed]; }; // Change locality for manipulation (some commands require local object, such as setVelocity) From e083652d2a4c1f9f898cb2814109b51b0204124a Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 24 Jul 2016 20:28:43 +0200 Subject: [PATCH 37/54] Prevent throwing in quick succession (2 second cool-down like vanilla), Disallow throwing on ladder due to positioning issues on throw --- addons/advancedthrowing/functions/fnc_canPrepare.sqf | 3 ++- addons/advancedthrowing/functions/fnc_throw.sqf | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/advancedthrowing/functions/fnc_canPrepare.sqf b/addons/advancedthrowing/functions/fnc_canPrepare.sqf index 641069e0916..a7a1f526cd6 100644 --- a/addons/advancedthrowing/functions/fnc_canPrepare.sqf +++ b/addons/advancedthrowing/functions/fnc_canPrepare.sqf @@ -18,6 +18,7 @@ params ["_unit"]; GVAR(enabled) && +{_unit getVariable [QGVAR(lastThrownTime), CBA_missionTime - 3] < CBA_missionTime - 2} && // Prevent throwing in quick succession {!(call EFUNC(common,isFeatureCameraActive))} && -{[_unit, objNull, ["isNotInside", "isNotSitting", "isNotOnLadder"]] call EFUNC(common,canInteractWith)} && +{[_unit, objNull, ["isNotInside", "isNotSitting"/*, "isNotOnLadder"*/]] call EFUNC(common,canInteractWith)} && // Ladder needs positioning fixes on throw {_unit call CBA_fnc_canUseWeapon} // Disable in non-FFV seats due to surface detection issues diff --git a/addons/advancedthrowing/functions/fnc_throw.sqf b/addons/advancedthrowing/functions/fnc_throw.sqf index c7ef32928b7..0925ed1e164 100644 --- a/addons/advancedthrowing/functions/fnc_throw.sqf +++ b/addons/advancedthrowing/functions/fnc_throw.sqf @@ -52,6 +52,8 @@ if (!(_unit getVariable [QGVAR(primed), false])) then { _activeThrowable setVelocity _newVelocity; }; + _unit setVariable [QGVAR(lastThrownTime), CBA_missionTime]; + // Invoke listenable event ["ace_throwableThrown", [_unit, _activeThrowable]] call CBA_fnc_localEvent; }, [ From 84aba3a31bad405ada06177d9c9fb8058b54b6dc Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 24 Jul 2016 21:59:33 +0200 Subject: [PATCH 38/54] Disallow preparing throwable if reloading --- addons/advancedthrowing/functions/fnc_canPrepare.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/advancedthrowing/functions/fnc_canPrepare.sqf b/addons/advancedthrowing/functions/fnc_canPrepare.sqf index a7a1f526cd6..0f00ab8cd2d 100644 --- a/addons/advancedthrowing/functions/fnc_canPrepare.sqf +++ b/addons/advancedthrowing/functions/fnc_canPrepare.sqf @@ -20,5 +20,6 @@ params ["_unit"]; GVAR(enabled) && {_unit getVariable [QGVAR(lastThrownTime), CBA_missionTime - 3] < CBA_missionTime - 2} && // Prevent throwing in quick succession {!(call EFUNC(common,isFeatureCameraActive))} && +{!EGVAR(common,isReloading)} && {[_unit, objNull, ["isNotInside", "isNotSitting"/*, "isNotOnLadder"*/]] call EFUNC(common,canInteractWith)} && // Ladder needs positioning fixes on throw {_unit call CBA_fnc_canUseWeapon} // Disable in non-FFV seats due to surface detection issues From 0f6d54ee01881b6c548b8cb09344022881c89f19 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 25 Jul 2016 01:35:54 +0200 Subject: [PATCH 39/54] Possibly fix pick-up interaction stutter --- .../advancedthrowing/functions/fnc_renderPickUpInteraction.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/advancedthrowing/functions/fnc_renderPickUpInteraction.sqf b/addons/advancedthrowing/functions/fnc_renderPickUpInteraction.sqf index e19c4a81db2..15ce0477a83 100644 --- a/addons/advancedthrowing/functions/fnc_renderPickUpInteraction.sqf +++ b/addons/advancedthrowing/functions/fnc_renderPickUpInteraction.sqf @@ -32,7 +32,7 @@ if (_x in _throwablesHelped) exitWith {}; TRACE_2("Making PickUp Helper",_x,typeOf _x); - private _pickUpHelper = QGVAR(pickUpHelper) createVehicleLocal (getPosASL _x); + private _pickUpHelper = QGVAR(pickUpHelper) createVehicleLocal [0, 0, 0]; _pickUpHelper attachTo [_x, [0, 0, 0]]; _pickUpHelper setVariable [QGVAR(throwable), _x]; From d468a51af206830367ba23e35759f0c60d90dbf2 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sat, 6 Aug 2016 13:48:48 +0200 Subject: [PATCH 40/54] Use createVehicleLocal with [0,0,0] in drawThrowable --- addons/advancedthrowing/functions/fnc_drawThrowable.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index 667237c3e06..9deb836fb61 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -65,7 +65,7 @@ if (isNull _activeThrowable || {(_throwableType != typeOf _activeThrowable) && { if (!isNull _activeThrowable) then { deleteVehicle _activeThrowable; }; - _activeThrowable = _throwableType createVehicleLocal (getPosWorld ACE_player); + _activeThrowable = _throwableType createVehicleLocal [0, 0, 0]; _activeThrowable enableSimulation false; ACE_player setVariable [QGVAR(activeThrowable), _activeThrowable]; }; From 31653748be16cf8d350a55dceb05953bce22b27b Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 9 Aug 2016 00:09:55 +0200 Subject: [PATCH 41/54] Make pick-up settings not be client settable --- addons/advancedthrowing/ACE_Settings.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/addons/advancedthrowing/ACE_Settings.hpp b/addons/advancedthrowing/ACE_Settings.hpp index db8991b8fc7..63de71cac7c 100644 --- a/addons/advancedthrowing/ACE_Settings.hpp +++ b/addons/advancedthrowing/ACE_Settings.hpp @@ -29,7 +29,6 @@ class ACE_Settings { description = CSTRING(EnablePickUp_Description); typeName = "BOOL"; value = 1; - isClientSettable = 1; }; class GVAR(enablePickUpAttached) { category = CSTRING(Category); @@ -37,6 +36,5 @@ class ACE_Settings { description = CSTRING(EnablePickUpAttached_Description); typeName = "BOOL"; value = 1; - isClientSettable = 1; }; }; From 7f5ecfa4ea4d495ee940d737ada17e5c636f4aaf Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 9 Aug 2016 00:12:02 +0200 Subject: [PATCH 42/54] Convert to CBA Player Events --- addons/advancedthrowing/XEH_postInitClient.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/advancedthrowing/XEH_postInitClient.sqf b/addons/advancedthrowing/XEH_postInitClient.sqf index af7a5a58d58..b9d22b9c8e8 100644 --- a/addons/advancedthrowing/XEH_postInitClient.sqf +++ b/addons/advancedthrowing/XEH_postInitClient.sqf @@ -49,9 +49,9 @@ if (!hasInterface) exitWith {}; // Event handlers -["ace_playerChanged", { +["unit", { [_this select 1, "Player changed"] call FUNC(exitThrowMode); -}] call CBA_fnc_addEventhandler; +}] call CBA_fnc_addPlayerEventhandler; ["ace_interactMenuOpened", { // Exit if advanced throwing is disabled (pick up only supports advanced throwing) From 86dd06aa205baa78c19fca2194e80e93e06fc05f Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 9 Aug 2016 02:53:24 +0200 Subject: [PATCH 43/54] Fix locality (again), Move prepared grenade closer to the edge to not obstruct view, Fix high throw arc being way off, Fix script error on intersect with object --- addons/advancedthrowing/functions/fnc_drawArc.sqf | 2 +- addons/advancedthrowing/functions/fnc_drawThrowable.sqf | 4 ++-- addons/advancedthrowing/functions/fnc_pickUp.sqf | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_drawArc.sqf b/addons/advancedthrowing/functions/fnc_drawArc.sqf index cb1517f825c..766a9e826a3 100644 --- a/addons/advancedthrowing/functions/fnc_drawArc.sqf +++ b/addons/advancedthrowing/functions/fnc_drawArc.sqf @@ -30,7 +30,7 @@ private _throwType = ACE_player getVariable [QGVAR(throwType), THROW_TYPE_DEFAUL private _throwSpeed = ACE_player getVariable [QGVAR(throwSpeed), THROW_SPEED_DEFAULT]; private _direction = [THROWSTYLE_NORMAL_DIR, THROWSTYLE_HIGH_DIR] select (_throwType == "high" || {_dropMode}); -private _velocity = [_throwSpeed, _throwSpeed / THROWSTYLE_HIGH_VEL_COEF] select (_throwType == "high"); +private _velocity = [_throwSpeed, _throwSpeed / THROWSTYLE_HIGH_VEL_COEF / 1.25] select (_throwType == "high"); _velocity = [_velocity, THROWSTYLE_DROP_VEL] select _dropMode; private _viewStart = AGLToASL (positionCameraToWorld [0, 0, 0]); diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index 9deb836fb61..4d63d6fb451 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -102,12 +102,12 @@ if (ACE_player getVariable [QGVAR(dropMode), false]) then { // Even vanilla throwables go through glass, only "GEOM" LOD will stop it but that will also stop it when there is glass in a window if (lineIntersects [AGLtoASL _posCameraWorld, _posFin vectorDiff _posCameraWorld]) then { - ACE_player setVariable [QGVAR(dropDistance), (ACE_player getVariable [QGVAR(dropDistance), DROP_DISTANCE_DEFAULT] - 0.1) max DROP_DISTANCE_DEFAULT] + ACE_player setVariable [QGVAR(dropDistance), ((ACE_player getVariable [QGVAR(dropDistance), DROP_DISTANCE_DEFAULT]) - 0.1) max DROP_DISTANCE_DEFAULT]; }; } else { private _xAdjustBonus = [0, -0.075] select (_throwType == "high"); private _yAdjustBonus = [0, 0.1] select (_throwType == "high"); - private _cameraOffset = [_leanCoef, 0, 0.3] vectorAdd [-0.05, -0.12, -0.03] vectorAdd [_xAdjustBonus, _yAdjustBonus, 0]; + private _cameraOffset = [_leanCoef, 0, 0.3] vectorAdd [-0.1, -0.15, -0.03] vectorAdd [_xAdjustBonus, _yAdjustBonus, 0]; _posFin = _posFin vectorAdd (positionCameraToWorld _cameraOffset); diff --git a/addons/advancedthrowing/functions/fnc_pickUp.sqf b/addons/advancedthrowing/functions/fnc_pickUp.sqf index 3206e778216..b2478dd7f11 100644 --- a/addons/advancedthrowing/functions/fnc_pickUp.sqf +++ b/addons/advancedthrowing/functions/fnc_pickUp.sqf @@ -30,7 +30,7 @@ if (!isNull _attachedTo) then { // Change locality for manipulation (some commands require local object, such as setVelocity) if (!local _activeThrowable) then { - ["setOwner", [_activeThrowable, clientOwner]] call EFUNC(common,serverEvent); + ["ace_setOwner", [_activeThrowable, clientOwner]] call CBA_fnc_serverEvent; }; // Invoke listenable event From 4a604d5538c05311efb936f633265d1f9ec1eb4f Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 16 Aug 2016 05:13:12 -0500 Subject: [PATCH 44/54] Improvments for advanced throwing branch (#4248) * better banana throwing * Handle detaching from ace_attach --- addons/advancedthrowing/CfgVehicles.hpp | 2 +- .../advancedthrowing/XEH_postInitClient.sqf | 9 ++++++ .../functions/fnc_drawArc.sqf | 2 +- .../functions/fnc_drawThrowable.sqf | 29 +++++++++++-------- .../functions/fnc_exitThrowMode.sqf | 1 + .../advancedthrowing/functions/fnc_pickUp.sqf | 18 +++++++++--- .../functions/fnc_prepare.sqf | 7 ++++- .../advancedthrowing/functions/fnc_prime.sqf | 1 + .../advancedthrowing/functions/fnc_throw.sqf | 2 ++ .../functions/fnc_updateControlsHint.sqf | 2 +- 10 files changed, 53 insertions(+), 20 deletions(-) diff --git a/addons/advancedthrowing/CfgVehicles.hpp b/addons/advancedthrowing/CfgVehicles.hpp index af63f7caf99..6eab1b75011 100644 --- a/addons/advancedthrowing/CfgVehicles.hpp +++ b/addons/advancedthrowing/CfgVehicles.hpp @@ -50,7 +50,7 @@ class CfgVehicles { class Items_base_F; class GVAR(pickUpHelper): Items_base_F { - author = ECSTRING(common,Author); + author = ECSTRING(common,ACETeam); displayName = "ACE Throwable Pick Up Helper"; model = "\a3\weapons_f\dummyweapon.p3d"; scope = 1; diff --git a/addons/advancedthrowing/XEH_postInitClient.sqf b/addons/advancedthrowing/XEH_postInitClient.sqf index b9d22b9c8e8..22e98490ae4 100644 --- a/addons/advancedthrowing/XEH_postInitClient.sqf +++ b/addons/advancedthrowing/XEH_postInitClient.sqf @@ -3,6 +3,15 @@ // Exit on HC if (!hasInterface) exitWith {}; +GVAR(ammoMagLookup) = call CBA_fnc_createNamespace; +{ + { + private _ammo = getText (configFile >> "CfgMagazines" >> _x >> "ammo"); + GVAR(ammoMagLookup) setVariable [_ammo, _x]; + } count (getArray (configFile >> "CfgWeapons" >> "Throw" >> _x >> "magazines")); + nil +} count getArray (configFile >> "CfgWeapons" >> "Throw" >> "muzzles"); + // Add keybinds ["ACE3 Weapons", QGVAR(prepare), localize LSTRING(Prepare), { diff --git a/addons/advancedthrowing/functions/fnc_drawArc.sqf b/addons/advancedthrowing/functions/fnc_drawArc.sqf index 766a9e826a3..d79264e9356 100644 --- a/addons/advancedthrowing/functions/fnc_drawArc.sqf +++ b/addons/advancedthrowing/functions/fnc_drawArc.sqf @@ -62,7 +62,7 @@ for "_i" from 0.05 to 1.45 step 0.1 do { private _col = [ [1, 1, 1, _alpha], [0, 1, 0, _alpha], [1, 0, 0, _alpha] ] select _cross; - if (_cross != 2 && lineIntersects [eyePos ACE_player, _newTrajASL]) then { + if (_cross != 2 && {lineIntersects [eyePos ACE_player, _newTrajASL]}) then { _col set [3, 0.1] }; diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index 4d63d6fb451..7a869112cbf 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -20,10 +20,25 @@ if (dialog || {!(ACE_player getVariable [QGVAR(inHand), false])} || {!([ACE_play }; private _throwable = currentThrowable ACE_player; -private _throwableMag = _throwable select 0; +private _throwableMag = _throwable param [0, "#none"]; private _primed = ACE_player getVariable [QGVAR(primed), false]; private _activeThrowable = ACE_player getVariable [QGVAR(activeThrowable), objNull]; +// Get correct throw power for primed grenade +if (_primed) then { + private _ammoType = typeOf _activeThrowable; + _throwableMag = GVAR(ammoMagLookup) getVariable _ammoType; + if (isNil "_throwableMag") then { + // What we're trying to throw must not be a normal throwable because it is not in our lookup hash (e.g. 40mm smoke) + // Just use HandGrenade as it has a average initSpeed value + _throwableMag = "HandGrenade"; + }; +}; +// Inventory check +if (_throwable isEqualTo [] && {!_primed}) exitWith { + [ACE_player, "No valid throwables"] call FUNC(exitThrowMode); +}; + // Some throwables have different classname for magazine and ammo // Primed magazine may be different, read speed before checking primed magazine! private _throwSpeed = getNumber (configFile >> "CfgMagazines" >> _throwableMag >> "initSpeed"); @@ -40,19 +55,9 @@ private _power = linearConversion [0, 180, _phi - 30, 1, 0.3, true]; ACE_player setVariable [QGVAR(throwSpeed), _throwSpeed * _power]; #ifdef DEBUG_MODE_FULL -hintSilent format ["Heading: %1\nPower: %2\nSpeed: %3", _phi, _power, _throwSpeed * _power]; +hintSilent format ["Heading: %1\nPower: %2\nSpeed: %3\nThrowMag: %4", _phi, _power, _throwSpeed * _power, _throwableMag]; #endif -// Handle cooking last throwable in inventory -if (_primed) then { - _throwableMag = typeOf _activeThrowable; -}; - -// Inventory check -if (_throwable isEqualTo [] && {!_primed}) exitWith { - [ACE_player, "No valid throwables"] call FUNC(exitThrowMode); -}; - private _throwableType = getText (configFile >> "CfgMagazines" >> _throwableMag >> "ammo"); if (!([ACE_player] call FUNC(canThrow)) && {!_primed}) exitWith { diff --git a/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf b/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf index 13c3a333221..51bfc224997 100644 --- a/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf +++ b/addons/advancedthrowing/functions/fnc_exitThrowMode.sqf @@ -17,6 +17,7 @@ #include "script_component.hpp" params ["_unit", "_reason"]; +TRACE_2("params",_unit,_reason); if !(_unit getVariable [QGVAR(inHand), false]) exitWith {}; diff --git a/addons/advancedthrowing/functions/fnc_pickUp.sqf b/addons/advancedthrowing/functions/fnc_pickUp.sqf index b2478dd7f11..c5fc6786e0d 100644 --- a/addons/advancedthrowing/functions/fnc_pickUp.sqf +++ b/addons/advancedthrowing/functions/fnc_pickUp.sqf @@ -10,27 +10,37 @@ * None * * Example: - * [unit, throwable] call ace_advancedthrowing_fnc_pickUp + * [helper, player] call ace_advancedthrowing_fnc_pickUp * * Public: No */ #include "script_component.hpp" params ["_helper", "_unit"]; +TRACE_2("params",_helper,_unit); -_activeThrowable = _helper getVariable [QGVAR(throwable), objNull]; +private _activeThrowable = _helper getVariable [QGVAR(throwable), objNull]; -if (isNull _activeThrowable) exitWith {}; +if (isNull _activeThrowable) exitWith {TRACE_2("throwable is null",_helper,_activeThrowable);}; // Detach if attached (to vehicle for example or another player) private _attachedTo = attachedTo _activeThrowable; if (!isNull _attachedTo) then { + private _attachedList = _attachedTo getVariable [QEGVAR(attach,attached), []]; + { + _x params ["_xObject"]; + if (_activeThrowable == _xObject) exitWith { + TRACE_2("removing from ace_attach",_attachedTo,_attachedList); + _attachedList deleteAt _forEachIndex; + _attachedTo setVariable [QEGVAR(attach,attached), _attachedList, true]; + }; + } forEach _attachedList; detach _activeThrowable; }; // Change locality for manipulation (some commands require local object, such as setVelocity) if (!local _activeThrowable) then { - ["ace_setOwner", [_activeThrowable, clientOwner]] call CBA_fnc_serverEvent; + ["ace_setOwner", [_activeThrowable, CBA_clientID]] call CBA_fnc_serverEvent; }; // Invoke listenable event diff --git a/addons/advancedthrowing/functions/fnc_prepare.sqf b/addons/advancedthrowing/functions/fnc_prepare.sqf index 3022fa71789..ae91978aff9 100644 --- a/addons/advancedthrowing/functions/fnc_prepare.sqf +++ b/addons/advancedthrowing/functions/fnc_prepare.sqf @@ -16,16 +16,21 @@ #include "script_component.hpp" params ["_unit"]; +TRACE_1("params",_unit); // Select next throwable if one already in hand if (_unit getVariable [QGVAR(inHand), false]) exitWith { + TRACE_1("inHand",_unit); if (!(_unit getVariable [QGVAR(primed), false])) then { + TRACE_1("not primed",_unit); [_unit] call EFUNC(weaponselect,selectNextGrenade); }; }; // Try selecting next throwable if none currently selected -if ((currentThrowable _unit) isEqualTo [] && {!([_unit] call EFUNC(weaponselect,selectNextGrenade))}) exitWith {}; +if ((isNull (_unit getVariable [QGVAR(activeThrowable), objNull])) && {(currentThrowable _unit) isEqualTo []} && {!([_unit] call EFUNC(weaponselect,selectNextGrenade))}) exitWith { + TRACE_1("no throwables",_unit); +}; _unit setVariable [QGVAR(inHand), true]; diff --git a/addons/advancedthrowing/functions/fnc_prime.sqf b/addons/advancedthrowing/functions/fnc_prime.sqf index 1ae9504625b..f20fee6221f 100644 --- a/addons/advancedthrowing/functions/fnc_prime.sqf +++ b/addons/advancedthrowing/functions/fnc_prime.sqf @@ -17,6 +17,7 @@ #include "script_component.hpp" params ["_unit", ["_showHint", false]]; +TRACE_2("params",_unit,_showHint); _unit setVariable [QGVAR(primed), true]; diff --git a/addons/advancedthrowing/functions/fnc_throw.sqf b/addons/advancedthrowing/functions/fnc_throw.sqf index 0925ed1e164..14b0a74ea76 100644 --- a/addons/advancedthrowing/functions/fnc_throw.sqf +++ b/addons/advancedthrowing/functions/fnc_throw.sqf @@ -16,6 +16,7 @@ #include "script_component.hpp" params ["_unit"]; +TRACE_1("params",_unit); // Prime the throwable if it hasn't been cooking already // Next to proper simulation this also has to happen before delay for orientation of the throwable to be set @@ -28,6 +29,7 @@ if (!(_unit getVariable [QGVAR(primed), false])) then { // Pass position to reset later because animation may change it in certain stances [{ params ["_unit", "_activeThrowable", "_posThrown", "_throwType", "_throwSpeed", "_dropMode"]; + TRACE_6("delayParams",_unit,_activeThrowable,_posThrown,_throwType,_throwSpeed,_dropMode); // Reset position in case animation changed it _activeThrowable setPosASL _posThrown; diff --git a/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf b/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf index fbe3c4c082e..a087808cbec 100644 --- a/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf +++ b/addons/advancedthrowing/functions/fnc_updateControlsHint.sqf @@ -1,4 +1,4 @@ - /* +/* * Author: Jonpas * Updates controls hints based on current state. * From f040497f07cd82a2f6c4a41439cf3365e8be3228 Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 16 Aug 2016 12:53:45 +0200 Subject: [PATCH 45/54] Slightly improve arc accuracy --- addons/advancedthrowing/functions/fnc_drawArc.sqf | 5 ++++- addons/advancedthrowing/script_component.hpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_drawArc.sqf b/addons/advancedthrowing/functions/fnc_drawArc.sqf index d79264e9356..4c8f4a98103 100644 --- a/addons/advancedthrowing/functions/fnc_drawArc.sqf +++ b/addons/advancedthrowing/functions/fnc_drawArc.sqf @@ -42,7 +42,7 @@ private _prevTrajASL = getPosASLVisual _activeThrowable; private _pathData = []; for "_i" from 0.05 to 1.45 step 0.1 do { - private _newTrajASL = _prevTrajASL vectorAdd (_initialVelocity vectorMultiply _i) vectorAdd ([0, 0, -4.12] vectorMultiply (_i * _i)); + private _newTrajASL = _prevTrajASL vectorAdd (_initialVelocity vectorMultiply _i) vectorAdd ([0, 0, -6] vectorMultiply (_i * _i)); private _cross = 0; if (_newTrajASL distance (getPosASLVisual ACE_player) <= 20) then { @@ -79,4 +79,7 @@ reverse _pathData; { _x params ["_col", "_newTrajAGL", "_iDim"]; drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_1_ca.paa", _col, _newTrajAGL, _iDim, _iDim, 0, "", 2]; + #ifdef DEBUG_MODE_FULL + drawIcon3D ["", _col, _newTrajAGL, _iDim, _iDim, 0, str (ACE_player distance _newTrajAGL), 2, 0.05, "RobotoCondensed"]; + #endif } forEach _pathData; diff --git a/addons/advancedthrowing/script_component.hpp b/addons/advancedthrowing/script_component.hpp index 5b9906ead07..a21b2026315 100644 --- a/addons/advancedthrowing/script_component.hpp +++ b/addons/advancedthrowing/script_component.hpp @@ -24,5 +24,5 @@ #define THROWSTYLE_DROP_VEL 2 #define THROW_TYPE_DEFAULT "normal" -#define THROW_SPEED_DEFAULT 14 +#define THROW_SPEED_DEFAULT 18 #define DROP_DISTANCE_DEFAULT 0.2 From 9384d8602080857add2772350b21de6a6e846acd Mon Sep 17 00:00:00 2001 From: jonpas Date: Tue, 16 Aug 2016 17:56:03 +0200 Subject: [PATCH 46/54] Add comment for ammoMagLookup namespace --- addons/advancedthrowing/XEH_postInitClient.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/advancedthrowing/XEH_postInitClient.sqf b/addons/advancedthrowing/XEH_postInitClient.sqf index 22e98490ae4..b617a1e1218 100644 --- a/addons/advancedthrowing/XEH_postInitClient.sqf +++ b/addons/advancedthrowing/XEH_postInitClient.sqf @@ -3,6 +3,7 @@ // Exit on HC if (!hasInterface) exitWith {}; +// Ammo/Magazines look-up hash for correctness of initSpeed GVAR(ammoMagLookup) = call CBA_fnc_createNamespace; { { From 57e8df3f02cabe136bbdcb634354756844ce2194 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 16 Aug 2016 18:45:57 -0500 Subject: [PATCH 47/54] Made draw/throw consistant and add 3d tracing debug --- addons/advancedthrowing/XEH_postInitClient.sqf | 16 ++++++++++++++++ .../advancedthrowing/functions/fnc_drawArc.sqf | 8 +++++--- addons/advancedthrowing/functions/fnc_throw.sqf | 14 +++++++++++++- addons/advancedthrowing/script_component.hpp | 1 + 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/addons/advancedthrowing/XEH_postInitClient.sqf b/addons/advancedthrowing/XEH_postInitClient.sqf index b617a1e1218..1686c7e7922 100644 --- a/addons/advancedthrowing/XEH_postInitClient.sqf +++ b/addons/advancedthrowing/XEH_postInitClient.sqf @@ -88,3 +88,19 @@ GVAR(ammoMagLookup) = call CBA_fnc_createNamespace; ["KeyDown", {_this call FUNC(onKeyDown)}] call CBA_fnc_addDisplayHandler; ["MouseButtonDown", {_this call FUNC(onMouseButtonDown)}] call CBA_fnc_addDisplayHandler; ["MouseZChanged", {_this call FUNC(onMouseScroll)}] call CBA_fnc_addDisplayHandler; + +#ifdef DRAW_THROW_PATH +GVAR(predictedPath) = []; +GVAR(flightPath) = []; + +addMissionEventHandler ["Draw3D", { // Blue is predicted before throw, red is real + { + _x params ["", "_newTrajAGL"]; + drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_1_ca.paa", [0,0,1,1], _newTrajAGL, 1, 1, 0, "", 2]; + } forEach GVAR(predictedPath); + { + _newTrajAGL = _x; + drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_1_ca.paa", [1,0,0,1], _newTrajAGL, 1, 1, 0, "", 2]; + } forEach GVAR(flightPath) +}]; +#endif diff --git a/addons/advancedthrowing/functions/fnc_drawArc.sqf b/addons/advancedthrowing/functions/fnc_drawArc.sqf index 4c8f4a98103..f8fe395c381 100644 --- a/addons/advancedthrowing/functions/fnc_drawArc.sqf +++ b/addons/advancedthrowing/functions/fnc_drawArc.sqf @@ -6,7 +6,7 @@ * None * * Return Value: - * None + * Flight path (just for debug) * * Example: * call ace_advancedthrowing_fnc_drawArc @@ -36,13 +36,13 @@ _velocity = [_velocity, THROWSTYLE_DROP_VEL] select _dropMode; private _viewStart = AGLToASL (positionCameraToWorld [0, 0, 0]); private _viewEnd = AGLToASL (positionCameraToWorld _direction); -private _initialVelocity = (vectorNormalized (_viewEnd vectorDiff _viewStart)) vectorMultiply (_velocity / 1.8); +private _initialVelocity = (vectorNormalized (_viewEnd vectorDiff _viewStart)) vectorMultiply (_velocity); private _prevTrajASL = getPosASLVisual _activeThrowable; private _pathData = []; for "_i" from 0.05 to 1.45 step 0.1 do { - private _newTrajASL = _prevTrajASL vectorAdd (_initialVelocity vectorMultiply _i) vectorAdd ([0, 0, -6] vectorMultiply (_i * _i)); + private _newTrajASL = (getPosASLVisual _activeThrowable) vectorAdd (_initialVelocity vectorMultiply _i) vectorAdd ([0, 0, -4.9] vectorMultiply (_i * _i)); private _cross = 0; if (_newTrajASL distance (getPosASLVisual ACE_player) <= 20) then { @@ -83,3 +83,5 @@ reverse _pathData; drawIcon3D ["", _col, _newTrajAGL, _iDim, _iDim, 0, str (ACE_player distance _newTrajAGL), 2, 0.05, "RobotoCondensed"]; #endif } forEach _pathData; + +_pathData diff --git a/addons/advancedthrowing/functions/fnc_throw.sqf b/addons/advancedthrowing/functions/fnc_throw.sqf index 14b0a74ea76..559ea17396b 100644 --- a/addons/advancedthrowing/functions/fnc_throw.sqf +++ b/addons/advancedthrowing/functions/fnc_throw.sqf @@ -36,7 +36,7 @@ if (!(_unit getVariable [QGVAR(primed), false])) then { // Launch actual throwable private _direction = [THROWSTYLE_NORMAL_DIR, THROWSTYLE_HIGH_DIR] select (_throwType == "high" || {_dropMode}); - private _velocity = [_throwSpeed, _throwSpeed / THROWSTYLE_HIGH_VEL_COEF] select (_throwType == "high"); + private _velocity = [_throwSpeed, _throwSpeed / THROWSTYLE_HIGH_VEL_COEF / 1.25] select (_throwType == "high"); _velocity = [_velocity, THROWSTYLE_DROP_VEL] select _dropMode; private _p2 = (eyePos _unit) vectorAdd (positionCameraToWorld _direction) vectorDiff (positionCameraToWorld [0, 0, 0]); @@ -67,5 +67,17 @@ if (!(_unit getVariable [QGVAR(primed), false])) then { _unit getVariable [QGVAR(dropMode), false] ], 0.3] call CBA_fnc_waitAndExecute; +#ifdef DRAW_THROW_PATH +GVAR(predictedPath) = call FUNC(drawArc); // save the current throw arc +GVAR(flightPath) = []; +[_unit getVariable QGVAR(activeThrowable)] spawn { + params ["_grenade"]; + while {!isNull _grenade} do { + GVAR(flightPath) pushBack ASLtoAGL getPosASL _grenade; + sleep 0.05; + }; +}; +#endif + // Stop rendering arc and doing rendering magic while throw is happening [_unit, "Completed a throw fully"] call FUNC(exitThrowMode); diff --git a/addons/advancedthrowing/script_component.hpp b/addons/advancedthrowing/script_component.hpp index a21b2026315..3436ad0bad0 100644 --- a/addons/advancedthrowing/script_component.hpp +++ b/addons/advancedthrowing/script_component.hpp @@ -2,6 +2,7 @@ #define COMPONENT_BEAUTIFIED Advanced Throwing #include "\z\ace\addons\main\script_mod.hpp" +// #define DRAW_THROW_PATH // #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE // #define CBA_DEBUG_SYNCHRONOUS From 76283a463e17bb94bf8a0f5e4390408ef96669dc Mon Sep 17 00:00:00 2001 From: jonpas Date: Thu, 18 Aug 2016 19:19:34 +0200 Subject: [PATCH 48/54] Add Advanced Throwing Docudentation (new location) --- docs/wiki/feature/advancedthrowing.md | 60 +++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 docs/wiki/feature/advancedthrowing.md diff --git a/docs/wiki/feature/advancedthrowing.md b/docs/wiki/feature/advancedthrowing.md new file mode 100644 index 00000000000..23e7a660fc3 --- /dev/null +++ b/docs/wiki/feature/advancedthrowing.md @@ -0,0 +1,60 @@ +--- +layout: wiki +title: Advanced Throwing +description: Precise system for throwing grenades and other throwable items. +group: feature +category: interaction +parent: wiki +--- + +## 1. Overview + +Advanced Throwing adds an alternate way of throwing grenades and other throwable items. It solves the issues vanilla Arma throwing has, such as hard to effectively throw through a window even when you are standing right next to it, hard to judge distance and similar. Additionally, it adds other features, such as cooking, picking up already thrown grenades, different throw modes, distance and flight arc indicators, which vanilla lacks. It is also entirely optional (can be disabled through settings) and configurable. + +### 1.1. Throwing Modes + +There are 3 throwing modes in Advanced Throwing, normal, high and drop. Normal mode is similar in power to vanilla throwing, high mode lobs the grenade higher, for example for throwing over walls, drop mode drops the grenade at your feet or slightly away, for example for dropping smoke or chemlights. Drop mods are indicated by both the throw arc indicator and the actual representation of the grenade in the world. + +Drop mode has additional functionality which allows you to extend the arm and drop the grenade slightly further away, for example for dropping through windows, especially helpful where Arma's geometry would simply make it bounce back into your lap. + +After cooking a grenade any mode can be used to throw it further or it can simply be held in hand (at least with smoke grenades, chemlights and similar, not recommended with frag grenades). + +Grenade will be thrown where you are currently looking at, free-look (including TrackIR) is fully supported. However, the further to the side and back you are looking, the lower the throw power will be. + +### 1.2. Rethrowing + +Advanced Throwing allows you to pick up grenades that have already been thrown. You have to be very close to it to effectively pick it up. Useful for rethrowing smoke grenades or repositioning chemlights. Frag grenades can also be thrown back, for example out of the house, however doing so is extremely risky. + +### 1.3. Settings + +Various settings can be set according to your likeness. Next to global toggle to disable Advanced Throwing there are settings to hide the throw arc indicating approximate throw distance and the arc it will fly through and hide mouse controls. Additionally for server administrators and mission makers, picking up grenades can be entirely disabled, as well as a setting to enable picking up attached items such as chemlights attached to vehicles or other player's shoulder. + + +## 2. Usage + +Make sure to use different keybinds for Advanced Throwing or unbind vanilla throwing keybinds to prevent incidents. + +### 2.1. Throwing +- You need a throwable item. +- Press ⇧ Shift+G (ACE3 default) to prepare the item. +- Press the keybind again to select next throwable item in the inventory. +- Press LMB to throw. +- Press MMB to prime/cook. +- Press RMB to cancel throw. +- Throw will also be cancelled when opening any interface, reloading, switching weapons and aiming. + +### 2.2. Changing Mode +- Use Scroll Wheel to change between **normal** and **high** modes. +- Press Ctrl+G (ACE3 default) to change to **drop** mode. +- Use Scroll Wheel to extend or contract drop distance. + +### 2.3. Picking Up +- Approach a throwable item on the ground. +- Interact with the item ⊞ Win (ACE3 default). +- Select `Pick Up`. +- Item will be placed in your hands, but you may not cancel the throw. + + +## 3. Dependencies + +{% include dependencies_list.md component="advancedthrowing" %} From d4d9bb571505c98f24047e4cb0311bc74d6a997d Mon Sep 17 00:00:00 2001 From: jonpas Date: Fri, 19 Aug 2016 15:55:28 +0200 Subject: [PATCH 49/54] Remove wiki closing points --- docs/wiki/feature/advancedthrowing.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/wiki/feature/advancedthrowing.md b/docs/wiki/feature/advancedthrowing.md index 23e7a660fc3..34d3dbc8deb 100644 --- a/docs/wiki/feature/advancedthrowing.md +++ b/docs/wiki/feature/advancedthrowing.md @@ -11,7 +11,7 @@ parent: wiki Advanced Throwing adds an alternate way of throwing grenades and other throwable items. It solves the issues vanilla Arma throwing has, such as hard to effectively throw through a window even when you are standing right next to it, hard to judge distance and similar. Additionally, it adds other features, such as cooking, picking up already thrown grenades, different throw modes, distance and flight arc indicators, which vanilla lacks. It is also entirely optional (can be disabled through settings) and configurable. -### 1.1. Throwing Modes +### 1.1 Throwing Modes There are 3 throwing modes in Advanced Throwing, normal, high and drop. Normal mode is similar in power to vanilla throwing, high mode lobs the grenade higher, for example for throwing over walls, drop mode drops the grenade at your feet or slightly away, for example for dropping smoke or chemlights. Drop mods are indicated by both the throw arc indicator and the actual representation of the grenade in the world. @@ -21,11 +21,11 @@ After cooking a grenade any mode can be used to throw it further or it can simpl Grenade will be thrown where you are currently looking at, free-look (including TrackIR) is fully supported. However, the further to the side and back you are looking, the lower the throw power will be. -### 1.2. Rethrowing +### 1.2 Rethrowing Advanced Throwing allows you to pick up grenades that have already been thrown. You have to be very close to it to effectively pick it up. Useful for rethrowing smoke grenades or repositioning chemlights. Frag grenades can also be thrown back, for example out of the house, however doing so is extremely risky. -### 1.3. Settings +### 1.3 Settings Various settings can be set according to your likeness. Next to global toggle to disable Advanced Throwing there are settings to hide the throw arc indicating approximate throw distance and the arc it will fly through and hide mouse controls. Additionally for server administrators and mission makers, picking up grenades can be entirely disabled, as well as a setting to enable picking up attached items such as chemlights attached to vehicles or other player's shoulder. @@ -34,7 +34,7 @@ Various settings can be set according to your likeness. Next to global toggle to Make sure to use different keybinds for Advanced Throwing or unbind vanilla throwing keybinds to prevent incidents. -### 2.1. Throwing +### 2.1 Throwing - You need a throwable item. - Press ⇧ Shift+G (ACE3 default) to prepare the item. - Press the keybind again to select next throwable item in the inventory. @@ -43,12 +43,12 @@ Make sure to use different keybinds for Advanced Throwing or unbind vanilla thro - Press RMB to cancel throw. - Throw will also be cancelled when opening any interface, reloading, switching weapons and aiming. -### 2.2. Changing Mode +### 2.2 Changing Mode - Use Scroll Wheel to change between **normal** and **high** modes. - Press Ctrl+G (ACE3 default) to change to **drop** mode. - Use Scroll Wheel to extend or contract drop distance. -### 2.3. Picking Up +### 2.3 Picking Up - Approach a throwable item on the ground. - Interact with the item ⊞ Win (ACE3 default). - Select `Pick Up`. From 2ca4859312a05d80b8f2fbcd3b32a3d5b9287020 Mon Sep 17 00:00:00 2001 From: jonpas Date: Fri, 19 Aug 2016 19:01:37 +0200 Subject: [PATCH 50/54] Fix positioning when over land (non-VR) --- addons/advancedthrowing/XEH_postInitClient.sqf | 1 + .../advancedthrowing/functions/fnc_drawThrowable.sqf | 12 ++++++------ addons/advancedthrowing/functions/fnc_throw.sqf | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/advancedthrowing/XEH_postInitClient.sqf b/addons/advancedthrowing/XEH_postInitClient.sqf index 1686c7e7922..75df42bf345 100644 --- a/addons/advancedthrowing/XEH_postInitClient.sqf +++ b/addons/advancedthrowing/XEH_postInitClient.sqf @@ -89,6 +89,7 @@ GVAR(ammoMagLookup) = call CBA_fnc_createNamespace; ["MouseButtonDown", {_this call FUNC(onMouseButtonDown)}] call CBA_fnc_addDisplayHandler; ["MouseZChanged", {_this call FUNC(onMouseScroll)}] call CBA_fnc_addDisplayHandler; + #ifdef DRAW_THROW_PATH GVAR(predictedPath) = []; GVAR(flightPath) = []; diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index 7a869112cbf..3d4c7320d3e 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -29,8 +29,8 @@ if (_primed) then { private _ammoType = typeOf _activeThrowable; _throwableMag = GVAR(ammoMagLookup) getVariable _ammoType; if (isNil "_throwableMag") then { - // What we're trying to throw must not be a normal throwable because it is not in our lookup hash (e.g. 40mm smoke) - // Just use HandGrenade as it has a average initSpeed value + // What we're trying to throw must not be a normal throwable because it is not in our lookup hash (e.g. 40mm smoke) + // Just use HandGrenade as it has an average initSpeed value _throwableMag = "HandGrenade"; }; }; @@ -89,7 +89,7 @@ if (abs _leanCoef < 0.15 || {vehicle ACE_player != ACE_player} || {weaponLowered _leanCoef = 0; }; -private _posCameraWorld = positionCameraToWorld [0, 0, 0]; +private _posCameraWorld = AGLToASL (positionCameraToWorld [0, 0, 0]); _posHeadRel = _posHeadRel vectorAdd [-0.03, 0.01, 0.15]; // Bring closer to eyePos value private _posFin = AGLToASL (ACE_player modelToWorldVisual _posHeadRel); @@ -103,10 +103,10 @@ private _pitch = [-30, -90] select (_throwType == "high"); if (ACE_player getVariable [QGVAR(dropMode), false]) then { - _posFin = _posFin vectorAdd (positionCameraToWorld [_leanCoef, 0, ACE_player getVariable [QGVAR(dropDistance), DROP_DISTANCE_DEFAULT]]); + _posFin = _posFin vectorAdd (AGLToASL (positionCameraToWorld [_leanCoef, 0, ACE_player getVariable [QGVAR(dropDistance), DROP_DISTANCE_DEFAULT]])); // Even vanilla throwables go through glass, only "GEOM" LOD will stop it but that will also stop it when there is glass in a window - if (lineIntersects [AGLtoASL _posCameraWorld, _posFin vectorDiff _posCameraWorld]) then { + if (lineIntersects [_posCameraWorld, _posFin vectorDiff _posCameraWorld]) then { ACE_player setVariable [QGVAR(dropDistance), ((ACE_player getVariable [QGVAR(dropDistance), DROP_DISTANCE_DEFAULT]) - 0.1) max DROP_DISTANCE_DEFAULT]; }; } else { @@ -114,7 +114,7 @@ if (ACE_player getVariable [QGVAR(dropMode), false]) then { private _yAdjustBonus = [0, 0.1] select (_throwType == "high"); private _cameraOffset = [_leanCoef, 0, 0.3] vectorAdd [-0.1, -0.15, -0.03] vectorAdd [_xAdjustBonus, _yAdjustBonus, 0]; - _posFin = _posFin vectorAdd (positionCameraToWorld _cameraOffset); + _posFin = _posFin vectorAdd (AGLToASL (positionCameraToWorld _cameraOffset)); if (vehicle ACE_player != ACE_player) then { // Counteract vehicle velocity including acceleration diff --git a/addons/advancedthrowing/functions/fnc_throw.sqf b/addons/advancedthrowing/functions/fnc_throw.sqf index 559ea17396b..e1c965cfb76 100644 --- a/addons/advancedthrowing/functions/fnc_throw.sqf +++ b/addons/advancedthrowing/functions/fnc_throw.sqf @@ -39,7 +39,7 @@ if (!(_unit getVariable [QGVAR(primed), false])) then { private _velocity = [_throwSpeed, _throwSpeed / THROWSTYLE_HIGH_VEL_COEF / 1.25] select (_throwType == "high"); _velocity = [_velocity, THROWSTYLE_DROP_VEL] select _dropMode; - private _p2 = (eyePos _unit) vectorAdd (positionCameraToWorld _direction) vectorDiff (positionCameraToWorld [0, 0, 0]); + private _p2 = (eyePos _unit) vectorAdd (AGLToASL (positionCameraToWorld _direction)) vectorDiff (AGLToASL (positionCameraToWorld [0, 0, 0])); private _p1 = AGLtoASL (_activeThrowable modelToWorldVisual [0, 0, 0]); private _newVelocity = (_p1 vectorFromTo _p2) vectorMultiply _velocity; From 24027400dc0b8462c86a64023c66c2cc0ffadca8 Mon Sep 17 00:00:00 2001 From: jonpas Date: Fri, 19 Aug 2016 19:07:24 +0200 Subject: [PATCH 51/54] Allow quick throwing in debug mode --- addons/advancedthrowing/functions/fnc_canPrepare.sqf | 6 ++++++ addons/advancedthrowing/functions/fnc_throw.sqf | 2 ++ 2 files changed, 8 insertions(+) diff --git a/addons/advancedthrowing/functions/fnc_canPrepare.sqf b/addons/advancedthrowing/functions/fnc_canPrepare.sqf index 0f00ab8cd2d..ab6b336da7f 100644 --- a/addons/advancedthrowing/functions/fnc_canPrepare.sqf +++ b/addons/advancedthrowing/functions/fnc_canPrepare.sqf @@ -18,7 +18,13 @@ params ["_unit"]; GVAR(enabled) && + +#ifndef DEBUG_MODE_FULL {_unit getVariable [QGVAR(lastThrownTime), CBA_missionTime - 3] < CBA_missionTime - 2} && // Prevent throwing in quick succession +#else +{true} && +#endif + {!(call EFUNC(common,isFeatureCameraActive))} && {!EGVAR(common,isReloading)} && {[_unit, objNull, ["isNotInside", "isNotSitting"/*, "isNotOnLadder"*/]] call EFUNC(common,canInteractWith)} && // Ladder needs positioning fixes on throw diff --git a/addons/advancedthrowing/functions/fnc_throw.sqf b/addons/advancedthrowing/functions/fnc_throw.sqf index e1c965cfb76..7fb07336f56 100644 --- a/addons/advancedthrowing/functions/fnc_throw.sqf +++ b/addons/advancedthrowing/functions/fnc_throw.sqf @@ -67,6 +67,7 @@ if (!(_unit getVariable [QGVAR(primed), false])) then { _unit getVariable [QGVAR(dropMode), false] ], 0.3] call CBA_fnc_waitAndExecute; + #ifdef DRAW_THROW_PATH GVAR(predictedPath) = call FUNC(drawArc); // save the current throw arc GVAR(flightPath) = []; @@ -79,5 +80,6 @@ GVAR(flightPath) = []; }; #endif + // Stop rendering arc and doing rendering magic while throw is happening [_unit, "Completed a throw fully"] call FUNC(exitThrowMode); From 847dc898bef31962b6608fe4149fac4dea465995 Mon Sep 17 00:00:00 2001 From: jonpas Date: Fri, 19 Aug 2016 20:10:16 +0200 Subject: [PATCH 52/54] Fix comment --- addons/advancedthrowing/functions/fnc_drawThrowable.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index 3d4c7320d3e..a2f71823cf4 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -105,7 +105,7 @@ private _pitch = [-30, -90] select (_throwType == "high"); if (ACE_player getVariable [QGVAR(dropMode), false]) then { _posFin = _posFin vectorAdd (AGLToASL (positionCameraToWorld [_leanCoef, 0, ACE_player getVariable [QGVAR(dropDistance), DROP_DISTANCE_DEFAULT]])); - // Even vanilla throwables go through glass, only "GEOM" LOD will stop it but that will also stop it when there is glass in a window + // Even vanilla throwables go through glass, only "GEOM" LOD will stop it but that will also stop it when there is no glass in a window if (lineIntersects [_posCameraWorld, _posFin vectorDiff _posCameraWorld]) then { ACE_player setVariable [QGVAR(dropDistance), ((ACE_player getVariable [QGVAR(dropDistance), DROP_DISTANCE_DEFAULT]) - 0.1) max DROP_DISTANCE_DEFAULT]; }; From 21c7360397c63eb1d42e0ac255475bcf574fc30f Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 22 Aug 2016 03:58:26 +0200 Subject: [PATCH 53/54] Fix throwable stuck in hand after previous died primed in hand, Move inventory check above throw power calculations --- .../functions/fnc_drawThrowable.sqf | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index a2f71823cf4..ae43a7d2886 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -15,15 +15,27 @@ */ #include "script_component.hpp" -if (dialog || {!(ACE_player getVariable [QGVAR(inHand), false])} || {!([ACE_player] call FUNC(canPrepare))}) exitWith { +if (dialog || {!(ACE_player getVariable [QGVAR(inHand), false])} || {!([ACE_player] call FUNC(canPrepare))} || {}) exitWith { [ACE_player, "In dialog or no throwable in hand or cannot prepare throwable"] call FUNC(exitThrowMode); }; -private _throwable = currentThrowable ACE_player; -private _throwableMag = _throwable param [0, "#none"]; private _primed = ACE_player getVariable [QGVAR(primed), false]; private _activeThrowable = ACE_player getVariable [QGVAR(activeThrowable), objNull]; +// Exit if throwable died primed in hand +if (isNull _activeThrowable && {_primed}) exitWith { + [ACE_player, "Throwable died primed in hand"] call FUNC(exitThrowMode); +}; + +private _throwable = currentThrowable ACE_player; + +// Inventory check +if (_throwable isEqualTo [] && {!_primed}) exitWith { + [ACE_player, "No valid throwables"] call FUNC(exitThrowMode); +}; + +private _throwableMag = _throwable param [0, "#none"]; + // Get correct throw power for primed grenade if (_primed) then { private _ammoType = typeOf _activeThrowable; @@ -34,10 +46,6 @@ if (_primed) then { _throwableMag = "HandGrenade"; }; }; -// Inventory check -if (_throwable isEqualTo [] && {!_primed}) exitWith { - [ACE_player, "No valid throwables"] call FUNC(exitThrowMode); -}; // Some throwables have different classname for magazine and ammo // Primed magazine may be different, read speed before checking primed magazine! From 1648daf47db5bd999a1d16c4dc3ab5cd02933072 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 22 Aug 2016 03:59:46 +0200 Subject: [PATCH 54/54] Remove redundant empty condition --- addons/advancedthrowing/functions/fnc_drawThrowable.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf index ae43a7d2886..dfc2ab948dd 100644 --- a/addons/advancedthrowing/functions/fnc_drawThrowable.sqf +++ b/addons/advancedthrowing/functions/fnc_drawThrowable.sqf @@ -15,7 +15,7 @@ */ #include "script_component.hpp" -if (dialog || {!(ACE_player getVariable [QGVAR(inHand), false])} || {!([ACE_player] call FUNC(canPrepare))} || {}) exitWith { +if (dialog || {!(ACE_player getVariable [QGVAR(inHand), false])} || {!([ACE_player] call FUNC(canPrepare))}) exitWith { [ACE_player, "In dialog or no throwable in hand or cannot prepare throwable"] call FUNC(exitThrowMode); };