DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ActionCreateGreenhouseGardenPlot.c
Go to the documentation of this file.
2{
3 override void CreateActionComponent()
4 {
6 }
7};
8
10{
11 GardenPlot m_GardenPlot;
12 private const float CAMERA_PITCH_THRESHOLD = -30;
13
15 {
17 m_FullBody = true;
18 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIGMANIPULATE;
19 m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
21 m_Text = "#make_garden_plot";
22 }
23
25 {
28 }
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
40 Land_Misc_Greenhouse greenHouse = Land_Misc_Greenhouse.Cast( target_object );
41 Land_Misc_Polytunnel polytunnel = Land_Misc_Polytunnel.Cast( target_object) ;
42
43 if ( target_object && ( greenHouse || polytunnel ) )
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
51 ref array<Object> nearest_objects = new array<Object>;
52 ref array<CargoBase> proxy_cargos = new array<CargoBase>;
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 {
63 return false;
64 }
65 }
66
67 return true;
68 }
69
70 return false;
71 }
72
73 override void OnFinishProgressServer( ActionData action_data )
74 {
75 PlaceObjectActionData poActionData;
76 poActionData = PlaceObjectActionData.Cast(action_data);
77 EntityAI entity_for_placing = action_data.m_MainItem;
78 Object targetObject = action_data.m_Target.GetObject();
79
80 vector position = targetObject.GetPosition();
81
82 //Depending on where we dig the required height offset is not the same
83 Land_Misc_Greenhouse greenHouse = Land_Misc_Greenhouse.Cast( targetObject );
84 Land_Misc_Polytunnel polytunnel = Land_Misc_Polytunnel.Cast( targetObject) ;
85
86 if ( polytunnel )
87 position[1] = position[1] - 1.15; //Lower Y position by roughly 1 meter to compensate for spawning location offset
88 else
89 position[1] = position[1] - 1.05;
90
91 vector orientation = targetObject.GetOrientation();
92
93 if ( GetGame().IsMultiplayer() )
94 {
95 Land_Misc_Polytunnel tunnel = Land_Misc_Polytunnel.Cast(action_data.m_Target.GetObject());
96 if (tunnel)
97 {
98 m_GardenPlot = GardenPlot.Cast( GetGame().CreateObjectEx( "GardenPlotPolytunnel", position, ECE_KEEPHEIGHT ) );
99 }
100 else
101 {
102 m_GardenPlot = GardenPlot.Cast( GetGame().CreateObjectEx( "GardenPlotGreenhouse", position, ECE_KEEPHEIGHT ) );
103 }
104
105 m_GardenPlot.SetOrientation( orientation );
106 }
107 }
108}
protected float m_SpecialtyWeight
Definition ActionBase.c:68
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
protected string m_Text
Definition ActionBase.c:49
protected bool m_FullBody
Definition ActionBase.c:52
protected int m_StanceMask
Definition ActionBase.c:53
class ActionTargets ActionTarget
const int ECE_KEEPHEIGHT
class Land_Misc_Greenhouse extends BuildingSuper Land_Misc_Polytunnel()
void Land_Misc_Greenhouse()
protected ActionData m_ActionData
override void OnFinishProgressServer(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
ItemBase m_MainItem
Definition ActionBase.c:28
ref CABase m_ActionComponent
Definition ActionBase.c:30
ref ActionTarget m_Target
Definition ActionBase.c:32
proto native void GetObjectsAtPosition3D(vector pos, float radius, out array< Object > objects, out array< CargoBase > proxyCargos)
Returns list of all objects in sphere "radius" around position "pos".
const float DIG_GARDEN
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()