DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ActionDeployBase.c
Go to the documentation of this file.
2{
6}
7
8class ActiondeployObjectCB : ActionContinuousBaseCB
9{
10 override void CreateActionComponent()
11 {
12 m_ActionData.m_ActionComponent = new CAContinuousTime(m_ActionData.m_MainItem.GetDeployTime());
14 }
15
18 {
19 }
20};
21
23{
24 protected const float POSITION_OFFSET = 0.5; // The forward offset at which the item will be placed (if not using hologram)
25
27 {
28 m_CallbackClass = ActiondeployObjectCB;
30 m_FullBody = true;
31 m_Text = "#deploy_object";
32 }
33
35 {
38 }
39
40 override bool HasTarget()
41 {
42 return false;
43 }
44
45 override bool HasProgress()
46 {
47 return true;
48 }
49
51 {
53 return action_data;
54 }
55
56 override void OnFinishProgressServer(ActionData action_data)
57 {
58 PlaceObjectActionData poActionData;
59 poActionData = PlaceObjectActionData.Cast(action_data);
60
61 if (!poActionData)
62 return;
63 if (!action_data.m_MainItem)
64 return;
65
66 EntityAI entity_for_placing = action_data.m_MainItem;
67 vector position;
68 vector orientation;
69
70 // In case of placement with hologram
71 if (action_data.m_Player.GetHologramServer())
72 {
73 position = action_data.m_Player.GetLocalProjectionPosition();
74 orientation = action_data.m_Player.GetLocalProjectionOrientation();
75
76 action_data.m_Player.GetHologramServer().EvaluateCollision(action_data.m_MainItem);
77 if (GetGame().IsMultiplayer() && action_data.m_Player.GetHologramServer().IsColliding())
78 {
79 return;
80 }
81
82 action_data.m_Player.GetHologramServer().PlaceEntity(entity_for_placing);
83
84 if (GetGame().IsMultiplayer())
85 action_data.m_Player.GetHologramServer().CheckPowerSource();
86 }
87 else
88 {
89 position = action_data.m_Player.GetPosition();
90 orientation = action_data.m_Player.GetOrientation();
91
92 position = position + (action_data.m_Player.GetDirection() * POSITION_OFFSET);
93 }
94
95 action_data.m_Player.PlacingCompleteServer();
96 entity_for_placing.OnPlacementComplete(action_data.m_Player, position, orientation);
97
98 MoveEntityToFinalPosition(action_data, position, orientation);
99 GetGame().ClearJunctureEx(action_data.m_Player, entity_for_placing);
100 action_data.m_MainItem.SetIsBeingPlaced(false);
101 action_data.m_Player.GetSoftSkillsManager().AddSpecialty(m_SpecialtyWeight);
102 poActionData.m_AlreadyPlaced = true;
103 action_data.m_MainItem.SoundSynchRemoteReset();
104 }
105
107 {
108 ItemBase item;
109 if (!Class.CastTo(item,player.GetItemInHands()))
110 return;
111
112 if (item.IsBasebuildingKit())
113 return;
114
115 player.PredictiveDropEntity(item);
116 }
117
118 void MoveEntityToFinalPosition(ActionData action_data, vector position, vector orientation)
119 {
120 if (action_data.m_MainItem.IsBasebuildingKit())
121 return;
122
123 EntityAI entity_for_placing = action_data.m_MainItem;
124 vector rotation_matrix[3];
125 float direction[4];
127 InventoryLocation destination = new InventoryLocation;
128
129 Math3D.YawPitchRollMatrix(orientation, rotation_matrix);
130 Math3D.MatrixToQuat(rotation_matrix, direction);
131
132 if (entity_for_placing.GetInventory().GetCurrentInventoryLocation(source))
133 {
134 destination.SetGroundEx(entity_for_placing, position, direction);
135
136 if (GetGame().IsMultiplayer())
137 {
138 action_data.m_Player.ServerTakeToDst(source, destination);
139 }
140 //local singleplayer
141 else
142 {
143 MoveEntityToFinalPositionSinglePlayer(action_data, source, destination);
144 }
145 }
146 }
147
149 {
150 action_data.m_Player.GetInventory().TakeToDst(InventoryMode.LOCAL, source, destination);
151 }
152}
InventoryMode
Definition Inventory.c:20
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
void DropDuringPlacing()
DEPRECATED.
void CreateActionComponent()
ItemBase m_MainItem
Definition ActionBase.c:28
PlayerBase m_Player
Definition ActionBase.c:33
override void OnFinishProgressServer(ActionData action_data)
void MoveEntityToFinalPositionSinglePlayer(ActionData action_data, InventoryLocation source, InventoryLocation destination)
override ActionData CreateActionData()
override bool HasProgress()
protected const float POSITION_OFFSET
override void CreateConditionComponents()
void DropDuringPlacing(PlayerBase player)
void MoveEntityToFinalPosition(ActionData action_data, vector position, vector orientation)
override bool HasTarget()
bool ClearJunctureEx(Man player, notnull EntityAI item)
Definition Game.c:735
Super root of all classes in Enforce script.
Definition EnScript.c:11
InventoryLocation.
proto native void SetGroundEx(EntityAI e, vector pos, float dir[4])
sets current inventory location type to Ground with transformation mat
override bool IsBasebuildingKit()
Definition KitBase.c:17
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto void MatrixToQuat(vector mat[3], out float d[4])
Converts rotation matrix to quaternion.
static proto void YawPitchRollMatrix(vector ang, out vector mat[3])
Creates rotation matrix from angles.