Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actiondiggardenplot.c
Go to the documentation of this file.
1 class ActionDigGardenPlotCB : ActiondeployObjectCB
2 {
3  override void CreateActionComponent()
4  {
5  m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.DIG_GARDEN);
6  }
7 };
8 
10 {
11  GardenPlot m_GardenPlot;
12 
13  void ActionDigGardenPlot()
14  {
15  m_CallbackClass = ActionDigGardenPlotCB;
16  m_FullBody = true;
17  m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
19  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIGMANIPULATE;
20 
21  m_Text = "#make_garden_plot";
22  }
23 
24  override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
25  {
26  //Client
27  if (!GetGame().IsDedicatedServer())
28  {
29  //Action not allowed if player has broken legs
30  if (player.GetBrokenLegs() == eBrokenLegs.BROKEN_LEGS)
31  return false;
32 
33  if (player.IsPlacingLocal())
34  {
35  Hologram hologram = player.GetHologramLocal();
36  GardenPlot item_GP;
37  Class.CastTo(item_GP, hologram.GetProjectionEntity());
38  CheckSurfaceBelowGardenPlot(player, item_GP, hologram);
39 
40  if (!hologram.IsColliding())
41  {
42  return true;
43  }
44  }
45  return false;
46  }
47  //Server
48  return true;
49  }
50 
51  override void SetupAnimation(ItemBase item)
52  {
53  if (item)
54  {
55  m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIG;
56  }
57  }
58 
59  void CheckSurfaceBelowGardenPlot(PlayerBase player, GardenPlot item_GP, Hologram hologram)
60  {
61  vector min_max[2];
62  item_GP.GetCollisionBox(min_max);
63  float offset = min_max[1][1] - min_max[0][1];
64  //Print(offset);
65  vector pos_adjusted = item_GP.GetPosition();
66  pos_adjusted[1] = pos_adjusted[1] + offset;
67 
68  if (item_GP.CanBePlaced(player, /*item_GP.GetPosition()*/pos_adjusted) )
69  {
70  if (item_GP.CanBePlaced(NULL, item_GP.CoordToParent(hologram.GetLeftCloseProjectionVector())))
71  {
72  if (item_GP.CanBePlaced(NULL, item_GP.CoordToParent(hologram.GetRightCloseProjectionVector())))
73  {
74  if (item_GP.CanBePlaced(NULL, item_GP.CoordToParent(hologram.GetLeftFarProjectionVector())))
75  {
76  if (item_GP.CanBePlaced(NULL, item_GP.CoordToParent(hologram.GetRightFarProjectionVector())))
77  {
78  hologram.SetIsCollidingGPlot(false);
79 
80  return;
81  }
82  }
83  }
84  }
85  }
86 
87  hologram.SetIsCollidingGPlot(true);
88  }
89 
90  override void DropDuringPlacing(PlayerBase player)
91  {
92  }
93 
94  override void OnFinishProgressClient(ActionData action_data)
95  {
96  PlaceObjectActionData poActionData;
97  poActionData = PlaceObjectActionData.Cast(action_data);
98  poActionData.m_AlreadyPlaced = true;
99  }
100 
101  override void OnFinishProgressServer(ActionData action_data)
102  {
103  PlaceObjectActionData poActionData;
104  poActionData = PlaceObjectActionData.Cast(action_data);
105  EntityAI entity_for_placing = action_data.m_MainItem;
106  vector position = action_data.m_Player.GetLocalProjectionPosition();
107  vector orientation = action_data.m_Player.GetLocalProjectionOrientation();
108 
109  if (GetGame().IsMultiplayer())
110  {
111  m_GardenPlot = GardenPlot.Cast(action_data.m_Player.GetHologramServer().PlaceEntity(entity_for_placing));
112  m_GardenPlot.SetOrientation(orientation);
113  action_data.m_Player.GetHologramServer().CheckPowerSource();
114  action_data.m_Player.PlacingCompleteServer();
115 
116  m_GardenPlot.OnPlacementComplete(action_data.m_Player);
117  }
118 
119  //local singleplayer
120  if (!GetGame().IsMultiplayer())
121  {
122  m_GardenPlot = GardenPlot.Cast(action_data.m_Player.GetHologramLocal().PlaceEntity(entity_for_placing));
123  m_GardenPlot.SetOrientation(orientation);
124  action_data.m_Player.PlacingCompleteLocal();
125 
126  m_GardenPlot.OnPlacementComplete(action_data.m_Player);
127  }
128 
129  GetGame().ClearJuncture(action_data.m_Player, entity_for_placing);
130  action_data.m_MainItem.SetIsBeingPlaced(false);
131  action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
132  poActionData.m_AlreadyPlaced = true;
133  action_data.m_MainItem.SoundSynchRemoteReset();
134 
135  MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, 10);
136 
137  }
138 };
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
ActionDeployObject
PlaceObjectActionReciveData ActionReciveData ActionDeployObject()
Definition: actiondeployobject.c:9
CAContinuousTime
Definition: cacontinuoustime.c:1
UASoftSkillsWeight
Definition: actionconstants.c:118
Hologram
Definition: hologram.c:1
eBrokenLegs
eBrokenLegs
Definition: ebrokenlegs.c:1
m_FullBody
protected bool m_FullBody
Definition: actionbase.c:52
ActionDigGardenPlot
Definition: actiondiggardenplot.c:9
PlayerBase
Definition: playerbaseclient.c:1
vector
Definition: enconvert.c:105
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
PlaceObjectActionData
Definition: actiondeploybase.c:1
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
ActionDigGardenPlotCB
Definition: actiondiggardenplot.c:1
UATimeSpent
Definition: actionconstants.c:26
m_Text
protected string m_Text
Definition: actionbase.c:49
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53
EntityAI
Definition: building.c:5