DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
CraftTannedLeather.c
См. документацию.
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}
const int MAX
Определения EnConvert.c:27
class Pelt_Base extends ItemBase Pelt_Base
const float DEFAULT_SPAWN_DISTANCE
Определения RecipeBase.c:3
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
Определения InventoryItem.c:731
Определения EnMath.c:7
Определения PlayerBaseClient.c:2
bool m_IngredientDestroy[MAX_NUMBER_OF_INGREDIENTS]
Определения RecipeBase.c:36
override bool CanDo(ItemBase ingredients[], PlayerBase player)
Определения CraftTannedLeather.c:49
bool m_IngredientUseSoftSkills[MAX_NUMBER_OF_INGREDIENTS]
Определения RecipeBase.c:32
string m_Name
Определения RecipeBase.c:17
bool m_IsInstaRecipe
Определения RecipeBase.c:24
override void Do(ItemBase ingredients[], PlayerBase player, array< ItemBase > results, float specialty_weight)
Определения CraftTannedLeather.c:71
float m_IngredientAddHealth[MAX_NUMBER_OF_INGREDIENTS]
Определения RecipeBase.c:33
float m_Specialty
Определения RecipeBase.c:23
float m_IngredientSetHealth[MAX_NUMBER_OF_INGREDIENTS]
Определения RecipeBase.c:35
float m_MinQuantityIngredient[MAX_NUMBER_OF_INGREDIENTS]
Определения RecipeBase.c:27
float m_AnimationLength
Определения RecipeBase.c:22
override void Init()
Определения CraftTannedLeather.c:6
float m_MaxQuantityIngredient[MAX_NUMBER_OF_INGREDIENTS]
Определения RecipeBase.c:28
float m_IngredientAddQuantity[MAX_NUMBER_OF_INGREDIENTS]
Определения RecipeBase.c:34
float m_MinDamageIngredient[MAX_NUMBER_OF_INGREDIENTS]
Определения RecipeBase.c:29
float m_PercentageUsed
Определения CraftTannedLeather.c:3
float m_MaxDamageIngredient[MAX_NUMBER_OF_INGREDIENTS]
Определения RecipeBase.c:30
bool m_AnywhereInInventory
Определения RecipeBase.c:25
void InsertIngredient(int index, string ingredient, DayZPlayerConstants uid=DayZPlayerConstants.CMD_ACTIONFB_CRAFTING)
Определения RecipeBase.c:143
Определения RecipeBase.c:6
const float NARROW
Определения ActionConstants.c:127
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения EnConvert.c:106
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.