Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- disableSerialization;
- showCinemaBorder false;
- private _vehicleCount = 10;
- private _vehicleList = [
- "CUP_O_T72_SLA",
- "CUP_O_T90_RU",
- "CUP_O_ZSU23_SLA",
- "CUP_O_BRDM2_CHDKZ",
- "CUP_O_BTR40_MG_TKM",
- "CUP_O_BTR80A_GREEN_RU",
- "CUP_O_UAZ_AA_RU",
- "CUP_O_Ural_ZU23_RU"
- ];
- // === WEATHER FUNCTION ===
- fnc_changeWeatherAndTime = {
- private _hour = floor (random 24);
- private _minute = floor (random 60);
- private _overcast = random 1;
- private _rain = random 0.5;
- private _fog = random 0.3;
- private _windX = random 8;
- private _windY = random 8;
- setDate [2035, 6, 20, _hour, _minute];
- 0 setOvercast _overcast;
- 0 setRain _rain;
- 0 setFog _fog;
- setWind [_windX, _windY, true];
- forceWeatherChange;
- private _msg = format [
- "[ENV]\nTime: %1:%2\nOvercast: %3\nRain: %4\nFog: %5\nWind: [%6, %7]",
- _hour,
- if (_minute < 10) then {"0" + str _minute} else {str _minute},
- _overcast toFixed 2,
- _rain toFixed 2,
- _fog toFixed 2,
- _windX toFixed 1,
- _windY toFixed 1
- ];
- hint _msg;
- diag_log _msg;
- };
- // === CAMERA TARGET FIX ===
- fnc_getModelCenterTarget = {
- params ["_vehicle"];
- private _bbox = boundingBoxReal _vehicle;
- private _min = _bbox select 0;
- private _max = _bbox select 1;
- private _centerModel = [
- ((_min select 0) + (_max select 0)) / 2,
- ((_min select 1) + (_max select 1)) / 2,
- ((_min select 2) + (_max select 2)) / 2
- ];
- _vehicle modelToWorldVisual _centerModel
- };
- // === BOUNDING BOX FUNCTION ===
- fnc_getBoundingBoxWireframe = {
- params ["_vehicle"];
- if (isNull _vehicle) exitWith { diag_log "[BBOX_FAIL] Vehicle is null"; [] };
- private _bbox = boundingBoxReal _vehicle;
- if ((count _bbox) < 2) exitWith { diag_log "[BBOX_FAIL] Invalid bounding box"; [] };
- private _min = _bbox select 0;
- private _max = _bbox select 1;
- // Shrink factor for the bounding box (set to 0.5 to shrink by half)
- private _shrink = 0.5; // Shrinking the bounding box by half
- private _center = [
- ((_min select 0) + (_max select 0)) / 2,
- ((_min select 1) + (_max select 1)) / 2
- ];
- private _scaleCorner = {
- params ["_x", "_y", "_z", "_center", "_shrink"];
- private _cx = _center select 0;
- private _cy = _center select 1;
- private _scaledX = _cx + ((_x - _cx) * _shrink);
- private _scaledY = _cy + ((_y - _cy) * _shrink);
- [_scaledX, _scaledY, _z]
- };
- private _cornersModel = [
- [_min select 0, _min select 1, _min select 2],
- [_max select 0, _min select 1, _min select 2],
- [_max select 0, _max select 1, _min select 2],
- [_min select 0, _max select 1, _min select 2],
- [_min select 0, _min select 1, _max select 2],
- [_max select 0, _min select 1, _max select 2],
- [_max select 0, _max select 1, _max select 2],
- [_min select 0, _max select 1, _max select 2]
- ];
- private _corners2D = [];
- private _abort = false;
- {
- private _scaled = [_x select 0, _x select 1, _x select 2, _center, _shrink] call _scaleCorner;
- private _world = _vehicle modelToWorldVisual _scaled;
- private _screen = worldToScreen _world;
- if (!isNil "_screen" && {count _screen == 2}) then {
- _corners2D pushBack _screen;
- } else {
- _abort = true;
- };
- } forEach _cornersModel;
- if (_abort || (count _corners2D != 8)) exitWith {
- diag_log "[BBOX_FAIL] Screen projection failed.";
- []
- };
- diag_log format ["[BBOX3D] %1 | %2", typeOf _vehicle, _corners2D];
- _corners2D
- };
- // === SPAWN VEHICLE FUNCTION ===
- _spawnVehicle = {
- private ["_vehicleType", "_spawnPos", "_vehicle"];
- _vehicleType = _this select 0;
- _spawnPos = getPos player;
- _randomDistance = 500 + random 500;
- _randomAngle = random 360;
- // Adjust spawn position using the offset
- _spawnPos set [0, (_spawnPos select 0) + (_randomDistance * cos _randomAngle)];
- _spawnPos set [1, (_spawnPos select 1) + (_randomDistance * sin _randomAngle)];
- // Ensure vehicle spawns at a valid height above the terrain (avoiding water)
- private _z = getTerrainHeightASL [_spawnPos select 0, _spawnPos select 1];
- _spawnPos set [2, _z + 2]; // Ensure the vehicle spawns slightly above the terrain (increase +2 for higher positioning)
- // If the Z position is too low (e.g., in water), set a minimum safe height
- if (_spawnPos select 2 < 2) then {
- _spawnPos set [2, 2]; // Ensure vehicle spawns at least 2 meters above sea level
- };
- _vehicle = _vehicleType createVehicle _spawnPos;
- if (isNull _vehicle) then {
- hint "Fehler beim Spawnen des Fahrzeugs!";
- } else {
- hint format ["Fahrzeug gespawnt: %1", _vehicleType];
- };
- _vehicle
- };
- // === MAIN LOOP ===
- while {true} do {
- sleep 1;
- call fnc_changeWeatherAndTime;
- hint "Waiting 15 seconds to adapt brightness...";
- sleep 3;
- hint format ["Spawning %1 vehicles...", _vehicleCount];
- for "_i" from 1 to _vehicleCount do {
- private _vehicleType = selectRandom _vehicleList;
- hint format ["Spawning vehicle %1/%2: %3", _i, _vehicleCount, _vehicleType];
- private _playerPos = getPosATL player;
- private _angle = random 360;
- private _distance = 300 + random 300;
- private _x = (_playerPos select 0) + (_distance * cos _angle);
- private _y = (_playerPos select 1) + (_distance * sin _angle);
- private _z = getTerrainHeightASL [_x, _y];
- private _spawnPos = [_x, _y, _z + 0.5];
- private _vehicle = createVehicle [_vehicleType, _spawnPos, [], 0, "NONE"];
- _vehicle setDir (random 360);
- _vehicle setPosASL _spawnPos;
- _vehicle allowDamage false;
- _vehicle enableSimulation true;
- sleep 1;
- diag_log format ["[SPAWNED] %1 at [%2,%3,%4]", _vehicleType, _x, _y, _z];
- private _vehiclePos = getPosATL _vehicle;
- private _camAngle = random 360;
- private _camDist = 30 + random 40;
- private _camHeight = 10 + random 20;
- private _camX = (_vehiclePos select 0) + (_camDist * cos _camAngle);
- private _camY = (_vehiclePos select 1) + (_camDist * sin _camAngle);
- private _camZ = (_vehiclePos select 2) + _camHeight;
- private _camera = "camera" camCreate [_camX, _camY, _camZ];
- private _lookAt = [_vehicle] call fnc_getModelCenterTarget;
- _camera camSetTarget _lookAt;
- _camera camSetFov (0.7 + random 0.3);
- _camera camCommit 0;
- _camera cameraEffect ["INTERNAL", "BACK"];
- diag_log format ["[CAMERA] %1 | Pos: [%2,%3,%4] → Target: %5", _vehicleType, _camX, _camY, _camZ, _lookAt];
- sleep 2;
- private _bbox = [_vehicle] call fnc_getBoundingBoxWireframe;
- sleep 3;
- if (!isNull _camera) then {
- _camera cameraEffect ["TERMINATE", "BACK"];
- camDestroy _camera;
- };
- if (!isNull _vehicle) then {
- deleteVehicle _vehicle;
- };
- sleep 1;
- };
- titleText ["", "BLACK IN", 1];
- hint "Cycle complete. Restarting...";
- sleep 3;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement