Skip to content

Cargo - Make player carry/drag item on unload#8797

Merged
PabstMirror merged 5 commits intoacemod:masterfrom
LinkIsGrim:cargo-unload-carry
May 8, 2022
Merged

Cargo - Make player carry/drag item on unload#8797
PabstMirror merged 5 commits intoacemod:masterfrom
LinkIsGrim:cargo-unload-carry

Conversation

@LinkIsGrim
Copy link
Copy Markdown
Member

@LinkIsGrim LinkIsGrim commented Jan 26, 2022

When merged this pull request will:

  • Title.

Player will start carrying or dragging item after unloading from cargo if possible. Includes weight checking.

IMPORTANT

  • If the contribution affects the documentation, please include your changes in this pull request so the documentation will appear on the website.
  • Development Guidelines are read, understood and applied.
  • Title of this PR uses our standard template Component - Add|Fix|Improve|Change|Make|Remove {changes}.

@veteran29 veteran29 added the kind/enhancement Release Notes: **IMPROVED:** label Feb 21, 2022
@veteran29 veteran29 added this to the 3.14.2 milestone Feb 21, 2022
Comment thread addons/cargo/functions/fnc_unloadCarryItem.sqf Outdated
Co-authored-by: jonpas <jonpas33@gmail.com>
Copy link
Copy Markdown
Contributor

@PabstMirror PabstMirror left a comment

Choose a reason for hiding this comment

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

doesn't work in mp

*
* Public: No
*/
params ["_unloader", "_object"];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Don't have access to anything that can (conveniently) commit atm, but works for me. Thanks for testing.

@PabstMirror PabstMirror merged commit 9e133aa into acemod:master May 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement Release Notes: **IMPROVED:**

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants