DayZ 1.24
Loading...
Searching...
No Matches
PluginHorticulture.c
Go to the documentation of this file.
1class PluginHorticulture extends PluginBase
2{
4
6 {
7 m_PlantMaterials = new map<string, ref PlantMaterialHealth>;
8
10 }
11
13 {
14 string cfg_access = "CfgHorticulture"; // it is stored in dz\gear\cultivation\cfgHorticulture.hpp
15 int cfg_horticulture_count = GetGame().ConfigGetChildrenCount(cfg_access);
16
17 for (int i = 0; i < cfg_horticulture_count; i++)
18 {
19 string cfg_class_name = "";
20 GetGame().ConfigGetChildName(cfg_access, i, cfg_class_name);
22
23 int cfg_class_count = GetGame().ConfigGetChildrenCount(cfg_class_access);
24
25 for (int j = 0; j < cfg_class_count; j++)
26 {
27 string cfg_subclass_name = "";
28 GetGame().ConfigGetChildName(cfg_class_access, j, cfg_subclass_name);
30
31 int cfg_subclass_count = GetGame().ConfigGetChildrenCount(cfg_subclass_access);
32
34
35 if (cfg_class_name == "Plants")
36 {
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 GetGame().ConfigGetChildName(cfg_subclass_access, k, cfg_variable_name);
46
47 if (cfg_class_name == "Plants")
48 {
49 string string_param = "";
51
52 if (cfg_variable_name == "infestedTex")
53 plantMaterialHealth.m_InfestedTex = string_param;
54 else if (cfg_variable_name == "infestedMat")
55 plantMaterialHealth.m_InfestedMat = string_param;
56 else if (cfg_variable_name == "healthyTex")
57 plantMaterialHealth.m_HealthyTex = string_param;
58 else if (cfg_variable_name == "healthyMat")
59 plantMaterialHealth.m_HealthyMat = string_param;
60 }
61 }
62 }
63 }
64 }
65
66 string GetPlantType(Object obj)
67 {
68 string seed_type = obj.GetType();
69
70 string plant_type = "";
71 GetGame().ConfigGetText("cfgVehicles " + seed_type + " Horticulture PlantType", plant_type);
72
73 return plant_type;
74 }
75
77 {
78 float fertility = 0.8;
79 if (surface_type == "hlina" || surface_type == "CRGrass1" || surface_type == "CRGrass2" || surface_type == "CRForest1" || surface_type == "CRForest2" || surface_type == "CRGrit1")
80 fertility = 0.8;
81
82 return fertility;
83 }
84
86 {
87 if (Math.RandomFloat01() <= chance)
88 {
89 ItemBase item = ItemBase.Cast(player.GetHumanInventory().CreateInInventory("Food_Worm"));
90 item.SetQuantity(1);
91 return true;
92 }
93
94 return false;
95 }
96
98 {
99 if (m_PlantMaterials.Contains(plant_type))
100 return m_PlantMaterials.Get(plant_type);
101
102 return NULL;
103 }
104}
Definition EnMath.c:7
bool GiveWormsToPlayer(PlayerBase player, float chance)
string GetPlantType(Object obj)
ref map< string, ref PlantMaterialHealth > m_PlantMaterials
PlantMaterialHealth GetPlantMaterial(string plant_type)
float GetSurfaceFertility(string surface_type)
void PluginHorticulture()
proto native CGame GetGame()
static float RandomFloat01()
Returns a random float number between and min [inclusive] and max [inclusive].
Definition EnMath.c:126