Advertisement
ElDubya

player_build.sqf

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