Search the Community
Showing results for tags 'mass replacement'.
Found 2 results
-
Since I got the habit of placing tons of stuff in eden to get terrains to look better for my missions I ended up making a script that makes it much easier are a lot faster. The replaceobjects.sqf replaces whatever (even billboards in the fallujah map) and allows for tuning orientation, probability, randomisation, etc. I am satisfied with the results, but my lack of knowledge does not allow any further improvement. So I am asking for help to optimize the script and make it run in less time. I have no coding skills whatsoever so is highly probable that there are obviously better ways of doing stuff than the ones I used. This script makes it easy to mass replace buildings and other stuff. Here's two pictures of what it can do in two of my favourite maps: fallujah and diyala: This is my script: /* Replaceobjects.sqf by b3lx. This script replaces terrain objects randomly chosen out of a defined array. Good for batch changes in terrains like replacing tree types or houses. The following arguments have to be passed to the script - _pos = the center position of the area to include. - _radius = limits the max search range - _type = (optional) lists the types of objects the script should filter for. if empty it uses classnames passed through _oldobjlist - _oldobjlist = (optional) object classes to replace; only used if _type is empty - _newobjlist = object classes for replacement - _customdir = (optional) leave empty ("") or define aditional rotation angle for new objects. - _hidden = (optional) if true replacing includes hidden objects, default is false; - _percent = (optional) random percentage of matching object to replace, default is 1; - _sizefilter = (optional) array that defines minimum and maximum size values for object to be filtered. Useful when types or classnames don't work or if you want to use diferent replacements for different sized objects. Use [0,100] if you don't want to filter. - _code = (optional) custom code to be executed on each object, default is {}; - _altreplacer = classes to use when terrain slope is greater than 18 degrees (check isflatempty below). IF empty or false its not used. If true uses classes defined below in _altreplacerdefaul, otherwise use an array with desired classes. - _debug = (optional) markers for each replacement and message with number of replacements. Example 1: Replaces all "Land_House_L_6_EP1" houses with two RSO buildings with disabled simulation and rotated 180 degrees, and places debug markers. [player,200,[],["Land_House_L_6_EP1"],["rso_h21","rso_hut3"],180,true,1,[0,100], {_this disableSimulation true},false,true] execVM "replaceobjects.sqf"; Example 2: replaces 20% of houses around player between 0 and 10 size with two RSO buildings or rubble if the terrain is sloped [[worldsize select 0, worldsize select 1], (worldsize select 0) / 2,["house"],[],["rso_h21","rso_hut3"],0,true,0.2,[0,10], {},["Land_Fortress_01_bricks_v1_F"]] execVM "replaceobjects.sqf"; Example 3: replaces all houses around player with two RSO buildings [[player, worldsize,["house"],[],["rso_h21","rso_hut3"]] execVM "replaceobjects.sqf"; Example 4: replaces all billboards in fallujah by empty ones [replacer, radius,[],[], ["Land_Billboard_F"],0,true,1,[6.00263,6.00264]] execVM "replaceobjects.sqf"; List of types that can be filtered by, according to BIS: "TREE", "SMALL TREE", "BUSH", "object", "HOUSE", "FOREST BORDER", "FOREST TRIANGLE", "FOREST SQUARE", "CHURCH", "CHAPEL", "CROSS", "BUNKER", "FORTRESS", "FOUNTAIN", "VIEW-TOWER", "LIGHTHOUSE", "QUAY", "FUELSTATION", "HOSPITAL", "FENCE", "WALL", "HIDE","BUSSTOP", "ROAD", "FOREST", "TRANSMITTER", "STACK", "RUIN", "TOURISM", "WATERTOWER", "TRACK", "MAIN ROAD","ROCK", "ROCKS", "POWER LINES", "RAILWAY", "POWERSOLAR", "POWERWAVE", "POWERWIND", "SHIPWRECK", "TRAIL" */ //shuffle array function from killzonekid KK_fnc_arrayShuffle = { private "_cnt"; _cnt = count _this; for "_i" from 1 to _cnt do { _this pushBack (_this deleteAt floor random _cnt); if _debug then {systemchat format ["%1 randomized", _i]}; }; _this }; private ["_objArray","_filteredArray","_altreplacerdefault","_slctrl","_pos","_radius","_type","_oldobjlist","_newobjlist","_customdir","_hidden","_percent","_sizefilter","_code","_altreplacer","_debug"]; params ["_pos","_radius","_type","_oldobjlist","_newobjlist","_customdir","_hidden","_percent","_sizefilter","_code","_altreplacer","_debug"]; //finds objects according to criteria and puts them in an array _objArray = []; if (count _oldobjlist == 0) then { _objArray = nearestTerrainObjects [_pos, _type, _radius, false, true]; } else { _fullarray = nearestTerrainObjects [_pos, _type, _radius, false, true]; {if (typeOf _x in _oldobjlist) then {_objArray pushback _x}} forEach _fullarray; }; //filters array according to min and max size defined in _sizefilter if (isNil "_filteredArray") then {_filteredArray = []}; if (!isNil "_sizefilter") then { _sizeA = _sizefilter select 0; _sizeB = _sizefilter select 1; {if (((boundingboxREAL _x select 1 select 0) - (boundingboxREAL _x select 0 select 0) > _sizeA) && ((boundingboxREAL _x select 1 select 0) - (boundingboxREAL _x select 0 select 0) < _sizeB)) then { _filteredArray pushback _x}} forEach _objArray; } else { _filteredArray = _objArray; }; sleep 1; //sets default variables if undefined by user if (isNil "_customdir") then {_customdir = 0}; if (isNil "_hidden") then {_hidden = false}; if (isNil "_percent") then {_percent = 1}; if (isNil "_debug") then {_debug = false}; if (isNil "_code") then {_code = {}}; //houses to use if terrain slope is too great for specified ones. default values are used if _altreplacer is set to true _altreplacerdefault = ["Land_Addon_02_b_white_ruins_F"]; _altreplacer = true; if (isNil "_altreplacer" || !_altreplacer) then {_slctrl = false} else { _slctrl = true; if _altreplacer then {_altreplacer = _altreplacerdefault}; }; //randomizes the array using KK function _filteredArray call KK_fnc_arrayShuffle; if _debug then {systemchat "shuffled"}; reverse _filteredArray; sleep 1; _filteredArray resize (floor ((count _filteredArray) * _percent)); _rplcount = 0; //function that replaces the object _replaceobject = { params ["_oldobject", "_replacer"]; private ["_newobject"]; _position = getPosATL _oldobject; _direction = direction _oldobject; _oldobject hideObjectGlobal true; //checks if slope filter is used and selects from which array of objects (normal or for sloped terrain) to create new object if (!_slctrl) then { _newobject = _replacer createVehicle _position; } else { if (position _oldobject isFlatEmpty [-1, -1, 0.4, 1, 0, false] isEqualto []) then { _newobject = (selectRandom _altreplacer) createVehicle _position; _customdir = 0; } else { _newobject = _replacer createVehicle _position; }; }; //positions new created object on floor, adding custom direction and vertical orientation _newobject setPosATL [_position select 0, _position select 1, 0]; _newobject setDir _direction + _customdir; _newobject setvectorUp [0,0,1]; _newobject call _code; _rplcount = _rplcount + 1; //places debug markers if debug is on if (_debug) then { _mrk = createMarker [str _rplcount,_position]; _mrk setMarkerShape "ICON"; _mrk setMarkerType "hd_dot"; }; }; //checks if hidden objects are to be replaced and calls replacement function accordingly //sleep 1; if _hidden then { {[_x, (selectRandom _newobjlist)] call _replaceobject} forEach _filteredArray; } else { { if (!(isObjectHidden _x)) then {[_x, (selectRandom _newobjlist)] call _replaceobject} } forEach _filteredArray; }; if _debug then {systemchat format ["script replaced %1 objects", _rplcount]};
-
Terrain Object Replacement Modules Replace or delete massive numbers of terrain objects easily Download: https://steamcommunity.com/sharedfiles/filedetails/?id=2276624333 Check images below for how to use: Explanation: