Cargo - Make player carry/drag item on unload#8797
Cargo - Make player carry/drag item on unload#8797PabstMirror merged 5 commits intoacemod:masterfrom
Conversation
Co-authored-by: jonpas <jonpas33@gmail.com>
| * | ||
| * Public: No | ||
| */ | ||
| params ["_unloader", "_object"]; |
There was a problem hiding this comment.
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.1, { TRACE_1("unloadCarryItem-failed to unload nearby player",_this); }] call CBA_fnc_waitUntilAndExecute;
When unloading a object type in mp the distance check in dragging was failing
ace_cargo_fnc_unloadItem calls QGVAR(serverUnload) and then immeditly calls unloadCarryItem
but it takes a bit for the server to actually move the object down to where the player is
this adds a little delay so all that can happen (only local mp it's 4 frames)
It's possible for this to fail if the unload position is away from the player, but that's just something that can happen and not really an error
also I was worried about collision and physx but it seemed to behave ok
I also switched the nested if statements to the superior exitWith style
There was a problem hiding this comment.
Don't have access to anything that can (conveniently) commit atm, but works for me. Thanks for testing.
When merged this pull request will:
Player will start carrying or dragging item after unloading from cargo if possible. Includes weight checking.
IMPORTANT
Component - Add|Fix|Improve|Change|Make|Remove {changes}.