Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
crafttannedleather.c
Go to the documentation of this file.
1
class
CraftTannedLeather
extends
RecipeBase
2
{
3
float
m_PercentageUsed
= 0.05;
//Variable used to define relative quantity of Lime used when crafting tanned leather
4
5
//Init Leather crafting recipe
6
override
void
Init
()
7
{
8
m_Name
=
"#STR_CraftTannedLeather0"
;
9
m_IsInstaRecipe
=
false
;
//should this recipe be performed instantly without animation
10
m_AnimationLength
= 1;
//animation length in relative time units
11
m_Specialty
= 0.02;
// value > 0 for roughness, value < 0 for precision
12
13
m_AnywhereInInventory
=
true
;
14
//conditions
15
m_MinDamageIngredient
[0] = -1;
//-1 = disable check
16
m_MaxDamageIngredient
[0] = 3;
//-1 = disable check
17
18
m_MinQuantityIngredient
[0] = -1;
//-1 = disable check
19
m_MaxQuantityIngredient
[0] = -1;
//-1 = disable check
20
21
m_MinDamageIngredient
[1] = -1;
//-1 = disable check
22
m_MaxDamageIngredient
[1] = 3;
//-1 = disable check
23
24
m_MinQuantityIngredient
[1] = -1;
//-1 = disable check
25
m_MaxQuantityIngredient
[1] = -1;
//-1 = disable check
26
27
//INGREDIENTS
28
//ingredient 1
29
InsertIngredient
(0,
"Pelt_Base"
);
//you can insert multiple ingredients this way
30
31
m_IngredientAddHealth
[0] = 0;
// 0 = do nothing
32
m_IngredientSetHealth
[0] = -1;
// -1 = do nothing
33
m_IngredientAddQuantity
[0] = -1;
// 0 = do nothing
34
m_IngredientDestroy
[0] =
true
;
//true = destroy, false = do nothing
35
m_IngredientUseSoftSkills
[0] =
false
;
// set 'true' to allow modification of the values by softskills on this ingredient
36
37
//ingredient 2
38
InsertIngredient
(1,
"GardenLime"
);
//you can insert multiple ingredients this way
39
40
m_IngredientAddHealth
[1] = 0;
// 0 = do nothing
41
m_IngredientSetHealth
[1] = -1;
// -1 = do nothing
42
m_IngredientAddQuantity
[1] = 0;
// 0 = do nothing
43
m_IngredientDestroy
[1] =
false
;
//true = destroy, false = do nothing
44
m_IngredientUseSoftSkills
[1] =
false
;
// set 'true' to allow modification of the values by softskills on this ingredient
45
46
//----------------------------------------------------------------------------------------------------------------------
47
}
48
49
override
bool
CanDo
(
ItemBase
ingredients[],
PlayerBase
player)
//final check for recipe's validity
50
{
51
52
Pelt_Base
ingredient1 =
Pelt_Base
.Cast(ingredients[0]);
53
ItemBase
ingredient2 = ingredients[1];
//The garden lime
54
55
//Evaluate the amount of Lime required to craft leather from Pelt (percentage based)
56
float
yieldQuantity = ingredient1.ConfigGetFloat(
"leatherYield"
);
57
float
qtyModifier = (4 - ingredient1.GetHealthLevel(
""
))/4;
// Normalize the health level so Pristine is 1 and Ruined is 0. Necessary like this on CLIENT
58
yieldQuantity =
Math
.
Clamp
(yieldQuantity * qtyModifier,1,
float
.
MAX
);
59
60
float
m_NeededQuantity = (ingredient2.GetQuantityMax() *
m_PercentageUsed
) * yieldQuantity;
61
if
( ingredient1.ConfigGetFloat(
"leatherYield"
) >= 0 && ingredient2.GetQuantity() >= m_NeededQuantity)
62
{
63
return
true
;
64
}
65
else
66
{
67
return
false
;
68
}
69
}
70
71
override
void
Do
(
ItemBase
ingredients[],
PlayerBase
player,
array<ItemBase>
results,
float
specialty_weight )
//gets called upon recipe's completion
72
{
73
ItemBase
ingredient1 = ingredients[0];
74
75
//Set tanned leather output quantity
76
int
yieldQuantity = ingredient1.ConfigGetFloat(
"leatherYield"
);
77
float
qtyModifier = ingredient1.GetHealth01(
""
,
"Health"
);
78
yieldQuantity =
Math
.
Clamp
(yieldQuantity * qtyModifier,1,
float
.
MAX
);
79
80
//Use X% of GardenLime for each tanned leather item crafted
81
ItemBase
gardenLime = ingredients[1];
82
float
usedLime = (gardenLime.GetQuantityMax() *
m_PercentageUsed
) * yieldQuantity;
83
gardenLime.
SetQuantity
(gardenLime.GetQuantity() - usedLime);
84
85
//Create output piles
86
vector
posHead;
87
MiscGameplayFunctions.GetHeadBonePos(player,posHead);
88
vector
posTarget = player.GetPosition() + (player.GetDirection() *
DEFAULT_SPAWN_DISTANCE
);
89
MiscGameplayFunctions.CreateItemBasePilesDispersed(
"TannedLeather"
,posHead,posTarget,
UAItemsSpreadRadius
.
NARROW
,yieldQuantity,
float
.MAX,player);
90
}
91
}
m_Name
string m_Name
Definition
inventoryitemtype.c:34
ItemBase
Definition
inventoryitem.c:742
ItemBase::SetQuantity
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Definition
pileofwoodenplanks.c:88
Math
Definition
enmath.c:7
PlayerBase
Definition
playerbaseclient.c:2
RecipeBase
Definition
attachholster.c:2
RecipeBase::CanDo
override bool CanDo(ItemBase ingredients[], PlayerBase player)
Definition
crafttannedleather.c:49
RecipeBase::m_PercentageUsed
float m_PercentageUsed
Definition
crafttannedleather.c:3
RecipeBase::Init
override void Init()
Definition
crafttannedleather.c:6
RecipeBase::Do
override void Do(ItemBase ingredients[], PlayerBase player, array< ItemBase > results, float specialty_weight)
Definition
crafttannedleather.c:71
UAItemsSpreadRadius
Definition
actionconstants.c:124
UAItemsSpreadRadius::NARROW
const float NARROW
Definition
actionconstants.c:127
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
vector
Definition
enconvert.c:119
MAX
const int MAX
Definition
enconvert.c:27
Math::Clamp
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
Pelt_Base
class Pelt_Base extends ItemBase Pelt_Base
m_IngredientUseSoftSkills
bool m_IngredientUseSoftSkills[MAX_NUMBER_OF_INGREDIENTS]
Definition
recipebase.c:48
m_IngredientAddHealth
float m_IngredientAddHealth[MAX_NUMBER_OF_INGREDIENTS]
Definition
recipebase.c:49
m_IsInstaRecipe
bool m_IsInstaRecipe
Definition
recipebase.c:40
m_IngredientSetHealth
float m_IngredientSetHealth[MAX_NUMBER_OF_INGREDIENTS]
Definition
recipebase.c:51
DEFAULT_SPAWN_DISTANCE
const float DEFAULT_SPAWN_DISTANCE
Definition
recipebase.c:3
m_Specialty
float m_Specialty
Definition
recipebase.c:39
m_MinDamageIngredient
float m_MinDamageIngredient[MAX_NUMBER_OF_INGREDIENTS]
Definition
recipebase.c:45
m_MaxQuantityIngredient
float m_MaxQuantityIngredient[MAX_NUMBER_OF_INGREDIENTS]
Definition
recipebase.c:44
m_AnywhereInInventory
bool m_AnywhereInInventory
Definition
recipebase.c:41
InsertIngredient
void InsertIngredient(int index, string ingredient, DayZPlayerConstants uid=BASE_CRAFT_ANIMATION_ID, bool showItem=false)
Definition
recipebase.c:159
m_AnimationLength
float m_AnimationLength
Definition
recipebase.c:38
m_MaxDamageIngredient
float m_MaxDamageIngredient[MAX_NUMBER_OF_INGREDIENTS]
Definition
recipebase.c:46
m_IngredientAddQuantity
float m_IngredientAddQuantity[MAX_NUMBER_OF_INGREDIENTS]
Definition
recipebase.c:50
m_MinQuantityIngredient
float m_MinQuantityIngredient[MAX_NUMBER_OF_INGREDIENTS]
Definition
recipebase.c:43
m_IngredientDestroy
bool m_IngredientDestroy[MAX_NUMBER_OF_INGREDIENTS]
Definition
recipebase.c:52
Games
Dayz
scripts
4_world
classes
recipes
recipes
crafttannedleather.c
Generated by
1.17.0