/* Author: Bryan "Tonic" Boardwine Description: Starts automated mining of resource from the tempest device. */ private["_vehicle","_resourceZones","_zone","_weight","_item","_vInv","_itemIndex"]; _vehicle = [_this,0,ObjNull,[ObjNull]] call BIS_fnc_param; if(isNull _vehicle) exitWith {}; //Null was passed? if(!isNil {_vehicle getVariable "pumpen"}) exitWith {hint localize "STR_NOTF_TWpumpt";}; //Mining is already in process.. closeDialog 0; //Close the interaction menu. life_action_inUse = true; //Lock out the interaction menu for a bit.. _weight = [_vehicle] call life_fnc_vehicleWeight; if((_weight select 1) >= (_weight select 0)) exitWith {hint localize "STR_NOTF_TWvoll"; life_action_inUse = false;}; _resourceZones = ["sw_1"]; _zone = ""; veh = ["B_Truck_01_fuel_F","O_Truck_02_fuel_F","I_Truck_02_fuel_F","O_Truck_03_fuel_F","C_Van_01_fuel_white_F","C_Van_01_fuel_red_F","C_Van_01_fuel_white_v2_F","C_Van_01_fuel_red_v2_F","C_Van_01_fuel_F","I_G_Van_01_fuel_F","B_G_Van_01_fuel_F","O_G_Van_01_fuel_F"]; //Find out what zone we're near { if(player distance (getMarkerPos _x) < 150) exitWith {_zone = _x;}; } foreach _resourceZones; if(_zone == "") exitWith { hint localize "STR_NOTF_TWnotNearResource"; life_action_inUse = false; }; //Get the resource that will be gathered from the zone name... _item = switch(true) do { case (_zone in ["sw_1"]): {"sw"}; default {""}; }; if(_item == "") exitWith {hint "Bad Resource?"; life_action_inUse = false;}; _vehicle setVariable ["pumpen",true,true]; //Lock the device [_vehicle,"life_fnc_soundDevice",true,false] spawn life_fnc_MP; //Broadcast the 'mining' sound of the device for nearby units. life_action_inUse = false; //Unlock it since it's going to do it's own thing... while {true} do { if(!alive _vehicle OR isNull _vehicle) exitWith {}; if(isEngineOn _vehicle) exitWith {titleText[localize "STR_NOTF_TWPumpenStopped","PLAIN"];}; titleText[localize "STR_NOTF_TWMining","PLAIN"]; _time = time + 27; //Wait for 27 seconds with a 'delta-time' wait. waitUntil { if(isEngineOn _vehicle) exitWith {titleText[localize "STR_NOTF_TWPumpenStopped","PLAIN"]; true}; if(round(_time - time) < 1) exitWith {true}; sleep 0.2; false }; if(isEngineOn _vehicle) exitWith {titleText[localize "STR_NOTF_TWPumpenStopped","PLAIN"];}; _vInv = _vehicle getVariable ["Trunk",[[],0]]; _items = _vInv select 0; _space = _vInv select 1; _itemIndex = [_item,_items] call TON_fnc_index; _weight = [_vehicle] call life_fnc_vehicleWeight; _sum = [_item,15,_weight select 1,_weight select 0] call life_fnc_calWeightDiff; //Get a sum base of the remaining weight.. if(_sum < 1) exitWith {titleText[localize "STR_NOTF_TWvoll","PLAIN"];}; _itemWeight = ([_item] call life_fnc_itemWeight) * _sum; if(_itemIndex == -1) then { _items pushBack [_item,_sum]; } else { _val = _items select _itemIndex select 1; _items set[_itemIndex,[_item,_val + _sum]]; }; if(fuel _vehicle == 0) exitWith {titleText[localize "TWOutOfFuel","PLAIN"];}; //Locality checks... if(local _vehicle) then { _vehicle setFuel (fuel _vehicle)-0.045; } else { [[_vehicle,(fuel _vehicle)-0.04],"life_fnc_setFuel",_vehicle,false] spawn life_fnc_MP; }; if(fuel _vehicle == 0) exitWith {titleText[localize "TWOutOfFuel","PLAIN"];}; titleText[format[localize "STR_NOTF_DeviceMined",_sum],"PLAIN"]; _vehicle setVariable["Trunk",[_items,_space + _itemWeight],true]; _weight = [_vehicle] call life_fnc_vehicleWeight; _sum = [_item,15,_weight select 1,_weight select 0] call life_fnc_calWeightDiff; //Get a sum base of the remaining weight.. if(_sum < 1) exitWith {titleText[localize "STR_NOTF_TWvoll","PLAIN"];}; sleep 2; }; _vehicle setVariable["pumpen",nil,true];