Guest User

Untitled

a guest
Mar 1st, 2020
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. #include "..\..\script_macros.hpp"
  2. /*
  3. File: fn_gather.sqf
  4. Author: Devilfloh
  5.  
  6. Description:
  7. Main functionality for gathering.
  8. */
  9. private ["_maxGather","_resource","_amount","_maxGather","_requiredItem"];
  10. if (life_action_inUse) exitWith {};
  11. if !(isNull objectParent player) exitWith {};
  12. if (player getVariable "restrained") exitWith {hint localize "STR_NOTF_isrestrained";};
  13. if (player getVariable "playerSurrender") exitWith {hint localize "STR_NOTF_surrender";};
  14.  
  15. life_action_inUse = true;
  16. _zone = "";
  17. _requiredItem = "";
  18. _exit = false;
  19.  
  20. _resourceCfg = missionConfigFile >> "CfgGather" >> "Resources";
  21. for "_i" from 0 to count(_resourceCfg)-1 do {
  22.  
  23. _curConfig = _resourceCfg select _i;
  24. _resource = configName _curConfig;
  25. _maxGather = getNumber(_curConfig >> "amount");
  26. _zoneSize = getNumber(_curConfig >> "zoneSize");
  27. _resourceZones = getArray(_curConfig >> "zones");
  28. _requiredItem = getText(_curConfig >> "item");
  29. {
  30. if ((player distance2D (getMarkerPos _x)) < _zoneSize) exitWith {_zone = _x;};
  31. } forEach _resourceZones;
  32.  
  33. if (_zone != "") exitWith {};
  34. };
  35.  
  36. if (_zone isEqualTo "") exitWith {life_action_inUse = false;};
  37.  
  38. if (_requiredItem != "") then {
  39. _valItem = missionNamespace getVariable "life_inv_" + _requiredItem;
  40.  
  41. if (_valItem < 1) exitWith {
  42. switch (_requiredItem) do {
  43. //Messages here
  44. };
  45. life_action_inUse = false;
  46. _exit = true;
  47. };
  48. };
  49.  
  50. if (_exit) exitWith {life_action_inUse = false;};
  51.  
  52. _amount = round(random(_maxGather)) + 1;
  53. _diff = [_resource,_amount,life_carryWeight,life_maxWeight] call life_fnc_calWeightDiff;
  54. if (_diff isEqualTo 0) exitWith {
  55. hint localize "STR_NOTF_InvFull";
  56. life_action_inUse = false;
  57. };
  58.  
  59. switch (_requiredItem) do {
  60. case "pickaxe": {player say3D "mining";};
  61. default {player say3D "harvest";};
  62. };
  63.  
  64. for "_i" from 0 to 4 do {
  65. player playMoveNow "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon";
  66. waitUntil{animationState player != "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon";};
  67. sleep 0.5;
  68. };
  69.  
  70. if ([true,_resource,_diff] call life_fnc_handleInv) then {
  71. _itemName = M_CONFIG(getText,"VirtualItems",_resource,"displayName");
  72. titleText[format [localize "STR_NOTF_Gather_Success",(localize _itemName),_diff],"PLAIN"];
  73. };
  74.  
  75. sleep 1;
  76. life_action_inUse = false;
Advertisement
Add Comment
Please, Sign In to add comment