DayZ 1.24
Loading...
Searching...
No Matches
ActionCreateGreenhouseGardenPlot.c
Go to the documentation of this file.
8
10{
11 GardenPlot m_GardenPlot;
12 private const float CAMERA_PITCH_THRESHOLD = -30;
13
23
29
30 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
31 {
32 if (!target)
33 return false;
34
35 if (player.IsPlacingLocal())
36 return false;
37
38 Object target_object = target.GetObject();
39
42
44 {
45 string action_selection = target_object.GetActionComponentName(target.GetComponentIndex());
46 //Update selections in model, name the desired part Soil to improve action condition check
47 if (action_selection != "soil")
48 return false;
49
50 //check if there is any gardenplot objects in the current building
53 vector pos = target_object.GetPosition();
54 pos[1] = pos[1] - 1; //Lower by one meter for check if plot already present
55 GetGame().GetObjectsAtPosition3D(pos, 2, nearest_objects, proxy_cargos);
56
57 for (int i = 0; i < nearest_objects.Count(); ++i)
58 {
59 Object object = nearest_objects.Get(i);
60
61 if (object.IsInherited(GardenPlot))
62 return false;
63 }
64
65 return true;
66 }
67
68 return false;
69 }
70
72 {
76 Object targetObject = action_data.m_Target.GetObject();
77
78 vector position = targetObject.GetPosition();
79
80 //Depending on where we dig the required height offset is not the same
83
84 if (polytunnel)
85 position[1] = position[1] - 1.15; //Lower Y position by roughly 1 meter to compensate for spawning location offset
86 else
87 position[1] = position[1] - 1.05;
88
89 vector orientation = targetObject.GetOrientation();
90
91 if (GetGame().IsMultiplayer())
92 {
94 if (tunnel)
95 m_GardenPlot = GardenPlot.Cast(GetGame().CreateObjectEx("GardenPlotPolytunnel", position, ECE_KEEPHEIGHT));
96 else
97 m_GardenPlot = GardenPlot.Cast(GetGame().CreateObjectEx("GardenPlotGreenhouse", position, ECE_KEEPHEIGHT));
98
99 m_GardenPlot.SetOrientation(orientation);
100 }
101 }
102}
bool m_FullBody
Definition ActionBase.c:52
string m_Text
Definition ActionBase.c:49
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
float m_SpecialtyWeight
Definition ActionBase.c:68
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
int m_StanceMask
Definition ActionBase.c:53
const int ECE_KEEPHEIGHT
class Land_Misc_Greenhouse extends BuildingSuper Land_Misc_Polytunnel()
void Land_Misc_Greenhouse()
ActionData m_ActionData
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void OnFinishProgressServer(ActionData action_data)
ref CABase m_ActionComponent
Definition ActionBase.c:30
const float DIG_GARDEN
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()