Advertisement
jhondominic

modular_build.sqf

May 26th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. //Check if building already in progress, exit if so.
  2. if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_40") , "PLAIN DOWN"]; };
  3. DZE_ActionInProgress = true;
  4.  
  5. private ["_itemConfig","_classname","_classnametmp","_require","_text","_ghost","_lockable","_requireplot","_isAllowedUnderGround","_offset","_isPole","_isLandFireDZ","_hasRequired","_hasrequireditem","_reason","_buildObject","_location1","_object","_objectHelper","_position","_controls","_cancel","_dir","_plot_check_result","_nearest_pole"];
  6.  
  7. /*Basic Defines*/
  8. DZE_Q = false;
  9. DZE_Z = false;
  10.  
  11. DZE_Q_alt = false;
  12. DZE_Z_alt = false;
  13.  
  14. DZE_Q_ctrl = false;
  15. DZE_Z_ctrl = false;
  16.  
  17. DZE_5 = false;
  18. DZE_4 = false;
  19. DZE_6 = false;
  20.  
  21. DZE_F = false;
  22.  
  23. DZE_cancelBuilding = false;
  24.  
  25. call gear_ui_init;
  26. closeDialog 1;
  27.  
  28. DZE_buildItem = _this; //This is a magazine! It's global to allow access to it from outside functions
  29.  
  30. //count nearby objects. Returns [_cnt] number
  31. [] call player_build_countNearby;
  32.  
  33. //Check illegal player states. Returns [_isFine] string
  34. [] call player_build_states;
  35.  
  36. //check for nearby requirements (campfire, workshop, fueltank).
  37. [] call player_build_needNearby;
  38.  
  39. //check config files and gather info about item (if using custom buildables, make your own similar function instead).
  40. _itemConfig = [] call player_build_getConfig;
  41.  
  42. //define items collected from function
  43. _classname = _itemConfig select 0; //string
  44. _classnametmp = _itemConfig select 1; //string
  45. _require = _itemConfig select 2; // array
  46. _text = _itemConfig select 3; // string
  47. _ghost = _itemConfig select 4; //string
  48. _lockable = _itemConfig select 5; //int -- 0/1=No 2=lockbox, 3=combolock, 4=safe
  49. _requireplot = _itemConfig select 6; //int
  50. _isAllowedUnderGround = _itemConfig select 7; //int
  51. _offset = _itemConfig select 8; //array
  52. _isPole = _itemConfig select 9; //bool
  53. _isLandFireDZ = _itemConfig select 10; //bool
  54.  
  55. //Check for nearby plotpoles. Returns [_IsNearPlot,_nearestPole,_ownerID,_friendlies] [int,Obj,int,array]
  56. _plot_check_result = [_isPole, _requireplot, _isLandFireDZ] call player_build_plotCheck;
  57.  
  58. if (DZE_ActionInProgress) then { //needed otherwise _hasRequired gets RPT error
  59.  
  60. _nearest_pole = _plot_check_result select 1;
  61. _distance = _plot_check_result select 4;
  62.  
  63. //Check for build requirements (missing tools and items). Returns [_hasrequireditem,_reason] [bool,string]
  64. _hasRequired = [_require, _text, true, true] call player_build_buildReq;
  65.  
  66. //define item collected from function
  67. _hasrequireditem = _hasRequired select 0; //bool
  68.  
  69. if (_hasrequireditem) then {
  70.  
  71. //Create object that is attached to a player (i.e Ghost preview if available)
  72. _buildObject = [_classname, _ghost, _offset, true, _requireplot, _nearest_pole,_distance] call player_build_create;
  73.  
  74. //define items collected from function
  75. _location1 = _buildObject select 0; //array
  76. _object = _buildObject select 1; //Obj
  77. _objectHelper = _buildObject select 2; //Obj
  78.  
  79. _controls = [_object, _isAllowedUnderGround, _location1, _objectHelper] call player_build_controls;
  80.  
  81. //define items collected from function
  82. _cancel = _controls select 0; //bool
  83. _reason = _controls select 1; //string
  84. _position = _controls select 2; //array
  85. _dir = _controls select 3; //int
  86.  
  87. //Publish item to a database
  88. [_cancel, _position, _classnametmp,_isAllowedUnderGround, _text, _isPole, _lockable,_dir, _reason,_requireplot] call player_build_publish;
  89. };
  90. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement