Give more randomness for throwing objects away from destroyed vehicle

This commit is contained in:
johnb432 2024-06-28 09:17:09 +02:00
parent ce9fadc366
commit 3d78aa2c98
2 changed files with 12 additions and 4 deletions

View File

@ -38,11 +38,18 @@
[QGVAR(unloadedCargoOnKilled), {
params ["_item", "_vehicle"];
private _velocity = velocity _vehicle apply {_x / CARGO_TUMBLE_VELOCITY_DIVISOR};
private _torque = _vehicle vectorModelToWorld [random CARGO_TUMBLE_TORQUE, 0, 0];
_item setVelocity _velocity;
_item addTorque _torque;
// Get direction from vehicle to item, so that item is thrown away from vehicle
private _vectorDir = (getPosWorld _vehicle) vectorFromTo (getPosWorld _item);
// Give some z
_vectorDir set [2, random [0.5, 0.75, 1]];
// Add some randomness to resulting velocity
_vectorDir = (_vectorDir vectorMultiply random CARGO_TUMBLE_RANDOM_MUL) vectorAdd (velocity _vehicle);
_item setVelocity _vectorDir;
_item addTorque [random CARGO_TUMBLE_TORQUE, random CARGO_TUMBLE_TORQUE, random CARGO_TUMBLE_TORQUE];
}] call CBA_fnc_addEventHandler;
// Direction must be set before setting position according to wiki

View File

@ -22,4 +22,5 @@
#define CARGO_TUMBLE_VELOCITY_DIVISOR (random [1, 2, 3])
#define CARGO_TUMBLE_RANDOM_MUL 8
#define CARGO_TUMBLE_TORQUE 500