Skip to content

Commit

Permalink
Fastrope animations and in-line privatization (#5501)
Browse files Browse the repository at this point in the history
* Add older Arma door animations and macroize them, In-line privatization, Fix comment

* Clarify animation macros

* Fix onCut delayed animations
  • Loading branch information
jonpas committed Sep 19, 2017
1 parent db36ee4 commit 333b24e
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 66 deletions.
7 changes: 3 additions & 4 deletions addons/fastroping/functions/fnc_canDeployRopes.sqf
Expand Up @@ -17,11 +17,10 @@

#include "script_component.hpp"
params ["_unit", "_vehicle"];
private ["_config", "_enabled", "_deploymentStage"];

_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_enabled = getNumber (_config >> QGVAR(enabled));
_deploymentStage = _vehicle getVariable [QGVAR(deploymentStage), 0];
private _config = configFile >> "CfgVehicles" >> typeOf _vehicle;
private _enabled = getNumber (_config >> QGVAR(enabled));
private _deploymentStage = _vehicle getVariable [QGVAR(deploymentStage), 0];

(driver _vehicle != _unit) &&
{getPos _vehicle select 2 > 2} &&
Expand Down
7 changes: 3 additions & 4 deletions addons/fastroping/functions/fnc_cutRopes.sqf
Expand Up @@ -16,9 +16,8 @@

#include "script_component.hpp"
params ["_vehicle"];
private ["_deployedRopes", "_config", "_waitTime"];

_deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
private _deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
{
_x params ["", "_ropeTop", "_ropeBottom", "_dummy", "_hook", "_occupied"];

Expand All @@ -42,8 +41,8 @@ _deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
_vehicle setVariable [QGVAR(deployedRopes), [], true];
_vehicle setVariable [QGVAR(deploymentStage), 1, true];

_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_waitTime = 0;
private _config = configFile >> "CfgVehicles" >> typeOf _vehicle;
private _waitTime = 0;
if (isText (_config >> QGVAR(onCut))) then {
_waitTime = [_vehicle] call (missionNamespace getVariable (getText (_config >> QGVAR(onCut))));
};
Expand Down
11 changes: 5 additions & 6 deletions addons/fastroping/functions/fnc_deployAI.sqf
Expand Up @@ -18,7 +18,6 @@

#include "script_component.hpp"
params [["_vehicle", objNull, [objNull]], ["_deploySpecial", false, [true]], ["_createDeploymentGroup", true, [true]]];
private ["_config", "_configEnabled", "_deployTime", "_unitsToDeploy", "_deployGroup"];

if (isNull _vehicle || {!(_vehicle isKindOf "Helicopter")}) exitWith {
if (hasInterface) then {
Expand All @@ -28,8 +27,8 @@ if (isNull _vehicle || {!(_vehicle isKindOf "Helicopter")}) exitWith {
ERROR('FUNC(deployAI): deployAI was called with an invalid or non-existant vehicle.');
};

_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_configEnabled = getNumber (_config >> QGVAR(enabled));
private _config = configFile >> "CfgVehicles" >> typeOf _vehicle;
private _configEnabled = getNumber (_config >> QGVAR(enabled));
if (_configEnabled == 0) exitWith {
if (hasInterface) then {
[format ["You cannot fast rope from a ""%1"" helicopter.", getText (_config >> "DisplayName")], QFUNC(deployAI)] spawn BIS_fnc_guiMessage;
Expand All @@ -44,7 +43,7 @@ if (_configEnabled == 2 && {isNull (_vehicle getVariable [QGVAR(FRIES), objNull]
ERROR_1('FUNC(deployAI): "%1" requires a FRIES for fastroping but has not been equipped with one.',getText (_config >> "DisplayName"));
};

_unitsToDeploy = crew _vehicle;
private _unitsToDeploy = crew _vehicle;
if (_deploySpecial) then {
_unitsToDeploy deleteAt (_unitsToDeploy find driver _vehicle);
} else {
Expand All @@ -56,11 +55,11 @@ if (_unitsToDeploy isEqualTo []) exitWith {
};

if (_createDeploymentGroup) then {
_deployGroup = createGroup side (_unitsToDeploy select 0);
private _deployGroup = createGroup side (_unitsToDeploy select 0);
_unitsToDeploy joinSilent _deployGroup;
};

_deployTime = 0;
private _deployTime = 0;
if (getText (_config >> QGVAR(onPrepare)) != "") then {
_deployTime = [_vehicle] call (missionNamespace getVariable (getText (_config >> QGVAR(onPrepare))));
};
Expand Down
9 changes: 4 additions & 5 deletions addons/fastroping/functions/fnc_deployAIWaypoint.sqf
Expand Up @@ -7,7 +7,7 @@
* 1: Waypoint position <ARRAY>
*
* Return Value:
* true <BOOLEAN>
* true <BOOL>
*
* Example:
* [_group, [6560, 12390, 0]] call ace_fastroping_fnc_deployAIWayoint
Expand All @@ -17,11 +17,10 @@

#include "script_component.hpp"
params [["_group", grpNull, [grpNull]], ["_position", [0, 0, 0], [[]], 3]];
private ["_vehicle", "_commander", "_speedMode"];

_vehicle = vehicle leader _group;
_commander = effectiveCommander _vehicle;
_speedMode = speedMode _group;
private _vehicle = vehicle leader _group;
private _commander = effectiveCommander _vehicle;
private _speedMode = speedMode _group;

// - Approach -----------------------------------------------------------------
if (_vehicle distance2D _position > 50) then {
Expand Down
4 changes: 2 additions & 2 deletions addons/fastroping/functions/fnc_equipFRIES.sqf
Expand Up @@ -18,12 +18,12 @@
params ["_vehicle"];
private ["_config", "_fries"];

_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
private _config = configFile >> "CfgVehicles" >> typeOf _vehicle;
if !(isNumber (_config >> QGVAR(enabled))) then {
["%1 has not been configured for ACE_Fastroping.", getText (_config >> "DisplayName")] call BIS_fnc_error;
} else {
if (getNumber (_config >> QGVAR(enabled)) == 2) then {
_fries = (getText (_config >> QGVAR(friesType))) createVehicle [0, 0, 0];
private _fries = (getText (_config >> QGVAR(friesType))) createVehicle [0, 0, 0];
_fries attachTo [_vehicle, (getArray (_config >> QGVAR(friesAttachmentPoint)))];
_vehicle setVariable [QGVAR(FRIES), _fries, true];
_vehicle addEventHandler ["Killed", {
Expand Down
7 changes: 3 additions & 4 deletions addons/fastroping/functions/fnc_fastRope.sqf
Expand Up @@ -17,12 +17,11 @@

#include "script_component.hpp"
params ["_unit", "_vehicle"];
private ["_deployedRopes", "_usableRope", "_usableRopeIndex"];

//Select unoccupied rope
_deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
_usableRope = _deployedRopes select 0;
_usableRopeIndex = 0;
private _deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
private _usableRope = _deployedRopes select 0;
private _usableRopeIndex = 0;
{
if !(_x select 5) exitWith {
_usableRope = _x;
Expand Down
5 changes: 2 additions & 3 deletions addons/fastroping/functions/fnc_fastRopeLocalPFH.sqf
Expand Up @@ -17,9 +17,8 @@

#include "script_component.hpp"
params ["_arguments", "_pfhHandle"];
_arguments params ["_unit", "_vehicle", "_rope", "_ropeIndex", "_timeToPlayRopeSound"];
_rope params ["_attachmentPoint", "_ropeTop", "_ropeBottom", "_dummy", "_hook", "_occupied"];
private ["_vectorUp", "_vectorDir", "_origin"];
_arguments params ["_unit", "", "_rope", "", "_timeToPlayRopeSound"];
_rope params ["", "", "", "_dummy"];

//Wait until the unit is actually outside of the helicopter
if (vehicle _unit != _unit) exitWith {};
Expand Down
9 changes: 4 additions & 5 deletions addons/fastroping/functions/fnc_fastRopeServerPFH.sqf
Expand Up @@ -18,8 +18,7 @@
#include "script_component.hpp"
params ["_arguments", "_pfhHandle"];
_arguments params ["_unit", "_vehicle", "_rope", "_ropeIndex", "_hasBeenAttached"];
_rope params ["_attachmentPoint", "_ropeTop", "_ropeBottom", "_dummy", "_hook", "_occupied"];
private ["_vectorUp", "_vectorDir", "_origin"];
_rope params ["_attachmentPoint", "_ropeTop", "_ropeBottom", "_dummy", "_hook"];

//Wait until the unit is actually outside of the helicopter
if (vehicle _unit != _unit) exitWith {};
Expand All @@ -29,7 +28,7 @@ if (getMass _dummy != 80) exitWith {
//Fix for twitchyness
_dummy setMass 80;
_dummy setCenterOfMass [0, 0, -2];
_origin = getPosASL _hook;
private _origin = getPosASL _hook;
_dummy setPosASL (_origin vectorAdd [0, 0, -2]);
_dummy setVectorUp [0, 0, 1];

Expand Down Expand Up @@ -65,7 +64,7 @@ if (
deleteVehicle _ropeTop;
deleteVehicle _ropeBottom;

_origin = getPosASL _hook;
private _origin = getPosASL _hook;
_dummy setPosASL (_origin vectorAdd [0, 0, -1]);

//Restore original mass and center of mass
Expand All @@ -79,7 +78,7 @@ if (
_ropeBottom addEventHandler ["RopeBreak", {[_this, "bottom"] call FUNC(onRopeBreak)}];

//Update deployedRopes array
_deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
private _deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
_deployedRopes set [_ropeIndex, [_attachmentPoint, _ropeTop, _ropeBottom, _dummy, _hook, false]];
_vehicle setVariable [QGVAR(deployedRopes), _deployedRopes, true];

Expand Down
23 changes: 6 additions & 17 deletions addons/fastroping/functions/fnc_onCutCommon.sqf
@@ -1,6 +1,6 @@
/*
* Author: BaerMitUmlaut
* Function for opening doors and extending the hook for most vanilla helos.
* Function for closing doors and retracting the hook for most vanilla and older Arma helos.
*
* Arguments:
* 0: Helicopter <OBJECT>
Expand All @@ -19,28 +19,17 @@ params ["_vehicle"];

private _fries = _vehicle getVariable [QGVAR(FRIES), objNull];
if !(isNull _fries) then {
_fries animate ["extendHookRight", 0];
_fries animate ["extendHookLeft", 0];
{_fries animate [_x, 0]} forEach ANIMS_HOOK;
[{
_this animateDoor ["door_R", 0];
_this animateDoor ["door_L", 0];
_this animateDoor ["CargoRamp_Open", 0];
_this animateDoor ["Door_rear_source", 0];
_this animateDoor ["Door_6_source", 0];
_this animate ["dvere1_posunZ", 0];
_this animate ["dvere2_posunZ", 0];
{_this animateDoor [_x, 0]} forEach ANIMS_ANIMATEDOOR;
{_this animate [_x, 0]} forEach ANIMS_ANIMATE;
_this setVariable [QGVAR(doorsLocked), false, true];
}, _vehicle, 2] call CBA_fnc_waitAndExecute;

4
} else {
_vehicle animateDoor ["door_R", 0];
_vehicle animateDoor ["door_L", 0];
_vehicle animateDoor ["CargoRamp_Open", 0];
_vehicle animateDoor ["Door_rear_source", 0];
_vehicle animateDoor ["Door_6_source", 0];
_vehicle animate ["dvere1_posunZ", 0];
_vehicle animate ["dvere2_posunZ", 0];
{_vehicle animateDoor [_x, 0]} forEach ANIMS_ANIMATEDOOR;
{_vehicle animate [_x, 0]} forEach ANIMS_ANIMATE;
_vehicle setVariable [QGVAR(doorsLocked), false, true];

2
Expand Down
19 changes: 6 additions & 13 deletions addons/fastroping/functions/fnc_onPrepareCommon.sqf
@@ -1,6 +1,6 @@
/*
* Author: BaerMitUmlaut
* Function for closing doors and retracting the hook for most vanilla helos.
* Function for opening doors and extending the hook for most vanilla and older Arma helos.
*
* Arguments:
* 0: Helicopter <OBJECT>
Expand All @@ -16,25 +16,18 @@

#include "script_component.hpp"
params ["_vehicle"];
private ["_fries", "_waitTime"];

_waitTime = 2;
private _waitTime = 2;

_vehicle animateDoor ["door_R", 1];
_vehicle animateDoor ["door_L", 1];
_vehicle animateDoor ["CargoRamp_Open", 1];
_vehicle animateDoor ["Door_rear_source", 1];
_vehicle animateDoor ["Door_6_source", 1];
_vehicle animate ["dvere1_posunZ", 1];
_vehicle animate ["dvere2_posunZ", 1];
{_vehicle animateDoor [_x, 1]} forEach ANIMS_ANIMATEDOOR;
{_vehicle animate [_x, 1]} forEach ANIMS_ANIMATE;

_vehicle setVariable [QGVAR(doorsLocked), true, true];

_fries = _vehicle getVariable [QGVAR(FRIES), objNull];
private _fries = _vehicle getVariable [QGVAR(FRIES), objNull];
if !(isNull _fries) then {
[{
_this animate ["extendHookRight", 1];
_this animate ["extendHookLeft", 1];
{_this animate [_x, 1]} forEach ANIMS_HOOK;
}, _fries, 2] call CBA_fnc_waitAndExecute;
_waitTime = 4;
};
Expand Down
5 changes: 2 additions & 3 deletions addons/fastroping/functions/fnc_prepareFRIES.sqf
Expand Up @@ -16,13 +16,12 @@

#include "script_component.hpp"
params ["_vehicle"];
private ["_config", "_waitTime"];

//Stage indicator: 0 - travel mode; 1 - preparing FRIES; 2 - FRIES ready; 3 - ropes deployed
_vehicle setVariable [QGVAR(deploymentStage), 1, true];

_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_waitTime = 0;
private _config = configFile >> "CfgVehicles" >> typeOf _vehicle;
private _waitTime = 0;
if (isText (_config >> QGVAR(onPrepare))) then {
_waitTime = [_vehicle] call (missionNamespace getVariable (getText (_config >> QGVAR(onPrepare))));
};
Expand Down
5 changes: 5 additions & 0 deletions addons/fastroping/script_component.hpp
Expand Up @@ -16,3 +16,8 @@
#endif

#include "\z\ace\addons\main\script_macros.hpp"


#define ANIMS_HOOK ["extendHookRight", "extendHookLeft"]
#define ANIMS_ANIMATEDOOR ["door_R", "door_L", "CargoRamp_Open", "Door_rear_source", "Door_6_source", "CargoDoorR", "CargoDoorL"]
#define ANIMS_ANIMATE ["dvere1_posunZ", "dvere2_posunZ", "doors"]

0 comments on commit 333b24e

Please sign in to comment.