Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo - Add unloading of cargo to killed vehicles #10017

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

Drofseh
Copy link
Contributor

@Drofseh Drofseh commented May 27, 2024

When merged this pull request will:

  • Add a setting to allow a chance that cargo loaded into a vehicle is unloaded when the vehicle is killed.

@johnb432 johnb432 self-requested a review May 27, 2024 06:47
@Drofseh
Copy link
Contributor Author

Drofseh commented May 27, 2024

Would it be worth giving the unloaded cargo some percentage of the velocity of the destroyed vehicle?

@Drofseh Drofseh marked this pull request as draft May 27, 2024 07:39
@Drofseh
Copy link
Contributor Author

Drofseh commented May 27, 2024

Converted to draft because ace_cargo_fnc_unloadItem is always returning false when vehicle is moving.
It checks EFUNC(common,findUnloadPosition), but does so without the param to skip the stability check.
Will work on it more later this week.

@Drofseh Drofseh marked this pull request as ready for review May 31, 2024 06:59
Copy link
Contributor

@johnb432 johnb432 left a comment

Choose a reason for hiding this comment

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

Imo it might be better to replace Killed with Destroyed, but on the other hand it might cause confusion and make people think it also applies when the vehicle is deleted. Thoughts?

addons/cargo/functions/fnc_unloadItem.sqf Outdated Show resolved Hide resolved
addons/cargo/functions/fnc_unloadItem.sqf Outdated Show resolved Hide resolved
addons/cargo/XEH_postInit.sqf Show resolved Hide resolved
addons/cargo/XEH_postInit.sqf Outdated Show resolved Hide resolved
addons/cargo/stringtable.xml Outdated Show resolved Hide resolved
addons/cargo/functions/fnc_handleDestroyed.sqf Outdated Show resolved Hide resolved
@Drofseh
Copy link
Contributor Author

Drofseh commented May 31, 2024

Imo it might be better to replace Killed with Destroyed, but on the other hand it might cause confusion and make people think it also applies when the vehicle is deleted. Thoughts?

I prefer Killed for that reason

Copy link
Contributor

@johnb432 johnb432 left a comment

Choose a reason for hiding this comment

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

Seems to work ok. It's a bit unsettling seeing all the cargo be unloaded at once, but I'm not sure if adding a delay between unloading items would help with that perception.

@Drofseh
Copy link
Contributor Author

Drofseh commented Jun 1, 2024

Seems to work ok. It's a bit unsettling seeing all the cargo be unloaded at once, but I'm not sure if adding a delay between unloading items would help with that perception.

I like to think of it as the vehicle exploding blowing them all out of it lol

it would be nice it was a little smoother, but not sure much can be done about it

@johnb432 johnb432 self-requested a review June 1, 2024 17:39
Copy link
Contributor

@johnb432 johnb432 left a comment

Choose a reason for hiding this comment

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

  • Explosion pattern is not random enough imo. Most items are thrown towards the front and rear.
  • Torque is applied on the wrong axis when items are fly to the side.
  • The larger items in the test script don't move, when I feel they should.
  • I'm not sure things such as ammo boxes and fuel canisters should be able to survive, imo ammo boxes should cook off and fuel canister explode/burn.

I used this test script:

_truck = createVehicle ["B_Truck_01_box_F", (getPos player) vectorAdd (player vectorModelToWorld [0, 10, 1]), [], 0, ""];

_objects = [];

{
    for "_index" from 1 to (_x select 1) do {
        private _object = createVehicle [_x select 0, [0, 0, 0], [], 0, ""];

        [_object, _truck, true] call ace_cargo_fnc_loadItem;

        _objects pushBack _object;
    };
} forEach [["FlexibleTank_01_forest_F", 2], ["ACE_Wheel", 10], ["ACE_Track", 10], ["ACE_Box_82mm_Mo_Combo", 1], ["CargoNet_01_box_F", 1]];

_truck setVelocity [0, 0, 0];

[{
    params ["_truck", "_objects"];

    (getAssignedCuratorLogic player) addCuratorEditableObjects [_objects, true]; 

    _truck setDamage 1;
}, [_truck, _objects], 1] call CBA_fnc_waitAndExecute;

@Drofseh
Copy link
Contributor Author

Drofseh commented Jun 4, 2024

  • Explosion pattern is not random enough imo. Most items are thrown towards the front and rear.
  • Torque is applied on the wrong axis when items are fly to the side.
  • The larger items in the test script don't move, when I feel they should.
  • I'm not sure things such as ammo boxes and fuel canisters should be able to survive, imo ammo boxes should cook off and fuel canister explode/burn.

I'm not sure what you mean by "explosion pattern" the unload position is controlled entirely by the FUNC(unloadItem), and the cargo shouldn't get any velocity unless the vehicle was moving, in which case it's always less than the velocity of the vehicle.

I added the torque to just give it a little motion. I'm not sure how to take the direction and velocity of the vehicle and then get torque to be applied in that same direction on the cargo. If you want to add that I'm more than happy to accept it.

I don't want to deliberately damage or destroy cargo regardless of contents; there's little point in having it unload just to kill it vs having it be deleted as it was previously doing.

@johnb432
Copy link
Contributor

johnb432 commented Jun 4, 2024

I'm not sure what you mean by "explosion pattern" the unload position is controlled entirely by the FUNC(unloadItem), and the cargo shouldn't get any velocity unless the vehicle was moving, in which case it's always less than the velocity of the vehicle.

By "explosion pattern" I meant the objects flying in random directions from the vehicle, regardless of where they are unloaded.
If you run the test script, the tracks will be yeeted quite some ways, but mostly towards the front and rear (I assume it's because they have mass 0 and therefore the applied torque has a very noticeable effect). The other objects usually just fall over or maybe do a couple of turns before coming to a rest, but they very often fall/roll towards the front, no randomness in the direction.

Maybe my expectations are wrong: Are the unloaded objects supposed to fly away or remain on the ground and roll/fall over? I initially thought it was the prior, but now I'm guessing you were aiming more towards the latter.

[...] I'm not sure how to take the direction and velocity of the vehicle and then get torque to be applied in that same direction on the cargo. If you want to add that I'm more than happy to accept it.

I haven't tested my idea yet, but it would be to wait for the object to be unloaded, then get the vector between the object's center and the vehicle's. That direction vector would be the basis for generating velocity and torque. The vehicle's velocity would then be added to the generated velocity of the object.
I want to implement myself, but it might be a while before I get around to it.

I don't want to deliberately damage or destroy cargo regardless of contents; there's little point in having it unload just to kill it vs having it be deleted as it was previously doing.

For fuel containers I agree, we could kill them inside the vehicle, but I disagree for ammo boxes, as we have cookoff that handles ammo box cooking-off.
For that, we'd be better off waiting for #9758 to be merged (I'll be working on it soonTM), but I can implement the described behaviour later in another PR.

@Drofseh Drofseh marked this pull request as draft June 28, 2024 07:09
@Drofseh
Copy link
Contributor Author

Drofseh commented Jun 28, 2024

My work has turned into a shitshow and I won't be able to work on this for a while.

@johnb432
Copy link
Contributor

johnb432 commented Jun 28, 2024

My work has turned into a shitshow and I won't be able to work on this for a while.

I've been planning on pushing my suggestion for a while now, finally got around to doing it. Really unfortunate timing, I was hoping you would be able to take a look at the proposed changes soon, but we can easily postpone this PR after 3.18.0.

For fuel containers I agree, we could kill them inside the vehicle, but I disagree for ammo boxes, as we have cookoff that handles ammo box cooking-off.
For that, we'd be better off waiting for #9758 to be merged (I'll be working on it soonTM), but I can implement the described behaviour later in another PR.

I also pushed code that would address this in b9531b0.

Feedback in general is needed and welcome.

@Drofseh
Copy link
Contributor Author

Drofseh commented Jun 28, 2024

My work has turned into a shitshow and I won't be able to work on this for a while.

Really unfortunate timing,

Yeah, I work with a small team of 5 people and 3 of them have put in their resignations lol
All for separate and sensible reasons (moving, other opportunity, etc), it just really sucks having it happen all at once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants