2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-04-05 19:08:55 +00:00
|
|
|
/*
|
|
|
|
* Author: Ruthberg
|
2019-09-28 21:03:55 +00:00
|
|
|
* Initializes the advanced ballistics extension with terrain data
|
2015-04-05 19:08:55 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2015-08-05 03:01:30 +00:00
|
|
|
* None
|
2015-04-05 19:08:55 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2015-08-05 03:01:30 +00:00
|
|
|
* None
|
2015-04-05 19:08:55 +00:00
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [] call ace_advanced_ballistics_fnc_initializeTerrainExtension
|
|
|
|
*
|
2015-04-05 19:08:55 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2015-04-13 10:56:18 +00:00
|
|
|
if (!hasInterface) exitWith {};
|
2015-05-01 22:36:23 +00:00
|
|
|
if (!GVAR(enabled)) exitWith {};
|
2015-04-12 14:10:45 +00:00
|
|
|
|
2017-11-17 19:00:57 +00:00
|
|
|
private _initStartTime = diag_tickTime;
|
2023-09-12 18:04:06 +00:00
|
|
|
private _mapSize = worldSize;
|
2015-04-11 16:18:38 +00:00
|
|
|
|
|
|
|
if (("ace_advanced_ballistics" callExtension format["init:%1:%2", worldName, _mapSize]) == "Terrain already initialized") exitWith {
|
2024-02-05 17:04:24 +00:00
|
|
|
INFO_1("Terrain already initialized [world: %1]",worldName);
|
2015-08-05 16:33:28 +00:00
|
|
|
#ifdef DEBUG_MODE_FULL
|
2015-04-11 16:18:38 +00:00
|
|
|
systemChat "AdvancedBallistics: Terrain already initialized";
|
2016-03-24 17:23:48 +00:00
|
|
|
#endif
|
2015-04-11 16:18:38 +00:00
|
|
|
};
|
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _mapGrids = ceil(_mapSize / 50) + 1;
|
|
|
|
private _gridCells = _mapGrids * _mapGrids;
|
2015-04-11 16:18:38 +00:00
|
|
|
|
|
|
|
GVAR(currentGrid) = 0;
|
|
|
|
|
2024-02-05 17:04:24 +00:00
|
|
|
INFO_2("Starting Terrain Extension [cells: %1] [world: %2]",_gridCells,worldName);
|
2016-09-18 20:00:34 +00:00
|
|
|
|
2015-04-11 16:18:38 +00:00
|
|
|
[{
|
2015-08-04 22:32:48 +00:00
|
|
|
params ["_args","_idPFH"];
|
|
|
|
_args params ["_mapGrids", "_gridCells", "_initStartTime"];
|
|
|
|
|
2015-04-11 16:18:38 +00:00
|
|
|
if (GVAR(currentGrid) >= _gridCells) exitWith {
|
2024-02-05 17:04:24 +00:00
|
|
|
INFO_2("Finished terrain initialization in %1 seconds [world: %2]",(diag_tickTime - _initStartTime) toFixed 2,worldName);
|
2015-08-05 16:33:28 +00:00
|
|
|
#ifdef DEBUG_MODE_FULL
|
2017-11-17 19:00:57 +00:00
|
|
|
systemChat format["AdvancedBallistics: Finished terrain initialization in %1 seconds", (diag_tickTime - _initStartTime) toFixed 2];
|
2015-08-05 16:33:28 +00:00
|
|
|
#endif
|
2015-11-30 15:45:20 +00:00
|
|
|
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
2015-04-07 19:27:04 +00:00
|
|
|
};
|
2015-08-04 22:32:48 +00:00
|
|
|
|
2015-04-11 16:18:38 +00:00
|
|
|
for "_i" from 1 to 50 do {
|
2017-10-10 14:39:59 +00:00
|
|
|
private _x = floor(GVAR(currentGrid) / _mapGrids) * 50;
|
|
|
|
private _y = (GVAR(currentGrid) - floor(GVAR(currentGrid) / _mapGrids) * _mapGrids) * 50;
|
|
|
|
private _gridCenter = [_x + 25, _y + 25];
|
|
|
|
private _gridHeight = round(getTerrainHeightASL _gridCenter);
|
|
|
|
private _gridNumObjects = count (_gridCenter nearObjects ["Building", 50]);
|
2024-02-04 17:50:24 +00:00
|
|
|
private _gridSurfaceIsWater = parseNumber (surfaceIsWater _gridCenter);
|
2015-04-11 16:18:38 +00:00
|
|
|
"ace_advanced_ballistics" callExtension format["set:%1:%2:%3", _gridHeight, _gridNumObjects, _gridSurfaceIsWater];
|
|
|
|
GVAR(currentGrid) = GVAR(currentGrid) + 1;
|
|
|
|
if (GVAR(currentGrid) >= _gridCells) exitWith {};
|
2015-04-07 19:27:04 +00:00
|
|
|
};
|
2015-08-04 22:32:48 +00:00
|
|
|
|
2015-04-11 16:18:38 +00:00
|
|
|
}, 0, [_mapGrids, _gridCells, _initStartTime]] call CBA_fnc_addPerFrameHandler
|