-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathfn_sites_generate.sqf
More file actions
82 lines (68 loc) · 2.5 KB
/
Copy pathfn_sites_generate.sqf
File metadata and controls
82 lines (68 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
File: fn_sites_generate.sqf
Author: Savage Game Design
Public: No
Description:
Places new sites down on the map procedurally.
Parameter(s):
_zonesToGenerateIn - Targeted zones in the zoneData format - Array (Optional)
Returns:
None
Example(s):
[] call vn_mf_fnc_sites_generate
*/
params [["_zonesToGenerateIn", 0]];
private _attempts = 3;
//Simple approach for now - surround hostile zones with AA and artillery.
if (_zonesToGenerateIn isEqualType 0) then {
_zonesToGenerateIn = mf_s_zones select {!(_x select struct_zone_m_captured)};
};
private _fnc_noSitesZoneCheck = {
params ["_position"];
vn_mf_markers_blocked_areas findIf {_position inArea _x} != -1
};
private _fnc_findPos = {
params ["_startPos", "_minDist", "_maxDist"];
private _result = _startPos;
for "_i" from 1 to _attempts do
{
_attempt = _startPos getPos [_minDist + random (_maxDist - _minDist), random 360];
if (!surfaceIsWater _attempt && !([_attempt] call _fnc_noSitesZoneCheck)) exitWith {
_result = _attempt;
break;
};
};
_result
};
{
private _zoneData = _x;
private _center = markerPos (_zoneData select struct_zone_m_marker);
private _rawSizes = markerSize (_zoneData select struct_zone_m_marker);
private _sizes = _rawSizes apply {abs _x};
private _sizeMax = selectMax _sizes;
//Create initial AA emplacements
for "_i" from 1 to (1 + ceil random (vn_mf_s_max_aa_per_zone - 1)) do
{
private _pos = [_center, _sizeMax / 4, _sizeMax / 2] call _fnc_findPos;
[_pos] call vn_mf_fnc_sites_create_aa_site;
[_pos, 5] call vn_mf_fnc_sites_hide_terrain_objects_bbox_intersections;
};
//Create initial artillery emplacements
for "_i" from 1 to (1 + ceil random (vn_mf_s_max_artillery_per_zone - 1)) do
{
private _pos = [_center, _sizeMax / 3, _sizeMax] call _fnc_findPos;
[_pos] call vn_mf_fnc_sites_create_artillery_site;
[_pos, 5] call vn_mf_fnc_sites_hide_terrain_objects_bbox_intersections;
};
//Create zone HQ
private _hqPosition = _center;
for "_i" from 0 to 10 do {
private _testPosition = _hqPosition getPos [100, random 360];
_testPosition = (selectBestPlaces [_testPosition, 200, "-(houses + 10 * waterDepth)", 10, 1]) select 0 select 0;
if !(_testPosition isFlatEmpty [0, -1, 0.5, 50, 0] isEqualTo []) exitWith {
_hqPosition = _testPosition + [0];
};
};
[_hqPosition] call vn_mf_fnc_sites_create_hq;
[_pos, 50] call vn_mf_fnc_sites_hide_terrain_objects_bbox_intersections;
} forEach _zonesToGenerateIn;