Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3. File: fn_excavator.sqf
  4. Author: Unknown
  5. Adapted by: Apocalyptos
  6.  
  7. Description:
  8. Wreck excavator for ShipWreck.
  9. */
  10.  
  11. private["_shipWreck","_ship","_maxGather","_resource","_amount","_requiredItem","_mined"];
  12. if (life_excavation_active) exitWith {};
  13. if !(isNull objectParent player) exitWith {};
  14. if (playerSide != civilian) exitWith {hint localize "STR_Dialog_NotCivil"};
  15. _shipWreck = nearestObjects [player,["Land_Wreck_Traw_F","Land_Wreck_Traw2_F"],20];
  16. if (count _shipWreck isEqualTo 0) exitWith {hint localize "STR_Dialog_WreckOnly"};
  17. _shipWreck = _shipWreck select 0;
  18.  
  19. if (!isNull _shipWreck) then {
  20. if (_shipWreck getVariable["opened", false]) then {
  21. life_excavation_active = true;
  22. while {life_excavation_active} do {
  23. _zone = "";
  24. _requiredItem = "";
  25. _resourceCfg = missionConfigFile >> "CfgGather" >> "Others";
  26. _percent = (floor random 100) + 1;
  27. _ship = nearestObjects [player,["Land_Wreck_Traw_F","Land_Wreck_Traw2_F"],20];
  28.  
  29. if (count _ship isEqualTo 0) exitWith {
  30. life_excavation_active = false;
  31. hint localize "STR_Dialog_WreckDistance";
  32. };
  33.  
  34. for "_i" from 0 to count(_resourceCfg)-1 do {
  35. _curConfig = _resourceCfg select _i;
  36. _resources = getArray(_curConfig >> "mined");
  37. _maxGather = getNumber(_curConfig >> "amount");
  38. _zoneSize = getNumber(_curConfig >> "zoneSize");
  39. _resourceZones = getArray(_curConfig >> "zones");
  40. _requiredItem = getText(_curConfig >> "item");
  41. _mined = "";
  42.  
  43. for "_i" from 0 to count (_resources) do {
  44. _resource = (_resources select _i) select 0;
  45. _prob = (_resources select _i) select 1;
  46. _probdiff = (_resources select _i) select 2;
  47. if ((_percent >= _prob) && (_percent <= _probdiff)) exitWith { _mined = _resource; };
  48. };
  49.  
  50. {
  51. if ((player distance(getMarkerPos _x)) < _zoneSize) exitWith {
  52. _zone = _x;
  53. };
  54. } forEach _resourceZones;
  55.  
  56. if (_zone != "") exitWith {};
  57. };
  58.  
  59. if (_zone isEqualTo "") exitWith {
  60. life_excavation_active = false;
  61. };
  62.  
  63. if (_requiredItem != "") then {
  64. _valItem = missionNamespace getVariable "life_inv_" + _requiredItem;
  65.  
  66. if (_valItem < 1) exitWith {
  67. switch (_requiredItem) do {
  68. case "excavator": {
  69. titleText[(localize "STR_NOTF_Excavator"), "PLAIN"];
  70. };
  71. };
  72. life_excavation_active = false;
  73. };
  74. };
  75.  
  76. _amount = round(random(_maxGather)) + 1;
  77. _diff = [_mined, _amount, life_carryWeight, life_maxWeight] call life_fnc_calWeightDiff;
  78.  
  79. if (_diff isEqualTo 0) exitWith {
  80. hint localize "STR_NOTF_InvFull";
  81. life_excavation_active = false;
  82. };
  83.  
  84. if (([true, _mined, _diff] call life_fnc_handleInv)) then {
  85. _itemName = M_CONFIG(getText, "VirtualItems", _mined, "displayName");
  86. titleText[format [localize "STR_NOTF_Gather_Success", (localize _itemName), _diff], "PLAIN"];
  87. };
  88.  
  89. sleep 5;
  90. };
  91. } else {
  92. hint localize "STR_Dialog_NotOpen";
  93. life_excavation_active = false;
  94. };
  95. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement