FastRoping - Add rope items which deploy at lengths (#6498)

* Update stringtable.xml

* Update config.cpp

* New CFGWeapon

* Update CfgVehicles.hpp

* Update fnc_deployRopes.sqf

* Update CfgVehicles.hpp

* Update CfgWeapons.hpp

* Update CfgVehicles.hpp

cheapest check before others

* Update fnc_deployRopes.sqf

Corrected the double remove.

* Cleanup PR

Add setting, move rope len to config, simplify strings, add rope image, fix rope unwind length

* Add setting name to stringtable

* Update stringtable.xml

French translation for settings
This commit is contained in:
pokertour 2019-01-12 04:05:25 +01:00 committed by PabstMirror
parent 188aabe699
commit 4a5b5113cd
11 changed files with 215 additions and 36 deletions

View File

@ -40,33 +40,48 @@ class CfgVehicles {
class ACE_SelfActions { class ACE_SelfActions {
class ACE_prepareFRIES { class ACE_prepareFRIES {
displayName = CSTRING(Interaction_prepareFRIES); displayName = CSTRING(Interaction_prepareFRIES);
condition = QUOTE([vehicle _player] call FUNC(canPrepareFRIES)); condition = QUOTE([_target] call FUNC(canPrepareFRIES));
statement = QUOTE([vehicle _player] call FUNC(prepareFRIES)); statement = QUOTE([_target] call FUNC(prepareFRIES));
showDisabled = 0;
}; };
class ACE_stowFRIES { class ACE_stowFRIES {
displayName = CSTRING(Interaction_stowFRIES); displayName = CSTRING(Interaction_stowFRIES);
condition = QUOTE([vehicle _player] call FUNC(canStowFRIES)); condition = QUOTE([_target] call FUNC(canStowFRIES));
statement = QUOTE([vehicle _player] call FUNC(stowFRIES)); statement = QUOTE([_target] call FUNC(stowFRIES));
showDisabled = 0;
}; };
class ACE_deployRopes { class ACE_deployRopes12 {
displayName = CSTRING(Interaction_deployRopes); displayName = CSTRING(Interaction_deployRopes12);
condition = QUOTE([ARR_2(_player, vehicle _player)] call FUNC(canDeployRopes)); condition = QUOTE([ARR_3(_target, _player, 'ACE_rope12')] call FUNC(canDeployRopes));
statement = QUOTE([ARR_2(QUOTE(QGVAR(deployRopes)), [vehicle _player])] call CBA_fnc_serverEvent); statement = QUOTE([ARR_2(QUOTE(QGVAR(deployRopes)), [ARR_3(_target, _player, 'ACE_rope12'))]] call CBA_fnc_serverEvent);
showDisabled = 0; };
class ACE_deployRopes15 {
displayName = CSTRING(Interaction_deployRopes15);
condition = QUOTE([ARR_3(_target, _player, 'ACE_rope15')] call FUNC(canDeployRopes));
statement = QUOTE([ARR_2(QUOTE(QGVAR(deployRopes)), [ARR_3(_target, _player, 'ACE_rope15'))]] call CBA_fnc_serverEvent);
};
class ACE_deployRopes18 {
displayName = CSTRING(Interaction_deployRopes18);
condition = QUOTE([ARR_3(_target, _player, 'ACE_rope18')] call FUNC(canDeployRopes));
statement = QUOTE([ARR_2(QUOTE(QGVAR(deployRopes)), [ARR_3(_target, _player, 'ACE_rope18'))]] call CBA_fnc_serverEvent);
};
class ACE_deployRopes27 {
displayName = CSTRING(Interaction_deployRopes27);
condition = QUOTE([ARR_3(_target, _player, 'ACE_rope27')] call FUNC(canDeployRopes));
statement = QUOTE([ARR_2(QUOTE(QGVAR(deployRopes)), [ARR_3(_target, _player, 'ACE_rope27'))]] call CBA_fnc_serverEvent);
};
class ACE_deployRopes36 {
displayName = CSTRING(Interaction_deployRopes36);
condition = QUOTE([ARR_4(_target, _player, 'ACE_rope36', true)] call FUNC(canDeployRopes));
statement = QUOTE([ARR_2(QUOTE(QGVAR(deployRopes)), [ARR_3(_target, _player, 'ACE_rope36'))]] call CBA_fnc_serverEvent);
}; };
class ACE_cutRopes { class ACE_cutRopes {
displayName = CSTRING(Interaction_cutRopes); displayName = CSTRING(Interaction_cutRopes);
condition = [vehicle _player] call FUNC(canCutRopes); condition = [_target] call FUNC(canCutRopes);
statement = [vehicle _player] call FUNC(cutRopes); statement = [_target] call FUNC(cutRopes);
showDisabled = 0;
}; };
class ACE_fastRope { class ACE_fastRope {
displayName = CSTRING(Interaction_fastRope); displayName = CSTRING(Interaction_fastRope);
condition = [_player, vehicle _player] call FUNC(canFastRope); condition = [_player, _target] call FUNC(canFastRope);
statement = [_player, vehicle _player] call FUNC(fastRope); statement = [_player, _target] call FUNC(fastRope);
showDisabled = 0;
}; };
}; };
}; };
@ -252,4 +267,20 @@ class CfgVehicles {
}; };
}; };
}; };
class NATO_Box_Base;
class ACE_fastropingSupplyCrate: NATO_Box_Base {
scope = 2;
scopeCurator = 2;
accuracy = 1000;
displayName = CSTRING(Ropesupply);
model = "\A3\Weapons_F\AmmoBoxes\Box_NATO_AmmoVeh_F.p3d";
author = "Pokertour";
class TransportItems {
MACRO_ADDITEM(ACE_rope12,15);
MACRO_ADDITEM(ACE_rope15,15);
MACRO_ADDITEM(ACE_rope18,15);
MACRO_ADDITEM(ACE_rope27,15);
MACRO_ADDITEM(ACE_rope36,15);
};
};
}; };

View File

@ -0,0 +1,60 @@
class CfgWeapons {
class ACE_ItemCore;
class CBA_MiscItem_ItemInfo;
class ACE_rope12: ACE_ItemCore {
scope = 2;
GVAR(ropeLength) = 12.2;
picture = QPATHTOF(data\m_rope_ca);
model = "\A3\Structures_F_Heli\Items\Tools\Rope_01_F.p3d";
displayName = CSTRING(Rope_12_Display);
descriptionShort = CSTRING(descriptionShort);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 36;
};
};
class ACE_rope15: ACE_ItemCore {
scope = 2;
GVAR(ropeLength) = 15.2;
picture = QPATHTOF(data\m_rope_ca);
model = "\A3\Structures_F_Heli\Items\Tools\Rope_01_F.p3d";
displayName = CSTRING(Rope_15_Display);
descriptionShort = CSTRING(descriptionShort);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 45;
};
};
class ACE_rope18: ACE_ItemCore {
scope = 2;
GVAR(ropeLength) = 18.3;
picture = QPATHTOF(data\m_rope_ca);
model = "\A3\Structures_F_Heli\Items\Tools\Rope_01_F.p3d";
displayName = CSTRING(Rope_18_Display);
descriptionShort = CSTRING(descriptionShort);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 54;
};
};
class ACE_rope27: ACE_ItemCore {
scope = 2;
GVAR(ropeLength) = 27.4;
picture = QPATHTOF(data\m_rope_ca);
model = "\A3\Structures_F_Heli\Items\Tools\Rope_01_F.p3d";
displayName = CSTRING(Rope_27_Display);
descriptionShort = CSTRING(descriptionShort);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 81;
};
};
class ACE_rope36: ACE_ItemCore {
scope = 2;
GVAR(ropeLength) = 36.6;
picture = QPATHTOF(data\m_rope_ca);
model = "\A3\Structures_F_Heli\Items\Tools\Rope_01_F.p3d";
displayName = CSTRING(Rope_36_Display);
descriptionShort = CSTRING(descriptionShort);
class ItemInfo: CBA_MiscItem_ItemInfo {
mass = 108;
};
};
};

View File

@ -6,4 +6,6 @@ PREP_RECOMPILE_START;
#include "XEH_PREP.hpp" #include "XEH_PREP.hpp"
PREP_RECOMPILE_END; PREP_RECOMPILE_END;
#include "initSettings.sqf"
ADDON = true; ADDON = true;

View File

@ -8,7 +8,7 @@ class CfgPatches {
requiredVersion = REQUIRED_VERSION; requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_interaction"}; requiredAddons[] = {"ace_interaction"};
author = ECSTRING(common,ACETeam); author = ECSTRING(common,ACETeam);
authors[] = {"KoffeinFlummi", "BaerMitUmlaut"}; authors[] = {"KoffeinFlummi", "BaerMitUmlaut", "Pokertour"};
url = ECSTRING(main,URL); url = ECSTRING(main,URL);
VERSION_CONFIG; VERSION_CONFIG;
}; };
@ -19,3 +19,4 @@ class CfgPatches {
#include "CfgSounds.hpp" #include "CfgSounds.hpp"
#include "CfgVehicles.hpp" #include "CfgVehicles.hpp"
#include "CfgWaypoints.hpp" #include "CfgWaypoints.hpp"
#include "CfgWeapons.hpp"

Binary file not shown.

View File

@ -4,27 +4,30 @@
* Checks if the unit can deploy ropes from the helicopter. * Checks if the unit can deploy ropes from the helicopter.
* *
* Arguments: * Arguments:
* 0: Unit occupying the helicopter <OBJECT> * 0: The helicopter itself <OBJECT>
* 1: The helicopter itself <OBJECT> * 1: Unit occupying the helicopter <OBJECT>
* 2: Rope classname <STRING>
* 3: Default (show when setting disabled) <BOOL> (default: false)
* *
* Return Value: * Return Value:
* Able to deploy ropes <BOOL> * Able to deploy ropes <BOOL>
* *
* Example: * Example:
* [_player, _vehicle] call ace_fastroping_fnc_canDeployRopes * [vehicle player, player, "ACE_rope36"] call ace_fastroping_fnc_canDeployRopes
* *
* Public: No * Public: No
*/ */
params ["_unit", "_vehicle"]; params ["_vehicle", "_player", "_ropeClass", ["_defaultOption", false]];
private _config = configFile >> "CfgVehicles" >> typeOf _vehicle; private _config = configFile >> "CfgVehicles" >> typeOf _vehicle;
private _enabled = getNumber (_config >> QGVAR(enabled));
private _deploymentStage = _vehicle getVariable [QGVAR(deploymentStage), 0];
(driver _vehicle != _unit) && (driver _vehicle != _player) &&
{getPos _vehicle select 2 > 2} && {getPos _vehicle select 2 > 2} && {
{_enabled == 1 || {_enabled == 2 && {!(isNull (_vehicle getVariable [QGVAR(FRIES), objNull]))}}} && private _enabled = getNumber (_config >> QGVAR(enabled));
{ _enabled == 1 || {_enabled == 2 && {!(isNull (_vehicle getVariable [QGVAR(FRIES), objNull]))}}
(_deploymentStage == 0 && {getText (_config >> QGVAR(onPrepare)) == ""}) || } && {
{_deploymentStage == 2 && {getText (_config >> QGVAR(onPrepare)) != ""}} private _deploymentStage = _vehicle getVariable [QGVAR(deploymentStage), 0];
if (getText (_config >> QGVAR(onPrepare)) == "") then { _deploymentStage == 0 } else { _deploymentStage == 2 };
} && {
(_defaultOption && {!GVAR(requireRopeItems)}) || {(_ropeClass in (_player call EFUNC(common,uniqueItems))) || {_ropeClass in (itemCargo _vehicle)}}
} }

View File

@ -5,22 +5,36 @@
* *
* Arguments: * Arguments:
* 0: The helicopter itself <OBJECT> * 0: The helicopter itself <OBJECT>
* 1: The unit that called the action (may be remote) <OBJECT>
* 2: Rope classname <STRING>
* *
* Return Value: * Return Value:
* None * None
* *
* Example: * Example:
* [_vehicle] call ace_fastroping_fnc_deployRopes * [vehicle player, player, "ACE_rope36"] call ace_fastroping_fnc_deployRopes
* *
* Public: No * Public: No
*/ */
params ["_vehicle"]; params ["_vehicle", "_player", "_ropeClass"];
TRACE_3("deployRopes",_vehicle,_player,_ropeClass);
private _config = configFile >> "CfgVehicles" >> typeOf _vehicle; private _config = configFile >> "CfgVehicles" >> typeOf _vehicle;
private _ropeOrigins = getArray (_config >> QGVAR(ropeOrigins)); private _ropeOrigins = getArray (_config >> QGVAR(ropeOrigins));
private _deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []]; private _deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];
private _hookAttachment = _vehicle getVariable [QGVAR(FRIES), _vehicle]; private _hookAttachment = _vehicle getVariable [QGVAR(FRIES), _vehicle];
private _ropeLength = getNumber (configfile >> "CfgWeapons" >> _ropeClass >> QGVAR(ropeLength));
TRACE_3("",_ropeClass,_ropeLength,GVAR(requireRopeItems));
if (GVAR(requireRopeItems)) then {
if (_ropeClass in (items _player)) then {
_player removeItem _ropeClass;
} else {
_vehicle removeItem _ropeClass;
};
};
{ {
private _ropeOrigin = _x; private _ropeOrigin = _x;
private _hook = QGVAR(helper) createVehicle [0, 0, 0]; private _hook = QGVAR(helper) createVehicle [0, 0, 0];
@ -39,7 +53,7 @@ private _hookAttachment = _vehicle getVariable [QGVAR(FRIES), _vehicle];
private _ropeTop = ropeCreate [_dummy, [0, 0, 0], _hook, [0, 0, 0], 0.5]; private _ropeTop = ropeCreate [_dummy, [0, 0, 0], _hook, [0, 0, 0], 0.5];
private _ropeBottom = ropeCreate [_dummy, [0, 0, 0], 1]; private _ropeBottom = ropeCreate [_dummy, [0, 0, 0], 1];
ropeUnwind [_ropeBottom, 30, 34.5, false]; ropeUnwind [_ropeBottom, 30, _ropelength, false];
_ropeTop addEventHandler ["RopeBreak", {[_this, "top"] call FUNC(onRopeBreak)}]; _ropeTop addEventHandler ["RopeBreak", {[_this, "top"] call FUNC(onRopeBreak)}];
_ropeBottom addEventHandler ["RopeBreak", {[_this, "bottom"] call FUNC(onRopeBreak)}]; _ropeBottom addEventHandler ["RopeBreak", {[_this, "bottom"] call FUNC(onRopeBreak)}];
@ -52,3 +66,4 @@ private _hookAttachment = _vehicle getVariable [QGVAR(FRIES), _vehicle];
_vehicle setVariable [QGVAR(deployedRopes), _deployedRopes, true]; _vehicle setVariable [QGVAR(deployedRopes), _deployedRopes, true];
_vehicle setVariable [QGVAR(deploymentStage), 3, true]; _vehicle setVariable [QGVAR(deploymentStage), 3, true];
_vehicle setVariable [QGVAR(ropeLength), _ropeLength, true];

View File

@ -16,6 +16,7 @@
* Public: No * Public: No
*/ */
params ["_unit", "_vehicle"]; params ["_unit", "_vehicle"];
TRACE_2("fastRope",_unit,_vehicle);
//Select unoccupied rope //Select unoccupied rope
private _deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []]; private _deployedRopes = _vehicle getVariable [QGVAR(deployedRopes), []];

View File

@ -28,8 +28,11 @@ if (isNull _hook) exitWith {
[_pfhHandle] call CBA_fnc_removePerFrameHandler; [_pfhHandle] call CBA_fnc_removePerFrameHandler;
}; };
private _ropeLength = _vehicle getVariable [QGVAR(ropeLength), 34.5];
//Start fast roping //Start fast roping
if (getMass _dummy != 80) exitWith { if (getMass _dummy != 80) exitWith {
TRACE_1("unwinding ropes",_ropeLength);
//Fix for twitchyness //Fix for twitchyness
_dummy setMass 80; _dummy setMass 80;
_dummy setCenterOfMass [0, 0, -2]; _dummy setCenterOfMass [0, 0, -2];
@ -37,7 +40,7 @@ if (getMass _dummy != 80) exitWith {
_dummy setPosASL (_origin vectorAdd [0, 0, -2]); _dummy setPosASL (_origin vectorAdd [0, 0, -2]);
_dummy setVectorUp [0, 0, 1]; _dummy setVectorUp [0, 0, 1];
ropeUnwind [_ropeTop, 6, 34.5]; ropeUnwind [_ropeTop, 6, _ropeLength];
ropeUnwind [_ropeBottom, 6, 0.5]; ropeUnwind [_ropeBottom, 6, 0.5];
}; };
@ -59,7 +62,7 @@ _dummy setVelocity [0,0,-6];
//Check if fast rope is finished //Check if fast rope is finished
if ( if (
((getPos _unit select 2) < 0.2) ((getPos _unit select 2) < 0.2)
|| {ropeLength _ropeTop == 34.5} || {ropeLength _ropeTop == _ropeLength}
|| {vectorMagnitude (velocity _vehicle) > 5} || {vectorMagnitude (velocity _vehicle) > 5}
|| {!([_unit] call EFUNC(common,isAwake))} || {!([_unit] call EFUNC(common,isAwake))}
) exitWith { ) exitWith {
@ -77,7 +80,7 @@ if (
_dummy setCenterOfMass [0.000143227,0.00105986,-0.246147]; _dummy setCenterOfMass [0.000143227,0.00105986,-0.246147];
_ropeTop = ropeCreate [_dummy, [0, 0, 0], _hook, [0, 0, 0], 0.5]; _ropeTop = ropeCreate [_dummy, [0, 0, 0], _hook, [0, 0, 0], 0.5];
_ropeBottom = ropeCreate [_dummy, [0, 0, 0], 34.5]; _ropeBottom = ropeCreate [_dummy, [0, 0, 0], _ropeLength];
_ropeTop addEventHandler ["RopeBreak", {[_this, "top"] call FUNC(onRopeBreak)}]; _ropeTop addEventHandler ["RopeBreak", {[_this, "top"] call FUNC(onRopeBreak)}];
_ropeBottom addEventHandler ["RopeBreak", {[_this, "bottom"] call FUNC(onRopeBreak)}]; _ropeBottom addEventHandler ["RopeBreak", {[_this, "bottom"] call FUNC(onRopeBreak)}];

View File

@ -0,0 +1,11 @@
// CBA Settings [ADDON: ace_fastroping]:
[
QGVAR(requireRopeItems), "CHECKBOX",
[LSTRING(setting_requireRopeItems_displayName)],
["ACE Uncategorized", QUOTE(COMPONENT_BEAUTIFIED)],
false, // default value
true, // isGlobal
{[QGVAR(requireRopeItems), _this] call EFUNC(common,cbaSettings_settingChanged)},
false // needRestart
] call CBA_settings_fnc_init;

View File

@ -144,5 +144,57 @@
<Chinese>讓單位快速繩降</Chinese> <Chinese>讓單位快速繩降</Chinese>
<Korean>패스트 로프를 놓음</Korean> <Korean>패스트 로프를 놓음</Korean>
</Key> </Key>
<Key ID="STR_ACE_Fastroping_Interaction_deployRopes12">
<English>Deploy 12m ropes</English>
<French>Déployer les cordes 12m</French>
</Key>
<Key ID="STR_ACE_Fastroping_Interaction_deployRopes15">
<English>Deploy 15m ropes</English>
<French>Déployer les cordes 15m</French>
</Key>
<Key ID="STR_ACE_Fastroping_Interaction_deployRopes18">
<English>Deploy 18m ropes</English>
<French>Déployer les cordes 18m</French>
</Key>
<Key ID="STR_ACE_Fastroping_Interaction_deployRopes27">
<English>Deploy 27m ropes</English>
<French>Déployer les cordes 27m</French>
</Key>
<Key ID="STR_ACE_Fastroping_Interaction_deployRopes36">
<English>Deploy 36m ropes</English>
<French>Déployer les cordes 36m</French>
</Key>
<Key ID="STR_ACE_Fastroping_Ropesupply">
<English>[ACE] Ropes Supply crate</English>
<French>[ACE] Caisse de Cordes</French>
</Key>
<Key ID="STR_ACE_Fastroping_descriptionShort">
<English>Used to do deploy ropes from a compatibile helicopter</English>
<French>Utilisé pour déployer des cordes depuis un hélicoptère compatible</French>
</Key>
<Key ID="STR_ACE_Fastroping_Rope_12_Display">
<English>Rope 12.2 meters</English>
<French>Corde 12.2 mètres</French>
</Key>
<Key ID="STR_ACE_Fastroping_Rope_15_Display">
<English>Rope 15.2 meters</English>
<French>Corde 15.2 mètres</French>
</Key>
<Key ID="STR_ACE_Fastroping_Rope_18_Display">
<English>Rope 18.3 meters</English>
<French>Corde 18.3 mètres</French>
</Key>
<Key ID="STR_ACE_Fastroping_Rope_27_Display">
<English>Rope 27.4 meters</English>
<French>Corde 27.4 mètres</French>
</Key>
<Key ID="STR_ACE_Fastroping_Rope_36_Display">
<English>Rope 36.6 meters</English>
<French>Corde 36.6 mètres</French>
</Key>
<Key ID="STR_ACE_Fastroping_setting_requireRopeItems_displayName">
<English>Require rope item to deploy</English>
<French>Exiger une corde pour déployer</French>
</Key>
</Package> </Package>
</Project> </Project>