Advertisement
DeanReid

newhp

May 15th, 2014 (edited)
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. private ["_isOk","_i","_objName","_started","_finished","_animState","_isMedic","_proceed","_itemOut","_countOut","_tree","_trees","_findNearestTree","_index","_invResult","_treesOutput","_text"];
  2.  
  3. if(DZE_ActionInProgress) exitWith { cutText [(localize "str_epoch_player_72") , "PLAIN DOWN"]; };
  4. DZE_ActionInProgress = true;
  5.  
  6. // allowed trees list move this later
  7. _trees = ["pumpkin.p3d","p_helianthus.p3d","p_fiberplant_ep1.p3d","fiberplant"];
  8. _treesOutput = ["FoodPumpkin","FoodSunFlowerSeed","ItemKiloHemp","ItemKiloHemp"];
  9.  
  10. //_item = _this;
  11. call gear_ui_init;
  12.  
  13. _countOut = 0;
  14.  
  15. _findNearestTree = [];
  16. {
  17. if("" == typeOf _x) then {
  18.  
  19. if (alive _x) then {
  20.  
  21. _objName = _x call DZE_getModelName;
  22.  
  23. // Exit since we found a tree
  24. if (_objName in _trees) exitWith {
  25. _findNearestTree set [(count _findNearestTree),_x];
  26.  
  27. _index = _trees find _objName;
  28.  
  29. _itemOut = _treesOutput select _index;
  30.  
  31. _countOut = 1;
  32.  
  33. };
  34. };
  35. };
  36.  
  37. } foreach nearestObjects [getPos player, [], 10];
  38.  
  39. //diag_log format["DEBUG TREES: %1", _findNearestTree];
  40.  
  41. if (count(_findNearestTree) >= 1) then {
  42.  
  43. _tree = _findNearestTree select 0;
  44.  
  45. // Start chop tree loop
  46. _isOk = true;
  47. _proceed = false;
  48. while {_isOk} do {
  49.  
  50. [1,1] call dayz_HungerThirst;
  51. player playActionNow "Medic";
  52. [player,20,true,(getPosATL player)] spawn player_alertZombies;
  53.  
  54. r_interrupt = false;
  55. _animState = animationState player;
  56. r_doLoop = true;
  57. _started = false;
  58. _finished = false;
  59.  
  60. while {r_doLoop} do {
  61. _animState = animationState player;
  62. _isMedic = ["medic",_animState] call fnc_inString;
  63. if (_isMedic) then {
  64. _started = true;
  65. };
  66. if (_started and !_isMedic) then {
  67. r_doLoop = false;
  68. _finished = true;
  69. [player,"chopwood",0,false] call dayz_zombieSpeak;
  70. };
  71. if (r_interrupt) then {
  72. r_doLoop = false;
  73. };
  74.  
  75. sleep 0.1;
  76.  
  77. };
  78.  
  79. if(!_finished) exitWith {
  80. _isOk = false;
  81. _proceed = false;
  82. };
  83.  
  84. if(_finished) exitWith {
  85. _isOk = false;
  86. _proceed = true;
  87. };
  88. };
  89.  
  90. if (_proceed) then {
  91.  
  92. _invResult = false;
  93. _i = 0;
  94. for "_x" from 1 to _countOut do {
  95. _invResult = [player,_itemOut] call BIS_fnc_invAdd;
  96. if(_invResult) then {
  97. _i = _i + 1;
  98. };
  99. };
  100.  
  101. _text = getText (configFile >> "CfgMagazines" >> _itemOut >> "displayName");
  102.  
  103. if(_i != 0) then {
  104. // chop down tree
  105. if("" == typeOf _tree) then {
  106. _tree setDamage 1;
  107. };
  108. //diag_log format["DEBUG TREE DAMAGE: %1", _tree];
  109.  
  110. cutText [format[(localize "str_epoch_player_154"), _i,_text], "PLAIN DOWN"];
  111. } else {
  112. cutText [format[(localize "str_epoch_player_143"), _i,_text], "PLAIN DOWN"];
  113. };
  114. } else {
  115. r_interrupt = false;
  116. if (vehicle player == player) then {
  117. [objNull, player, rSwitchMove,""] call RE;
  118. player playActionNow "stop";
  119. };
  120. cutText [(localize "str_epoch_player_73"), "PLAIN DOWN"];
  121. };
  122.  
  123.  
  124.  
  125. } else {
  126. cutText [(localize "str_epoch_player_74"), "PLAIN DOWN"];
  127. };
  128. DZE_ActionInProgress = false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement