mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2026-02-18 22:22:57 +03:00
1.0.2.12 developer build
This commit is contained in:
@@ -81,7 +81,6 @@ if (_finished) then {
|
||||
|
||||
_vehicle setVariable ["GeneratorSound", _soundSource,true];
|
||||
|
||||
// TODO: Add running sounds to generator
|
||||
cutText ["Generator has been started.", "PLAIN DOWN"];
|
||||
|
||||
};
|
||||
|
||||
@@ -50,14 +50,14 @@ _qty = count _obj;
|
||||
if(_qty >= 1) then {
|
||||
|
||||
//Remove melee magazines (BIS_fnc_invAdd fix) (add new melee ammo to array if needed)
|
||||
{player removeMagazines _x} forEach ["Hatchet_Swing","Crowbar_Swing","Machete_Swing","Fishing_Swing"];
|
||||
{player removeMagazines _x} forEach ["Hatchet_Swing","Crowbar_Swing","Machete_Swing","Fishing_Swing","sledge_swing"];
|
||||
|
||||
_config = (configFile >> _type >> _classname);
|
||||
_isOk = [player,_config] call BIS_fnc_invAdd;
|
||||
if (_isOk) then {
|
||||
|
||||
deleteVehicle _holder;
|
||||
if (_classname in ["MeleeHatchet","MeleeCrowbar","MeleeMachete","MeleeFishingPole"]) then {
|
||||
if (_classname in ["MeleeHatchet","MeleeCrowbar","MeleeMachete","MeleeFishingPole","MeleeSledge"]) then {
|
||||
|
||||
if (_type == "cfgWeapons") then {
|
||||
_muzzles = getArray(configFile >> "cfgWeapons" >> _classname >> "muzzles");
|
||||
@@ -77,6 +77,7 @@ if(_qty >= 1) then {
|
||||
case "MeleeCrowbar": {player addMagazine 'Crowbar_Swing';};
|
||||
case "MeleeMachete": {player addMagazine 'Machete_Swing';};
|
||||
case "MeleeFishingPole": {player addMagazine 'Fishing_Swing';};
|
||||
case "MeleeSledge": {player addMagazine 'sledge_swing';};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ _create = getArray (_config >> "ItemActions" >> "Toolbelt" >> "output") select
|
||||
_config2 = configFile >> "cfgWeapons" >> _create;
|
||||
|
||||
//Remove magazines if needed
|
||||
if (_item in ["MeleeHatchet","MeleeCrowbar","MeleeMachete","MeleeFishingPole"]) then {
|
||||
if (_item in ["MeleeHatchet","MeleeCrowbar","MeleeMachete","MeleeFishingPole","MeleeSledge"]) then {
|
||||
_magType = ([] + getArray (configFile >> "cfgWeapons" >> _item >> "magazines")) select 0;
|
||||
_meleeNum = ({_x == _magType} count magazines player);
|
||||
for "_i" from 1 to _meleeNum do {
|
||||
@@ -28,12 +28,14 @@ if (_item in ["MeleeHatchet","MeleeCrowbar","MeleeMachete","MeleeFishingPole"])
|
||||
};
|
||||
};
|
||||
|
||||
if (_item in ["ItemHatchet","ItemCrowbar","ItemMachete"]) then {
|
||||
if (_item in ["ItemHatchet","ItemCrowbar","ItemMachete","ItemFishingPole","ItemSledge"]) then {
|
||||
switch (primaryWeapon player) do
|
||||
{
|
||||
case "MeleeHatchet": { "MeleeHatchet" call player_addToolbelt };
|
||||
case "MeleeCrowbar": { "MeleeCrowbar" call player_addToolbelt };
|
||||
case "MeleeMachete": { "MeleeMachete" call player_addToolbelt };
|
||||
case "MeleeFishingPole": { "MeleeFishingPole" call player_addToolbelt };
|
||||
case "MeleeSledge": { "MeleeSledge" call player_addToolbelt };
|
||||
};
|
||||
};
|
||||
|
||||
@@ -44,10 +46,13 @@ if (_isOk) then {
|
||||
player removeWeapon _item;
|
||||
|
||||
//Add magazines if needed
|
||||
if (_create in ["MeleeHatchet","MeleeCrowbar","MeleeMachete","MeleeFishingPole"]) then {
|
||||
if (_create in ["MeleeHatchet","MeleeCrowbar","MeleeMachete","MeleeFishingPole","MeleeSledge"]) then {
|
||||
if (_create == "MeleeCrowbar") then {
|
||||
player addMagazine 'crowbar_swing';
|
||||
};
|
||||
if (_create == "MeleeSledge") then {
|
||||
player addMagazine 'sledge_swing';
|
||||
};
|
||||
if (_create == "MeleeHatchet") then {
|
||||
player addMagazine 'hatchet_swing';
|
||||
};
|
||||
@@ -71,10 +76,13 @@ if (_isOk) then {
|
||||
cutText [localize "STR_DAYZ_CODE_2", "PLAIN DOWN"];
|
||||
|
||||
//Add magazines back
|
||||
if (_item in ["MeleeHatchet","MeleeCrowbar","MeleeMachete","MeleeFishingPole"]) then {
|
||||
if (_item in ["MeleeHatchet","MeleeCrowbar","MeleeMachete","MeleeFishingPole","MeleeSledge"]) then {
|
||||
if (_item == "MeleeCrowbar") then {
|
||||
player addMagazine 'crowbar_swing';
|
||||
};
|
||||
if (_item == "MeleeSledge") then {
|
||||
player addMagazine 'sledge_swing';
|
||||
};
|
||||
if (_item == "MeleeHatchet") then {
|
||||
player addMagazine 'hatchet_swing';
|
||||
};
|
||||
|
||||
@@ -1,14 +1,36 @@
|
||||
/*
|
||||
DayZ Crafting
|
||||
Usage: spawn player_goFishing;
|
||||
Made for DayZ Epoch please ask permission to use/edit/distrubute email vbawol@veteranbastards.com.
|
||||
DayZ Epoch Crafting 0.3
|
||||
Made for DayZ Unleashed by [VB]AWOL please ask permission to use/edit/distrubute email vbawol@veteranbastards.com.
|
||||
Thanks to thevisad for help with the spawn call fixes.
|
||||
|
||||
USAGE EXAMPLE:
|
||||
class ItemActions
|
||||
{
|
||||
class Crafting
|
||||
{
|
||||
text = "Craft Tent";
|
||||
script = ";['Crafting','CfgMagazines', _id] spawn player_craftItem;"; // [Class of itemaction,CfgMagazines or CfgWeapons, item]
|
||||
neednearby[] = {"workshop","fire"};
|
||||
requiretools[] = {"ItemToolbox","ItemKnife"}; // (cfgweapons only)
|
||||
output[] = {{"ItemTent",1}}; // (CfgMagazines, qty)
|
||||
input[] = {{"ItemCanvas",2},{"ItemPole",2}}; // (CfgMagazines, qty)
|
||||
inputweapons[] = {"ItemToolbox"}; // consume toolbox (cfgweapons only)
|
||||
outputweapons[] = {"ItemToolbox"}; // return toolbox (cfgweapons only)
|
||||
};
|
||||
};
|
||||
*/
|
||||
private ["_onLadder","_canDo","_selectedRecipeOutput","_proceed","_itemIn","_countIn","_missing","_missingQty","_qty","_itemOut","_countOut","_started","_finished","_animState","_isMedic","_removed","_tobe_removed_total","_textCreate","_textMissing","_selectedRecipeInput","_num_removed","_removed_total","_temp_removed_array","_abort","_reason","_isNear","_missingTools","_hastoolweapon","_selectedRecipeTools","_distance","_crafting","_needNear","_consumeweapons","_item","_craft_doLoop"];
|
||||
private ["_onLadder","_canDo","_selectedRecipeOutput","_proceed","_itemIn","_countIn","_missing","_missingQty","_qty","_itemOut","_countOut","_started","_finished","_animState","_isMedic","_removed","_tobe_removed_total","_textCreate","_textMissing","_selectedRecipeInput","_num_removed","_removed_total","_temp_removed_array","_abort","_reason","_isNear","_missingTools","_hastoolweapon","_selectedRecipeTools","_distance","_crafting","_needNear","_item","_baseClass","_num_removed_weapons","_outputWeapons","_inputWeapons"];
|
||||
|
||||
if(TradeInprogress) exitWith { cutText ["\n\nCrafting already in progress." , "PLAIN DOWN"]; };
|
||||
TradeInprogress = true;
|
||||
|
||||
// temp array of removed parts
|
||||
// This is used to find correct recipe based what itemaction was click allows multiple recipes per item.
|
||||
_crafting = _this select 0;
|
||||
|
||||
// This tells the script what type of item we are clicking on
|
||||
_baseClass = _this select 1;
|
||||
|
||||
_item = _this select 2;
|
||||
|
||||
_abort = false;
|
||||
_distance = 3;
|
||||
@@ -17,12 +39,8 @@ _reason = "";
|
||||
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
|
||||
_canDo = (!r_drag_sqf and !r_player_unconscious and !_onLadder);
|
||||
|
||||
_item = _this;
|
||||
_crafting = "Crafting";
|
||||
|
||||
// check if fire is reqired
|
||||
_needNear = getArray (configFile >> "cfgMagazines" >> _item >> "ItemActions" >> _crafting >> "neednearby");
|
||||
|
||||
// Need Near Requirements
|
||||
_needNear = getArray (configFile >> _baseClass >> _item >> "ItemActions" >> _crafting >> "neednearby");
|
||||
if("fire" in _needNear) then {
|
||||
_isNear = {inflamed _x} count (position player nearObjects _distance);
|
||||
if(_isNear == 0) then {
|
||||
@@ -30,15 +48,13 @@ if("fire" in _needNear) then {
|
||||
_reason = "fire";
|
||||
};
|
||||
};
|
||||
|
||||
if("workshop" in _needNear) then {
|
||||
_isNear = count (nearestObjects [player, ["Wooden_shed_DZ","WoodShack_DZ","WorkBench_DZ"], 5]);
|
||||
_isNear = count (nearestObjects [player, ["Wooden_shed_DZ","WoodShack_DZ","WorkBench_DZ"], _distance]); // Needs changed to your workbench class
|
||||
if(_isNear == 0) then {
|
||||
_abort = true;
|
||||
_reason = "workshop";
|
||||
};
|
||||
};
|
||||
|
||||
if(_abort) exitWith {
|
||||
cutText [format["\n\nCrafting needs a %1 within %2 meters",_reason,_distance], "PLAIN DOWN"];
|
||||
TradeInprogress = false;
|
||||
@@ -48,65 +64,56 @@ if(_abort) exitWith {
|
||||
|
||||
if (_canDo) then {
|
||||
|
||||
// Moved all recipes input and outputs to configs
|
||||
|
||||
_selectedRecipeOutput = getArray (configFile >> "cfgMagazines" >> _item >> "ItemActions" >> _crafting >> "output");
|
||||
_selectedRecipeInput = getArray (configFile >> "cfgMagazines" >> _item >> "ItemActions" >> _crafting >> "input");
|
||||
_selectedRecipeTools = getArray (configFile >> "cfgMagazines" >> _item >> "ItemActions" >> _crafting >> "requiretools");
|
||||
_consumeweapons = getArray (configFile >> "cfgMagazines" >> _item >> "ItemActions" >> _crafting >> "consumeweapons");
|
||||
_selectedRecipeTools = getArray (configFile >> _baseClass >> _item >> "ItemActions" >> _crafting >> "requiretools");
|
||||
_selectedRecipeOutput = getArray (configFile >> _baseClass >> _item >> "ItemActions" >> _crafting >> "output");
|
||||
_selectedRecipeInput = getArray (configFile >> _baseClass >> _item >> "ItemActions" >> _crafting >> "input");
|
||||
_outputWeapons = getArray (configFile >> _baseClass >> _item >> "ItemActions" >> _crafting >> "outputweapons");
|
||||
_inputWeapons = getArray (configFile >> _baseClass >> _item >> "ItemActions" >> _crafting >> "inputweapons");
|
||||
|
||||
_craft_doLoop = true;
|
||||
|
||||
while {_craft_doLoop} do {
|
||||
|
||||
_temp_removed_array = [];
|
||||
|
||||
|
||||
_missing = "";
|
||||
_missingTools = false;
|
||||
{
|
||||
_hastoolweapon = _x in weapons player;
|
||||
if(!_hastoolweapon) exitWith { _craft_doLoop = false; _missingTools = true; _missing = _x; };
|
||||
} forEach _selectedRecipeTools;
|
||||
|
||||
|
||||
if(!_missingTools) then {
|
||||
|
||||
//diag_log format["Selected Recipe Input: %1", _selectedRecipeInput];
|
||||
//diag_log format["Selected Recipe Output: %1", _selectedRecipeOutput];
|
||||
|
||||
|
||||
|
||||
// Dry run to see if all parts are available.
|
||||
_proceed = true;
|
||||
{
|
||||
_itemIn = _x select 0;
|
||||
_countIn = _x select 1;
|
||||
|
||||
//diag_log format["Recipe Check: %1 %2", _itemIn,_countIn];
|
||||
|
||||
// not neccessary
|
||||
//if (!(_itemIn in magazines player)) exitWith { _missing = _itemIn; _missingQty = _countIn; _proceed = false; };
|
||||
|
||||
// match against class and parentClass
|
||||
_qty = { (_x == _itemIn) || (configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn) } count magazines player;
|
||||
|
||||
|
||||
_qty = { (_x == _itemIn) || (configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn) } count magazines player;
|
||||
|
||||
if(_qty < _countIn) exitWith { _missing = _itemIn; _missingQty = (_countIn - _qty); _proceed = false; };
|
||||
|
||||
} forEach _selectedRecipeInput;
|
||||
|
||||
|
||||
// If all parts proceed
|
||||
if (_proceed) then {
|
||||
|
||||
|
||||
cutText ["\n\nCrafting started", "PLAIN DOWN"];
|
||||
|
||||
|
||||
player playActionNow "Medic";
|
||||
|
||||
|
||||
[player,"repair",0,false] call dayz_zombieSpeak;
|
||||
[player,50,true,(getPosATL player)] spawn player_alertZombies;
|
||||
|
||||
|
||||
r_interrupt = false;
|
||||
_animState = animationState player;
|
||||
r_doLoop = true;
|
||||
_started = false;
|
||||
_finished = false;
|
||||
|
||||
|
||||
while {r_doLoop} do {
|
||||
_animState = animationState player;
|
||||
_isMedic = ["medic",_animState] call fnc_inString;
|
||||
@@ -123,9 +130,9 @@ if (_canDo) then {
|
||||
sleep 0.1;
|
||||
};
|
||||
r_doLoop = false;
|
||||
|
||||
|
||||
if (_finished) then {
|
||||
|
||||
|
||||
_removed_total = 0; // count total of removed items
|
||||
_tobe_removed_total = 0; // count total of all to be removed items
|
||||
// Take items
|
||||
@@ -135,7 +142,7 @@ if (_canDo) then {
|
||||
_countIn = _x select 1;
|
||||
// diag_log format["Recipe Finish: %1 %2", _itemIn,_countIn];
|
||||
_tobe_removed_total = _tobe_removed_total + _countIn;
|
||||
|
||||
|
||||
{
|
||||
if( (_removed < _countIn) && ((_x == _itemIn) || configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn)) then {
|
||||
_num_removed = ([player,_x] call BIS_fnc_invRemove);
|
||||
@@ -145,48 +152,47 @@ if (_canDo) then {
|
||||
_temp_removed_array set [count _temp_removed_array,_x];
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
} forEach magazines player;
|
||||
|
||||
|
||||
} forEach _selectedRecipeInput;
|
||||
|
||||
|
||||
//diag_log format["removed: %1 of: %2", _removed, _tobe_removed_total];
|
||||
|
||||
|
||||
// Only proceed if all parts were removed successfully
|
||||
if(_removed_total == _tobe_removed_total) then {
|
||||
|
||||
// Put items
|
||||
_num_removed_weapons = 0;
|
||||
{
|
||||
// consumeweapons
|
||||
_num_removed_weapons = _num_removed_weapons + ([player,_x] call BIS_fnc_invRemove);
|
||||
} forEach _inputWeapons;
|
||||
if (_num_removed_weapons == (count _inputWeapons)) then {
|
||||
{
|
||||
player removeWeapon _x;
|
||||
} forEach _consumeweapons;
|
||||
|
||||
_itemOut = _x select 0;
|
||||
_countOut = _x select 1;
|
||||
//diag_log format["Recipe Output: %1 %2", _itemOut,_countOut];
|
||||
player addWeapon _x;
|
||||
} forEach _outputWeapons;
|
||||
{
|
||||
|
||||
_itemOut = _x select 0;
|
||||
_countOut = _x select 1;
|
||||
|
||||
for "_x" from 1 to _countOut do {
|
||||
player addMagazine _itemOut;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// get display name
|
||||
_textCreate = getText(configFile >> "CfgMagazines" >> _itemOut >> "displayName");
|
||||
for "_x" from 1 to _countOut do {
|
||||
player addMagazine _itemOut;
|
||||
};
|
||||
|
||||
_textCreate = getText(configFile >> "CfgMagazines" >> _itemOut >> "displayName");
|
||||
|
||||
// Add crafted item
|
||||
cutText [format["\n\nCrafted Item: %1 x %2",_textCreate,_countOut], "PLAIN DOWN"];
|
||||
|
||||
} forEach _selectedRecipeOutput;
|
||||
|
||||
|
||||
} forEach _selectedRecipeOutput;
|
||||
};
|
||||
|
||||
} else {
|
||||
// Refund parts since we failed
|
||||
{player addMagazine _x;} forEach _temp_removed_array;
|
||||
|
||||
|
||||
cutText [format["\n\nMissing Parts after first check Item: %1 / %2",_removed_total,_tobe_removed_total], "PLAIN DOWN"];
|
||||
};
|
||||
|
||||
|
||||
} else {
|
||||
r_interrupt = false;
|
||||
if (vehicle player == player) then {
|
||||
@@ -196,7 +202,7 @@ if (_canDo) then {
|
||||
cutText ["\n\nCanceled crafting.", "PLAIN DOWN"];
|
||||
_craft_doLoop = false;
|
||||
};
|
||||
|
||||
|
||||
} else {
|
||||
_textMissing = getText(configFile >> "CfgMagazines" >> _missing >> "displayName");
|
||||
cutText [format["\n\nMissing %1 more of %2",_missingQty, _textMissing], "PLAIN DOWN"];
|
||||
@@ -209,7 +215,6 @@ if (_canDo) then {
|
||||
};
|
||||
};
|
||||
} else {
|
||||
cutText ["\n\nCrafting needs a fire within 3 meters.", "PLAIN DOWN"];
|
||||
cutText ["\n\nCanceled crafting.", "PLAIN DOWN"];
|
||||
};
|
||||
|
||||
TradeInprogress = false;
|
||||
@@ -18,7 +18,9 @@ player removeWeapon _item;
|
||||
if (_item == "MeleeHatchet") then {_item = "ItemHatchet";};
|
||||
if (_item == "MeleeCrowbar") then {_item = "MeleeCrowbar";};
|
||||
if (_item == "MeleeMachete") then {_item = "ItemMachete";};
|
||||
if (_item == "MeleeFishingPole") then {_item = "MeleeFishingPole";};
|
||||
|
||||
//if (_item == "MeleeFishingPole") then {_item = "MeleeFishingPole";};
|
||||
//if (_item == "MeleeSledge") then {_item = "MeleeSledge";};
|
||||
|
||||
_bag = createVehicle [format["WeaponHolder_%1",_item],getPosATL player,[], 0, "CAN_COLLIDE"];
|
||||
_bag setdir (getDir player);
|
||||
|
||||
@@ -127,7 +127,6 @@ for "_x" from 1 to _total_trades do {
|
||||
} else {
|
||||
|
||||
// Return items from botched trade.
|
||||
// TODO: this may never happen if so remove
|
||||
for "_x" from 1 to _removed do {
|
||||
player addMagazine _part_in;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user