Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cutoutseeds.c
Go to the documentation of this file.
1 class CutOutSeeds extends RecipeBase
2 {
3  override void Init()
4  {
5 
6  }
7 
8  override bool CanDo(ItemBase ingredients[], PlayerBase player)//final check for recipe's validity
9  {
10  return true;
11  }
12 
13  override void Do(ItemBase ingredients[], PlayerBase player, array<ItemBase> results, float specialty_weight)//gets called upon recipe's completion
14  {
15  // Adjusts quantity of results to the quantity of the 1st ingredient
16  Edible_Base item_ingredient = Edible_Base.Cast(ingredients[0]);
17 
18  float MaxQuantity = item_ingredient.GetQuantityMax();
19  float CurrentQuantity = item_ingredient.GetQuantity();
20  float qtPercentage = CurrentQuantity / MaxQuantity;
21 
22  FoodStageType stage = item_ingredient.GetFoodStageType();
23 
24  float seedMultiplier = Math.RandomFloat(0.5, 1);
25 
26  //Set seeds amount proportional to ingredient quantity. No seeds if the is less that 30% of ingredient
27  if(qtPercentage < 0.3)
28  seedMultiplier = 0;
29  else
30  seedMultiplier *= qtPercentage;
31 
32  //Set seeds amount based on the stage of the ingredient
33  switch(stage)
34  {
35  case FoodStageType.BURNED:
36  case FoodStageType.BOILED:
37  case FoodStageType.BAKED:
38  seedMultiplier *= 0;
39  break;
40  case FoodStageType.DRIED:
41  case FoodStageType.ROTTEN:
42  seedMultiplier *= 0.5;
43  break;
44  case FoodStageType.RAW:
45  default:
46  seedMultiplier *= 1;
47  break;
48  }
49 
50  ItemBase result = results[0];
51  float maxQuantity = result.GetQuantityMax();
52  float resultQty = m_ResultSetQuantity[0]/ maxQuantity;
53  resultQty *= seedMultiplier * maxQuantity;
54 
55  resultQty = Math.Ceil(resultQty);
56 
57  result.SetQuantity(resultQty);
58 
59  Debug.Log("Recipe Do method called","recipes");
60  }
61 };
ItemBase
Definition: inventoryitem.c:730
RecipeBase
Definition: recipebase.c:4
CutOutSeeds
Definition: cutoutpepperseeds.c:1
PlayerBase
Definition: playerbaseclient.c:1
FoodStageType
FoodStageType
Definition: foodstage.c:1
array< ItemBase >
Debug
Definition: debug.c:13
Math
Definition: enmath.c:6
Edible_Base
Definition: bearsteakmeat.c:1