Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "..\..\script_macros.hpp"
- /*
- File: fn_excavator.sqf
- Author: Unknown
- Adapted by: Apocalyptos
- Description:
- Wreck excavator for ShipWreck.
- */
- private["_shipWreck","_ship","_maxGather","_resource","_amount","_requiredItem","_mined"];
- if (life_excavation_active) exitWith {};
- if !(isNull objectParent player) exitWith {};
- if (playerSide != civilian) exitWith {hint localize "STR_Dialog_NotCivil"};
- _shipWreck = nearestObjects [player,["Land_Wreck_Traw_F","Land_Wreck_Traw2_F"],20];
- if (count _shipWreck isEqualTo 0) exitWith {hint localize "STR_Dialog_WreckOnly"};
- _shipWreck = _shipWreck select 0;
- if (!isNull _shipWreck) then {
- if (_shipWreck getVariable["opened", false]) then {
- life_excavation_active = true;
- while {life_excavation_active} do {
- _zone = "";
- _requiredItem = "";
- _resourceCfg = missionConfigFile >> "CfgGather" >> "Others";
- _percent = (floor random 100) + 1;
- _ship = nearestObjects [player,["Land_Wreck_Traw_F","Land_Wreck_Traw2_F"],20];
- if (count _ship isEqualTo 0) exitWith {
- life_excavation_active = false;
- hint localize "STR_Dialog_WreckDistance";
- };
- for "_i" from 0 to count(_resourceCfg)-1 do {
- _curConfig = _resourceCfg select _i;
- _resources = getArray(_curConfig >> "mined");
- _maxGather = getNumber(_curConfig >> "amount");
- _zoneSize = getNumber(_curConfig >> "zoneSize");
- _resourceZones = getArray(_curConfig >> "zones");
- _requiredItem = getText(_curConfig >> "item");
- _mined = "";
- for "_i" from 0 to count (_resources) do {
- _resource = (_resources select _i) select 0;
- _prob = (_resources select _i) select 1;
- _probdiff = (_resources select _i) select 2;
- if ((_percent >= _prob) && (_percent <= _probdiff)) exitWith { _mined = _resource; };
- };
- {
- if ((player distance(getMarkerPos _x)) < _zoneSize) exitWith {
- _zone = _x;
- };
- } forEach _resourceZones;
- if (_zone != "") exitWith {};
- };
- if (_zone isEqualTo "") exitWith {
- life_excavation_active = false;
- };
- if (_requiredItem != "") then {
- _valItem = missionNamespace getVariable "life_inv_" + _requiredItem;
- if (_valItem < 1) exitWith {
- switch (_requiredItem) do {
- case "excavator": {
- titleText[(localize "STR_NOTF_Excavator"), "PLAIN"];
- };
- };
- life_excavation_active = false;
- };
- };
- _amount = round(random(_maxGather)) + 1;
- _diff = [_mined, _amount, life_carryWeight, life_maxWeight] call life_fnc_calWeightDiff;
- if (_diff isEqualTo 0) exitWith {
- hint localize "STR_NOTF_InvFull";
- life_excavation_active = false;
- };
- if (([true, _mined, _diff] call life_fnc_handleInv)) then {
- _itemName = M_CONFIG(getText, "VirtualItems", _mined, "displayName");
- titleText[format [localize "STR_NOTF_Gather_Success", (localize _itemName), _diff], "PLAIN"];
- };
- sleep 5;
- };
- } else {
- hint localize "STR_Dialog_NotOpen";
- life_excavation_active = false;
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement