Code cleanup, restructured rope deployment

This commit is contained in:
BaerMitUmlaut 2015-11-30 18:35:34 +01:00
parent 2695fc6beb
commit 7241e703ae
13 changed files with 153 additions and 62 deletions

View File

@ -13,7 +13,7 @@ class CfgVehicles {
class AnimationSources;
};
class ACE_friesBase: NonStrategic {
destrType = "DestructNo";
destrType = "";
};
class ACE_friesAnchorBar: ACE_friesBase {
author = "BaerMitUmlaut";
@ -70,22 +70,29 @@ class CfgVehicles {
class Air;
class Helicopter: Air {
class ACE_SelfActions {
class ACE_prepareFRIES {
displayName = CSTRING(Interaction_prepareFRIES);
condition = [_player, vehicle _player] call FUNC(canPrepareFRIES);
statement = [_player, vehicle _player] call FUNC(prepareFRIES);
showDisabled = 0;
priority = 1;
};
class ACE_deployRopes {
displayName = "Deploy ropes";
displayName = CSTRING(Interaction_deployRopes);
condition = [_player, vehicle _player] call FUNC(canDeployRopes);
statement = [_player, vehicle _player] call FUNC(deployRopes);
showDisabled = 0;
priority = 1;
};
class ACE_cutRopes {
displayName = "Cut ropes";
displayName = CSTRING(Interaction_cutRopes);
condition = [_player, vehicle _player] call FUNC(canCutRopes);
statement = [vehicle _player] call FUNC(cutRopes);
showDisabled = 0;
priority = 1;
};
class ACE_fastRope {
displayName = "Fast rope";
displayName = CSTRING(Interaction_fastRope);
condition = [_player, vehicle _player] call FUNC(canFastRope);
statement = [_player, vehicle _player] call FUNC(fastRope);
showDisabled = 0;
@ -107,10 +114,10 @@ class CfgVehicles {
GVAR(enabled) = 2;
GVAR(ropeOrigins[]) = {"hookRight", "hookLeft"};
GVAR(friesType) = "ACE_friesAnchorBar";
GVAR(friesAttachmentPoint[]) = {0, 2.2, -0.15};
GVAR(friesAttachmentPoint[]) = {0.065, 2.2, -0.15};
GVAR(onDeploy) = QFUNC(onDeployRopesCommon);
GVAR(onCut) = QFUNC(onCutRopesCommon);
GVAR(onPrepare) = QFUNC(onPrepareCommon);
GVAR(onCut) = QFUNC(onCutCommon);
};
class Heli_Transport_02_base_F: Helicopter_Base_H {
GVAR(enabled) = 1;

View File

@ -5,13 +5,15 @@ ADDON = false;
PREP(canCutRopes);
PREP(canDeployRopes);
PREP(canFastRope);
PREP(canPrepareFRIES);
PREP(cutRopes);
PREP(deployRopes);
PREP(fastRope);
PREP(fastRopePFH);
PREP(moduleEquipFRIES);
PREP(onCutRopesCommon);
PREP(onDeployRopesCommon);
PREP(onCutCommon);
PREP(onPrepareCommon);
PREP(onRopeBreak);
PREP(prepareFRIES);
ADDON = true;

View File

@ -20,6 +20,5 @@ params ["_unit", "_vehicle"];
private ["_deployedRopes"];
_deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
if (!(_deployedRopes isEqualTo []) &&
{{_x select 6} count (_deployedRopes) == 0}) exitWith {true};
false
!(_deployedRopes isEqualTo [])

View File

@ -21,8 +21,7 @@ private ["_deployedRopes", "_config"];
_deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
if (isNumber (_config >> QGVAR(enabled)) &&
{(getNumber (_config >> QGVAR(enabled)) == 1) || {!(isNull (_vehicle getVariable [QGVAR(FRIES), objNull]))}} &&
{_deployedRopes isEqualTo []} &&
{getPos _vehicle select 2 > 2}) exitWith {true};
false
((driver _vehicle != _unit) &&
{(_vehicle getVariable [QGVAR(deploymentStage), 0]) == 2} &&
{getPos _vehicle select 2 > 2})

View File

@ -20,8 +20,8 @@ params ["_unit", "_vehicle"];
private ["_deployedRopes"];
_deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
if ((driver _vehicle != _unit) &&
{!(_deployedRopes isEqualTo [])} &&
{{!(_x select 6)} count (_deployedRopes) > 0} &&
{getPos _vehicle select 2 > 2}) exitWith {true};
false
((driver _vehicle != _unit) &&
{!(_deployedRopes isEqualTo [])} &&
{{!(_x select 6)} count (_deployedRopes) > 0} &&
{getPos _vehicle select 2 > 2})

View File

@ -0,0 +1,27 @@
/*
* Author: BaerMitUmlaut
* Checks if the unit can prepare the helicopters FRIES.
*
* Arguments:
* 0: Unit occupying the helicopter <OBJECT>
* 1: The helicopter itself <OBJECT>
*
* Return Value:
* Able to prepare FRIES <BOOL>
*
* Example:
* [_player, _vehicle] call ace_fastroping_canPrepareFRIES
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_vehicle"];
private ["_deployedRopes", "_config"];
_deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
(isNumber (_config >> QGVAR(enabled)) &&
{(getNumber (_config >> QGVAR(enabled)) == 1) || {!(isNull (_vehicle getVariable [QGVAR(FRIES), objNull]))}} &&
{(_vehicle getVariable [QGVAR(deploymentStage), 0]) == 0})

View File

@ -16,7 +16,7 @@
#include "script_component.hpp"
params ["_vehicle"];
private ["_deployedRopes"];
private ["_deployedRopes", "_config", "_waitTime"];
_deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
{
@ -27,3 +27,14 @@ _deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
} count _deployedRopes;
_vehicle setVariable [QGVAR(deployedRopes), [], true];
_vehicle setVariable [QGVAR(deploymentStage), 1, true];
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_waitTime = 0;
if (isText (_config >> QGVAR(onCut))) then {
_waitTime = [_vehicle] call (missionNamespace getVariable (getText (_config >> QGVAR(onCut))));
};
[{
_this setVariable [QGVAR(deploymentStage), 0, true];
}, _vehicle, _waitTime] call EFUNC(common,waitAndExecute);

View File

@ -17,28 +17,22 @@
#include "script_component.hpp"
params ["_unit", "_vehicle"];
private ["_config", "_waitTime"];
private ["_config", "_ropeOrigins", "_ropeOrigin", "_deployedRopes", "_hookAttachment", "_origin", "_dummy", "_anchor", "_hook", "_ropeTop", "_ropeBottom"];
_config = configFile >> "CfgVehicles" >> typeOf _vehicle;
_waitTime = 0;
if (isText (_config >> QGVAR(onDeploy))) then {
_waitTime = [_vehicle] call (missionNamespace getVariable (getText (_config >> QGVAR(onDeploy))));
};
[{
params ["_vehicle", "_config"];
private ["_ropeOrigins", "_deployedRopes", "_hookAttachment", "_origin", "_dummy", "_anchor", "_hook", "_ropeTop", "_ropeBottom"];
_ropeOrigins = getArray (_config >> QGVAR(ropeOrigins));
_deployedRopes = [];
_hookAttachment = _vehicle getVariable [QGVAR(FRIES), _vehicle];
{
_ropeOrigins = getArray (_config >> QGVAR(ropeOrigins));
_deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
_hookAttachment = _vehicle getVariable [QGVAR(FRIES), _vehicle];
{
_ropeOrigin = _x;
if ({_x select 0 == _ropeOrigin} count _deployedRopes == 0) then {
_hook = QGVAR(helper) createVehicle [0, 0, 0];
_hook allowDamage false;
if (typeName _x == "ARRAY") then {
_hook attachTo [_hookAttachment, _x];
if (typeName _ropeOrigin == "ARRAY") then {
_hook attachTo [_hookAttachment, _ropeOrigin];
} else {
_hook attachTo [_hookAttachment, [0, 0, 0], _x];
_hook attachTo [_hookAttachment, [0, 0, 0], _ropeOrigin];
};
_origin = getPosASL _hook;
@ -58,9 +52,11 @@ if (isText (_config >> QGVAR(onDeploy))) then {
_ropeBottom addEventHandler ["RopeBreak", {[_this, "bottom"] call FUNC(onRopeBreak)}];
//deployedRopes format: attachment point, top part of the rope, bottom part of the rope, attachTo helper object, anchor helper object, occupied
_deployedRopes pushBack [_x, _ropeTop, _ropeBottom, _dummy, _anchor, _hook, false];
true
} count _ropeOrigins;
_deployedRopes pushBack [_ropeOrigin, _ropeTop, _ropeBottom, _dummy, _anchor, _hook, false];
};
_vehicle setVariable [QGVAR(deployedRopes), _deployedRopes, true];
}, [_vehicle, _config], _waitTime] call EFUNC(common,waitAndExecute);
false
} count _ropeOrigins;
_vehicle setVariable [QGVAR(deployedRopes), _deployedRopes, true];
_vehicle setVariable [QGVAR(deploymentStage), 3, true];

View File

@ -18,13 +18,19 @@
params ["_vehicle"];
private ["_fries"];
_vehicle animateDoor ["door_R", 0];
_vehicle animateDoor ["door_L", 0];
_fries = _vehicle getVariable [QGVAR(FRIES), objNull];
if !(isNull _fries) then {
_fries animate ["extendHookRight", 0];
_fries animate ["extendHookLeft", 0];
};
[{
_this animateDoor ["door_R", 0];
_this animateDoor ["door_L", 0];
}, _vehicle, 2] call EFUNC(common,waitAndExecute);
0
4
} else {
_vehicle animateDoor ["door_R", 0];
_vehicle animateDoor ["door_L", 0];
2
};

View File

@ -16,24 +16,20 @@
#include "script_component.hpp"
params ["_vehicle"];
private ["_fries"];
private ["_fries", "_waitTime"];
_waitTime = 2;
_vehicle animateDoor ["door_R", 1];
_vehicle animateDoor ["door_L", 1];
/*_fries = _vehicle getVariable [QGVAR(FRIES), objNull];
_fries = _vehicle getVariable [QGVAR(FRIES), objNull];
if !(isNull _fries) then {
[{
_this animate ["extendHookRight", 1];
_this animate ["extendHookLeft", 1];
}, _fries, 2] call EFUNC(common,waitAndExecute);
};*/
_waitTime = 4;
};
[{
private ["_fries"];
_fries = _this getVariable [QGVAR(FRIES), objNull];
_fries animate ["extendHookRight", 1];
_fries animate ["extendHookLeft", 1];
}, _vehicle, 2] call EFUNC(common,waitAndExecute);
4
_waitTime

View File

@ -30,11 +30,11 @@ if (_vehicle isKindOf "ACE_friesBase") then {
_deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
_brokenRope = [];
{
if (_x select 1 == _rope) exitWith {
if ((_x select 1 == _rope) || {(_x select 2 == _rope)}) exitWith {
_brokenRope = _x;
};
} forEach _deployedRopes;
_brokenRope set [6, false];
_brokenRope set [6, true];
_vehicle setVariable [QGVAR(deployedRopes), _deployedRopes, true];
_unit = {

View File

@ -0,0 +1,32 @@
/*
* Author: BaerMitUmlaut
* Prepares the helicopters FRIES.
*
* Arguments:
* 0: A helicopter with deployed ropes <OBJECT>
*
* Return Value:
* None
*
* Example:
* [_unit, _vehicle] call ace_fastroping_prepareFRIES
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_vehicle"];
private ["_deployedRopes"];
//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;
if (isText (_config >> QGVAR(onPrepare))) then {
_waitTime = [_vehicle] call (missionNamespace getVariable (getText (_config >> QGVAR(onPrepare))));
};
[{
_this setVariable [QGVAR(deploymentStage), 2, true];
}, _vehicle, _waitTime] call EFUNC(common,waitAndExecute);

View File

@ -9,5 +9,21 @@
<English>Equips compatible helicopters with a Fast Rope Insertion Extraction System.</English>
<German>Rüstet kompatible Helikopter mit einem Fast Rope Insertion Extraction System aus.</German>
</Key>
<Key ID="STR_ACE_Fastroping_Interaction_prepareFRIES">
<English>Prepare fast roping system</English>
<German>Bereite Fast Roping System vor</German>
</Key>
<Key ID="STR_ACE_Fastroping_Interaction_deployRopes">
<English>Deploy ropes</English>
<German>Seile auswerfen</German>
</Key>
<Key ID="STR_ACE_Fastroping_Interaction_fastRope">
<English>Fast rope</English>
<German>Abseilen</German>
</Key>
<Key ID="STR_ACE_Fastroping_Interaction_cutRopes">
<English>Cut ropes</English>
<German>Seile abwerfen</German>
</Key>
</Package>
</Project>