Skip to content

Instantly share code, notes, and snippets.

@commy2
Last active November 5, 2019 03:09
Show Gist options
  • Save commy2/243c20b6c3147d0a032d8487604c5e20 to your computer and use it in GitHub Desktop.
Save commy2/243c20b6c3147d0a032d8487604c5e20 to your computer and use it in GitHub Desktop.
if (!isServer) exitWith {};
private _dir = 90;
private _position = getPosASL thisTrigger;
_dir = -_dir - 90;
private _direction = [cos _dir, sin _dir, 0];
private _fnc_carpetBomber = {
params ["_position", "_direction"];
private _distance = 3000;
private _height = 200;
private _speed = 200;
private _velocity = _direction vectorMultiply (_speed / 3.6);
private _origin = _position vectorAdd (_direction vectorMultiply -_distance);
_origin set [2, getTerrainHeightASL _position + _height];
private _bomber = createVehicle ["CUP_B_C47_USA", ASLToAGL _origin, [], 0, "FLY"];
createVehicleCrew _bomber;
_bomber setPosASL _origin;
_bomber setVectorDir _direction;
private _dropDistance = 300 + 430/2;
private _fnc_dropBombs = {
params ["_bomber"];
for "_i" from 1 to 48 do {
private _delay = (_i - 1) * random [0.1,0.15,0.25];
[{
params ["_bomber"];
if (!alive _bomber) exitWith {};
private _position = getPosASL _bomber;
private _dir = vectorDir _bomber;
private _up = vectorUp _bomber;
private _lat = _dir vectorCrossProduct _up;
private _velocity = velocity _bomber;
_position = _position vectorAdd (_dir vectorMultiply 0) vectorAdd (_up vectorMultiply -2);
_position = _position vectorAdd (_lat vectorMultiply random [-6, 0, 6]);
private _bomb = "Bo_Mk82" createVehicle [0,0,1E4];
_bomb setPosASL _position;
_bomb setVectorDirAndUp [_dir, _up];
_bomb setVelocity (_velocity vectorMultiply 0.5);
}, _bomber, _delay] call CBA_fnc_waitAndExecute;
};
};
[[_bomber, _velocity], {
[{
params ["_bomber", "_velocity"];
_bomber setVelocity _velocity;
_bomber setVectorDirAndUp [vectorNormalized _velocity, [0,0,1]];
!alive _bomber
}, {}, _this] call CBA_fnc_waitUntilAndExecute;
}] remoteExec ["call", 0, _bomber];
[{
params ["_bomber", "_position", "_dropDistance", "_fnc_dropBombs"];
if (_bomber distance2D _position < _dropDistance) exitWith {
_bomber call _fnc_dropBombs;
true
};
!alive _bomber
}, {}, [_bomber, _position, _dropDistance, _fnc_dropBombs]] call CBA_fnc_waitUntilAndExecute;
[{
params ["_bomber", "_origin", "_distance"];
if (getPosASL _bomber vectorDistance _origin > 2 * _distance) then {
private _group = group _bomber;
private _crew = crew _bomber;
deleteVehicle _bomber;
{deleteVehicle _x} forEach _crew;
deleteGroup _group;
};
!alive _bomber
}, {}, [_bomber, _origin, _distance]] call CBA_fnc_waitUntilAndExecute;
};
[[_position, _direction], _fnc_carpetBomber] remoteExec ["call", 2];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment