Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Repair items

Skilled Illusionist
Joined
Jul 27, 2006
Messages
357
Reaction score
25
I started a little research about how items can be repaired and I share my results. I know for some this is not something new, and I think the result of reinventing the wheel is because not all wants to share, their reasons are their own.
Aaaanyways, in Dayz items durability is given as damage % for item:

Code:
0 - 0.3 - pristine
0.31 - 0.6 - worn
0.61 - 0.9 - damaged
0.9 - 0.99 - badly damaged
1 - ruined, 100% damaged

Items that can be repaired have a property that defines it could be repaired with what:
Code:
itemSize[] = {2, 2};
		repairableWith = 2;		// < -- repairable with "repairKitType"

on boots for example :
Code:
repairableWith="RepairLeatherSewingKit"; //this means maybe that you can define a new class for repair (as string)

and items that are assumed as "repairKitType", have also a property:
Code:
Tool_WeaponCleaningKit	->	repairKitType = 1;
Tool_SewingKit		->	repairKitType = 2;
Tool_LeatherSewingKit	->	repairKitType = "RepairLeatherSewingKit";

Still not sure about what repair items is repairKitType = 0; that some items have repairableWith = 0;

The only item that don't have property "repairKitType" is duct tape, and because from starting is assumed it can repair all items except some blacklisted, defined in modules_dayz/scripts/fnc_isItemDuctTapeCompatible.sqf

Also there is also defined how much it can repair:
Code:
ductTapeRepairDamage = 0.5; // Damage tolerance. No repairing below this amount. <-- means if ductTapeRepairDamage = 0, then duct tape will repair to pristine, if _item setDamage 0.0 in function player_mendItem.

The other items, maximum level that it can repair is defined in server_data/scripts/players/player_mendItem.sqf :
Code:
switch true do
{
	case (_damageItem >= 1):
	{
		[_owner,format["%1 is ruined and cannot be mended with %2",displayName _item,displayName _kit],'colorAction'] call fnc_playerMessage;
	};
	case (_damageItem > 0.3):
	{
		[_owner,format["I have mended %1.",displayName _item],'colorAction'] call fnc_playerMessage;
		_item setDamage 0.31;		// <-- setDamage 0.0; = repair to pristine
		_kit setDamage (_damageKit + 0.1);	//<-- (_damageKit + 0.1) if commented, kit will not suffer degradation
	};
	case (_damageItem <= 0.3):
	{
		[_owner,format["%1 is pristine and it doesn't need to be mended.",displayName _item],'colorAction'] call fnc_playerMessage;
	};
};

I think custom repair items can be defined as repairKitType = "SomeCustomRepairKit" and items that can be repaired with must have property repairableWith="SomeCustomRepairKit";
 
Skilled Illusionist
Joined
Jul 27, 2006
Messages
357
Reaction score
25
This is a practical example:

Repair weapon attachments: the AK buttstock wooden

Weapon_supports/config.bin
Code:
class ButtstockBase : AttachmentBase
	{
		scope = 0;
		handAnim[] = {
				"OFP2_ManSkeleton", "\DZ\anims\data\anim\sdr\ik\tools\hammer_ik.rtm"
		};
		itemSize[] = {
				1, 2
		};
		repairableWith = 1;	//ADD THIS HERE, means that can be repaired with weapon cleaning kit			

		class Melee 
		{
			range = 1.500000;
			swingTime = 0.500000;
			action = "MeleeKnifeSlash";
			ammo = "MeleeLightBlunt";
			useCursor = 0;
		};
		recoilModifier = "[1, 0.8, 0.6]";
	};

In gear_tools/config.bin we define that the buttstocks can be repaired with weapon cleaning kit:
search
Code:
class CleanRifle {
		name = "Clean %TOOL1 with %TOOL2";
		tools[] = {"DefaultWeapon", "Tool_WeaponCleaningKit"};
		playerAction = "PlayerCraft";
		action = "'cfgWeapons' call player_mendItem;";
	};
and add it after :

Code:
	class CleanButtstocks {
		name = "Clean %TOOL1 with %TOOL2";
		tools[] = {"ButtstockBase", "Tool_WeaponCleaningKit"};
		playerAction = "PlayerCraft";
		action = "'cfgVehicles' call player_mendItem;";
	};

now pack back to pbo or simply you can make an gear_tools_fix pbo if you don't want to edit the whole addon.
 
Back
Top