Hi NN,
ich habe ein kleines Problem mit dem Auto Farmen vom Tempest Gerät (ich nutze die 4.4r3):
Das Tempest Gerät ist nach meiner ansicht nach verbuggt, da es nicht richtig farmt. Was ich damit meine: Wenn man eine Farm Zone hat in der mehr als ein Item gefarmt werden kann (geht ab der 4.4r3 evtl auch 4.0 kann aber nicht bestätigen) farmt das Gerät immer nur das erste der Items, nicht aber wie es sein sollte ein zufälliges der möglichkeiten.
Ich habe mich da mal etwas rein gewurstelt, aber bin nicht ganz durchgestiegen was das Problem ist, hier mal meine aktuelle Datei:
Code: fn_deviceMine.sqf
#include "..\..\script_macros.hpp"
/*
File: fn_deviceMine.sqf
Author: Bryan "Tonic" Boardwine
Modified: Devilfloh
Description:
Starts automated mining of resource from the tempest device. Not integrated with percents.
*/
private[
"_vehicle","_resourceZones","_zone","_weight",
"_resource","_vInv","_itemIndex","_items",
"_sum","_itemWeight","_amount","_isMineral",
"_mined"
];
_vehicle = param [0,ObjNull,[ObjNull]];
_isMineral = true;
if (isNull _vehicle) exitWith {};
if (!isNil {_vehicle getVariable "mining"}) exitWith {
hint localize "STR_NOTF_DeviceIsMining";
};
if (fuel _vehicle isEqualTo 0) exitWith {
titleText[localize "STR_NOTF_OutOfFuel","PLAIN"];
};
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_DeviceFull";
life_action_inUse = false;
};
//check if we are in the resource zone for any of the resources
_zone = "";
_zoneSize = (getNumber(missionConfigFile >> "CfgGather" >> "zoneSize"));
_resourceCfg = missionConfigFile >> "CfgGather" >> "Resources";
for "_i" from 0 to count(_resourceCfg)-1 do {
_curConfig = (_resourceCfg select _i);
_resource = configName(_curConfig);
_resourceZones = getArray(_curConfig >> "zones");
_amount = getNumber(_curConfig >> "amount");
{
if ((player distance (getMarkerPos _x)) < _zoneSize) exitWith {
_zone = _x;
};
} forEach _resourceZones;
if (_zone != "") exitWith {_isMineral = false;};
};
_resourceCfg = missionConfigFile >> "CfgGather" >> "Minerals";
_percent = (floor random 100) + 1; //Make sure it's not 0
for "_i" from 0 to count(_resourceCfg)-1 do {
if (!_isMineral) exitWith {};
_curConfig = _resourceCfg select _i;
_resources = getArray(_curConfig >> "mined");
_resourceZones = getArray(_curConfig >> "zones");
_mined = "";
if (_resources isEqualTo []) exitWith {}; //Smart guy :O
for "_i" from 0 to count (_resources) do {
if (count _resources isEqualTo 1) exitWith {
if (!((_resources select 0) isEqualType [])) then {
_mined = _resources select 0;
} else {
_mined = (_resources select 0) select 0;
};
};
_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 {
hint localize "STR_NOTF_notNearResource";
life_action_inUse = false;
};
_vehicle setVariable ["mining",true,true]; //Lock the device
_vehicle remoteExec ["life_fnc_soundDevice",RCLIENT]; //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...
for "_i" from 0 to 1 step 0 do {
if (!alive _vehicle || isNull _vehicle) exitWith {};
if ((isEngineOn _vehicle) || ((speed _vehicle) > 5)) exitWith {
titleText[localize "STR_NOTF_MiningStopped","PLAIN"];
};
if (fuel _vehicle isEqualTo 0) exitWith {
titleText[localize "STR_NOTF_OutOfFuel","PLAIN"];
};
titleText[localize "STR_NOTF_DeviceMining","PLAIN"];
_time = time + 27;
//Wait for 27 seconds with a 'delta-time' wait.
waitUntil {
if ((isEngineOn _vehicle) || ((speed _vehicle) > 5)) exitWith {
_vehicle setVariable["mining",nil,true];
titleText[localize "STR_NOTF_MiningStopped","PLAIN"];
true
};
if (round(_time - time) < 1) exitWith {
true
};
if (fuel _vehicle < 0.1) exitWith {
_vehicle setVariable["mining",nil,true];
titleText[localize "STR_NOTF_OutOfFuel","PLAIN"];
true
};
sleep 0.2;
false
};
if ((isEngineOn _vehicle) || ((speed _vehicle) > 5)) exitWith {
_vehicle setVariable["mining",nil,true];
titleText[localize "STR_NOTF_MiningStopped","PLAIN"];
};
_vehicle_data = _vehicle getVariable ["Trunk",[[],0]];
_inv = (_vehicle_data select 0);
_space = (_vehicle_data select 1);
_itemIndex = [_resource,_inv] call TON_fnc_index;
_weight = [_vehicle] call life_fnc_vehicleWeight;
_random = 10 + round((random(10)));
_sum = [_resource,_random,(_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_DeviceFull","PLAIN"];
_vehicle setVariable["mining",nil,true];
};
if (_itemIndex isEqualTo -1) then {
_inv pushBack [_resource,_sum];
} else {
_val = (_inv select _itemIndex) select 1;
_inv set[_itemIndex,[_resource,_val + _sum]];
};
if (fuel _vehicle < 0.1) exitWith {
_vehicle setVariable["mining",nil,true];
titleText[localize "STR_NOTF_OutOfFuel","PLAIN"];
};
//Locality checks...
if (local _vehicle) then {
_vehicle setFuel (fuel _vehicle)-0.05;
} else {
[_vehicle,(fuel _vehicle)-0.05] remoteExec ["life_fnc_setFuel",_vehicle];
};
if (fuel _vehicle < 0.1) exitWith {
titleText[localize "STR_NOTF_OutOfFuel","PLAIN"];
_vehicle setVariable["mining",nil,true];
};
_itemName = M_CONFIG(getText,"VirtualItems",_resource,"displayName");
titleText[format[localize "STR_NOTF_DeviceMined",_sum,(localize _itemName)],"PLAIN"];
_itemWeight = ([_resource] call life_fnc_itemWeight) * _sum;
_vehicle setVariable["Trunk",[_inv,_space + _itemWeight],true];
_weight = [_vehicle] call life_fnc_vehicleWeight;
_sum = [_resource,_random,(_weight select 1),(_weight select 0)] call life_fnc_calWeightDiff; //Get a sum base of the remaining weight..
if (_sum < 1) exitWith {
_vehicle setVariable["mining",nil,true];
titleText[localize "STR_NOTF_DeviceFull","PLAIN"];
};
sleep 2;
};
_vehicle setVariable ["mining",nil,true];
Alles anzeigen
und hier mal ein kleiner auszug aus meiner Config worum es geht^^:
Code: Config_Gather.hpp
class CfgGather {
zoneSize = 30;
class Resources {
class apple {
amount = 5;
zones[] = { "apple_1", "apple_2", "apple_3", "apple_4" };
item = "";
};
};
/*
This block can be set using percent,if you want players to mine only one resource ,just leave it as it is.
Example:
class copper_unrefined
{
amount = 2;
zones[] = { "copper_mine" };
item = "pickaxe";
mined[] = { "copper_unrefined" };
};
This will make players mine only copper_unrefined
Now let's go deeper
Example 2:
class copper_unrefined
{
amount = 2;
zones[] = { "copper_mine" };
item = "pickaxe";
mined[] = { {"copper_unrefined",0,25},{"iron_unrefined",25,95},{"diamond_uncut",95,100} };
};
This will give :
25(±1)% to copper_unrefined;
70(±1)% to iron_unrefined;
5%(±1)% to diamond_uncut;
! Watch Out !
If percents are used,you MUST put more than 1 resource in the mined parameter
mined[] = { {"copper_unrefined",0,25} }; NOT OK (But the script will work)
mined[] = { {"copper_unrefined",0,45 },{"iron_unrefined",45} }; NOT OK (The script won't work )
mined[] = { {"copper_unrefined",0,45},{"copper_unrefined",80,100} }; NOT OK
mined[] = { "copper_unrefined" }; OK
mined[] = { {"copper_unrefined",0,35} , { "iron_unrefined" ,35,100 } }; OK
*/
class Minerals {
class diamond_uncut {
amount = 1;
zones[] = { "diamond_mine" };
item = "pickaxe";
mined[] = { {"diamond_uncut",0,60}, {"emerald_uncut",60,90}, {"sapphire_uncut",90,100} };
};
};
};
Alles anzeigen