[Release] Crafting Wooden Arrows (pwnzor0z 1.7.7.1)

BDC

Well-Known Member
(Updated Aug 24 - added 8th Empty Tin Can type)

Howdy folks, I just finished up an add-on that enables the player to craft his or her own wooden arrows. I'm not sure if any add-ons of this type exist as I didn't check ahead of time. This was tested on my own private server using Pwnzor0z's private Hive setup version 1.7.7.1 and seems to work pretty well so far. The option for crafting is enabled when the player is looking at a wood pile on the ground (un-lit fireplace). If the necessary components aren't in the player's inventory, the option will still exist but will be grey in colour and, upon selecting the option, will inform the player what he or she is missing components-wise.

The crafting process requires a deck of playing cards (just one deck and they are not consumed in the process, any type of tin can (I have found four different types in DayZ so far), a hunting knife, and a toolbox, with the aforementioned wood pile made into a fireplace on the ground. The entire process takes about a minute and 15 seconds and can be interrupted. There is also an 18% possibility that an individual arrow fabrication can fail resulting in getting only one arrow or getting neither. Best case is completion of two wooden arrows that then appear in your inventory. It's my opinion that due to the time and item constraints as well as the chance of failure that this add-on is balanced given the reward potential.

One script file is added (player_craftwoodenarrows.sqf) and three others are modified (fn_selfActions.sqf, compiles.sqf, and init.sqf).

[Installation]

Installation is very simple. In my scripts, I use the compiles.sqf editing method instead of unpacking the dayz_code.pbo files. Everything is done server-side only. This installation applies only to the Pwnzor0z package as the pathing for file locations is different.

1) First, in your \dayzinstallfolder\MPMissions\dayz_1.Chernarus folder, create a subfolder called "fixes" or use another name if a folder with other add-on scripts exists.

2) Place the file player_craftwoodenarrows.sqf in this new \MPMissions\dayz_1.Chernarus\fixes folder. This file can be downloaded here: http://www.mediafire.com/?ywr4u1b8ojak9vo

- If there is a problem with the link or the Mediafire website, scroll down to the next post as I will have posted the entire body of this file into its own Code section so it can be replicated by hand.

3) Modify the file compiles.sqf located in the \dayzinstallfolder\MPMissions\dayz_1.Chernarus folder. If one does not already exist there, the compiles.sqf file can be unpacked from the dayz_code.pbo file located in the \dayzinstallfolder\@dayz\addons folder. Many of the add-on mods modify a certain section of this file so it may already be located in this folder. In this file, look for the following on or about line 14:

Code:
fnc_usec_selfActions = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_selfActions.sqf";        //Checks which actions for self



Comment that line out with two forward slashes and add this just below it:

Code:
fnc_usec_selfActions = compile preprocessFileLineNumbers "fixes\fn_selfActions.sqf";            // Modified by ^bdc

Here's how it ought to look now:

Code:
//fnc_usec_selfActions = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_selfActions.sqf";//Checks which actions for self
fnc_usec_selfActions = compile preprocessFileLineNumbers "fixes\fn_selfActions.sqf";// Modified by ^bdc


This should point compiles.sqf, when loading the server, to look for the file fn_selfActions.sqf in our new fixes folder we've just added.

3a) For those unfamiliar with the .pbo file unpacking/packing process, it is similar to using an archive extraction program like WinRAR or 7-Zip. Many of the scripts used in the DayZ mod are in several of these .pbo files. The program I use is PBOView and more can be learned about it (plus a download link provided) in this thread here: http://forums.bistudio.com/showthread.php?123041-Pbo-Tools-(PBOView-amp-cpbo)

4) Modify the file init.sqf located in \dayzinstallfolder\MPMissions\dayz_1.Chernarus folder. If it does not exist there (that would be a real trip), a "stock" version of this can be found linked on GitHub here: https://github.com/Pwnoz0r/DayZ-Private-Server/blob/master/MPMissions/dayz_1.Chernarus/init.sqf

Open up the file and head down to on or about line 30 and look for this:

Code:
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf";                    //Compile regular functions

Comment that line out by adding two // in front of it and just below it add this:

Code:
call compile preprocessFileLineNumbers "compiles.sqf";                    // Modified for addons by ^bdc

... and how it should now look:

Code:
//call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf";                    //Compile regular functions
call compile preprocessFileLineNumbers "compiles.sqf";                    // Modified for addons by ^bdc

5) Unpack \dayzinstallfolder\@dayz\addons\dayz_code.pbo, get to the compile folder within that, and extract the file fn_selfActions.sqf. Place it in the new fixes folder located off of \dayzinstallfolder\MPMissions\dayz_1.Chernarus that we created earlier. Open up this file in a good quality editor like Notepad++.


Look for these two lines on or about line 28:

Code:
_hasKnife = "ItemKnife" in items player;
_hasToolbox = "ItemToolbox" in items player;

Directly below those two lines, add this:

Code:
_hasTinCan = "TrashTinCan" in magazines player;
_hasTinCan2 = "FoodCanRusStewEmpty" in magazines player;
_hasTinCan3 = "FoodCanUnlabeledEmpty" in magazines player;
_hasTinCan4 = "FoodCanRusMilkEmpty" in magazines player;
_hasTinCan5 = "FoodCanRusPeasEmpty" in magazines player;
_hasTinCan6 = "FoodCanRusPorkEmpty" in magazines player;
_hasTinCan7 = "FoodCanRusCornEmpty" in magazines player;
_hasTinCan8 = "FoodCanRusUnlabeledEmpty" in magazines player;
_hasPlayingCards = "ItemCards" in magazines player;

This adds the variables required to populate the coloured "Craft Wooden Arrows (x2)" option. These are used to collect information on whether or not the player has any of the different types of tin cans as well as playing cards.

Further down, on or about line 42, we'll find this section of code with the commented out title "Grab Flare" that enables the ability for players to pick up lit flares on the ground:

Code:
//Grab Flare
if (_canPickLight and !dayz_hasLight) then {
if (s_player_grabflare < 0) then {
_text = getText (configFile >> "CfgAmmo" >> (typeOf _nearLight) >> "displayName");
s_player_grabflare = player addAction [format[localize "str_actions_medical_15",_text], "\z\addons\dayz_code\actions\flare_pickup.sqf",_nearLight, 1, false, true, "", ""];
s_player_removeflare = player addAction [format[localize "str_actions_medical_17",_text], "\z\addons\dayz_code\actions\flare_remove.sqf",_nearLight, 1, false, true, "", ""];
};
} else {
player removeAction s_player_grabflare;
player removeAction s_player_removeflare;
s_player_grabflare = -1;
s_player_removeflare = -1;
};

Just below that complete section, add this additional section:

Code:
//Craft Wooden Arrows - by ^bdc
if (!_inVehicle and _canDo and (cursorTarget isKindOf "Land_Fire_DZ") and !a_player_jerryfilling and !a_player_cooking) then {
_isCrafting = cursorTarget getVariable["meatHarvested",false];
if (s_player_craftwoodenarrows < 0) then {
  if (_hasToolbox and _hasKnife and _hasPlayingCards and (_hasTinCan or _hasTinCan2 or _hasTinCan3 or _hasTinCan4 or _hasTinCan5 or _hasTinCan6 or _hasTinCan7 or _hasTinCan8) and (!_isCrafting) and !(inflamed cursorTarget)) then {
s_player_craftwoodenarrows = player addAction [("<t color=""#EC7600"">" + ("Craft Wooden Arrows (x2)") + "</t>"), "fixes\player_craftwoodenarrows.sqf",[], 1, false, true, "", ""];
} else {
s_player_craftwoodenarrows = player addAction [("<t color=""#A0A0A0"">" + ("Craft Wooden Arrows (x2)") + "</t>"), "fixes\player_craftwoodenarrows.sqf",[], 1, false, true, "", ""];
};
};
} else {
player removeAction s_player_craftwoodenarrows;
s_player_craftwoodenarrows = -1;
};

This chunk of code enables the either greyed-out option or the coloured option to "Craft Wooden Arrows (x2)" depending upon inventory. In each of the two "s_player_craftwoodenarrows = player addAction" lines, you'll notice the path to the new script file as "fixes\player_craftwoodenarrows.sqf". Check and ensure the player_craftwoodenarrows.sqf file is located in \dayzinstallfolder\MPMissions\dayz_1.Chernarus\fixes folder as reflected in these two lines. If not, change the folder name to accomodate.

Questions? PM me or visit the the help thread and post your questions here: http://opendayz.net/threads/bdcs-script-addon-help-thread.13295/

B
 
Update note for the 24th of Aug - I found a 8th "Empty Tin Can" type and added it into both the player_craftwoodenarrows.sqf script file as well as the variable declaration and "Craft Wooden Arrows (x2)" selection code in fn_selfActions.sqf. Also updated the player_craftwoodenarrows.sqf download link:

http://www.mediafire.com/?ywr4u1b8ojak9vo
 
Back
Top