-
Notifications
You must be signed in to change notification settings - Fork 737
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cargo - Add alternative unloading item from vehicle cargo (#8827)
Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> Co-authored-by: LinkIsGrim <salluci.lovi@gmail.com> Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
- Loading branch information
1 parent
6637a15
commit 8731bcc
Showing
17 changed files
with
506 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "script_component.hpp" | ||
|
||
params ["_display"]; | ||
|
||
_display displayAddEventHandler ["MouseZChanged", {(_this select 1) call FUNC(handleScrollWheel)}]; | ||
_display displayAddEventHandler ["MouseButtonDown", { | ||
// Right clicking cancels deployment | ||
if (_this select 1 == 1) then { | ||
ACE_player call FUNC(handleDeployInterrupt); | ||
}; | ||
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: Garth 'L-H' de Wet, Ruthberg, commy2, Smith | ||
* Cancels unloading when deploying. | ||
* | ||
* Arguments: | ||
* 0: Unit <OBJECT> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* player call ace_cargo_fnc_deployCancel | ||
* | ||
* Public: No | ||
*/ | ||
|
||
if (GVAR(deployPFH) == -1) exitWith {}; | ||
|
||
// Remove deployment pfh | ||
GVAR(deployPFH) call CBA_fnc_removePerFrameHandler; | ||
GVAR(deployPFH) = -1; | ||
|
||
params ["_unit"]; | ||
|
||
// Enable running again | ||
[_unit, "forceWalk", QUOTE(ADDON), false] call EFUNC(common,statusEffect_set); | ||
[_unit, "blockThrow", QUOTE(ADDON), false] call EFUNC(common,statusEffect_set); | ||
|
||
// Delete placement dummy | ||
deleteVehicle GVAR(itemPreviewObject); | ||
|
||
// Remove mouse button actions | ||
call EFUNC(interaction,hideMouseHint); | ||
|
||
[_unit, "DefaultAction", _unit getVariable [QGVAR(deploy), -1]] call EFUNC(common,removeActionEventHandler); | ||
_unit setVariable [QGVAR(deploy), -1]; | ||
|
||
_unit setVariable [QGVAR(isDeploying), false, true]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: Garth 'L-H' de Wet, Ruthberg, commy2, Smith | ||
* Confirms unloading when deploying. | ||
* | ||
* Arguments: | ||
* 0: Unit <OBJECT> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* player call ace_cargo_fnc_deployConfirm | ||
* | ||
* Public: No | ||
*/ | ||
|
||
if (GVAR(deployPFH) == -1) exitWith {}; | ||
|
||
params ["_unit"]; | ||
|
||
// Delete placement dummy and unload real item from cargo at dummy position | ||
if (!isNull GVAR(itemPreviewObject) && {[GVAR(selectedItem), GVAR(interactionVehicle), _unit, false, true] call FUNC(canUnloadItem)}) then { | ||
// Position is AGL for unloading event | ||
private _position = ASLToAGL getPosASL GVAR(itemPreviewObject); | ||
private _direction = getDir GVAR(itemPreviewObject); | ||
private _duration = GVAR(loadTimeCoefficient) * (GVAR(selectedItem) call FUNC(getSizeItem)); | ||
|
||
// If unload time is 0, don't show a progress bar | ||
if (_duration <= 0) exitWith { | ||
["ace_unloadCargo", [GVAR(selectedItem), GVAR(interactionVehicle), _unit, [_position, _direction]]] call CBA_fnc_localEvent; | ||
}; | ||
|
||
[ | ||
_duration, | ||
[GVAR(selectedItem), GVAR(interactionVehicle), _unit, [_position, _direction]], | ||
{ | ||
TRACE_1("deploy finish",_this); | ||
|
||
["ace_unloadCargo", _this select 0] call CBA_fnc_localEvent; | ||
}, | ||
{ | ||
TRACE_1("deploy fail",_this); | ||
}, | ||
format [LLSTRING(unloadingItem), [GVAR(selectedItem), true] call FUNC(getNameItem), getText (configOf GVAR(interactionVehicle) >> "displayName")], | ||
{ | ||
(_this select 0) params ["_item", "_vehicle", "_unit"]; | ||
|
||
[_item, _vehicle, _unit, false, true] call FUNC(canUnloadItem) // don't check for a suitable unloading position when deploying | ||
}, | ||
["isNotSwimming"] | ||
] call EFUNC(common,progressBar); | ||
}; | ||
|
||
// Cleanup EHs and preview object | ||
_unit call FUNC(deployCancel); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: Glowbal, Smith | ||
* Get selected item from cargo menu. | ||
* | ||
* Arguments: | ||
* None | ||
* | ||
* Return Value: | ||
* Classname of selected item or selected object <STRING> or <OBJECT> (default: nil) | ||
* | ||
* Example: | ||
* call ace_cargo_fnc_getSelectedItem | ||
* | ||
* Public: No | ||
*/ | ||
|
||
disableSerialization; | ||
|
||
private _display = uiNamespace getVariable QGVAR(menuDisplay); | ||
|
||
if (isNil "_display") exitWith {}; | ||
|
||
private _loaded = GVAR(interactionVehicle) getVariable [QGVAR(loaded), []]; | ||
|
||
if (_loaded isEqualTo []) exitWith {}; | ||
|
||
// This can be an object or a classname string | ||
_loaded param [lbCurSel (_display displayCtrl 100), nil] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: commy2, Smith | ||
* Handle various interruption types. | ||
* | ||
* Arguments: | ||
* 0: (New) unit <OBJECT> | ||
* 1: Old unit (for player change) <OBJECT> (default: objNull) | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* player call ace_cargo_fnc_handleDeployInterrupt | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_newPlayer", ["_oldPlayer", objNull]]; | ||
TRACE_2("params",_newPlayer,_oldPlayer); | ||
|
||
if (!local _newPlayer) exitWith {}; | ||
|
||
if (_newPlayer getVariable [QGVAR(isDeploying), false]) then { | ||
_newPlayer call FUNC(deployCancel); | ||
}; | ||
|
||
if (_oldPlayer getVariable [QGVAR(isDeploying), false]) then { | ||
_oldPlayer call FUNC(deployCancel); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: L-H, commy2, Smith | ||
* Handles rotation of object to unload. | ||
* | ||
* Arguments: | ||
* 0: Scroll amount <NUMBER> | ||
* | ||
* Return Value: | ||
* If the scroll was handled <BOOL> | ||
* | ||
* Example: | ||
* 1.2 call ace_cargo_fnc_handleScrollWheel | ||
* | ||
* Public: No | ||
*/ | ||
|
||
if (GVAR(deployPFH) == -1) exitWith {false}; | ||
|
||
params ["_scrollAmount"]; | ||
|
||
private _deployedItem = GVAR(itemPreviewObject); | ||
|
||
if (!CBA_events_control) then { | ||
private _unit = ACE_player; | ||
|
||
// Raise/lower | ||
// Move deployed item 15 cm per scroll interval | ||
_scrollAmount = _scrollAmount * 0.15; | ||
|
||
private _position = getPosASL _deployedItem; | ||
private _maxHeight = (_unit modelToWorldVisualWorld [0, 0, 0]) select 2; | ||
|
||
_position set [2, ((_position select 2) + _scrollAmount min (_maxHeight + 1.5)) max _maxHeight]; | ||
|
||
// Move up/down object and reattach at current position | ||
detach _deployedItem; | ||
|
||
// Uses this method of selecting position because setPosATL did not have immediate effect | ||
private _positionChange = _position vectorDiff (getPosASL _deployedItem); | ||
private _selectionPosition = _unit worldToModel (ASLtoAGL getPosWorld _deployedItem); | ||
_selectionPosition = _selectionPosition vectorAdd _positionChange; | ||
_deployedItem attachTo [_unit, _selectionPosition]; | ||
|
||
// Reset the deploy direction | ||
private _direction = _deployedItem getVariable [QGVAR(deployDirection_temp), 0]; | ||
_deployedItem setDir _direction; | ||
} else { | ||
// Rotate | ||
private _direction = _deployedItem getVariable [QGVAR(deployDirection_temp), 0]; | ||
_scrollAmount = _scrollAmount * 10; | ||
_direction = _direction + _scrollAmount; | ||
|
||
_deployedItem setDir _direction; | ||
_deployedItem setVariable [QGVAR(deployDirection_temp), _direction]; | ||
}; | ||
|
||
true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.