mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Add Advanced Throwing torque (rotation) (#5621)
* Add throwable rotation * torque grenade config * Cleanup * Do vectorNormalized on direction only
This commit is contained in:
parent
6e219b8678
commit
7183a765f5
7
addons/advanced_throwing/CfgAmmo.hpp
Normal file
7
addons/advanced_throwing/CfgAmmo.hpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
class CfgAmmo {
|
||||||
|
class Default;
|
||||||
|
class Grenade: Default {
|
||||||
|
GVAR(torqueDirection)[] = {1, 1, 0};
|
||||||
|
GVAR(torqueMagnitude) = "(50 + random 100) * selectRandom [1, -1]";
|
||||||
|
};
|
||||||
|
};
|
@ -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];
|
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);
|
} 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];
|
_x params ["_pos", "_vectorUp"];
|
||||||
} forEach GVAR(flightPath)
|
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
|
#endif
|
||||||
|
@ -15,5 +15,6 @@ class CfgPatches {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#include "ACE_Settings.hpp"
|
#include "ACE_Settings.hpp"
|
||||||
|
#include "CfgAmmo.hpp"
|
||||||
#include "CfgEventHandlers.hpp"
|
#include "CfgEventHandlers.hpp"
|
||||||
#include "CfgVehicles.hpp"
|
#include "CfgVehicles.hpp"
|
||||||
|
@ -49,9 +49,15 @@ if (!(_unit getVariable [QGVAR(primed), false])) then {
|
|||||||
_newVelocity = _newVelocity vectorAdd (velocity (vehicle _unit));
|
_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
|
// Drop if unit dies during throw process
|
||||||
if (alive _unit) then {
|
if (alive _unit) then {
|
||||||
_activeThrowable setVelocity _newVelocity;
|
_activeThrowable setVelocity _newVelocity;
|
||||||
|
_activeThrowable addTorque (_unit vectorModelToWorld _torque);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Invoke listenable event
|
// Invoke listenable event
|
||||||
@ -67,12 +73,12 @@ if (!(_unit getVariable [QGVAR(primed), false])) then {
|
|||||||
|
|
||||||
|
|
||||||
#ifdef DRAW_THROW_PATH
|
#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) = [];
|
GVAR(flightPath) = [];
|
||||||
[_unit getVariable QGVAR(activeThrowable)] spawn {
|
GVAR(flightRotation) = [];
|
||||||
params ["_grenade"];
|
(_unit getVariable QGVAR(activeThrowable)) spawn {
|
||||||
while {!isNull _grenade} do {
|
while {!isNull _this && {(getPosATL _this) select 2 > 0.05}} do {
|
||||||
GVAR(flightPath) pushBack ASLtoAGL getPosASL _grenade;
|
GVAR(flightPath) pushBack [ASLtoAGL (getPosASL _this), vectorUp _this];
|
||||||
sleep 0.05;
|
sleep 0.05;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user