Advertisement
Guest User

Untitled

a guest
Dec 7th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.68 KB | None | 0 0
  1. /*
  2. DayZ Base Building
  3. Made for DayZ Epoch please ask permission to use/edit/distrubute email vbawol@veteranbastards.com.
  4. */
  5. private ["_helperColor","_objectHelper","_objectHelperDir","_objectHelperPos","_canDo", "_pos", "_cnt",
  6. "_location","_dir","_classname","_item","_hasrequireditem","_missing","_hastoolweapon","_cancel","_reason","_started","_finished","_animState","_isMedic","_dis","_sfx","_hasbuilditem","_tmpbuilt","_onLadder","_isWater","_require","_text","_offset","_IsNearPlot","_isOk","_location1","_location2","_counter","_limit","_proceed","_num_removed","_position","_object","_canBuildOnPlot","_friendlies","_nearestPole","_ownerID","_findNearestPoles","_findNearestPole","_distance","_classnametmp","_ghost","_isPole","_needText","_lockable","_zheightchanged","_rotate","_combination_1","_combination_2","_combination_3","_combination_4","_combination","_combination_1_Display","_combinationDisplay","_zheightdirection","_abort","_isNear","_need","_needNear","_vehicle","_inVehicle","_requireplot","_objHDiff","_isLandFireDZ","_isTankTrap"];
  7.  
  8. if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_40") , "PLAIN DOWN"]; };
  9. DZE_ActionInProgress = true;
  10.  
  11. //snap vars -- temporary fix for errors so variables.sqf can be skipped
  12. if (isNil "snapProVariables") then {
  13. if (isNil "DZE_snapExtraRange") then {
  14. DZE_snapExtraRange = 0;
  15. };
  16. if (isNil "DZE_checkNearbyRadius") then {
  17. DZE_checkNearbyRadius = 30;
  18. };
  19. s_player_toggleSnap = -1;
  20. s_player_toggleSnapSelect = -1;
  21. s_player_toggleSnapSelectPoint=[];
  22. snapActions = -1;
  23. snapGizmos = [];
  24. snapGizmosNearby = [];
  25. snapProVariables = true; // will skip this statement from now on.
  26. };
  27. // snap vars
  28.  
  29. // disallow building if too many objects are found within (30m by default) add DZE_checkNearbyRadius = 30; to your init.sqf to change
  30. _pos = [player] call FNC_GetPos;
  31. _cnt = count (_pos nearObjects ["All",DZE_checkNearbyRadius]);
  32. if (_cnt >= DZE_BuildingLimit) exitWith { //end script if too many objects nearby
  33. DZE_ActionInProgress = false;
  34. cutText [(localize "str_epoch_player_41"), "PLAIN DOWN"];
  35. };
  36.  
  37. _onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
  38. _isWater = dayz_isSwimming;
  39. _cancel = false;
  40. _reason = "";
  41. _canBuildOnPlot = false;
  42.  
  43. _vehicle = vehicle player;
  44. _inVehicle = (_vehicle != player);
  45.  
  46. helperDetach = false;
  47. _canDo = (!r_drag_sqf and !r_player_unconscious);
  48.  
  49. _vector = [];
  50. fnc_SetPitchBankYaw = {
  51. private ["_object","_rotations","_aroundX","_aroundY","_aroundZ","_dirX","_dirY","_dirZ","_upX","_upY","_upZ","_dir","_up","_dirXTemp",
  52. "_upXTemp"];
  53. _object = _this select 0;
  54. _rotations = _this select 1;
  55. _aroundX = _rotations select 0;
  56. _aroundY = _rotations select 1;
  57. _aroundZ = (360 - (_rotations select 2)) - 360;
  58. _dirX = 0;
  59. _dirY = 1;
  60. _dirZ = 0;
  61. _upX = 0;
  62. _upY = 0;
  63. _upZ = 1;
  64. if (_aroundX != 0) then {
  65. _dirY = cos _aroundX;
  66. _dirZ = sin _aroundX;
  67. _upY = -sin _aroundX;
  68. _upZ = cos _aroundX;
  69. };
  70. if (_aroundY != 0) then {
  71. _dirX = _dirZ * sin _aroundY;
  72. _dirZ = _dirZ * cos _aroundY;
  73. _upX = _upZ * sin _aroundY;
  74. _upZ = _upZ * cos _aroundY;
  75. };
  76. if (_aroundZ != 0) then {
  77. _dirXTemp = _dirX;
  78. _dirX = (_dirXTemp* cos _aroundZ) - (_dirY * sin _aroundZ);
  79. _dirY = (_dirY * cos _aroundZ) + (_dirXTemp * sin _aroundZ);
  80. _upXTemp = _upX;
  81. _upX = (_upXTemp * cos _aroundZ) - (_upY * sin _aroundZ);
  82. _upY = (_upY * cos _aroundZ) + (_upXTemp * sin _aroundZ);
  83. };
  84. _dir = [_dirX,_dirY,_dirZ];
  85. _up = [_upX,_upY,_upZ];
  86. _object setVectorDirAndUp [_dir,_up];
  87. DZE_BuildVector = [_dir,_up];
  88. };
  89.  
  90. DZE_Q = false;
  91. DZE_Z = false;
  92.  
  93. DZE_Q_alt = false;
  94. DZE_Z_alt = false;
  95.  
  96. DZE_Q_ctrl = false;
  97. DZE_Z_ctrl = false;
  98.  
  99. DZE_5 = false;
  100. DZE_4 = false;
  101. DZE_6 = false;
  102. DZE_F = false;
  103.  
  104. DZE_cancelBuilding = false;
  105.  
  106. call gear_ui_init;
  107. closeDialog 1;
  108.  
  109. if (_isWater) exitWith {DZE_ActionInProgress = false; cutText [localize "str_player_26", "PLAIN DOWN"];};
  110. if (_inVehicle) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_42"), "PLAIN DOWN"];};
  111. if (_onLadder) exitWith {DZE_ActionInProgress = false; cutText [localize "str_player_21", "PLAIN DOWN"];};
  112. if (player getVariable["combattimeout", 0] >= time) exitWith {DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_43"), "PLAIN DOWN"];};
  113.  
  114. _item = _this;
  115.  
  116. // Need Near Requirements
  117. _abort = false;
  118. _reason = "";
  119.  
  120. _needNear = getArray (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "neednearby");
  121.  
  122. {
  123. switch(_x) do{
  124. case "fire":
  125. {
  126. _distance = 3;
  127. _isNear = {inflamed _x} count (_pos nearObjects _distance);
  128. if(_isNear == 0) then {
  129. _abort = true;
  130. _reason = "fire";
  131. };
  132. };
  133. case "workshop":
  134. {
  135. _distance = 3;
  136. _isNear = count (nearestObjects [_pos, ["Wooden_shed_DZ","WoodShack_DZ","WorkBench_DZ"], _distance]);
  137. if(_isNear == 0) then {
  138. _abort = true;
  139. _reason = "workshop";
  140. };
  141. };
  142. case "fueltank":
  143. {
  144. _distance = 30;
  145. _isNear = count (nearestObjects [_pos, dayz_fuelsources, _distance]);
  146. if(_isNear == 0) then {
  147. _abort = true;
  148. _reason = "fuel tank";
  149. };
  150. };
  151. };
  152. } forEach _needNear;
  153.  
  154.  
  155. if(_abort) exitWith {
  156. cutText [format[(localize "str_epoch_player_135"),_reason,_distance], "PLAIN DOWN"];
  157. DZE_ActionInProgress = false;
  158. };
  159.  
  160. _classname = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create");
  161. _classnametmp = _classname;
  162. _require = getArray (configFile >> "cfgMagazines" >> _this >> "ItemActions" >> "Build" >> "require");
  163. _text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
  164. _ghost = getText (configFile >> "CfgVehicles" >> _classname >> "ghostpreview");
  165.  
  166. _lockable = 0;
  167. if(isNumber (configFile >> "CfgVehicles" >> _classname >> "lockable")) then {
  168. _lockable = getNumber(configFile >> "CfgVehicles" >> _classname >> "lockable");
  169. };
  170.  
  171. _requireplot = DZE_requireplot;
  172. if(isNumber (configFile >> "CfgVehicles" >> _classname >> "requireplot")) then {
  173. _requireplot = getNumber(configFile >> "CfgVehicles" >> _classname >> "requireplot");
  174. };
  175.  
  176. _isAllowedUnderGround = 1;
  177. if(isNumber (configFile >> "CfgVehicles" >> _classname >> "nounderground")) then {
  178. _isAllowedUnderGround = getNumber(configFile >> "CfgVehicles" >> _classname >> "nounderground");
  179. };
  180.  
  181. _offset = getArray (configFile >> "CfgVehicles" >> _classname >> "offset");
  182. if((count _offset) <= 0) then {
  183. _offset = [0,1.5,0];
  184. };
  185.  
  186. _isPole = (_classname == "Plastic_Pole_EP1_DZ");
  187. _isLandFireDZ = (_classname == "Land_Fire_DZ");
  188.  
  189. _distance = DZE_PlotPole select 0;
  190. _needText = localize "str_epoch_player_246";
  191.  
  192. if(_isPole) then {
  193. _distance = DZE_PlotPole select 1;
  194. };
  195.  
  196. // check for near plot
  197. _findNearestPoles = nearestObjects [(vehicle player), ["Plastic_Pole_EP1_DZ"], _distance];
  198. _findNearestPole = [];
  199.  
  200. {
  201. if (alive _x) then {
  202. _findNearestPole set [(count _findNearestPole),_x];
  203. };
  204. } count _findNearestPoles;
  205.  
  206. _IsNearPlot = count (_findNearestPole);
  207.  
  208. // If item is plot pole && another one exists within 45m
  209. if(_isPole && _IsNearPlot > 0) exitWith { DZE_ActionInProgress = false; cutText [(localize "str_epoch_player_44") , "PLAIN DOWN"]; };
  210.  
  211. if(_IsNearPlot == 0) then {
  212.  
  213. // Allow building of plot
  214. if(_requireplot == 0 || _isLandFireDZ) then {
  215. _canBuildOnPlot = true;
  216. };
  217.  
  218. } else {
  219. // Since there are plots nearby we check for ownership && then for friend status
  220.  
  221. // check nearby plots ownership && then for friend status
  222. _nearestPole = _findNearestPole select 0;
  223.  
  224. // Find owner
  225. _ownerID = _nearestPole getVariable ["CharacterID","0"];
  226.  
  227. // diag_log format["DEBUG BUILDING: %1 = %2", dayz_characterID, _ownerID];
  228.  
  229. // check if friendly to owner
  230. if(dayz_characterID == _ownerID) then { //Keep ownership
  231. // owner can build anything within his plot except other plots
  232. if(!_isPole) then {
  233. _canBuildOnPlot = true;
  234. };
  235.  
  236. } else {
  237. // disallow building plot
  238. if(!_isPole) then {
  239. _friendlies = player getVariable ["friendlyTo",[]];
  240. // check if friendly to owner
  241. if(_ownerID in _friendlies) then {
  242. _canBuildOnPlot = true;
  243. };
  244. };
  245. };
  246. };
  247.  
  248. // _message
  249. if(!_canBuildOnPlot) exitWith { DZE_ActionInProgress = false; cutText [format[(localize "STR_EPOCH_PLAYER_135"),_needText,_distance] , "PLAIN DOWN"]; };
  250.  
  251. _missing = "";
  252. _hasrequireditem = true;
  253. {
  254. _hastoolweapon = _x in weapons player;
  255. if(!_hastoolweapon) exitWith { _hasrequireditem = false; _missing = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); };
  256. } count _require;
  257.  
  258. _hasbuilditem = _this in magazines player;
  259. if (!_hasbuilditem) exitWith {DZE_ActionInProgress = false; cutText [format[(localize "str_player_31"),_text,"build"] , "PLAIN DOWN"]; };
  260.  
  261. if (!_hasrequireditem) exitWith {DZE_ActionInProgress = false; cutText [format[(localize "str_epoch_player_137"),_missing] , "PLAIN DOWN"]; };
  262. if (_hasrequireditem) then {
  263.  
  264. _location = [0,0,0];
  265. _isOk = true;
  266.  
  267. // get inital players position
  268. _location1 = [player] call FNC_GetPos;
  269. _dir = getDir player;
  270.  
  271. // if ghost preview available use that instead
  272. if (_ghost != "") then {
  273. _classname = _ghost;
  274. };
  275.  
  276. _object = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"];
  277. //Build gizmo
  278. _objectHelper = "Sign_sphere10cm_EP1" createVehicle _location;
  279. _helperColor = "#(argb,8,8,3)color(0,0,0,0,ca)";
  280. _objectHelper setobjecttexture [0,_helperColor];
  281. _objectHelper attachTo [player,_offset];
  282. _object attachTo [_objectHelper,[0,0,0]];
  283. _position = [_objectHelper] call FNC_GetPos;
  284.  
  285. _objHDiff = 0;
  286.  
  287. if (isClass (missionConfigFile >> "SnapBuilding" >> _classname)) then {
  288. ["","","",["Init",_object,_classname,_objectHelper]] spawn snap_build;
  289. };
  290.  
  291. DZE_updateVec = false;
  292. DZE_memDir = getDir _objectHelper;
  293. DZE_memForBack = 0;
  294. DZE_memLeftRight = 0;
  295. if !(_classnametmp in DZE_noRotate) then{
  296. s_player_setVectorsReset = player addaction ["Reset","custom\snap_pro\player_vectorChange.sqf","reset"];
  297. s_player_setVectorsForward = player addaction ["Pitch Forward","custom\snap_pro\player_vectorChange.sqf","forward"];
  298. s_player_setVectorsBack = player addaction ["Pitch Back","custom\snap_pro\player_vectorChange.sqf","back"];
  299. s_player_setVectorsLeft = player addaction ["Bank Left","custom\snap_pro\player_vectorChange.sqf","left"];
  300. s_player_setVectorsRight = player addaction ["Bank Right","custom\snap_pro\player_vectorChange.sqf","right"];
  301. s_player_setVectors1 = player addaction ["Increment by 1 degree","custom\snap_pro\player_vectorChange.sqf","1"];
  302. s_player_setVectors5 = player addaction ["Increment by 5 degrees","custom\snap_pro\player_vectorChange.sqf","5"];
  303. s_player_setVectors45 = player addaction ["Increment by 45 degrees","custom\snap_pro\player_vectorChange.sqf","45"];
  304. s_player_setVectors90 = player addaction ["Increment by 90 degrees","custom\snap_pro\player_vectorChange.sqf","90"];
  305. };
  306.  
  307. while {_isOk} do {
  308.  
  309. _zheightchanged = false;
  310. _zheightdirection = "";
  311. _rotate = false;
  312.  
  313. if (DZE_Q) then {
  314. DZE_Q = false;
  315. _zheightdirection = "up";
  316. _zheightchanged = true;
  317. };
  318. if (DZE_Z) then {
  319. DZE_Z = false;
  320. _zheightdirection = "down";
  321. _zheightchanged = true;
  322. };
  323. if (DZE_Q_alt) then {
  324. DZE_Q_alt = false;
  325. _zheightdirection = "up_alt";
  326. _zheightchanged = true;
  327. };
  328. if (DZE_Z_alt) then {
  329. DZE_Z_alt = false;
  330. _zheightdirection = "down_alt";
  331. _zheightchanged = true;
  332. };
  333. if (DZE_Q_ctrl) then {
  334. DZE_Q_ctrl = false;
  335. _zheightdirection = "up_ctrl";
  336. _zheightchanged = true;
  337. };
  338. if (DZE_Z_ctrl) then {
  339. DZE_Z_ctrl = false;
  340. _zheightdirection = "down_ctrl";
  341. _zheightchanged = true;
  342. };
  343. if (DZE_4) then {
  344. _rotate = true;
  345. DZE_4 = false;
  346. _dir = -45;
  347. DZE_memDir = DZE_memDir - 45;
  348. };
  349. if (DZE_6) then {
  350. _rotate = true;
  351. DZE_6 = false;
  352. _dir = 45;
  353. DZE_memDir = DZE_memDir + 45;
  354. };
  355.  
  356. if(DZE_updateVec) then{
  357. [_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYaw;
  358. DZE_updateVec = false;
  359. };
  360.  
  361. if (DZE_F and _canDo) then {
  362. if (helperDetach) then {
  363. _objectHelper attachTo [player];
  364. DZE_memDir = DZE_memDir-(getDir player);
  365. helperDetach = false;
  366. [_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYaw;
  367. } else {
  368. _objectHelperDir = getDir _objectHelper;
  369. detach _objectHelper;
  370. DZE_memDir = getDir _objectHelper;
  371. [_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYaw;
  372. [_objectHelper] call FNC_GetSetPos;
  373. _objectHelper setVelocity [0,0,0]; //fix sliding glitch
  374. helperDetach = true;
  375. };
  376. DZE_F = false;
  377. };
  378.  
  379. if(_rotate) then {
  380. [_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYaw;
  381. };
  382.  
  383. if(_zheightchanged) then {
  384. if (!helperDetach) then {
  385. detach _objectHelper;
  386. _objectHelperDir = getDir _objectHelper;
  387. };
  388.  
  389. _position = [_objectHelper] call FNC_GetPos;
  390.  
  391. if(_zheightdirection == "up") then {
  392. _position set [2,((_position select 2)+0.1)];
  393. _objHDiff = _objHDiff + 0.1;
  394. };
  395. if(_zheightdirection == "down") then {
  396. _position set [2,((_position select 2)-0.1)];
  397. _objHDiff = _objHDiff - 0.1;
  398. };
  399.  
  400. if(_zheightdirection == "up_alt") then {
  401. _position set [2,((_position select 2)+1)];
  402. _objHDiff = _objHDiff + 1;
  403. };
  404. if(_zheightdirection == "down_alt") then {
  405. _position set [2,((_position select 2)-1)];
  406. _objHDiff = _objHDiff - 1;
  407. };
  408.  
  409. if(_zheightdirection == "up_ctrl") then {
  410. _position set [2,((_position select 2)+0.01)];
  411. _objHDiff = _objHDiff + 0.01;
  412. };
  413. if(_zheightdirection == "down_ctrl") then {
  414. _position set [2,((_position select 2)-0.01)];
  415. _objHDiff = _objHDiff - 0.01;
  416. };
  417.  
  418. if((_isAllowedUnderGround == 0) && ((_position select 2) < 0)) then {
  419. _position set [2,0];
  420. };
  421.  
  422. if (surfaceIsWater _position) then {
  423. _objectHelper setPosASL _position;
  424. } else {
  425. _objectHelper setPosATL _position;
  426. };
  427.  
  428. if (!helperDetach) then {
  429. _objectHelper attachTo [player];
  430. _objectHelper setDir _objectHelperDir-(getDir player);
  431. };
  432.  
  433. [_objectHelper,[DZE_memForBack,DZE_memLeftRight,DZE_memDir]] call fnc_SetPitchBankYaw;
  434. };
  435.  
  436. sleep 0.5;
  437.  
  438. _location2 = [player] call FNC_GetPos;
  439. _objectHelperPos = [_objectHelper] call FNC_GetPos;
  440.  
  441. if(DZE_5) exitWith {
  442. _isOk = false;
  443. _position = [_object] call FNC_GetPos;
  444. detach _object;
  445. _dir = getDir _object;
  446. _vector = [(vectorDir _object),(vectorUp _object)];
  447. deleteVehicle _object;
  448. detach _objectHelper;
  449. deleteVehicle _objectHelper;
  450. };
  451.  
  452. if(_location1 distance _location2 > 10) exitWith {
  453. _isOk = false;
  454. _cancel = true;
  455. _reason = "You've moved to far away from where you started building (within 10 meters)";
  456. detach _object;
  457. deleteVehicle _object;
  458. detach _objectHelper;
  459. deleteVehicle _objectHelper;
  460. };
  461.  
  462. if(_location1 distance _objectHelperPos > 10) exitWith {
  463. _isOk = false;
  464. _cancel = true;
  465. _reason = "Object is placed to far away from where you started building (within 10 meters)";
  466. detach _object;
  467. deleteVehicle _object;
  468. detach _objectHelper;
  469. deleteVehicle _objectHelper;
  470. };
  471.  
  472. if(abs(_objHDiff) > 10) exitWith {
  473. _isOk = false;
  474. _cancel = true;
  475. _reason = "Cannot move up or down more than 10 meters";
  476. detach _object;
  477. deleteVehicle _object;
  478. detach _objectHelper;
  479. deleteVehicle _objectHelper;
  480. };
  481.  
  482. if (player getVariable["combattimeout", 0] >= time) exitWith {
  483. _isOk = false;
  484. _cancel = true;
  485. _reason = (localize "str_epoch_player_43");
  486. detach _object;
  487. deleteVehicle _object;
  488. detach _objectHelper;
  489. deleteVehicle _objectHelper;
  490. };
  491.  
  492. if (DZE_cancelBuilding) exitWith {
  493. _isOk = false;
  494. _cancel = true;
  495. _reason = "Cancelled building.";
  496. detach _object;
  497. deleteVehicle _object;
  498. detach _objectHelper;
  499. deleteVehicle _objectHelper;
  500. };
  501. };
  502.  
  503. if !(_classnametmp in DZE_noRotate) then{
  504. player removeAction s_player_setVectorsReset;
  505. player removeAction s_player_setVectorsForward;
  506. player removeAction s_player_setVectorsBack;
  507. player removeAction s_player_setVectorsLeft;
  508. player removeAction s_player_setVectorsRight;
  509. player removeAction s_player_setVectors1;
  510. player removeAction s_player_setVectors5;
  511. player removeAction s_player_setVectors45;
  512. player removeAction s_player_setVectors90;
  513. };
  514.  
  515. //No building on roads unless toggled
  516. if (!DZE_BuildOnRoads) then {
  517. if (isOnRoad _position) then { _cancel = true; _reason = "Cannot build on a road."; };
  518. };
  519.  
  520. // No building in trader zones
  521. if(!canbuild) then { _cancel = true; _reason = "Cannot build in a city."; };
  522.  
  523. if(!_cancel) then {
  524.  
  525. _classname = _classnametmp;
  526.  
  527. // Start Build
  528. _tmpbuilt = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"];
  529. //#########################INDESTRUCTIBLE ITEMS#########################
  530. if ((typeOf _tmpbuilt) in indestructible) then {
  531. _tmpbuilt addEventHandler ["HandleDamage", {false}];
  532. _tmpbuilt enableSimulation false;
  533. };
  534. //######################################################################
  535. _tmpbuilt setdir _dir;
  536.  
  537. _tmpbuilt setVectorDirAndUp _vector;
  538.  
  539. // Get position based on object
  540. _location = _position;
  541.  
  542. if((_isAllowedUnderGround == 0) && ((_location select 2) < 0)) then {
  543. _location set [2,0];
  544. };
  545.  
  546. _buildOffset = [0,0,0];
  547. _vUp = _vector select 1;
  548. switch (_classname) do {
  549. case "MetalFloor_DZ": { _buildOffset = [(_vUp select 0) * .148, (_vUp select 1) * .148,0]; };
  550. };
  551.  
  552. _location = [
  553. (_location select 0) - (_buildOffset select 0),
  554. (_location select 1) - (_buildOffset select 1),
  555. (_location select 2) - (_buildOffset select 2)
  556. ];
  557.  
  558. if (surfaceIsWater _location) then {
  559. _tmpbuilt setPosASL _location;
  560. _location = ASLtoATL _location;
  561. } else {
  562. _tmpbuilt setPosATL _location;
  563. };
  564.  
  565. cutText [format[(localize "str_epoch_player_138"),_text], "PLAIN DOWN"];
  566.  
  567. _limit = 3;
  568.  
  569. if (DZE_StaticConstructionCount > 0) then {
  570. _limit = DZE_StaticConstructionCount;
  571. }
  572. else {
  573. if (isNumber (configFile >> "CfgVehicles" >> _classname >> "constructioncount")) then {
  574. _limit = getNumber(configFile >> "CfgVehicles" >> _classname >> "constructioncount");
  575. };
  576. };
  577.  
  578. _isOk = true;
  579. _proceed = false;
  580. _counter = 0;
  581.  
  582. while {_isOk} do {
  583.  
  584. [10,10] call dayz_HungerThirst;
  585. player playActionNow "Medic";
  586.  
  587. _dis=20;
  588. _sfx = "repair";
  589. [player,_sfx,0,false,_dis] call dayz_zombieSpeak;
  590. [player,_dis,true,(getPosATL player)] spawn player_alertZombies;
  591.  
  592. r_interrupt = false;
  593. r_doLoop = true;
  594. _started = false;
  595. _finished = false;
  596.  
  597. while {r_doLoop} do {
  598. _animState = animationState player;
  599. _isMedic = ["medic",_animState] call fnc_inString;
  600. if (_isMedic) then {
  601. _started = true;
  602. };
  603. if (_started && !_isMedic) then {
  604. r_doLoop = false;
  605. _finished = true;
  606. };
  607. if (r_interrupt || (player getVariable["combattimeout", 0] >= time)) then {
  608. r_doLoop = false;
  609. };
  610. if (DZE_cancelBuilding) exitWith {
  611. r_doLoop = false;
  612. };
  613. sleep 0.1;
  614. };
  615. r_doLoop = false;
  616.  
  617.  
  618. if(!_finished) exitWith {
  619. _isOk = false;
  620. _proceed = false;
  621. };
  622.  
  623. if(_finished) then {
  624. _counter = _counter + 1;
  625. };
  626.  
  627. cutText [format[(localize "str_epoch_player_139"),_text, _counter,_limit], "PLAIN DOWN"];
  628.  
  629. if(_counter == _limit) exitWith {
  630. _isOk = false;
  631. _proceed = true;
  632. };
  633.  
  634. };
  635.  
  636. if (_proceed) then {
  637.  
  638. _num_removed = ([player,_item] call BIS_fnc_invRemove);
  639. if(_num_removed == 1) then {
  640.  
  641. cutText [format[localize "str_build_01",_text], "PLAIN DOWN"];
  642.  
  643. if (_isPole) then {
  644. [] spawn player_plotPreview;
  645. };
  646.  
  647. _tmpbuilt setVariable ["OEMPos",_location,true];
  648.  
  649. if(_lockable > 1) then {
  650.  
  651. _combinationDisplay = "";
  652.  
  653. switch (_lockable) do {
  654.  
  655. case 2: { // 2 lockbox
  656. _combination_1 = (floor(random 3)) + 100; // 100=red,101=green,102=blue
  657. _combination_2 = floor(random 10);
  658. _combination_3 = floor(random 10);
  659. _combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
  660. dayz_combination = _combination;
  661. if (_combination_1 == 100) then {
  662. _combination_1_Display = "Red";
  663. };
  664. if (_combination_1 == 101) then {
  665. _combination_1_Display = "Green";
  666. };
  667. if (_combination_1 == 102) then {
  668. _combination_1_Display = "Blue";
  669. };
  670. _combinationDisplay = format["%1%2%3",_combination_1_Display,_combination_2,_combination_3];
  671. };
  672.  
  673. case 3: { // 3 combolock
  674. _combination_1 = floor(random 10);
  675. _combination_2 = floor(random 10);
  676. _combination_3 = floor(random 10);
  677. _combination = format["%1%2%3",_combination_1,_combination_2,_combination_3];
  678. dayz_combination = _combination;
  679. _combinationDisplay = _combination;
  680. };
  681.  
  682. case 4: { // 4 safe
  683. _combination_1 = floor(random 10);
  684. _combination_2 = floor(random 10);
  685. _combination_3 = floor(random 10);
  686. _combination_4 = floor(random 10);
  687. _combination = format["%1%2%3%4",_combination_1,_combination_2,_combination_3,_combination_4];
  688. dayz_combination = _combination;
  689. _combinationDisplay = _combination;
  690. };
  691. };
  692.  
  693. _tmpbuilt setVariable ["CharacterID",_combination,true];
  694.  
  695.  
  696. PVDZE_obj_Publish = [_combination,_tmpbuilt,[_dir,_location,_vector],_classname];
  697. publicVariableServer "PVDZE_obj_Publish";
  698.  
  699. cutText [format[(localize "str_epoch_player_140"),_combinationDisplay,_text], "PLAIN DOWN", 5];
  700.  
  701.  
  702. } else {
  703. _tmpbuilt setVariable ["CharacterID",dayz_characterID,true];
  704.  
  705. // fire?
  706. if(_tmpbuilt isKindOf "Land_Fire_DZ") then {
  707. _tmpbuilt spawn player_fireMonitor;
  708. } else {
  709. PVDZE_obj_Publish = [dayz_characterID,_tmpbuilt,[_dir,_location,_vector],_classname];
  710. publicVariableServer "PVDZE_obj_Publish";
  711. };
  712. };
  713. } else {
  714. deleteVehicle _tmpbuilt;
  715. cutText [(localize "str_epoch_player_46") , "PLAIN DOWN"];
  716. };
  717.  
  718. } else {
  719. r_interrupt = false;
  720. if (vehicle player == player) then {
  721. [objNull, player, rSwitchMove,""] call RE;
  722. player playActionNow "stop";
  723. };
  724.  
  725. deleteVehicle _tmpbuilt;
  726.  
  727. cutText [(localize "str_epoch_player_46") , "PLAIN DOWN"];
  728. };
  729.  
  730. } else {
  731. cutText [format[(localize "str_epoch_player_47"),_text,_reason], "PLAIN DOWN"];
  732. };
  733. };
  734.  
  735. DZE_ActionInProgress = false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement