2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-09-16 21:01:01 +00:00
|
|
|
/*
|
|
|
|
* Author: BaerMitUmlaut
|
2015-12-22 07:53:57 +00:00
|
|
|
* Server PerFrameHandler during fast roping.
|
2015-09-16 21:01:01 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: PFH arguments <ARRAY>
|
|
|
|
* 1: PFH handle <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2015-12-22 07:53:57 +00:00
|
|
|
* [[_unit, _vehicle, _rope, _ropeIndex], 0] call ace_fastroping_fnc_fastRopeServerPFH
|
2015-09-16 21:01:01 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
params ["_arguments", "_pfhHandle"];
|
2016-05-07 20:35:18 +00:00
|
|
|
_arguments params ["_unit", "_vehicle", "_rope", "_ropeIndex", "_hasBeenAttached"];
|
2017-09-19 20:38:49 +00:00
|
|
|
_rope params ["_attachmentPoint", "_ropeTop", "_ropeBottom", "_dummy", "_hook"];
|
2015-09-16 21:01:01 +00:00
|
|
|
|
|
|
|
//Wait until the unit is actually outside of the helicopter
|
2024-03-26 12:54:06 +00:00
|
|
|
if (!isNull objectParent _unit) exitWith {};
|
2015-09-16 21:01:01 +00:00
|
|
|
|
2017-10-16 21:20:50 +00:00
|
|
|
//Prevent teleport if hook has been deleted due to rope cut
|
|
|
|
if (isNull _hook) exitWith {
|
|
|
|
detach _unit; //Does not matter if unit was not attached yet
|
|
|
|
[_pfhHandle] call CBA_fnc_removePerFrameHandler;
|
|
|
|
};
|
|
|
|
|
2020-02-20 05:28:57 +00:00
|
|
|
private _ropeLength = _vehicle getVariable [QGVAR(ropeLength), DEFAULT_ROPE_LENGTH];
|
2019-01-12 03:05:25 +00:00
|
|
|
|
2015-09-16 21:01:01 +00:00
|
|
|
//Start fast roping
|
2016-03-17 23:15:57 +00:00
|
|
|
if (getMass _dummy != 80) exitWith {
|
2019-01-12 03:05:25 +00:00
|
|
|
TRACE_1("unwinding ropes",_ropeLength);
|
2015-11-29 23:14:46 +00:00
|
|
|
//Fix for twitchyness
|
|
|
|
_dummy setMass 80;
|
2015-12-28 16:48:47 +00:00
|
|
|
_dummy setCenterOfMass [0, 0, -2];
|
2017-09-19 20:38:49 +00:00
|
|
|
private _origin = getPosASL _hook;
|
2015-11-29 23:14:46 +00:00
|
|
|
_dummy setPosASL (_origin vectorAdd [0, 0, -2]);
|
|
|
|
_dummy setVectorUp [0, 0, 1];
|
|
|
|
|
2019-01-12 03:05:25 +00:00
|
|
|
ropeUnwind [_ropeTop, 6, _ropeLength];
|
2015-12-22 07:53:57 +00:00
|
|
|
ropeUnwind [_ropeBottom, 6, 0.5];
|
2015-09-16 21:01:01 +00:00
|
|
|
};
|
|
|
|
|
2016-05-07 20:35:18 +00:00
|
|
|
//Check if the player has been attached to the rope yet
|
|
|
|
if (!_hasBeenAttached && {!(isNull attachedTo _unit)}) then {
|
|
|
|
_hasBeenAttached = true;
|
|
|
|
_arguments set [4, true];
|
|
|
|
};
|
|
|
|
|
|
|
|
//Exit when the unit has been detached and is falling (rope broke, heli flew too fast, etc.)
|
2016-03-17 23:15:57 +00:00
|
|
|
//Make sure this isn't executed before the unit is actually fastroping
|
2016-05-07 20:35:18 +00:00
|
|
|
if (_hasBeenAttached && {isNull attachedTo _unit}) exitWith {
|
2015-11-29 23:14:46 +00:00
|
|
|
[_pfhHandle] call CBA_fnc_removePerFrameHandler;
|
|
|
|
};
|
|
|
|
|
|
|
|
//Setting the velocity manually to reduce twitching
|
|
|
|
_dummy setVelocity [0,0,-6];
|
2015-11-26 13:56:19 +00:00
|
|
|
|
2015-09-16 21:01:01 +00:00
|
|
|
//Check if fast rope is finished
|
2016-10-11 16:48:20 +00:00
|
|
|
if (
|
|
|
|
((getPos _unit select 2) < 0.2)
|
2019-01-12 03:05:25 +00:00
|
|
|
|| {ropeLength _ropeTop == _ropeLength}
|
2016-10-11 16:48:20 +00:00
|
|
|
|| {vectorMagnitude (velocity _vehicle) > 5}
|
|
|
|
|| {!([_unit] call EFUNC(common,isAwake))}
|
|
|
|
) exitWith {
|
2015-09-16 21:01:01 +00:00
|
|
|
detach _unit;
|
|
|
|
|
|
|
|
//Reset rope
|
|
|
|
deleteVehicle _ropeTop;
|
|
|
|
deleteVehicle _ropeBottom;
|
|
|
|
|
2017-09-19 20:38:49 +00:00
|
|
|
private _origin = getPosASL _hook;
|
2016-03-14 15:16:23 +00:00
|
|
|
_dummy setPosASL (_origin vectorAdd [0, 0, -1]);
|
2015-09-16 21:01:01 +00:00
|
|
|
|
2015-11-29 23:14:46 +00:00
|
|
|
//Restore original mass and center of mass
|
|
|
|
_dummy setMass 40;
|
|
|
|
_dummy setCenterOfMass [0.000143227,0.00105986,-0.246147];
|
|
|
|
|
2015-12-22 07:53:57 +00:00
|
|
|
_ropeTop = ropeCreate [_dummy, [0, 0, 0], _hook, [0, 0, 0], 0.5];
|
2019-01-12 03:05:25 +00:00
|
|
|
_ropeBottom = ropeCreate [_dummy, [0, 0, 0], _ropeLength];
|
2015-11-29 23:14:46 +00:00
|
|
|
|
|
|
|
_ropeTop addEventHandler ["RopeBreak", {[_this, "top"] call FUNC(onRopeBreak)}];
|
|
|
|
_ropeBottom addEventHandler ["RopeBreak", {[_this, "bottom"] call FUNC(onRopeBreak)}];
|
2015-09-16 21:01:01 +00:00
|
|
|
|
|
|
|
//Update deployedRopes array
|
2017-09-19 20:38:49 +00:00
|
|
|
private _deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
|
2018-04-12 15:23:18 +00:00
|
|
|
_deployedRopes set [_ropeIndex, [_attachmentPoint, _ropeTop, _ropeBottom, _dummy, _hook, false, false]];
|
2015-09-16 21:01:01 +00:00
|
|
|
_vehicle setVariable [QGVAR(deployedRopes), _deployedRopes, true];
|
|
|
|
|
|
|
|
[_pfhHandle] call CBA_fnc_removePerFrameHandler;
|
|
|
|
};
|