DayZ 1.24
Loading...
Searching...
No Matches
CraftTannedLeather.c
Go to the documentation of this file.
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 //result1
49 AddResult("TannedLeather"); //add results here
50
51 m_ResultSetFullQuantity[0] = false; //true = set full quantity, false = do nothing
52 m_ResultSetQuantity[0] = -1; //-1 = do nothing
53 m_ResultSetHealth[0] = -1; //-1 = do nothing
54 m_ResultInheritsHealth[0] = -2; // (value) == -1 means do nothing; a (value) >= 0 means this result will inherit health from ingredient number (value);(value) == -2 means this result will inherit health from all ingredients averaged(result_health = combined_health_of_ingredients / number_of_ingredients)
55 m_ResultInheritsColor[0] = -1; // (value) == -1 means do nothing; a (value) >= 0 means this result classname will be a composite of the name provided in AddResult method and config value "color" of ingredient (value)
56 m_ResultToInventory[0] = -2; //(value) == -2 spawn result on the ground;(value) == -1 place anywhere in the players inventory, (value) >= 0 means switch position with ingredient number(value)
57 m_ResultUseSoftSkills[0] = false; // set 'true' to allow modification of the values by softskills on this result
58 m_ResultReplacesIngredient[0] = -1; // value == -1 means do nothing; a value >= 0 means this result will transfer item propertiesvariables, attachments etc.. from an ingredient value
59 }
60
61 override bool CanDo(ItemBase ingredients[], PlayerBase player)//final check for recipe's validity
62 {
63
64 //return true;
65 Pelt_Base ingredient1 = Pelt_Base.Cast(ingredients[0]);
66 ItemBase ingredient2 = ingredients[1]; //The garden lime
67
68 //Evaluate the amount of Lime required to craft leather from Pelt (percentage based)
69 float yieldQuantity = ingredient1.ConfigGetFloat("leatherYield");
70 float qtyModifier = (4 - ingredient1.GetHealthLevel("")) / 4; // Normalize the health level so Pristine is 1 and Ruined is 0
72
73 float m_NeededQuantity = (ingredient2.GetQuantityMax() * m_PercentageUsed) * yieldQuantity;
74 if (ingredient1.ConfigGetFloat("leatherYield") >= 0 && ingredient2.GetQuantity() >= m_NeededQuantity)
75 return true;
76 else
77 return false;
78
79 }
80
81
82 override void Do(ItemBase ingredients[], PlayerBase player, array<ItemBase> results, float specialty_weight) //gets called upon recipe's completion
83 {
84 Debug.Log("Craft Tanned Leather", "recipes");
85
87 Class.CastTo(result, results.Get(0));
89
90 //Set tanned leather output quantity
91 int quantity = ingredient1.ConfigGetFloat("leatherYield");
92 float qtyModifier = (4 - ingredient1.GetHealthLevel("")) / 4; // Normalize the health level so Pristine is 1 and Ruined is 0
94
95 result.SetQuantity(quantity);
96
97 //Use X% of GardenLime for each tanned leather item crafted
99 float usedLime = (gardenLime.GetQuantityMax() * m_PercentageUsed) * quantity;
100 gardenLime.SetQuantity(gardenLime.GetQuantity() - usedLime);
101
102 result.SetHealthMax("", "");
103
104 //Split stack if returned quantity over Max stack
105 if (quantity > result.GetQuantityMax())
106 {
107 //Allow spawn of a second stack of tanned leather
108 MiscGameplayFunctions.CreateItemBasePiles("TannedLeather", player.GetPosition(), (quantity - 8), result.GetMaxHealth(), false);
109 }
110 }
111}
string m_Name
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition Debug.c:14
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition Debug.c:133
override bool CanDo(ItemBase ingredients[], PlayerBase player)
override void Do(ItemBase ingredients[], PlayerBase player, array< ItemBase > results, float specialty_weight)
override void Init()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.