Darth_Rogue

Untitled

Sep 11th, 2015
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. /*
  2. Get Loot Position
  3. Made for DayZ Epoch please ask permission to use/edit/distrubute email [email protected].
  4. */
  5. private ["_target","_type","_ppos","_veh","_worldPos","_zheightChanged","_pos","_tagColor","_new"];
  6.  
  7. _new = (_this select 3) select 0;
  8.  
  9. if (isNil "Base_Z_height") then {
  10. Base_Z_height = 0;
  11. };
  12.  
  13. if(_new == "select") then {
  14. if(!isnull(cursortarget)) then {
  15. DZE_target = cursortarget;
  16. hintsilent str(typeOf DZE_target);
  17. };
  18. };
  19.  
  20. if(_new == "generateloot") then {
  21.  
  22. if(!isnull(cursortarget)) then {
  23. DZE_target = cursortarget;
  24. hintsilent str(typeOf DZE_target);
  25. };
  26.  
  27. _type = toLower(typeOf DZE_target);
  28.  
  29. //diag_log format["Spawning loot for: %1", _type];
  30. _config = configFile >> "CfgBuildingLoot" >> _type;
  31. _positions = [] + getArray (_config >> "lootPos");
  32. {
  33.  
  34. _iPos = DZE_target modelToWorld _x;
  35. _nearBy = nearestObjects [_iPos, ["ReammoBox","WeaponHolder","WeaponHolderBase"], 1];
  36. if (count _nearBy == 0) then {
  37.  
  38.  
  39. _item = createVehicle ["WeaponHolder", _iPos, [], 0.0, "CAN_COLLIDE"];
  40. _item addMagazineCargoGlobal ["CinderBlocks",1];
  41. if ((count _iPos) > 2) then
  42. {
  43. _item setPosATL _iPos;
  44. };
  45.  
  46. } else {
  47. diag_log format["position too close: %1", _iPos];
  48. };
  49.  
  50. } forEach _positions;
  51.  
  52. _positionsSmall = [] + getArray (_config >> "lootPosSmall");
  53. {
  54. _iPos = DZE_target modelToWorld _x;
  55. _nearBy = nearestObjects [_iPos, ["ReammoBox","WeaponHolder","WeaponHolderBase"], 1];
  56. if (count _nearBy == 0) then {
  57.  
  58. _item = createVehicle ["WeaponHolder", _iPos, [], 0.0, "CAN_COLLIDE"];
  59. _item addMagazineCargoGlobal ["ItemPainkiller",1]; //ItemDocument
  60. if ((count _iPos) > 2) then
  61. {
  62. _item setPosATL _iPos;
  63. };
  64.  
  65. } else {
  66. diag_log format["position too close: %1", _iPos];
  67. };
  68.  
  69. } forEach _positionsSmall;
  70.  
  71. _positionsZombie = [] + getArray (_config >> "lootPosZombie");
  72. {
  73. _iPos = DZE_target modelToWorld _x;
  74.  
  75. _veh = createVehicle ["Sign_sphere10cm_EP1", _iPos, [], 0, "CAN_COLLIDE"];
  76. _veh setPosATL _iPos;
  77. _tagColor = "#(argb,8,8,3)color(0,1,0,0.5,ca)";
  78. _veh setobjecttexture [0,_tagColor];
  79.  
  80. } forEach _positionsZombie;
  81.  
  82. };
  83.  
  84.  
  85. if (isnil "DZE_target") then {
  86. _target = nearestObject [player, "Building"];
  87. } else {
  88. _target = DZE_target;
  89. };
  90.  
  91. _type = toLower(typeOf _target);
  92.  
  93. _zheightChanged = false;
  94.  
  95. switch (_new) do
  96. {
  97. case "up": {Base_Z_height = Base_Z_height + 0.1; _zheightChanged = true;};
  98. case "down": {Base_Z_height = Base_Z_height - 0.1; _zheightChanged = true;};
  99. case "up_small": {Base_Z_height = Base_Z_height + 0.01; _zheightChanged = true;};
  100. case "down_small": {Base_Z_height = Base_Z_height - 0.01; _zheightChanged = true;};
  101. case "up_large": {Base_Z_height = Base_Z_height + 0.5; _zheightChanged = true;};
  102. case "down_large": {Base_Z_height = Base_Z_height - 0.5; _zheightChanged = true;};
  103. };
  104.  
  105. _pos = player modeltoworld [0,1.5,Base_Z_height];
  106.  
  107. if(_new == "tagzspawn") then {
  108. _pos = player modeltoworld [0,0,0.875];
  109. };
  110.  
  111. _ppos = _target worldToModel _pos;
  112. _worldPos = _pos;
  113.  
  114. if (isnil "DZE_vehTarget") then {
  115. DZE_vehTarget = createVehicle ["Sign_arrow_down_EP1", _worldPos, [], 0, "CAN_COLLIDE"];
  116. DZE_vehTarget setPosATL _worldPos;
  117. DZE_vehTarget attachto [player];
  118. };
  119.  
  120. if (!isnull(DZE_vehTarget) and _zheightChanged) then {
  121. detach DZE_vehTarget;
  122. DZE_vehTarget setPosATL _worldPos;
  123. DZE_vehTarget attachto [player];
  124. };
  125.  
  126. if(_new == "tagzspawn") then {
  127. _veh = createVehicle ["Sign_sphere10cm_EP1", _worldPos, [], 0, "CAN_COLLIDE"];
  128. _veh setPosATL _worldPos;
  129. _tagColor = "#(argb,8,8,3)color(0,1,0,0.5,ca)";
  130. _veh setobjecttexture [0,_tagColor];
  131. };
  132.  
  133. if(_new == "tag" or _new == "tagpile") then {
  134. _veh = createVehicle ["Sign_arrow_down_EP1", _worldPos, [], 0, "CAN_COLLIDE"];
  135. _veh setPosATL _worldPos;
  136. };
  137.  
  138. if(_new == "tagpile") then {
  139. _tagColor = "#(argb,8,8,3)color(0,0,1,0.5,ca)";
  140. _veh setobjecttexture [0,_tagColor];
  141. };
  142.  
  143. if(_new == "tag" or _new == "tagzspawn" or _new == "tagpile") then {
  144. diag_log text format ["%1 { %2 }", _type,_ppos];
  145. copyToClipboard format ["%1 : %2", _type,_ppos];
  146. hintsilent format ["SAVED %1\n%2", _type,_ppos];
  147. };
  148.  
  149. _marker = "Sign_arrow_down_EP1";
  150. //_distanceMarker = player distance _marker;
  151. //_badMarker = _distanceMarker > 3;
  152. //_badMarker = nearestObject [player, "Sign_arrow_down_EP1"];
  153.  
  154. _playerObject = player;
  155. _playerPosition = getPosATL _playerObject;
  156. _goodMarker = nearestObject [player, "Sign_arrow_down_EP1"];
  157. //_distOK = player distance "Sign_arrow_down_EP1";
  158. //_deleteOK = _goodMarker > 3;
  159. if(_new == "removemarker") then {
  160. if (player distance _goodMarker > 3) then {deleteVehicle _marker};
  161. systemChat "Marker Deleted";
  162. };
Advertisement
Add Comment
Please, Sign In to add comment