Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
pluginhorticulture.c
Go to the documentation of this file.
1
class
PluginHorticulture
extends
PluginBase
2
{
3
ref
map<string, ref PlantMaterialHealth>
m_PlantMaterials
;
4
5
void
PluginHorticulture
()
6
{
7
m_PlantMaterials
=
new
map<string, ref PlantMaterialHealth>
;
8
9
LoadFromCfg
();
10
}
11
12
void
LoadFromCfg
()
13
{
14
string
cfg_access =
"CfgHorticulture"
;
// it is stored in dz\gear\cultivation\cfgHorticulture.hpp
15
int
cfg_horticulture_count =
g_Game
.ConfigGetChildrenCount( cfg_access );
16
17
for
(
int
i = 0; i < cfg_horticulture_count; i++ )
18
{
19
string
cfg_class_name =
""
;
20
g_Game
.ConfigGetChildName( cfg_access, i, cfg_class_name );
21
string
cfg_class_access = cfg_access +
" "
+ cfg_class_name;
22
23
int
cfg_class_count =
g_Game
.ConfigGetChildrenCount( cfg_class_access );
24
25
for
(
int
j = 0; j < cfg_class_count; j++ )
26
{
27
string
cfg_subclass_name =
""
;
28
g_Game
.ConfigGetChildName( cfg_class_access, j, cfg_subclass_name );
29
string
cfg_subclass_access = cfg_class_access +
" "
+ cfg_subclass_name;
30
31
int
cfg_subclass_count =
g_Game
.ConfigGetChildrenCount( cfg_subclass_access );
32
33
PlantMaterialHealth
plantMaterialHealth = NULL;
34
35
if
( cfg_class_name ==
"Plants"
)
36
{
37
plantMaterialHealth =
new
PlantMaterialHealth
;
38
m_PlantMaterials
.Set( cfg_subclass_name, plantMaterialHealth );
39
}
40
41
for
(
int
k = 0; k < cfg_subclass_count; k++ )
42
{
43
string
cfg_variable_name =
""
;
44
g_Game
.ConfigGetChildName( cfg_subclass_access, k, cfg_variable_name );
45
string
cfg_variable_access = cfg_subclass_access +
" "
+ cfg_variable_name;
46
47
if
( cfg_class_name ==
"Plants"
)
48
{
49
string
string_param =
""
;
50
g_Game
.ConfigGetText( cfg_variable_access, string_param );
51
52
if
( cfg_variable_name ==
"infestedTex"
)
53
{
54
plantMaterialHealth.
m_InfestedTex
= string_param;
55
}
56
else
if
( cfg_variable_name ==
"infestedMat"
)
57
{
58
plantMaterialHealth.
m_InfestedMat
= string_param;
59
}
60
else
if
( cfg_variable_name ==
"healthyTex"
)
61
{
62
plantMaterialHealth.
m_HealthyTex
= string_param;
63
}
64
else
if
( cfg_variable_name ==
"healthyMat"
)
65
{
66
plantMaterialHealth.
m_HealthyMat
= string_param;
67
}
68
}
69
}
70
}
71
}
72
}
73
74
string
GetPlantType
(
Object
obj )
75
{
76
string
seed_type = obj.GetType();
77
78
string
plant_type =
""
;
79
g_Game
.ConfigGetText(
"cfgVehicles "
+ seed_type +
" Horticulture PlantType"
, plant_type );
80
81
return
plant_type;
82
}
83
84
float
GetSurfaceFertility
(
string
surface_type )
85
{
86
float
fertility = 0.8;
87
if
( surface_type ==
"hlina"
|| surface_type ==
"CRGrass1"
|| surface_type ==
"CRGrass2"
|| surface_type ==
"CRForest1"
|| surface_type ==
"CRForest2"
|| surface_type ==
"CRGrit1"
)
88
{
89
fertility = 0.8;
90
}
91
92
return
fertility;
93
}
94
95
bool
GiveWormsToPlayer
(
PlayerBase
player,
float
chance )
96
{
97
if
(
Math
.
RandomFloat01
() <= chance )
98
{
99
ItemBase
item =
ItemBase
.Cast( player.GetHumanInventory().CreateInInventory(
"Food_Worm"
) );
100
item.
SetQuantity
( 1 );
101
return
true
;
102
}
103
104
return
false
;
105
}
106
107
PlantMaterialHealth
GetPlantMaterial
(
string
plant_type )
108
{
109
if
(
m_PlantMaterials
.Contains(plant_type) )
110
{
111
return
m_PlantMaterials
.Get(plant_type);
112
}
113
114
return
NULL;
115
}
116
}
ItemBase
Definition
inventoryitem.c:742
ItemBase::SetQuantity
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Definition
pileofwoodenplanks.c:88
Math
Definition
enmath.c:7
Object
Definition
objecttyped.c:2
PlantMaterialHealth
Definition
plantmaterial.c:2
PlantMaterialHealth::m_InfestedMat
string m_InfestedMat
Definition
plantmaterial.c:4
PlantMaterialHealth::m_HealthyMat
string m_HealthyMat
Definition
plantmaterial.c:6
PlantMaterialHealth::m_InfestedTex
string m_InfestedTex
Definition
plantmaterial.c:3
PlantMaterialHealth::m_HealthyTex
string m_HealthyTex
Definition
plantmaterial.c:5
PlayerBase
Definition
playerbaseclient.c:2
PluginBase
Class PluginMessageManager provides some basic Message Distribution mechanics, if you get instance of...
Definition
pluginbase.c:2
PluginBase::GetSurfaceFertility
float GetSurfaceFertility(string surface_type)
Definition
pluginhorticulture.c:84
PluginBase::GetPlantType
string GetPlantType(Object obj)
Definition
pluginhorticulture.c:74
PluginBase::GiveWormsToPlayer
bool GiveWormsToPlayer(PlayerBase player, float chance)
Definition
pluginhorticulture.c:95
PluginBase::LoadFromCfg
void LoadFromCfg()
Definition
pluginhorticulture.c:12
PluginBase::PluginHorticulture
void PluginHorticulture()
Definition
pluginhorticulture.c:5
PluginBase::m_PlantMaterials
ref map< string, ref PlantMaterialHealth > m_PlantMaterials
Definition
pluginhorticulture.c:3
PluginBase::GetPlantMaterial
PlantMaterialHealth GetPlantMaterial(string plant_type)
Definition
pluginhorticulture.c:107
map
Definition
cachedequipmentstorage.c:4
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
Math::RandomFloat01
static float RandomFloat01()
Returns a random float number between and min [inclusive] and max [inclusive].
Definition
enmath.c:126
Games
Dayz
scripts
4_world
plugins
pluginbase
pluginhorticulture.c
Generated by
1.17.0