Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*//
- */// Author : Dmitry Yuri
- /*// Version : Alpha 0.1 (19/11/17)
- *///
- /*//
- *///
- /*//
- */// General information about the hiding process. Known Knowns.
- /*//
- */// * when a building is hidden it can still be found using nearest* commands.
- /*// * Explosives can still damage a hidden building. If the building takes enough damage it will transition to its damaged state.
- */// * The Damaged state of buildings is a different model and will not be hidden if transitioned to.
- /*//
- *///
- // Comments are important and you should always add comments to your code.
- _debug = true;
- _sTime = time;
- // Define some vars
- _MAP_TYPES_BUILDING = ["BUILDING","HOUSE","CHURCH","CHAPEL","FUELSTATION","HOSPITAL","RUIN","BUNKER"];
- _MAP_TYPES_VEGETATION = ["TREE","SMALL TREE","BUSH"];
- _MAP_TYPES_WALL = ["WALL","FENCE"];
- _MAP_TYPES_MISC = ["ROCK","ROCKS","FOREST BORDER","FOREST TRIANGLE","FOREST SQUARE","CROSS","FORTRESS","FOUNTAIN","VIEW-TOWER","LIGHTHOUSE","QUAY","HIDE","BUSSTOP","ROAD","FOREST","TRANSMITTER","STACK","TOURISM","WATERTOWER","TRACK","MAIN ROAD","POWER LINES","RAILWAY","POWERSOLAR","POWERWAVE","POWERWIND","SHIPWRECK","TRAIL"];
- _MAP_TYPES_ALL = (_MAP_TYPES_BUILDING + _MAP_TYPES_VEGETATION + _MAP_TYPES_WALL + _MAP_TYPES_MISC);
- /* DISABLED
- Ideally I want to have multiple triggers that I can use as safe zone designations. But at the moment we are going to stick with one trigger.
- // populate trigger array.
- _triggerArray = [];
- for "_i" from 0 to 100 do
- {
- _trig = call compile format["if (isNil 'playzone_trigger_%1') then {objNull} else {playzone_trigger_%1};",_i];
- if (isNull _trig) exitWith {};
- _triggerArray append [_trig];
- };
- */
- _int = worldSize;
- _num = (ceil (_int / 500));
- _trig = playzone_trigger_0;
- (triggerArea _trig) params ["_sX","_sY"];
- _size = if (_sX > _sY) then {_sX;} else {_sY;};
- for "_xNum" from 0 to _num do
- {
- _xPos = (_xNum * 500);
- for "_yNum" from 0 to (_num / 2) do
- {
- if (_debug) then
- {
- systemChat format["%1 - %2", _xNum, _yNum];
- };
- // If the machine running this code has less than 10 FPS then give them a little break until they get above 10 fps. Even wooden PCs should be able to keep above 10, hopefully.
- waitUntil {if (diag_fps > 10) then {true} else {sleep 0.1; false;}};
- _yPos = (_yNum * 1000);
- // If the x number is even then add 500 to the Y position.
- if ((_xNum%2) == 1) then
- {
- _yPos = (_yPos + 500);
- };
- _pos = [_xPos, _yPos, 0];
- // if (({(_pos distance _x) < 750} count _triggerArray) == 0) then
- // If the position is near the playzone then perform extra checks to make sure the objects are outside the zone.
- if (((_pos distance _trig) - 500) < _size) then
- {
- _objs = nearestTerrainObjects [_pos, _MAP_TYPES_ALL, 500, false, true];
- if ((_pos distance _trig) < (_size - 500)) then {};
- {
- _obj = _x;
- if !(_obj inArea _trig) then
- {
- _x hideObject true;
- };
- } forEach _objs;
- if (_debug) then
- {
- systemChat format["%1 objects found and hidden.", (count _objs)];
- _nme = format["m_%1_%2", _xNum, _yNum];
- _markerstr = createMarkerLocal [_nme, _pos];
- _markerstr setMarkerShapeLocal "ELLIPSE";
- _markerstr setMarkerSizeLocal [500,500];
- _markerstr setMarkerColorLocal "ColorBlue";
- _markerstr setMarkerAlphaLocal 0.5;
- [_markerstr] spawn
- {
- params ["_markerstr"];
- _val = 0.5;
- while {_val > 0} do
- {
- sleep 2;
- _val = _val - 0.05;
- _markerstr setMarkerAlphaLocal _val;
- };
- deleteMarkerLocal _markerstr;
- };
- };
- }
- else
- {
- _objs = nearestTerrainObjects [_pos, _MAP_TYPES_ALL, 500, false, true];
- {
- _x hideObject true;
- } forEach _objs;
- if (_debug) then
- {
- systemChat format["%1 objects found and hidden.", (count _objs)];
- _nme = format["m_%1_%2", _xNum, _yNum];
- _markerstr = createMarkerLocal [_nme, _pos];
- _markerstr setMarkerShapeLocal "ELLIPSE";
- _markerstr setMarkerSizeLocal [500,500];
- _markerstr setMarkerColorLocal "ColorRed";
- _markerstr setMarkerAlphaLocal 0.5;
- [_markerstr] spawn
- {
- params ["_markerstr"];
- _val = 0.5;
- while {_val > 0} do
- {
- sleep 2;
- _val = _val - 0.05;
- _markerstr setMarkerAlphaLocal _val;
- };
- deleteMarkerLocal _markerstr;
- };
- };
- };
- };
- };
- if (_debug) then
- {
- if (isServer) then {(diag_log format["Server finished hiding objects in %1 seconds",(time - _sTime)])};
- systemChat format["Finished hiding objects in %1 seconds",(time - _sTime)];
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement