Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
73bb125
add floating helper
ampersand38 Nov 19, 2021
512705b
add space
ampersand38 Nov 19, 2021
a3e881b
fix packs not hidden
ampersand38 Nov 19, 2021
c8608a6
if pack lands in water, make it float
ampersand38 Nov 19, 2021
1b2125d
fix incorrect position when lowering over water
ampersand38 Nov 19, 2021
3cedf09
disable Cut action if rope breaks
ampersand38 Nov 19, 2021
9ffddb6
fix game crash on cut
ampersand38 Nov 19, 2021
93c7c45
use ASL
ampersand38 Nov 19, 2021
b85c658
float, sink, and delete parachute pack
ampersand38 Nov 19, 2021
10a4772
Add discard parachute action
ampersand38 Nov 19, 2021
3e3b779
add depth check
ampersand38 Nov 19, 2021
d2f6dd2
tabs to spaces
ampersand38 Nov 19, 2021
01cd770
Update addons/main/functions/fnc_actionCutLoweringLine.sqf
ampersand38 Jan 12, 2022
1d3ab92
Update addons/main/functions/fnc_actionCutLoweringLine.sqf
ampersand38 Jan 12, 2022
2709bf7
Update addons/main/functions/fnc_actionLower.sqf
ampersand38 Jan 12, 2022
d617be8
Update addons/main/functions/fnc_actionLower.sqf
ampersand38 Jan 12, 2022
44913cb
Update addons/main/functions/fnc_actionLower.sqf
ampersand38 Jan 12, 2022
222c86a
Update addons/main/functions/fnc_actionLower.sqf
ampersand38 Jan 12, 2022
c5c8e4f
Update addons/main/XEH_postInit.sqf
ampersand38 Jan 12, 2022
df76699
Update addons/main/XEH_postInit.sqf
ampersand38 Jan 12, 2022
8d4469b
Update addons/main/functions/fnc_floatPack.sqf
ampersand38 Jan 12, 2022
2f3fc78
Update addons/main/functions/fnc_actionLower.sqf
ampersand38 Jan 12, 2022
e970180
Update addons/main/functions/fnc_actionLower.sqf
ampersand38 Jan 12, 2022
d912917
Update addons/main/functions/fnc_actionLower.sqf
ampersand38 Jan 12, 2022
9265092
Update addons/main/functions/fnc_canDiscardParachute.sqf
ampersand38 Jan 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions addons/main/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ class CfgVehicles {
class AnyPerson2 : AnyPerson1 {};
};
};
class Buoy_base_F;
class GVAR(float): Buoy_base_F {
Comment thread
mjc4wilton marked this conversation as resolved.
author = "Ampersand";
displayName = "Float";
_generalMacro = QGVAR(float);
model = QPATHTOF(data\float.p3d);
scope = 2;
};
class Man;
class CAManBase: Man {
class ACE_SelfActions {
Expand Down Expand Up @@ -133,6 +141,12 @@ class CfgVehicles {
condition = QUOTE([_player] call FUNC(canCutLoweringLine));
statement = QUOTE([_player] call FUNC(actionCutLoweringLine));
};
class GVAR(discardParachute) : GVAR(onChest) {
displayName = CSTRING(DiscardParachute);
exceptions[] = {"isNotSwimming"};
condition = QUOTE([_player] call FUNC(canDiscardParachute));
statement = QUOTE([_player] call FUNC(actionDiscardParachute));
};
};
};
};
Expand Down
4 changes: 4 additions & 0 deletions addons/main/Stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,9 @@
<Original>Cut Lowering Line</Original>
<English>Cut Lowering Line</Original>
</Key>
<Key ID="STR_BOCR_Main_DiscardParachute">
<Original>Discard Parachute</Original>
<English>Discard Parachute</Original>
</Key>
</Package>
</Project>
5 changes: 5 additions & 0 deletions addons/main/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ PREP(ace_arsenal_onButtonClick);
PREP(ace_arsenal_opened);
PREP(ace_arsenal_updateUI);
PREP(actionCutLoweringLine);
PREP(actionDiscardParachute);
PREP(actionLower);
PREP(actionOnBack);
PREP(actionOnChest);
PREP(actionOnChest);
PREP(actionSwap);
PREP(addChestpack);
PREP(addItemToChestpack);
Expand All @@ -15,8 +17,10 @@ PREP(arsenal_postInit);
PREP(arsenal_updateUI);
PREP(canAddItemToChestpack);
PREP(canCutLoweringLine);
PREP(canDiscardParachute);
PREP(canMovePack);
PREP(canLower);
PREP(checkLandedPFH);
PREP(chestpack);
PREP(chestpackContainer);
PREP(chestpackLoadout);
Expand All @@ -30,6 +34,7 @@ PREP(EHGetIn);
PREP(EHGetOut);
PREP(EHHandleDisconnect);
PREP(EHKilled);
PREP(floatPack);
PREP(itemMass);
PREP(moduleAdd);
PREP(moduleOnChest);
Expand Down
28 changes: 12 additions & 16 deletions addons/main/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@
// Clear inventory of every backpack in a container
[QGVAR(clearCargoBackpacks), {call FUNC(clearCargoBackpacks)}] call CBA_fnc_addEventHandler;

[QGVAR(floatPack), {call FUNC(floatPack)}] call CBA_fnc_addEventHandler;

if (isServer) then {
[QGVAR(hideObjectGlobal), {
params ["_object", "_isHidden"];
_object hideObjectGlobal _isHidden;
}] call CBA_fnc_addEventHandler;

[QGVAR(handleDisconnect), {
addMissionEventHandler ["HandleDisconnect", FUNC(EHHandleDisconnect)];
}] call CBA_fnc_addEventHandler;
Expand All @@ -24,22 +31,11 @@ if (isServer) then {
// holding the backpack have landed
[QGVAR(checkLandedPFH), {
params ["_ropeTop", "_holder"];
[{
params ["_ropeTop", "_pfhID"];
if (speed _ropeTop < 1 && {getPos _ropeTop # 2 < 1}) exitWith {
deleteVehicle _ropeTop;
[_pfhID] call CBA_fnc_removePerFrameHandler;
};
}, 1, _ropeTop] call CBA_fnc_addPerFrameHandler;
[{
params ["_holder", "_pfhID"];
if (speed _holder < 1 && {getPos _holder # 2 < 1}) exitWith {
private _pos = getPos _holder;
_pos set [2, 0];
_holder setPos _pos;
[_pfhID] call CBA_fnc_removePerFrameHandler;
};
}, 1, _holder] call CBA_fnc_addPerFrameHandler;
_ropeTop addEventHandler ["RopeBreak", {
//params ["_ropeTop", "_rope", "_holder"];
deleteVehicle (_this select 0);
}];
[{call FUNC(checkLandedPFH)}, 1, _this] call CBA_fnc_addPerFrameHandler;
}] call CBA_fnc_addEventHandler;
};

Expand Down
Binary file added addons/main/data/float.p3d
Binary file not shown.
4 changes: 2 additions & 2 deletions addons/main/functions/fnc_EHGetIn.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ private _chestpack = [_unit] call FUNC(chestpackContainer);
if (_veh isKindOf "ParachuteBase") then {
_chestpack attachTo [_veh, [0, -0.03, -0.5]];
_chestpack setVectorDirAndUp [[-0.25, -1, 0], [0, 0, 1]];
_chestpack hideObjectGlobal false;
[QGVAR(hideObjectGlobal), [_chestpack, false]] call CBA_fnc_serverEvent;
} else {
detach _chestpack;
hideObjectGlobal _chestpack;
_chestpack setPos [-10000,-10000,-100];
[QGVAR(hideObjectGlobal), [_chestpack, true]] call CBA_fnc_serverEvent;
};
2 changes: 1 addition & 1 deletion addons/main/functions/fnc_EHGetOut.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private _chestpackClass = [_unit] call FUNC(chestpack);
if !(_chestpackClass in GVAR(exceptions)) then {
_chestpack attachTo [_unit,[0,-0.03,-0.5],"pelvis"];
_chestpack setVectorDirAndUp [[-0.25,-1,0],[0,0,1]];
_chestpack hideObjectGlobal false;
[QGVAR(hideObjectGlobal), [_chestpack, false]] call CBA_fnc_serverEvent;
};

if (GVAR(walk)) then {
Expand Down
3 changes: 2 additions & 1 deletion addons/main/functions/fnc_EHKilled.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ private _chestpack = [_unit] call FUNC(chestpack);
private _chestpackLoadout = [_unit] call FUNC(chestpackLoadout);
private _chestpackVariables = [_unit] call FUNC(chestpackVariables);

private _holder = createVehicle ["WeaponHolderSimulated", (getPos _unit), [], 0, "CAN_COLLIDE"];
private _holder = createVehicle ["WeaponHolderSimulated", [0, 0, 0], [], 0, "CAN_COLLIDE"];
_holder setPosASL getPosASL _unit;

//add pack
_holder addBackpackCargoGlobal [_chestpack, 1];
Expand Down
27 changes: 17 additions & 10 deletions addons/main/functions/fnc_actionCutLoweringLine.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,24 @@
*/

params ["_unit"];
private _chute = vehicle _unit;
private _ropeTop = _chute getVariable [QGVAR(loweringLine), objNull];
private _vehicle = vehicle _unit;
private _ropeTop = _vehicle getVariable [QGVAR(loweringLine), objNull];
_vehicle setVariable [QGVAR(loweringLine), objNull, true];

if (!isNull _ropeTop) then {
private _rope = ropes _ropeTop # 0;
private _holder = ropeAttachedObjects _ropeTop # 0;
_holder ropeDetach _rope;
// ace_fastroping_helper is a helicopter and kind of autorotates down instead
// of falling, much slower than a falling object. Attaching to the holder
// also looks like the rope snapping under tension once cut
_ropeTop attachTo [_holder, [0.1,-0.45,-0.6]];

_chute setVariable [QGVAR(loweringLine), objNull, true];
private _attachedObjects = ropeAttachedObjects _ropeTop;
if (_attachedObjects isEqualTo []) then {
deleteVehicle _ropeTop;
} else {
private _holder = _attachedObjects # 0;
_holder ropeDetach _rope;
// ace_fastroping_helper is a helicopter and kind of autorotates down instead
// of falling, much slower than a falling object. Attaching to the holder
// also looks like the rope snapping under tension once cut
[{
params ["_ropeTop", "_holder"];
_ropeTop attachTo [_holder, [0.1,-0.45,-0.6]];
}, [_ropeTop, _holder]] call CBA_fnc_execNextFrame;
};
};
31 changes: 31 additions & 0 deletions addons/main/functions/fnc_actionDiscardParachute.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "script_component.hpp"
/*
* Author: Ampersand
* Triggered by the discard-reserve-action.
* Puts the reserve parachute into WeaponHolderSimulated to sink and
* moves the chestpack to back if present.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* Nothing
*
* Example:
* [player] call bocr_main_fnc_actionDiscardParachute;
*
* Public: No
*/
params ["_unit"];

private _holder = createVehicle ["WeaponHolderSimulated", [0, 0, 0], [], 0, "CAN_COLLIDE"];
_holder addBackpackCargoGlobal [backpack _unit, 1];
removeBackpack _unit;
_holder setPosASL (getPosASL _unit vectorAdd vectorDir _unit);

[QGVAR(floatPack), [_holder]] call CBA_fnc_globalEvent;

private _chestpack = [_unit] call FUNC(chestpack);
if (_chestpack != "") then {
[_unit] call FUNC(actionOnBack);
};
23 changes: 13 additions & 10 deletions addons/main/functions/fnc_actionLower.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@

params ["_unit"];

private _chute = vehicle _unit;
private _vehicle = vehicle _unit;
private _pos = getPosASL _vehicle;

// Rope top helper, workaround parachute rope visual bug, allow cut
private _ropeTop = createVehicle ["ace_fastroping_helper", getPos _chute, [], 0, "CAN_COLLIDE"];
_chute setVariable [QGVAR(loweringLine), _ropeTop, true];
private _ropeTop = createVehicle ["ace_fastroping_helper", [0, 0, 100], [], 0, "CAN_COLLIDE"];
_vehicle setVariable [QGVAR(loweringLine), _ropeTop, true];
_ropeTop allowDamage false;
_ropeTop disableCollisionWith _chute;
_ropeTop disableCollisionWith _vehicle;
_ropeTop setPosASL _pos;

// Weapon holder with backpack
private _holder = [_unit] call FUNC(chestpackToHolder); // Chestpack to holder
_holder disableCollisionWith _chute;
_holder setPos (_chute modelToWorld [0, 1, -1]);
_holder setVelocity velocity _chute;
_holder disableCollisionWith _vehicle;
_holder attachTo [_vehicle, [0, 1, -1]];
detach _holder;
_holder setVelocity velocity _vehicle;

private _rope = ropeCreate [
_ropeTop, [0,0,0],
Expand All @@ -38,8 +41,8 @@ private _rope = ropeCreate [
];

[{
params ["_chute", "_ropeTop"];
_ropeTop attachTo [_chute, [0,0,0]];
}, [_chute, _ropeTop]] call CBA_fnc_execNextFrame;
params ["_vehicle", "_ropeTop"];
_ropeTop attachTo [_vehicle, [0, 0, 0]];
}, [_vehicle, _ropeTop]] call CBA_fnc_execNextFrame;

[QGVAR(checkLandedPFH), [_ropeTop, _holder]] call CBA_fnc_serverEvent;
2 changes: 1 addition & 1 deletion addons/main/functions/fnc_actionOnChest.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Public: No
*/

params["_unit"];
params ["_unit"];

private _backpack = backpack _unit;
private _backpackLoad = loadBackpack _unit;
Expand Down
23 changes: 23 additions & 0 deletions addons/main/functions/fnc_canDiscardParachute.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "script_component.hpp"
/*
* Author: Ampersand
* Checks if given unit can discard its reserve parachute
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* Success <BOOL>
*
* Example:
* [_unit] call bocr_main_fnc_canDiscardParachute;
*
* Public: No
*/

params ["_unit"];

if (GVAR(disabled)) exitWith {false};

// Can't move pack while in a parachute
[_unit] call ace_common_fnc_isSwimming && {backpackContainer _unit isKindOf "B_Parachute"}
33 changes: 33 additions & 0 deletions addons/main/functions/fnc_checkLandedPFH.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "script_component.hpp"
/*
* Author: Ampersand
* Called on server when chestpack is lowered.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* Nothing
*
* Example:
* [_ropeTop, _holder] call bocr_main_fnc_checkLandedPFH;
*
* Public: No
*/

params ["_args", "_pfhID"];
_args params ["_ropeTop", "_holder"];

private _pos = getPos _holder;
private _alt = _pos # 2;
if (speed _holder < 1 && {_alt < 1}) exitWith {
deleteVehicle _ropeTop;
_alt = getPosASL _holder # 2;
if (_alt < 1 && {surfaceIsWater _pos}) then {
[_holder] call bocr_main_fnc_floatPack;
} else {
_holder setVectorUp [0,0,1];
_holder setPosASL (_pos vectorAdd [0,0,0.1]);
};
[_pfhID] call CBA_fnc_removePerFrameHandler;
};
3 changes: 2 additions & 1 deletion addons/main/functions/fnc_chestpackToHolder.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ if (_chestpack isEqualTo "") exitWith {objNull};
private _chestpackLoadout = [_unit] call FUNC(chestpackLoadout);
private _chestpackVariables = [_unit] call FUNC(chestpackVariables);

private _holder = createVehicle ["WeaponHolderSimulated", (getPos _unit), [], 0, "CAN_COLLIDE"];
private _holder = createVehicle ["WeaponHolderSimulated", [0, 0, 0], [], 0, "CAN_COLLIDE"];
_holder setPosASL getPosASL _unit;

//add pack
_holder addBackpackCargoGlobal [_chestpack, 1];
Expand Down
54 changes: 54 additions & 0 deletions addons/main/functions/fnc_floatPack.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "script_component.hpp"
/*
* Author: Ampersand
* Attaches a backpack's weaponholder to a floating helper
*
* Arguments:
* 0: Weapon Holder <OBJECT>
*
* Return Value:
* Float <OBJECT>
*
* Example:
* [_holder] call bocr_main_fnc_floatPack;
*
* Public: No
*/

params ["_holder"];

// Float model is too big =/ Can't get it to be stable with a smaller model
_pos = getPosASL _holder;
_pos set [2, 0];
private _depth = ASLToATL (_pos select 2);
if (_depth < 5) exitWith {};

// Make pack float
if (isServer) then {
private _float = QGVAR(float) createVehicle [0, 0, 0];
_float setPosASL (getPosASL _holder vectorAdd [0, 0, -2]);
Comment thread
mjc4wilton marked this conversation as resolved.
_holder attachTo [_float, [0, 0, 1.5]];
_holder setVariable [QGVAR(float), _float, true];

_holder addEventHandler ["Deleted", {
params ["_holder"];
deleteVehicle (_holder getVariable QGVAR(float));
}];
_float addEventHandler ["EpeContact", {
//params ["_object1", "_object2", "_selection1", "_selection2", "_force"];
params ["_float", "_object2"];
if (isNull _object2) then {
{
deleteVehicle _x;
} forEach attachedObjects _float;
deleteVehicle _float; // Delete when on ocean bottom
};
}];
};

if (hasInterface) then {
_holder addaction ["Discard", {
// Make pack sink
((_this # 0) getVariable QGVAR(float) setMass 10000);
}, nil, 7, true, true, "", "firstBackpack _target isKindOf 'B_Parachute'"];
};
Comment on lines +49 to +54
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (hasInterface) then {
_holder addaction ["Discard", {
// Make pack sink
((_this # 0) getVariable QGVAR(float) setMass 10000);
}, nil, 7, true, true, "", "firstBackpack _target isKindOf 'B_Parachute'"];
};

This addaction is broken it seems since it add an action to discard whatever backpack you have if you are swimming. Additionally, I'd much rather muddle around and shove actions into ace than an infinite scroll menu since that just gets annoying.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action should actually get added to the weaponHolder that is holding the used parachute that has just been discarded, and would make it sink and get deleted once it's no longer relevant to the player. I felt it was on the same sort of level as the Release vanilla action you get when escorting a prisoner. Should this be done in an ace action?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave it as an ACE action as to not clutter up the scroll menu since I personally hate it (the menu not your feature). As for the feature itself, decouple it from the action so a function can call it to sink a pack which would probably be more useful for those making automated cleanup scripts and the like.