Alles anzeigennaja in der 5.0 würde ich es so umsetzen
fn_gather.sqf
Code Alles anzeigen#include "..\..\script_macros.hpp" /* File: fn_gather.sqf Author: Devilfloh Description: Main functionality for gathering. */ private ["_maxGather","_resource","_amount","_maxGather","_requiredItem"]; if (life_action_inUse) exitWith {}; if !(isNull objectParent player) exitWith {}; if (player getVariable "restrained") exitWith {hint localize "STR_NOTF_isrestrained";}; if (player getVariable "playerSurrender") exitWith {hint localize "STR_NOTF_surrender";}; life_action_inUse = true; _zone = ""; _requiredItem = ""; _exit = false; _resourceCfg = missionConfigFile >> "CfgGather" >> "Resources"; for "_i" from 0 to count(_resourceCfg)-1 do { _curConfig = _resourceCfg select _i; _resource = configName _curConfig; _maxGather = getNumber(_curConfig >> "amount"); _zoneSize = getNumber(_curConfig >> "zoneSize"); _resourceZones = getArray(_curConfig >> "zones"); _requiredItem = getText(_curConfig >> "item"); _randomItem = getArray(_curConfig >> "Random"); { if ((player distance (getMarkerPos _x)) < _zoneSize) exitWith {_zone = _x;}; } forEach _resourceZones; if (_zone != "") exitWith {}; }; if (_zone isEqualTo "") exitWith {life_action_inUse = false;}; if (_requiredItem != "") then { _valItem = missionNamespace getVariable "life_inv_" + _requiredItem; if (_valItem < 1) exitWith { switch (_requiredItem) do { //Messages here }; life_action_inUse = false; _exit = true; }; }; if (_exit) exitWith {life_action_inUse = false;}; _amount = round(random(_maxGather)) + 1; _diff = [_resource,_amount,life_carryWeight,life_maxWeight] call life_fnc_calWeightDiff; if (_diff isEqualTo 0) exitWith { hint localize "STR_NOTF_InvFull"; life_action_inUse = false; }; switch (_requiredItem) do { case "pickaxe": {player say3D "mining";}; default {player say3D "harvest";}; }; for "_i" from 0 to 4 do { player playMoveNow "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon"; waitUntil{animationState player != "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon";}; sleep 0.5; }; _dice = random(100); if(_dice < 80) then { if ([true,_resource,_diff] call life_fnc_handleInv) then { _itemName = M_CONFIG(getText,"VirtualItems",_resource,"displayName"); titleText[format [localize "STR_NOTF_Gather_Success",(localize _itemName),_diff],"PLAIN"]; }; }else{ _radom = random _randomItem; if ([true,_random,_diff] call life_fnc_handleInv) then { _itemName = M_CONFIG(getText,"VirtualItems",_resource,"displayName"); titleText[format [localize "STR_NOTF_Gather_Success",(localize _itemName),_diff],"PLAIN"]; }; sleep 1; life_action_inUse = false;
und in der Config_Gather.hpp
einafch bei den sachen
Random[] = {"apple","peach"};
z.b.
Codeclass apple { amount = 5; zones[] = { "apple_1", "apple_2", "apple_3", "apple_4" }; item = ""; zoneSize = 30; Random[] = {"sand","peach"}; };
so ist es eine 20% chanche das er beim apfel farmen auf einmal eins der eingetragenen sachen bekommt im Beispiel sand oder Pfrisich
Hab es in der 5.0 gerade getestet, funktioniert leider nicht, keine Fehler im LOG.
Er farmt zwar, leider nur ohne Erfolg, sprich man bekommt nichtmal einen Apfel.
P.S. ich weiß nicht, ob es damit zutun hat, dass ich das farmen generell an das vorhandene Skill-System angepasst habe