DayZ 1.24
Loading...
Searching...
No Matches
RefuelTorch.c
Go to the documentation of this file.
1// This recipe adds fuel to torch
2
3class RefuelTorch extends RecipeBase
4{
5 override void Init()
6 {
7 m_Name = "#STR_RefuelTorch0";
8 m_IsInstaRecipe = false;//should this recipe be performed instantly without animation
9 m_AnimationLength = 0.25;//animation length in relative time units
10 m_Specialty = 0.02;// value > 0 for roughness, value < 0 for precision
11
12 //conditions
13 m_MinDamageIngredient[0] = -1;//-1 = disable check
14 m_MaxDamageIngredient[0] = -1;//-1 = disable check
15
16 m_MinQuantityIngredient[0] = -1;//-1 = disable check
17 m_MaxQuantityIngredient[0] = -1;//-1 = disable check
18
19 m_MinDamageIngredient[1] = -1;//-1 = disable check
20 m_MaxDamageIngredient[1] = -1;//-1 = disable check
21
22 m_MinQuantityIngredient[1] = -1;//-1 = disable check
23 m_MaxQuantityIngredient[1] = -1;//-1 = disable check
24 //----------------------------------------------------------------------------------------------------------------------
25
26 //INGREDIENTS
27 //ingredient 1
28 InsertIngredient(0, "Rag"); //you can insert multiple ingredients this way
29
30 m_IngredientAddHealth[0] = 0;// 0 = do nothing
31 m_IngredientSetHealth[0] = -1; // -1 = do nothing
32 m_IngredientAddQuantity[0] = 0;// 0 = do nothing
33 m_IngredientDestroy[0] = false;//true = destroy, false = do nothing
34 m_IngredientUseSoftSkills[0] = false;// set 'true' to allow modification of the values by softskills on this ingredient
35
36 //ingredient 2
37 InsertIngredient(1, "Torch"); //you can insert multiple ingredients this way
38 InsertIngredient(1, "LongTorch"); //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] = -1;// 0 = do nothing
43 m_IngredientDestroy[1] = false;// false = do nothing
44 m_IngredientUseSoftSkills[1] = false;// set 'true' to allow modification of the values by softskills on this ingredient
45 //----------------------------------------------------------------------------------------------------------------------
46
47 //result1
48 //AddResult("Torch");//add results here
49
50 m_ResultSetFullQuantity[0] = false;//true = set full quantity, false = do nothing
51 m_ResultSetQuantity[0] = -1;//-1 = do nothing
52 m_ResultSetHealth[0] = -1;//-1 = do nothing
53 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)
54 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)
55 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)
56 m_ResultUseSoftSkills[0] = false;// set 'true' to allow modification of the values by softskills on this result
57 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
58 }
59
60 override bool CanDo(ItemBase ingredients[], PlayerBase player)//final check for recipe's validity
61 {
62 Rag rag = Rag.Cast(ingredients[0]);
63 Torch torch = Torch.Cast(ingredients[1]);
64
65 if (!rag || !torch)
66 return false;
67
68 Rag rag_on_torch = Rag.Cast(torch.GetInventory().FindAttachment(rag.GetInventory().GetSlotId(0)));
69
70 if (rag_on_torch) // Check if torch already has rag with 100% quantity
71 {
72 if (rag_on_torch.GetQuantity() == rag_on_torch.GetQuantityMax())
73 return false;
74 }
75
76 return true;
77 }
78
79 override void Do(ItemBase ingredients[], PlayerBase player, array<ItemBase> results, float specialty_weight) //gets called upon recipe's completion
80 {
81 Rag rag = Rag.Cast(ingredients[0]);
82 Torch torch = Torch.Cast(ingredients[1]);
83
84 if (!GetGame().IsMultiplayer())
85 {
87 rag.GetInventory().GetCurrentInventoryLocation(loc);
88 player.GetInventory().ClearInventoryReservationEx(rag, loc);
89 }
90
91 Rag rag_on_torch = Rag.Cast(torch.GetInventory().FindAttachment(rag.GetInventory().GetSlotId(0)));
92
93 if (rag_on_torch)
94 rag_on_torch.CombineItems(rag, false);
95 else
96 {
97 if (GetGame().IsServer() && GetGame().IsMultiplayer())
98 {
99 player.ServerTakeEntityToTargetAttachment(torch, rag); // multiplayer server side
100 }
101 else
102 {
103 player.LocalTakeEntityToTargetAttachment(torch, rag); // single player or multiplayer client side
104 }
105 }
106 }
107};
string m_Name
InventoryLocation.
override bool CanDo(ItemBase ingredients[], PlayerBase player)
Definition RefuelTorch.c:60
override void Do(ItemBase ingredients[], PlayerBase player, array< ItemBase > results, float specialty_weight)
Definition RefuelTorch.c:79
override void Init()
Definition RefuelTorch.c:5
proto native CGame GetGame()