mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Give more randomness for throwing objects away from destroyed vehicle
This commit is contained in:
parent
ce9fadc366
commit
3d78aa2c98
@ -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
|
||||
|
@ -22,4 +22,5 @@
|
||||
|
||||
#define CARGO_TUMBLE_VELOCITY_DIVISOR (random [1, 2, 3])
|
||||
|
||||
#define CARGO_TUMBLE_RANDOM_MUL 8
|
||||
#define CARGO_TUMBLE_TORQUE 500
|
||||
|
Loading…
Reference in New Issue
Block a user