2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-06-04 15:51:04 +00:00
|
|
|
/*
|
|
|
|
* Author: Rocko, Ruthberg
|
|
|
|
*
|
|
|
|
* Deploys the concertina wire
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: wire coil <OBJECT>
|
|
|
|
* 1: unit <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
2015-08-09 00:19:34 +00:00
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [coil, bob] call ace_concertina_wire_fnc_deploy
|
|
|
|
*
|
2015-08-09 00:19:34 +00:00
|
|
|
* Public: No
|
2015-06-04 15:51:04 +00:00
|
|
|
*/
|
2015-06-04 15:11:09 +00:00
|
|
|
|
2017-05-31 21:09:36 +00:00
|
|
|
params ["_wirecoil", "_unit"];
|
2015-06-04 15:11:09 +00:00
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _wireNoGeo = "ACE_ConcertinaWireNoGeo" createVehicle [0,0,0];
|
2015-06-04 15:11:09 +00:00
|
|
|
{
|
|
|
|
_wireNoGeo animate [_x, 1];
|
2015-08-09 00:19:34 +00:00
|
|
|
} count WIRE_FAST;
|
2015-06-04 15:11:09 +00:00
|
|
|
|
|
|
|
GVAR(placer) = _unit;
|
2016-09-04 14:44:22 +00:00
|
|
|
private _dir = getDir _unit;
|
|
|
|
private _pos = getPosASL _unit;
|
|
|
|
private _wireNoGeoPos = _pos vectorAdd [1.1 * sin(_dir), 1.1 * cos(_dir), 0];
|
2015-06-04 15:11:09 +00:00
|
|
|
|
|
|
|
_wireNoGeo setDir _dir;
|
|
|
|
_wireNoGeo setPosASL _wireNoGeoPos;
|
|
|
|
|
|
|
|
deleteVehicle _wirecoil;
|
|
|
|
|
|
|
|
_unit setVariable [QGVAR(wireDeployed), false];
|
|
|
|
|
|
|
|
GVAR(deployPFH) = [{
|
2015-08-09 00:19:34 +00:00
|
|
|
params ["_args", "_idPFH"];
|
|
|
|
_args params ["_wireNoGeo", "_wireNoGeoPos", "_unit"];
|
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _posStart = (_wireNoGeo modelToWorldVisual (_wireNoGeo selectionPosition "start")) call EFUNC(common,positionToASL);
|
|
|
|
private _posEnd = (getPosASL _unit) vectorAdd (vectorDir _unit);
|
|
|
|
private _dirVect = _posStart vectorDiff _posEnd;
|
|
|
|
private _dir = _dirVect call CBA_fnc_vectDir;
|
|
|
|
private _range = vectorMagnitude _dirVect;
|
|
|
|
private _anim = 0 max (1 - (_range / 12));
|
2015-08-09 00:19:34 +00:00
|
|
|
|
2015-06-04 15:11:09 +00:00
|
|
|
if (!(alive _unit) || _range >= 12 || (_unit getVariable [QGVAR(wireDeployed), false])) exitWith {
|
2016-09-04 14:44:22 +00:00
|
|
|
private _wire = "ACE_ConcertinaWire" createvehicle [0, 0, 0];
|
2015-06-04 15:11:09 +00:00
|
|
|
{
|
|
|
|
_wire animate [_x, _anim];
|
2015-08-09 00:19:34 +00:00
|
|
|
} count WIRE_FAST;
|
|
|
|
|
2015-06-04 15:11:09 +00:00
|
|
|
[{
|
2015-08-09 00:19:34 +00:00
|
|
|
params ["_args", "_idPFH"];
|
|
|
|
_args params ["_wireNoGeo", "_wire", "_anim", "_dir", "_wireNoGeoPos"];
|
2015-06-04 15:11:09 +00:00
|
|
|
if (_wire animationPhase "wire_2" == _anim) then {
|
|
|
|
deleteVehicle _wireNoGeo;
|
|
|
|
_wire setDir _dir;
|
|
|
|
_wire setPosASL _wireNoGeoPos;
|
2015-08-09 00:19:34 +00:00
|
|
|
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
2015-06-04 15:11:09 +00:00
|
|
|
};
|
|
|
|
}, 0, [_wireNoGeo, _wire, _anim, _dir, _wireNoGeoPos]] call CBA_fnc_addPerFrameHandler;
|
2015-08-09 00:19:34 +00:00
|
|
|
|
2015-06-04 15:11:09 +00:00
|
|
|
[_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(Common,removeActionEventHandler);
|
2017-12-07 17:26:21 +00:00
|
|
|
[_unit, "blockThrow", QUOTE(ADDON), false] call EFUNC(common,statusEffect_set);
|
2015-06-04 15:11:09 +00:00
|
|
|
call EFUNC(interaction,hideMouseHint);
|
2015-08-09 00:19:34 +00:00
|
|
|
|
|
|
|
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
2015-06-04 15:11:09 +00:00
|
|
|
};
|
2015-08-09 00:19:34 +00:00
|
|
|
|
2015-06-04 15:11:09 +00:00
|
|
|
_wireNoGeo setDir _dir;
|
|
|
|
{
|
|
|
|
_wireNoGeo animate [_x, _anim];
|
2015-08-09 00:19:34 +00:00
|
|
|
} count WIRE_FAST;
|
2015-08-01 23:26:38 +00:00
|
|
|
}, 0, [_wireNoGeo, _wireNoGeoPos, _unit]] call CBA_fnc_addPerFrameHandler;
|
2015-06-04 15:11:09 +00:00
|
|
|
|
2019-12-07 21:40:44 +00:00
|
|
|
[LLSTRING(RollWire), "", ""] call EFUNC(interaction,showMouseHint);
|
2015-08-09 00:19:34 +00:00
|
|
|
|
2017-12-07 17:26:21 +00:00
|
|
|
[_unit, "blockThrow", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
|
|
|
|
|
2015-08-02 06:05:28 +00:00
|
|
|
GVAR(placer) setVariable [QGVAR(Deploy),
|
|
|
|
[GVAR(placer), "DefaultAction",
|
|
|
|
{GVAR(deployPFH) != -1},
|
|
|
|
{GVAR(placer) setVariable [QGVAR(wireDeployed), true]}
|
|
|
|
] call EFUNC(common,AddActionEventHandler)];
|