Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
decraftwoodencrate.c
Go to the documentation of this file.
1 class DeCraftWoodenCrate extends RecipeBase
2 {
3  override void Init()
4  {
5  m_Name = "#STR_breakdown0";
6  m_IsInstaRecipe = false;//should this recipe be performed instantly without animation
7  m_AnimationLength = 1;//animation length in relative time units
8  m_Specialty = 0.02;// value > 0 for roughness, value < 0 for precision
9 
10  //conditions
11  m_MinDamageIngredient[0] = -1;//-1 = disable check
12  m_MaxDamageIngredient[0] = 3;//-1 = disable check
13 
14  m_MinQuantityIngredient[0] = -1;//-1 = disable check
15  m_MaxQuantityIngredient[0] = -1;//-1 = disable check
16 
17  m_MinDamageIngredient[1] = -1;//-1 = disable check
18  m_MaxDamageIngredient[1] = 3;//-1 = disable check
19 
20  m_MinQuantityIngredient[1] = -1;//-1 = disable check
21  m_MaxQuantityIngredient[1] = -1;//-1 = disable check
22  //----------------------------------------------------------------------------------------------------------------------
23 
24  //INGREDIENTS
25  //ingredient 1
26  InsertIngredient(0,"WoodenCrate");//you can insert multiple ingredients this way
27 
28  m_IngredientAddHealth[0] = 0;// 0 = do nothing
29  m_IngredientSetHealth[0] = -1; // -1 = do nothing
30  m_IngredientAddQuantity[0] = 0;// 0 = do nothing
31  m_IngredientDestroy[0] = true;//true = destroy, false = do nothing
32  m_IngredientUseSoftSkills[0] = false;// set 'true' to allow modification of the values by softskills on this ingredient
33 
34  //ingredient 2
35  InsertIngredient(1,"Crowbar");
36  InsertIngredient(1,"WoodAxe");
37  InsertIngredient(1,"Hatchet");
38  InsertIngredient(1,"FirefighterAxe");
39 
40  m_IngredientAddHealth[1] = -20;// 0 = do nothing
41  m_IngredientSetHealth[1] = -1; // -1 = do nothing
42  m_IngredientAddQuantity[1] = 0;// 0 = do nothing
43  m_IngredientDestroy[1] = false;// false = do nothing
44  m_IngredientUseSoftSkills[1] = true;// set 'true' to allow modification of the values by softskills on this ingredient
45 
46  //----------------------------------------------------------------------------------------------------------------------
47 
48  //result1
49  AddResult("WoodenPlank");//add results here
50 
51  m_ResultSetFullQuantity[0] = false;//true = set full quantity, false = do nothing
52  m_ResultSetQuantity[0] = 2;//-1 = do nothing
53  m_ResultSetHealth[0] = -1;//-1 = do nothing
54  m_ResultInheritsHealth[0] = 1;// (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  //result2
61  AddResult("Nail");//add results here
62 
63  m_ResultSetFullQuantity[1] = false;//true = set full quantity, false = do nothing
64  m_ResultSetQuantity[1] = 6;// -1 = do nothing
65  m_ResultSetHealth[1] = -1;// -1 = do nothing
66  m_ResultInheritsHealth[1] = 1;// (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)
67  m_ResultInheritsColor[1] = -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)
68  m_ResultToInventory[1] = -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)
69  m_ResultUseSoftSkills[1] = false;// set 'true' to allow modification of the values by softskills on this result
70  m_ResultReplacesIngredient[1] = -1;// value == -1 means do nothing; a value >= 0 means this result will transfer item propertiesvariables, attachments etc.. from an ingredient value
71  //----------------------------------------------------------------------------------------------------------------------
72  }
73 
74  override bool CanDo(ItemBase ingredients[], PlayerBase player)//final check for recipe's validity
75  {
76  ItemBase crate;
77  Class.CastTo(crate, ingredients[0]);
78 
79  if ( crate.GetInventory().CountInventory() > 1 )
80  return false;
81 
82  return true;
83  }
84 
85  override void Do(ItemBase ingredients[], PlayerBase player,array<ItemBase> results, float specialty_weight)//gets called upon recipe's completion
86  {
87  ItemBase crate;
88  Class.CastTo(crate, ingredients[0]);
89  int hp = crate.GetHealthLevel("");
90 
91  switch ( hp )
92  {
93  case GameConstants.STATE_PRISTINE:
94  results[0].SetQuantity(Math.RandomIntInclusive( 6, 8 ));
95  results[0].SetHealth( results[0].GetMaxHealth() * Math.RandomFloat( 0.6, 0.8 ));
96  results[1].SetQuantity(Math.RandomIntInclusive( 12, 16 ));
97  results[1].SetHealth( results[1].GetMaxHealth() * Math.RandomFloat( 0.6, 0.8 ));
98  break;
99 
100  case GameConstants.STATE_WORN:
101  results[0].SetQuantity(Math.RandomIntInclusive( 5, 7 ));
102  results[0].SetHealth( results[0].GetMaxHealth() * Math.RandomFloat( 0.5, 0.8 ));
103  results[1].SetQuantity(Math.RandomIntInclusive( 9, 13 ));
104  results[1].SetHealth( results[1].GetMaxHealth() * Math.RandomFloat( 0.5, 0.8 ));
105  break;
106 
107  case GameConstants.STATE_DAMAGED:
108  results[0].SetQuantity(Math.RandomIntInclusive( 4, 6 ));
109  results[0].SetHealth( results[0].GetMaxHealth() * Math.RandomFloat( 0.3, 0.6 ));
110  results[1].SetQuantity(Math.RandomIntInclusive( 6, 10 ));
111  results[1].SetHealth( results[1].GetMaxHealth() * Math.RandomFloat( 0.3, 0.6 ));
112  break;
113 
114  case GameConstants.STATE_BADLY_DAMAGED:
115  results[0].SetQuantity(Math.RandomIntInclusive( 3, 5 ));
116  results[0].SetHealth( results[0].GetMaxHealth() * Math.RandomFloat( 0.1, 0.3 ));
117  results[1].SetQuantity(Math.RandomIntInclusive( 3, 7 ));
118  results[1].SetHealth( results[1].GetMaxHealth() * Math.RandomFloat( 0.1, 0.3 ));
119  break;
120 
121  //unnescessary? We do not allow recipe crafting with ruined items?
122  case GameConstants.STATE_RUINED:
123  results[0].SetQuantity(Math.RandomIntInclusive( 1, 2 ));
124  results[0].SetHealth( results[0].GetMaxHealth() * Math.RandomFloat( 0.05, 0.2 ));
125  results[1].SetQuantity(Math.RandomIntInclusive( 1, 4 ));
126  results[1].SetHealth( results[1].GetMaxHealth() * Math.RandomFloat( 0.05, 0.2 ));
127  break;
128 
129  default:
130  results[0].SetQuantity(Math.RandomIntInclusive( 1, 2 ));
131  results[0].SetHealth( results[0].GetMaxHealth() * Math.RandomFloat( 0.05, 0.2 ));
132  results[1].SetQuantity(Math.RandomIntInclusive( 1, 4 ));
133  results[1].SetHealth( results[1].GetMaxHealth() * Math.RandomFloat( 0.05, 0.2 ));
134  break;
135  }
136 
137  /*
138  float originalPlanks = 8;
139  float originalNails = 16;
140 
141  float hp = crate.GetHealth01("","Health");
142  originalPlanks *= hp;
143  originalNails *= hp;
144 
145  int newPlanks = Math.Round( originalPlanks );
146  int newNails = Math.Round( originalNails );
147 
148  m_ResultSetQuantity[0] = newPlanks;
149  m_ResultSetQuantity[1] = newNails;
150  */
151  Debug.Log("Recipe Do method called","recipes");
152  }
153 };
ItemBase
Definition: inventoryitem.c:730
Do
override protected void Do(PlayerBase player)
Definition: spookyareamisc.c:13
m_Name
string m_Name
Definition: bioslobbyservice.c:35
RecipeBase
Definition: recipebase.c:4
PlayerBase
Definition: playerbaseclient.c:1
Init
class InventoryGridController extends ScriptedWidgetEventHandler Init
Definition: uihintpanel.c:46
CanDo
override protected bool CanDo(PlayerBase player, TStringVectorMap surfaceTypes)
Definition: spookyareamisc.c:8
array< ItemBase >
GameConstants
Definition: constants.c:612
Debug
Definition: debug.c:13
Math
Definition: enmath.c:6
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10