DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ActionDigGardenPlot.c
Go to the documentation of this file.
1class 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
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};
protected float m_SpecialtyWeight
Definition ActionBase.c:68
protected string m_Text
Definition ActionBase.c:49
protected bool m_FullBody
Definition ActionBase.c:52
protected int m_StanceMask
Definition ActionBase.c:53
PlaceObjectActionReciveData ActionReciveData ActionDeployObject()
class ActionTargets ActionTarget
eBrokenLegs
Definition EBrokenLegs.c:2
ItemBase m_MainItem
Definition ActionBase.c:28
PlayerBase m_Player
Definition ActionBase.c:33
override void CreateActionComponent()
override void OnFinishProgressServer(ActionData action_data)
override void DropDuringPlacing(PlayerBase player)
override void SetupAnimation(ItemBase item)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void OnFinishProgressClient(ActionData action_data)
void CheckSurfaceBelowGardenPlot(PlayerBase player, GardenPlot item_GP, Hologram hologram)
proto native bool ClearJuncture(Man player, notnull EntityAI item)
Super root of all classes in Enforce script.
Definition EnScript.c:11
void SetIsCollidingGPlot(bool is_colliding_gplot)
Definition Hologram.c:1296
bool IsColliding()
Definition Hologram.c:1309
vector GetRightFarProjectionVector()
Definition Hologram.c:1041
vector GetLeftCloseProjectionVector()
Definition Hologram.c:1014
EntityAI GetProjectionEntity()
Definition Hologram.c:1268
vector GetRightCloseProjectionVector()
Definition Hologram.c:1022
vector GetLeftFarProjectionVector()
Definition Hologram.c:1032
const float DIG_GARDEN
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.