Advertisement
Guest User

deploy fixed

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