DayZ 1.24
Loading...
Searching...
No Matches
ActionManagerServer.c
Go to the documentation of this file.
1class ActionManagerServer: ActionManagerBase
2{
3 protected ActionBase m_PendingAction;
4 ref ActionReciveData m_PendingActionReciveData;
5
11
12 //------------------------------------------
13 //EVENTS
14 //------------------------------------------
15 override void OnJumpStart()
16 {
18 {
20 {
23 }
24 else
25 m_CurrentActionData.m_Action.Interrupt(m_CurrentActionData);
26 }
27 }
28
30 {
31 switch (userDataType)
32 {
34 {
35 bool success = true;
36
37 int actionID = 0;
38 if (!ctx.Read(actionID))
39 return false;
40
41 ActionBase recvAction = GetAction(actionID);
42 if (!recvAction)
43 return false;
44
45 if (!recvAction.ReadFromContext(ctx, m_PendingActionReciveData))
46 success = false;
47
49
50 if (recvAction.UseAcknowledgment())
51 {
52 int ackID;
53 if (!ctx.Read(ackID))
54 success = false;
55
57 }
58
59 break;
60
61 }
62
64 {
65 //Debug.Log("Action want end request, STS = " + m_Player.GetSimulationTimeStamp());
66 int commandID = -10;
67 ctx.Read(commandID);
68
69 if (commandID == DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT)
70 {
71 //Print("INPUT_UDT_STANDARD_ACTION_END_REQUEST | CMD_ACTIONINT_INTERRUPT");
72 Interrupt();
73 }
74 else
75 {
76 //Print("INPUT_UDT_STANDARD_ACTION_END_REQUEST | m_ActionWantEndRequest");
78 }
79 }
80
82 {
83 //Debug.Log("Action input ended, STS = " + m_Player.GetSimulationTimeStamp());
85 }
86 default:
87 return false;
88 }
89
90 if (!success)
91 {
92 //Debug.Log("[AM] OnInputUserDataProcess INPUT_UDT_STANDARD_ACTION_START Error");
93 if (recvAction.UseAcknowledgment())
95 else
96 Interrupt();
97
98 return false;
99 }
100 return true;
101
102 }
103
104 override void StartDeliveredAction()
105 {
107 {
109 return;
110 }
111
112 m_Interrupted = false;
113
114 bool accepted = false;
115 ActionBase pickedAction = m_CurrentActionData.m_Action;
116 ActionTarget target = m_CurrentActionData.m_Target;
117 ItemBase item = m_CurrentActionData.m_MainItem;
118
120 Debug.ActionLog("Item = " + item + ", " + target.DumpToString(), pickedAction.ToString(), "n/a", "DeliveredAction", m_Player.ToString());
121
122 if (!m_Player.GetCommandModifier_Action() && !m_Player.GetCommand_Action() && !m_Player.IsSprinting() && pickedAction && pickedAction.Can(m_Player, target, item))
123 {
124 accepted = true;
125 if (pickedAction.HasTarget())
126 {
128 if (EntityAI.CastTo(targetEntity, target.GetObject()))
129 {
130 if (!AdvancedCommunication.Cast(targetEntity) && !Building.Cast(targetEntity) && pickedAction.IsLockTargetOnUse())
131 {
132 //Lock target
133 if (!GetGame().AddActionJuncture(m_Player, targetEntity, 10000))
134 accepted = false;
135 }
136 }
137 }
138 }
139
140 if (accepted)
141 {
143 Debug.ActionLog("Action accepted", pickedAction.ToString(), "n/a", "CheckDeliveredAction", m_Player.ToString());
144 //Debug.Log("[AM] Action acccepted");
145 if (pickedAction.UseAcknowledgment())
146 {
147 //Unlock target
150 }
151 else
153 }
154 else
155 {
157 Debug.ActionLog("Action rejected", pickedAction.ToString(), "n/a", "CheckDeliveredAction", m_Player.ToString());
158
159 if (pickedAction.UseAcknowledgment())
161 else
162 Interrupt();
163 }
164 }
165
166 override void OnActionEnd()
167 {
168 //Debug.Log("Action ended - hard, STS = " + m_Player.GetSimulationTimeStamp());
170 {
171 if (m_CurrentActionData.m_Target)
172 {
174 if (targetEntity.CastTo(targetEntity, m_CurrentActionData.m_Target.GetObject()) && !Building.Cast(targetEntity))
175 GetGame().ClearJuncture(m_CurrentActionData.m_Player, targetEntity);
176 }
177
178 super.OnActionEnd();
179 }
180 }
181
182 //pCurrentCommandID is command ID at time of call command handler, some called methods can change actual true value (need call m_Player.GetCurrentCommandID() for actual command ID)
183 override void Update(int pCurrentCommandID)
184 {
185 super.Update(pCurrentCommandID);
186 int currentCommandID = m_Player.GetCurrentCommandID();
187
188 //Debug.Log("m_ActionWantEnd " + m_ActionInputWantEnd);
189
190 if (m_PendingAction)
191 {
194 else
195 {
197 m_ActionInputWantEnd = false;
198
199 bool success = true;
200 ActionTarget target = new ActionTarget(null, null, -1, vector.Zero, 0);
201
203 Debug.ActionLog("n/a", m_PendingAction.ToString(), "n/a", "HandlePendingAction", m_Player.ToString());
204
205 if (!m_PendingAction.SetupAction(m_Player, target, m_Player.GetItemInHands(), m_CurrentActionData))
206 success = false;
207 //Debug.Log("[AM] Action data synced (" + m_Player + ") success: " + success);
208
209 if (success)
211 else
212 {
213 if (m_PendingAction.UseAcknowledgment())
215 else
216 Interrupt();
217 }
218 }
219
222 }
223
225 {
227 {
228 m_CurrentActionData.m_Action.OnUpdateServer(m_CurrentActionData);
229
230 if (m_CurrentActionData.m_RefreshJunctureTimer > 0)
231 m_CurrentActionData.m_RefreshJunctureTimer--;
232 else
233 {
234 m_CurrentActionData.m_RefreshJunctureTimer = m_CurrentActionData.m_Action.GetRefreshReservationTimerValue();
235 if (m_CurrentActionData.m_Target)
236 {
238 if (targetEntity.CastTo(targetEntity, m_CurrentActionData.m_Target.GetObject()) && !Building.Cast(targetEntity))
239 GetGame().ExtendActionJuncture(m_CurrentActionData.m_Player, targetEntity, 10000);
240 }
241 }
242 }
243
244 //Debug.Log("m_CurrentActionData.m_State: " + m_CurrentActionData.m_State +" m_ActionWantEnd: " + m_ActionWantEndRequest );
245 switch (m_CurrentActionData.m_State)
246 {
247 case UA_AM_PENDING:
248 break;
249
250 case UA_AM_ACCEPTED:
251 // check currentCommandID before start or reject
252
255 {
258
259 if (m_CurrentActionData.m_Action && m_CurrentActionData.m_Action.IsInstant())
260 OnActionEnd();
261 }
262 else
263 Interrupt();
265 break;
266
267 case UA_AM_REJECTED:
268 OnActionEnd();
270 break;
271
272 default:
274 {
275 m_ActionInputWantEnd = false;
276 m_CurrentActionData.m_Action.EndInput(m_CurrentActionData);
277 }
278
280 {
282 m_CurrentActionData.m_Action.EndRequest(m_CurrentActionData);
283 }
284 break;
285 }
286 }
287 }
288
289 override void Interrupt()
290 {
291 super.Interrupt();
292
295 }
296
297 override ActionReciveData GetReciveData()
298 {
300 }
301}
const int INPUT_UDT_STANDARD_ACTION_END_REQUEST
Definition _constants.c:3
const int INPUT_UDT_STANDARD_ACTION_START
Definition _constants.c:2
const int INPUT_UDT_STANDARD_ACTION_INPUT_END
Definition _constants.c:4
override ActionBase GetAction()
bool m_Interrupted
ref ActionData m_CurrentActionData
bool m_ActionInputWantEnd
bool ActionPossibilityCheck(int pCurrentCommandID)
int m_PendingActionAcknowledgmentID
bool m_ActionWantEndRequest
class ActionTargets ActionTarget
DayZPlayer m_Player
Definition Hand_Events.c:42
ref ActionReciveData m_PendingActionReciveData
override ActionReciveData GetReciveData()
void ActionManagerServer(PlayerBase player)
override bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
override void OnJumpStart()
override void StartDeliveredAction()
override void Update(int pCurrentCommandID)
override void OnActionEnd()
static void SendActionInterrupt(DayZPlayer pPlayer)
static void SendActionAcknowledgment(DayZPlayer pPlayer, int AckID, bool accept)
Definition Debug.c:14
static void ActionLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Definition Debug.c:143
static bool IsActionLogEnable()
Definition Debug.c:719
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
static const vector Zero
Definition EnConvert.c:110
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
const int UA_START
Definition constants.c:439
const int UA_AM_ACCEPTED
Definition constants.c:447
const int UA_AM_REJECTED
Definition constants.c:448
const int UA_AM_PENDING
Definition constants.c:446