Advertisement
Guest User

hide

a guest
Nov 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.58 KB | None | 0 0
  1. /*//
  2. */// Author : Dmitry Yuri
  3. /*// Version : Alpha 0.1 (19/11/17)
  4. *///
  5. /*//
  6. *///
  7. /*//
  8. */// General information about the hiding process. Known Knowns.
  9. /*//
  10. */// * when a building is hidden it can still be found using nearest* commands.
  11. /*// * Explosives can still damage a hidden building. If the building takes enough damage it will transition to its damaged state.
  12. */// * The Damaged state of buildings is a different model and will not be hidden if transitioned to.
  13. /*//
  14. *///
  15.  
  16.  
  17.  
  18. // Comments are important and you should always add comments to your code.
  19.  
  20. _debug = true;
  21. _sTime = time;
  22.  
  23. // Define some vars
  24. _MAP_TYPES_BUILDING = ["BUILDING","HOUSE","CHURCH","CHAPEL","FUELSTATION","HOSPITAL","RUIN","BUNKER"];
  25. _MAP_TYPES_VEGETATION = ["TREE","SMALL TREE","BUSH"];
  26. _MAP_TYPES_WALL = ["WALL","FENCE"];
  27. _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"];
  28.  
  29. _MAP_TYPES_ALL = (_MAP_TYPES_BUILDING + _MAP_TYPES_VEGETATION + _MAP_TYPES_WALL + _MAP_TYPES_MISC);
  30.  
  31.  
  32.  
  33. /* DISABLED
  34. 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.
  35. // populate trigger array.
  36. _triggerArray = [];
  37. for "_i" from 0 to 100 do
  38. {
  39. _trig = call compile format["if (isNil 'playzone_trigger_%1') then {objNull} else {playzone_trigger_%1};",_i];
  40. if (isNull _trig) exitWith {};
  41. _triggerArray append [_trig];
  42. };
  43. */
  44.  
  45.  
  46.  
  47. _int = worldSize;
  48. _num = (ceil (_int / 500));
  49. _trig = playzone_trigger_0;
  50.  
  51. (triggerArea _trig) params ["_sX","_sY"];
  52. _size = if (_sX > _sY) then {_sX;} else {_sY;};
  53.  
  54.  
  55. for "_xNum" from 0 to _num do
  56. {
  57. _xPos = (_xNum * 500);
  58.  
  59. for "_yNum" from 0 to (_num / 2) do
  60. {
  61. if (_debug) then
  62. {
  63. systemChat format["%1 - %2", _xNum, _yNum];
  64. };
  65.  
  66. // 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.
  67. waitUntil {if (diag_fps > 10) then {true} else {sleep 0.1; false;}};
  68.  
  69.  
  70. _yPos = (_yNum * 1000);
  71. // If the x number is even then add 500 to the Y position.
  72. if ((_xNum%2) == 1) then
  73. {
  74. _yPos = (_yPos + 500);
  75. };
  76.  
  77. _pos = [_xPos, _yPos, 0];
  78.  
  79.  
  80.  
  81.  
  82. // if (({(_pos distance _x) < 750} count _triggerArray) == 0) then
  83.  
  84. // If the position is near the playzone then perform extra checks to make sure the objects are outside the zone.
  85. if (((_pos distance _trig) - 500) < _size) then
  86. {
  87.  
  88. _objs = nearestTerrainObjects [_pos, _MAP_TYPES_ALL, 500, false, true];
  89.  
  90. if ((_pos distance _trig) < (_size - 500)) then {};
  91.  
  92.  
  93. {
  94. _obj = _x;
  95. if !(_obj inArea _trig) then
  96. {
  97. _x hideObject true;
  98. };
  99. } forEach _objs;
  100.  
  101. if (_debug) then
  102. {
  103. systemChat format["%1 objects found and hidden.", (count _objs)];
  104. _nme = format["m_%1_%2", _xNum, _yNum];
  105. _markerstr = createMarkerLocal [_nme, _pos];
  106. _markerstr setMarkerShapeLocal "ELLIPSE";
  107. _markerstr setMarkerSizeLocal [500,500];
  108. _markerstr setMarkerColorLocal "ColorBlue";
  109. _markerstr setMarkerAlphaLocal 0.5;
  110. [_markerstr] spawn
  111. {
  112. params ["_markerstr"];
  113. _val = 0.5;
  114. while {_val > 0} do
  115. {
  116. sleep 2;
  117. _val = _val - 0.05;
  118. _markerstr setMarkerAlphaLocal _val;
  119. };
  120. deleteMarkerLocal _markerstr;
  121. };
  122. };
  123. }
  124. else
  125. {
  126.  
  127. _objs = nearestTerrainObjects [_pos, _MAP_TYPES_ALL, 500, false, true];
  128. {
  129. _x hideObject true;
  130. } forEach _objs;
  131.  
  132. if (_debug) then
  133. {
  134. systemChat format["%1 objects found and hidden.", (count _objs)];
  135. _nme = format["m_%1_%2", _xNum, _yNum];
  136. _markerstr = createMarkerLocal [_nme, _pos];
  137. _markerstr setMarkerShapeLocal "ELLIPSE";
  138. _markerstr setMarkerSizeLocal [500,500];
  139. _markerstr setMarkerColorLocal "ColorRed";
  140. _markerstr setMarkerAlphaLocal 0.5;
  141. [_markerstr] spawn
  142. {
  143. params ["_markerstr"];
  144. _val = 0.5;
  145. while {_val > 0} do
  146. {
  147. sleep 2;
  148. _val = _val - 0.05;
  149. _markerstr setMarkerAlphaLocal _val;
  150. };
  151. deleteMarkerLocal _markerstr;
  152. };
  153. };
  154. };
  155. };
  156. };
  157.  
  158. if (_debug) then
  159. {
  160. if (isServer) then {(diag_log format["Server finished hiding objects in %1 seconds",(time - _sTime)])};
  161. systemChat format["Finished hiding objects in %1 seconds",(time - _sTime)];
  162. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement