mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Cargo - Make player carry/drag item on unload (#8797)
* carry item on unload * debug off * fix function header * ugly nested if blocks instead of superior switch statement Co-authored-by: jonpas <jonpas33@gmail.com> * Add delay for server event to finish Co-authored-by: jonpas <jonpas33@gmail.com> Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
parent
3ddec6cb15
commit
9e133aa0a5
@ -19,5 +19,6 @@ PREP(setSize);
|
|||||||
PREP(setSpace);
|
PREP(setSpace);
|
||||||
PREP(startLoadIn);
|
PREP(startLoadIn);
|
||||||
PREP(startUnload);
|
PREP(startUnload);
|
||||||
|
PREP(unloadCarryItem);
|
||||||
PREP(unloadItem);
|
PREP(unloadItem);
|
||||||
PREP(validateCargoSpace);
|
PREP(validateCargoSpace);
|
||||||
|
@ -50,8 +50,6 @@
|
|||||||
GVAR(interactionParadrop) = false;
|
GVAR(interactionParadrop) = false;
|
||||||
createDialog QGVAR(menu);
|
createDialog QGVAR(menu);
|
||||||
};
|
};
|
||||||
|
|
||||||
// TOOO maybe drag/carry the unloaded item?
|
|
||||||
}] call CBA_fnc_addEventHandler;
|
}] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
[QGVAR(serverUnload), {
|
[QGVAR(serverUnload), {
|
||||||
|
39
addons/cargo/functions/fnc_unloadCarryItem.sqf
Normal file
39
addons/cargo/functions/fnc_unloadCarryItem.sqf
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#include "script_component.hpp"
|
||||||
|
/*
|
||||||
|
* Author: GhostIsSpooky
|
||||||
|
* Dragging integration. Unloader starts carrying unloaded object.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Unloader <OBJECT>
|
||||||
|
* 1: Item <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [player, object] call ace_cargo_fnc_unloadCarryItem
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
params ["_unloader", "_object"];
|
||||||
|
TRACE_2("unloadCarryItem-start",_unloader,_object);
|
||||||
|
|
||||||
|
if !(["ace_dragging"] call EFUNC(common,isModLoaded)) exitWith {};
|
||||||
|
|
||||||
|
// When unloading attached objects, this code will run before server has finished moving object to the safe position
|
||||||
|
[{
|
||||||
|
params ["_unloader", "_object"];
|
||||||
|
(_unloader distance _object) < 10
|
||||||
|
}, {
|
||||||
|
params ["_unloader", "_object"];
|
||||||
|
TRACE_2("unloadCarryItem-unloaded",_unloader,_object);
|
||||||
|
if ([_unloader, _object] call EFUNC(dragging,canCarry)) exitWith {
|
||||||
|
[_unloader, _object] call EFUNC(dragging,startCarry);
|
||||||
|
};
|
||||||
|
if ([_unloader, _object] call EFUNC(dragging,canDrag)) exitWith {
|
||||||
|
[_unloader, _object] call EFUNC(dragging,startDrag);
|
||||||
|
};
|
||||||
|
}, _this, 1.0, { // delay is based on how long it will take server event to trigger and take effect
|
||||||
|
// not a hard error if this fails, could have just unloaded to other side of vehicle because of findSafePos
|
||||||
|
TRACE_1("unloadCarryItem-failed to unload nearby player",_this);
|
||||||
|
}] call CBA_fnc_waitUntilAndExecute;
|
@ -60,6 +60,10 @@ if (_object isEqualType objNull) then {
|
|||||||
[QEGVAR(common,fixCollision), _object] call CBA_fnc_localEvent;
|
[QEGVAR(common,fixCollision), _object] call CBA_fnc_localEvent;
|
||||||
[QEGVAR(common,fixPosition), _object] call CBA_fnc_localEvent;
|
[QEGVAR(common,fixPosition), _object] call CBA_fnc_localEvent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Dragging integration
|
||||||
|
[_unloader, _object] call FUNC(unloadCarryItem);
|
||||||
|
|
||||||
// Invoke listenable event
|
// Invoke listenable event
|
||||||
["ace_cargoUnloaded", [_object, _vehicle, "unload"]] call CBA_fnc_globalEvent;
|
["ace_cargoUnloaded", [_object, _vehicle, "unload"]] call CBA_fnc_globalEvent;
|
||||||
true
|
true
|
||||||
|
Loading…
Reference in New Issue
Block a user