DayZ 1.24
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
9class ActionDigGardenPlot: ActionDeployObject
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());
39
40 if (!hologram.IsColliding())
41 return true;
42 }
43 return false;
44 }
45 //Server
46 return true;
47 }
48
50 {
51 if (item)
52 m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIG;
53 }
54
56 {
57 vector min_max[2];
58 item_GP.GetCollisionBox(min_max);
59 float offset = min_max[1][1] - min_max[0][1];
60 //Print(offset);
61 vector pos_adjusted = item_GP.GetPosition();
63
64 if (item_GP.CanBePlaced(player, /*item_GP.GetPosition()*/pos_adjusted))
65 {
66 if (item_GP.CanBePlaced(NULL, item_GP.CoordToParent(hologram.GetLeftCloseProjectionVector())))
67 {
68 if (item_GP.CanBePlaced(NULL, item_GP.CoordToParent(hologram.GetRightCloseProjectionVector())))
69 {
70 if (item_GP.CanBePlaced(NULL, item_GP.CoordToParent(hologram.GetLeftFarProjectionVector())))
71 {
72 if (item_GP.CanBePlaced(NULL, item_GP.CoordToParent(hologram.GetRightFarProjectionVector())))
73 {
74 hologram.SetIsCollidingGPlot(false);
75
76 return;
77 }
78 }
79 }
80 }
81 }
82
83 hologram.SetIsCollidingGPlot(true);
84 }
85
87 {
88 }
89
96
98 {
102 vector position = action_data.m_Player.GetLocalProjectionPosition();
103 vector orientation = action_data.m_Player.GetLocalProjectionOrientation();
104
105 if (GetGame().IsMultiplayer())
106 {
107 m_GardenPlot = GardenPlot.Cast(action_data.m_Player.GetHologramServer().PlaceEntity(entity_for_placing));
108 m_GardenPlot.SetOrientation(orientation);
109 action_data.m_Player.GetHologramServer().CheckPowerSource();
110 action_data.m_Player.PlacingCompleteServer();
111
112 m_GardenPlot.OnPlacementComplete(action_data.m_Player);
113 }
114
115 //local singleplayer
116 if (!GetGame().IsMultiplayer())
117 {
118 m_GardenPlot = GardenPlot.Cast(action_data.m_Player.GetHologramLocal().PlaceEntity(entity_for_placing));
119 m_GardenPlot.SetOrientation(orientation);
120 action_data.m_Player.PlacingCompleteLocal();
121
122 m_GardenPlot.OnPlacementComplete(action_data.m_Player);
123 }
124
125 GetGame().ClearJuncture(action_data.m_Player, entity_for_placing);
126 action_data.m_MainItem.SetIsBeingPlaced(false);
127 action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
128 poActionData.m_AlreadyPlaced = true;
129 action_data.m_MainItem.SoundSynchRemoteReset();
130
131 MiscGameplayFunctions.DealAbsoluteDmg(action_data.m_MainItem, 10);
132
133 }
134};
bool m_FullBody
Definition ActionBase.c:52
string m_Text
Definition ActionBase.c:49
float m_SpecialtyWeight
Definition ActionBase.c:68
int m_StanceMask
Definition ActionBase.c:53
eBrokenLegs
Definition EBrokenLegs.c:2
override void CreateActionComponent()
override void SetupAnimation(ItemBase item)
override void OnFinishProgressServer(ActionData action_data)
override void OnFinishProgressClient(ActionData action_data)
override void DropDuringPlacing(PlayerBase player)
void CheckSurfaceBelowGardenPlot(PlayerBase player, GardenPlot item_GP, Hologram hologram)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Super root of all classes in Enforce script.
Definition EnScript.c:11
const float DIG_GARDEN
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.