ACE3/addons/advanced_ballistics/functions/fnc_initializeTerrainExtension.sqf

59 lines
2.0 KiB
Plaintext
Raw Normal View History

2015-04-05 19:08:55 +00:00
/*
* Author: Ruthberg
* Initializes the advanced ballistics dll extension with terrain data
*
* Arguments:
* None
2015-04-05 19:08:55 +00:00
*
* Return Value:
* None
2015-04-05 19:08:55 +00:00
*
* Public: No
*/
#include "script_component.hpp"
if (!hasInterface) exitWith {};
if (!GVAR(enabled)) exitWith {};
if (!GVAR(extensionAvailable)) exitWith {};
private ["_initStartTime", "_mapSize", "_mapGrids", "_gridCells", "_x", "_y", "_gridCenter", "_gridHeight", "_gridNumObjects", "_gridSurfaceIsWater"];
_initStartTime = ACE_time;
_mapSize = getNumber (configFile >> "CfgWorlds" >> worldName >> "MapSize");
if (("ace_advanced_ballistics" callExtension format["init:%1:%2", worldName, _mapSize]) == "Terrain already initialized") exitWith {
2015-08-05 16:33:28 +00:00
#ifdef DEBUG_MODE_FULL
systemChat "AdvancedBallistics: Terrain already initialized";
2015-08-05 16:33:28 +00:00
#endIf
};
_mapGrids = ceil(_mapSize / 50) + 1;
_gridCells = _mapGrids * _mapGrids;
GVAR(currentGrid) = 0;
[{
params ["_args","_idPFH"];
_args params ["_mapGrids", "_gridCells", "_initStartTime"];
if (GVAR(currentGrid) >= _gridCells) exitWith {
2015-08-05 16:33:28 +00:00
#ifdef DEBUG_MODE_FULL
systemChat format["AdvancedBallistics: Finished terrain initialization in %1 seconds", ceil(ACE_time - _initStartTime)];
2015-08-05 16:33:28 +00:00
#endif
[_idPFH] call cba_fnc_removePerFrameHandler;
2015-04-07 19:27:04 +00:00
};
for "_i" from 1 to 50 do {
_x = floor(GVAR(currentGrid) / _mapGrids) * 50;
_y = (GVAR(currentGrid) - floor(GVAR(currentGrid) / _mapGrids) * _mapGrids) * 50;
_gridCenter = [_x + 25, _y + 25];
_gridHeight = round(getTerrainHeightASL _gridCenter);
_gridNumObjects = count (_gridCenter nearObjects ["Building", 50]);
_gridSurfaceIsWater = if (surfaceIsWater _gridCenter) then {1} else {0};
"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
};
}, 0, [_mapGrids, _gridCells, _initStartTime]] call CBA_fnc_addPerFrameHandler