DayZ
1.24
Loading...
Searching...
No Matches
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
};
FoodStageType
FoodStageType
Definition
FoodStage.c:2
CutOutSeeds
Definition
CutOutPepperSeeds.c:2
Debug
Definition
Debug.c:14
Debug::Log
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
Edible_Base
Definition
Edible_Base.c:2
ItemBase
Definition
InventoryItem.c:697
Math
Definition
EnMath.c:7
Param3
Definition
EntityAI.c:95
PlayerBase
Definition
PlayerBaseClient.c:2
RecipeBase
Definition
RecipeBase.c:5
RecipeBase::CanDo
override bool CanDo(ItemBase ingredients[], PlayerBase player)
Definition
CutOutSeeds.c:8
RecipeBase::Do
override void Do(ItemBase ingredients[], PlayerBase player, array< ItemBase > results, float specialty_weight)
Definition
CutOutSeeds.c:13
RecipeBase::Init
override void Init()
Definition
CutOutSeeds.c:3
Math::RandomFloat
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
Math::Ceil
static proto float Ceil(float f)
Returns ceil of value.
scripts
4_World
Classes
Recipes
Recipes
CutOutSeeds.c
Generated by
1.10.0