Skip to content

Commit

Permalink
Remove trees precisely where the vehicles are
Browse files Browse the repository at this point in the history
  • Loading branch information
cerebral-314 committed Feb 5, 2025
1 parent 962534a commit 590dc67
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 11 deletions.
2 changes: 2 additions & 0 deletions mission/config/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ class CfgFunctions
// old not used
class sites_create_tunnel {};
class sites_create_camp {};

class sites_create_objects_with_tree_removal {};
}

// creating individual sites using main sites code and compositions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,5 @@ vn_mf_aa_compositions = [
];

private _randomAngle = [0,360] call BIS_fnc_randomInt;

private _aaObjects = [_position, _randomAngle, selectRandom vn_mf_aa_compositions] call BIS_fnc_objectsMapper;

private _aaObjects = [_position, _randomAngle, selectRandom vn_mf_aa_compositions] call vn_mf_fnc_sites_create_objects_with_tree_removal;
_aaObjects
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,6 @@ vn_mf_camp_site_compositions_v3 = [


private _randAngle = [1, 360] call BIS_fnc_randomInt;
private _site_objs = [_position, _randAngle, selectRandom vn_mf_camp_site_compositions_v3, 0] call BIS_fnc_objectsMapper;
private _site_objs = [_position, _randAngle, selectRandom vn_mf_camp_site_compositions_v3, 0] call vn_mf_fnc_sites_create_objects_with_tree_removal;

_site_objs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ if(toLower(worldName) in ["cam_lao_nam", "vn_khe_sanh"])then {
["Land_vn_t_ficusb1s_f",[20.4448,-24.2627,0],11.6895,1,0,[0,0],"","",false,false]
],
[
["vn_sign_town_d_09",[-1.49121,1.40283,0.904072],90.0001,1,0,[0,-0],"","",false,false],
["Land_vn_sign_town_d_09",[-1.49121,1.40283,0.904072],90.0001,1,0,[0,-0],"","",false,false],
["vn_o_nva_static_dshkm_low_01",[3.15723,2.77979,-0.0596199],270,1,0,[0,0],"","",false,false],
["Land_vn_pavn_weapons_stack2",[-5.32129,2.56689,0.00285816],0,1,0,[0,0],"","",false,false],
["Land_vn_controltower_01_f",[1.5166,-0.0322266,0],0,1,0,[0,0],"","",false,false],
Expand Down Expand Up @@ -569,7 +569,7 @@ if(toLower(worldName) in ["cam_lao_nam", "vn_khe_sanh"])then {
//};

private _randomAngle = [0,360] call BIS_fnc_randomInt;
private _factoryObjects = [_position, _randomAngle, selectRandom vn_mf_factory_compositions, 0] call BIS_fnc_objectsMapper;
private _factoryObjects = [_position, _randomAngle, selectRandom vn_mf_factory_compositions, 0] call vn_mf_fnc_sites_create_objects_with_tree_removal;
{
if (_x isKindOf "GRAD_envelope_giant") then {
_x setVectorUp (surfaceNormal getPos _x);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ vn_mf_sites_compositions_fuel = [
private _selectedHMap = selectRandom vn_mf_sites_compositions_fuel;

private _randAngle = [1, 360] call BIS_fnc_randomInt;
private _site_objs = [_position, _randAngle, _selectedHMap get "Composition", 0] call BIS_fnc_objectsMapper;
private _site_objs = [_position, _randAngle, _selectedHMap get "Composition", 0] call vn_mf_fnc_sites_create_objects_with_tree_removal;

_site_objs;
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ if(toLower(worldName) in ["cam_lao_nam", "vn_khe_sanh"])then {
//};

private _randomAngle = [0,360] call BIS_fnc_randomInt;
private _hqObjects = [_position, _randomAngle, selectRandom vn_mf_hq_compositions, 0] call BIS_fnc_objectsMapper;
private _hqObjects = [_position, _randomAngle, selectRandom vn_mf_hq_compositions, 0] call vn_mf_fnc_sites_create_objects_with_tree_removal;
{
if (_x isKindOf "GRAD_envelope_giant") then {
_x setVectorUp (surfaceNormal getPos _x);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,5 +613,5 @@ vn_mf_arty_compositions_v3 = [
];

private _randAngle = [1, 360] call BIS_fnc_randomInt;
private _site_objs = [_position, _randAngle, selectRandom vn_mf_arty_compositions_v3, 0] call BIS_fnc_objectsMapper;
private _site_objs = [_position, _randAngle, selectRandom vn_mf_arty_compositions_v3, 0] call vn_mf_fnc_sites_create_objects_with_tree_removal;
_site_objs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
File: fn_sites_create_objects_with_tree_removal.sqf
Author: Cerebral
Public: No
Description:
Creates objects using BIS_fnc_objectsMapper and removes trees within their bounding box area
Parameter(s):
_position - Position to create objects at [Position]
_angle - Angle to rotate composition [Number]
_objects - Array of objects to create [Array]
_badChance - Random chance to not create objects (optional, default 0) [Number]
Returns:
Created objects [Array]
Example(s):
[_pos, 0, _objects] call vn_mf_fnc_sites_create_objects_with_tree_removal
*/

params [
"_position",
"_angle",
"_objects",
["_badChance", 0]
];

// Create the objects using BIS_fnc_objectsMapper
private _createdObjects = [_position, _angle, _objects, _badChance] call BIS_fnc_objectsMapper;

// Get all trees in a large radius around the position
private _nearbyTrees = nearestTerrainObjects [_position, ["TREE", "SMALL TREE", "BUSH"], 50, false, true];

// Process each created object
{
private _object = _x;

// Get the object's bounding box
private _boundingBox = boundingBoxReal _object;
private _boundingBoxCenter = boundingCenter _object;

// Calculate the maximum radius of the bounding box
private _xSize = abs(((_boundingBox select 1) select 0) - ((_boundingBox select 0) select 0)) / 2;
private _ySize = abs(((_boundingBox select 1) select 1) - ((_boundingBox select 0) select 1)) / 2;
private _maxRadius = (_xSize max _ySize) * 1.2; // Add 20% margin

// Remove trees within the object's footprint
{
if (_x distance _object < _maxRadius) then {
_x hideObjectGlobal true;
};
} forEach _nearbyTrees;

} forEach _createdObjects;

_createdObjects
4 changes: 2 additions & 2 deletions mission/functions/systems/sites/fn_sites_generate.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
params ["_zone"];

private _zoneData = [_zone] call vn_mf_fnc_zones_load_zone;
private _allTerrainObjects = ["TREE", "HIDE", "WATERTOWER", "BUSH", "SMALL TREE", "ROCK", "ROCKS", "STACK", "FOUNTAIN", "RUIN", "TOURISM", "CHURCH", "CHAPEL", "BUILDING", "HOUSE", "FUELSTATION", "HOSPITAL", "FORTRESS", "BUNKER", "FENCE", "WALL"];
private _unnaturalObjects = ["ROCK", "ROCKS", "HIDE", "WATERTOWER", "STACK", "FOUNTAIN", "RUIN", "TOURISM", "CHURCH", "CHAPEL", "BUILDING", "HOUSE", "FUELSTATION", "HOSPITAL", "FORTRESS", "BUNKER", "FENCE", "WALL"];
private _allTerrainObjects = ["HIDE", "WATERTOWER", "ROCK", "ROCKS", "STACK", "FOUNTAIN", "RUIN", "TOURISM", "CHURCH", "CHAPEL", "BUILDING", "HOUSE", "FUELSTATION", "HOSPITAL", "FORTRESS", "BUNKER", "FENCE", "WALL"];
private _unnaturalObjects = ["ROCK", "ROCKS", "HIDE", "WATERTOWER", "STACK", "FOUNTAIN", "RUIN", "TOURISM", "CHURCH", "CHAPEL", "BUILDING", "HOUSE", "FUELSTATION", "HOSPITAL", "FORTRESS", "BUNKER", "FENCE", "WALL"];
private _center = markerPos (_zoneData select struct_zone_m_marker);
private _size = markerSize (_zoneData select struct_zone_m_marker);
private _sizeX = _size select 0;
Expand Down

0 comments on commit 590dc67

Please sign in to comment.