diff --git a/addons/advanced_throwing/CfgAmmo.hpp b/addons/advanced_throwing/CfgAmmo.hpp new file mode 100644 index 0000000000..9bcf6c37d8 --- /dev/null +++ b/addons/advanced_throwing/CfgAmmo.hpp @@ -0,0 +1,7 @@ +class CfgAmmo { + class Default; + class Grenade: Default { + GVAR(torqueDirection)[] = {1, 1, 0}; + GVAR(torqueMagnitude) = "(50 + random 100) * selectRandom [1, -1]"; + }; +}; diff --git a/addons/advanced_throwing/XEH_postInit.sqf b/addons/advanced_throwing/XEH_postInit.sqf index dcb605b7ad..7c0a194267 100644 --- a/addons/advanced_throwing/XEH_postInit.sqf +++ b/addons/advanced_throwing/XEH_postInit.sqf @@ -117,7 +117,9 @@ addMissionEventHandler ["Draw3D", { // Blue is predicted before throw, red is re 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); { - drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_1_ca.paa", [1,0,0,1], _x, 1, 1, 0, "", 2]; - } forEach GVAR(flightPath) + _x params ["_pos", "_vectorUp"]; + drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_1_ca.paa", [1,0,0,1], _pos, 1, 1, 0, "", 2]; + drawLine3D [_pos, _pos vectorAdd _vectorUp, [1,0,1,1]]; + } forEach GVAR(flightPath); }]; #endif diff --git a/addons/advanced_throwing/config.cpp b/addons/advanced_throwing/config.cpp index 021a57bea6..10ca7f642c 100644 --- a/addons/advanced_throwing/config.cpp +++ b/addons/advanced_throwing/config.cpp @@ -15,5 +15,6 @@ class CfgPatches { }; #include "ACE_Settings.hpp" +#include "CfgAmmo.hpp" #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" diff --git a/addons/advanced_throwing/functions/fnc_throw.sqf b/addons/advanced_throwing/functions/fnc_throw.sqf index a3273eb034..b7019b49dd 100644 --- a/addons/advanced_throwing/functions/fnc_throw.sqf +++ b/addons/advanced_throwing/functions/fnc_throw.sqf @@ -49,9 +49,15 @@ if (!(_unit getVariable [QGVAR(primed), false])) then { _newVelocity = _newVelocity vectorAdd (velocity (vehicle _unit)); }; + private _config = configFile >> "CfgAmmo" >> typeOf _activeThrowable; + private _torqueDir = vectorNormalized (getArray (_config >> QGVAR(torqueDirection))); + private _torqueMag = getNumber (_config >> QGVAR(torqueMagnitude)); + private _torque = _torqueDir vectorMultiply _torqueMag; + // Drop if unit dies during throw process if (alive _unit) then { _activeThrowable setVelocity _newVelocity; + _activeThrowable addTorque (_unit vectorModelToWorld _torque); }; // Invoke listenable event @@ -67,12 +73,12 @@ if (!(_unit getVariable [QGVAR(primed), false])) then { #ifdef DRAW_THROW_PATH -GVAR(predictedPath) = call FUNC(drawArc); // save the current throw arc +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; +GVAR(flightRotation) = []; +(_unit getVariable QGVAR(activeThrowable)) spawn { + while {!isNull _this && {(getPosATL _this) select 2 > 0.05}} do { + GVAR(flightPath) pushBack [ASLtoAGL (getPosASL _this), vectorUp _this]; sleep 0.05; }; };