Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
crafttannedleather.c
Go to the documentation of this file.
1class 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
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}
Definition enmath.c:7
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
override Widget Init()
Definition dayzgame.c:127
const int MAX
Definition enconvert.c:27
bool m_IngredientUseSoftSkills[MAX_NUMBER_OF_INGREDIENTS]
Definition recipebase.c:48
float m_IngredientAddHealth[MAX_NUMBER_OF_INGREDIENTS]
Definition recipebase.c:49
bool m_IsInstaRecipe
Definition recipebase.c:40
float m_IngredientSetHealth[MAX_NUMBER_OF_INGREDIENTS]
Definition recipebase.c:51
const float DEFAULT_SPAWN_DISTANCE
Definition recipebase.c:3
float m_Specialty
Definition recipebase.c:39
float m_MinDamageIngredient[MAX_NUMBER_OF_INGREDIENTS]
Definition recipebase.c:45
float m_MaxQuantityIngredient[MAX_NUMBER_OF_INGREDIENTS]
Definition recipebase.c:44
bool m_AnywhereInInventory
Definition recipebase.c:41
void InsertIngredient(int index, string ingredient, DayZPlayerConstants uid=BASE_CRAFT_ANIMATION_ID, bool showItem=false)
Definition recipebase.c:159
float m_AnimationLength
Definition recipebase.c:38
float m_MaxDamageIngredient[MAX_NUMBER_OF_INGREDIENTS]
Definition recipebase.c:46
float m_IngredientAddQuantity[MAX_NUMBER_OF_INGREDIENTS]
Definition recipebase.c:50
float m_MinQuantityIngredient[MAX_NUMBER_OF_INGREDIENTS]
Definition recipebase.c:43
bool m_IngredientDestroy[MAX_NUMBER_OF_INGREDIENTS]
Definition recipebase.c:52
bool CanDo(PlayerBase player, TStringVectorMap surfaceTypes)
void Do(PlayerBase player)
class SyncedValue m_Name