2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-09-16 21:01:01 +00:00
|
|
|
/*
|
|
|
|
* Author: BaerMitUmlaut
|
|
|
|
* Deploy ropes from the helicopter.
|
|
|
|
*
|
|
|
|
* Arguments:
|
2015-12-01 19:48:20 +00:00
|
|
|
* 0: The helicopter itself <OBJECT>
|
2019-01-12 03:05:25 +00:00
|
|
|
* 1: The unit that called the action (may be remote) <OBJECT>
|
|
|
|
* 2: Rope classname <STRING>
|
2015-09-16 21:01:01 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2019-01-12 03:05:25 +00:00
|
|
|
* [vehicle player, player, "ACE_rope36"] call ace_fastroping_fnc_deployRopes
|
2015-09-16 21:01:01 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2020-02-20 05:28:57 +00:00
|
|
|
|
|
|
|
params ["_vehicle", ["_player", objNull], ["_ropeClass", ""]];
|
2019-01-12 03:05:25 +00:00
|
|
|
TRACE_3("deployRopes",_vehicle,_player,_ropeClass);
|
2015-11-26 13:56:19 +00:00
|
|
|
|
2021-02-18 18:58:08 +00:00
|
|
|
private _config = configOf _vehicle;
|
2015-11-26 13:56:19 +00:00
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _ropeOrigins = getArray (_config >> QGVAR(ropeOrigins));
|
|
|
|
private _deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
|
|
|
|
private _hookAttachment = _vehicle getVariable [QGVAR(FRIES), _vehicle];
|
2019-01-12 03:05:25 +00:00
|
|
|
|
2021-10-12 09:33:05 +00:00
|
|
|
private _ropeLength = getNumber (configfile >> "CfgWeapons" >> _ropeClass >> QEGVAR(logistics_rope,length));
|
2020-02-20 05:28:57 +00:00
|
|
|
|
|
|
|
if (_ropeLength <= 0) then {
|
|
|
|
_ropeLength = DEFAULT_ROPE_LENGTH;
|
|
|
|
};
|
|
|
|
|
2019-01-12 03:05:25 +00:00
|
|
|
TRACE_3("",_ropeClass,_ropeLength,GVAR(requireRopeItems));
|
2020-02-20 05:28:57 +00:00
|
|
|
|
2020-02-20 05:48:03 +00:00
|
|
|
if (GVAR(requireRopeItems) && {_ropeClass != ""}) then {
|
2020-02-20 05:28:57 +00:00
|
|
|
if (_ropeClass in (_player call EFUNC(common,uniqueItems))) then {
|
2019-01-12 03:05:25 +00:00
|
|
|
_player removeItem _ropeClass;
|
|
|
|
} else {
|
|
|
|
_vehicle removeItem _ropeClass;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-11-30 17:35:34 +00:00
|
|
|
{
|
2016-09-04 14:44:22 +00:00
|
|
|
private _ropeOrigin = _x;
|
|
|
|
private _hook = QGVAR(helper) createVehicle [0, 0, 0];
|
2015-12-22 07:53:57 +00:00
|
|
|
_hook allowDamage false;
|
2016-09-04 14:44:22 +00:00
|
|
|
if (_ropeOrigin isEqualType []) then {
|
2015-12-22 07:53:57 +00:00
|
|
|
_hook attachTo [_hookAttachment, _ropeOrigin];
|
|
|
|
} else {
|
|
|
|
_hook attachTo [_hookAttachment, [0, 0, 0], _ropeOrigin];
|
|
|
|
};
|
2015-11-26 13:56:19 +00:00
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _origin = getPosATL _hook;
|
2015-11-26 13:56:19 +00:00
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _dummy = createVehicle [QGVAR(helper), _origin vectorAdd [0, 0, -1], [], 0, "CAN_COLLIDE"];
|
2015-12-22 07:53:57 +00:00
|
|
|
_dummy allowDamage false;
|
|
|
|
_dummy disableCollisionWith _vehicle;
|
2015-11-26 13:56:19 +00:00
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _ropeTop = ropeCreate [_dummy, [0, 0, 0], _hook, [0, 0, 0], 0.5];
|
|
|
|
private _ropeBottom = ropeCreate [_dummy, [0, 0, 0], 1];
|
2019-01-12 03:05:25 +00:00
|
|
|
ropeUnwind [_ropeBottom, 30, _ropelength, false];
|
2015-11-29 23:14:46 +00:00
|
|
|
|
2015-12-22 07:53:57 +00:00
|
|
|
_ropeTop addEventHandler ["RopeBreak", {[_this, "top"] call FUNC(onRopeBreak)}];
|
|
|
|
_ropeBottom addEventHandler ["RopeBreak", {[_this, "bottom"] call FUNC(onRopeBreak)}];
|
2015-11-26 13:56:19 +00:00
|
|
|
|
2018-04-12 15:23:18 +00:00
|
|
|
//deployedRopes format: attachment point, top part of the rope, bottom part of the rope, attachTo helper object, occupied, broken
|
|
|
|
_deployedRopes pushBack [_ropeOrigin, _ropeTop, _ropeBottom, _dummy, _hook, false, false];
|
2015-11-30 17:35:34 +00:00
|
|
|
|
|
|
|
false
|
|
|
|
} count _ropeOrigins;
|
2015-11-26 13:56:19 +00:00
|
|
|
|
2015-11-30 17:35:34 +00:00
|
|
|
_vehicle setVariable [QGVAR(deployedRopes), _deployedRopes, true];
|
|
|
|
_vehicle setVariable [QGVAR(deploymentStage), 3, true];
|
2019-01-12 03:05:25 +00:00
|
|
|
_vehicle setVariable [QGVAR(ropeLength), _ropeLength, true];
|