DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ActionManagerServer.c
Go to the documentation of this file.
2{
4 ref ActionReciveData m_PendingActionReciveData;
5
7 {
8 m_PendingAction = null;
10 }
11
12 //------------------------------------------
13 //EVENTS
14 //------------------------------------------
15 override void OnJumpStart()
16 {
18 {
20 {
23 }
24 else
25 {
27 }
28 }
29 }
30
31 override bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
32 {
33 switch (userDataType)
34 {
36 {
37 bool success = true;
38
39 int actionID = 0;
40 if (!ctx.Read(actionID))
41 return false;
42
43 ActionBase recvAction = GetAction(actionID);
44 if (!recvAction)
45 return false;
46
47 if (!recvAction.ReadFromContext(ctx, m_PendingActionReciveData))
48 success = false;
49
50 m_PendingAction = recvAction;
51
52 if (recvAction.UseAcknowledgment())
53 {
54 int ackID;
55 if (!ctx.Read(ackID))
56 success = false;
57
59 }
60
61 break;
62
63 }
64
66 {
67 //Debug.Log("Action want end request, STS = " + m_Player.GetSimulationTimeStamp());
68 int commandID = -10;
69 ctx.Read(commandID);
70
71 if (commandID == DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT)
72 {
73 //Print("INPUT_UDT_STANDARD_ACTION_END_REQUEST | CMD_ACTIONINT_INTERRUPT");
74 Interrupt();
75 }
76 else
77 {
78 //Print("INPUT_UDT_STANDARD_ACTION_END_REQUEST | m_ActionWantEndRequest");
80 }
81 }
82
84 {
85 //Debug.Log("Action input ended, STS = " + m_Player.GetSimulationTimeStamp());
87 }
88 default:
89 return false;
90 }
91
92 if (!success)
93 {
94 //Debug.Log("[AM] OnInputUserDataProcess INPUT_UDT_STANDARD_ACTION_START Error");
95 if (recvAction.UseAcknowledgment())
96 {
98 }
99 else
100 {
101 Interrupt();
102 }
103
104 return false;
105 }
106 return true;
107
108 }
109
110 override void StartDeliveredAction()
111 {
113 {
115 return;
116 }
117
118 m_Interrupted = false;
119
120 bool accepted = false;
124
126 {
127 Debug.ActionLog("Item = " + item + ", " + target.DumpToString(), pickedAction.ToString() , "n/a", "DeliveredAction", m_Player.ToString());
128 }
129
130 if (!m_Player.GetCommandModifier_Action() && !m_Player.GetCommand_Action() && !m_Player.IsSprinting() && pickedAction && pickedAction.Can(m_Player,target,item))
131 {
132 accepted = true;
133 if (pickedAction.HasTarget())
134 {
135 EntityAI targetEntity;
136 if (EntityAI.CastTo(targetEntity,target.GetObject()))
137 {
138 if (!AdvancedCommunication.Cast(targetEntity) && !Building.Cast(targetEntity) && pickedAction.IsLockTargetOnUse())
139 {
140 //Lock target
141 if (!GetGame().AddActionJuncture(m_Player, targetEntity, 10000))
142 {
143 accepted = false;
144 }
145 }
146 }
147 }
148 }
149
150 if (accepted)
151 {
153 {
154 Debug.ActionLog("Action accepted", pickedAction.ToString() , "n/a", "CheckDeliveredAction", m_Player.ToString() );
155 }
156 //Debug.Log("[AM] Action acccepted");
157 if (pickedAction.UseAcknowledgment())
158 {
159 //Unlock target
162 }
163 else
164 {
166 }
167 }
168 else
169 {
171 {
172 Debug.ActionLog("Action rejected", pickedAction.ToString() , "n/a", "CheckDeliveredAction", m_Player.ToString() );
173 }
174
175 if (pickedAction.UseAcknowledgment())
176 {
178 }
179 else
180 {
181 Interrupt();
182 }
183 }
184 }
185
186 override void OnActionEnd()
187 {
188 //Debug.Log("Action ended - hard, STS = " + m_Player.GetSimulationTimeStamp());
190 {
192 {
193 EntityAI targetEntity;
194 if (targetEntity.CastTo(targetEntity, m_CurrentActionData.m_Target.GetObject()) && !Building.Cast(targetEntity))
195 {
197 }
198 }
199
200 super.OnActionEnd();
201 }
202 }
203
204
205 override void Update(int pCurrentCommandID)
206 {
207 super.Update(pCurrentCommandID);
208
209 //Debug.Log("m_ActionWantEnd " + m_ActionInputWantEnd);
210
211 if (m_PendingAction)
212 {
214 {
216 }
217 else
218 {
220 m_ActionInputWantEnd = false;
221
222 bool success = true;
223 ActionTarget target = new ActionTarget(null, null, -1, vector.Zero, 0);
224
226 {
227 Debug.ActionLog("n/a", m_PendingAction.ToString() , "n/a", "HandlePendingAction", m_Player.ToString() );
228 }
229
230 if (!m_PendingAction.SetupAction(m_Player,target,m_Player.GetItemInHands(),m_CurrentActionData))
231 {
232 success = false;
233 }
234 //Debug.Log("[AM] Action data synced (" + m_Player + ") success: " + success);
235
236 if (success)
237 {
239 }
240 else
241 {
242 if (m_PendingAction.UseAcknowledgment())
243 {
245 }
246 else
247 {
248 Interrupt();
249 }
250 }
251 }
252
253 m_PendingAction = null;
255 }
256
258 {
260 {
262
264 {
266 }
267 else
268 {
271 {
272 EntityAI targetEntity;
273 if ( targetEntity.CastTo(targetEntity, m_CurrentActionData.m_Target.GetObject()) && !Building.Cast(targetEntity) )
274 {
276 }
277 }
278 }
279 }
280
281 //Debug.Log("m_CurrentActionData.m_State: " + m_CurrentActionData.m_State +" m_ActionWantEnd: " + m_ActionWantEndRequest );
283 {
284 case UA_AM_PENDING:
285 break;
286
287 case UA_AM_ACCEPTED:
288 // check pCurrentCommandID before start or reject
289
291 if (canActionPerform && ActionPossibilityCheck(pCurrentCommandID))
292 {
295
297 OnActionEnd();
298 }
299 else
300 {
301 OnActionEnd();
302 }
304 break;
305
306 case UA_AM_REJECTED:
307 OnActionEnd();
309 break;
310
311 default:
313 {
314 m_ActionInputWantEnd = false;
316 }
317
319 {
322 }
323 break;
324 }
325 }
326 }
327
328 override void Interrupt()
329 {
330 super.Interrupt();
331
334 }
335
336 override ActionReciveData GetReciveData()
337 {
339 }
340}
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
void ActionBase()
Definition ActionBase.c:73
override ActionBase GetAction()
bool m_Interrupted
protected bool m_ActionInputWantEnd
protected bool m_ActionWantEndRequest
bool ActionPossibilityCheck(int pCurrentCommandID)
void ActionManagerBase(PlayerBase player)
protected ref ActionData m_CurrentActionData
protected int m_PendingActionAcknowledgmentID
class ActionTargets ActionTarget
DayZPlayer m_Player
Definition Hand_Events.c:42
ItemBase m_MainItem
Definition ActionBase.c:28
PlayerBase m_Player
Definition ActionBase.c:33
ref ActionBase m_Action
Definition ActionBase.c:27
int m_RefreshJunctureTimer
Definition ActionBase.c:37
ref ActionTarget m_Target
Definition ActionBase.c:32
override bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
override void OnActionEnd()
override void Update(int pCurrentCommandID)
override ActionReciveData GetReciveData()
ref ActionReciveData m_PendingActionReciveData
void ActionManagerServer(PlayerBase player)
override void StartDeliveredAction()
override void OnJumpStart()
protected ActionBase m_PendingAction
proto native bool ClearJuncture(Man player, notnull EntityAI item)
proto native bool ExtendActionJuncture(Man player, notnull EntityAI item, int timeout_ms)
static void SendActionAcknowledgment(DayZPlayer pPlayer, int AckID, bool accept)
static void SendActionInterrupt(DayZPlayer pPlayer)
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:138
static bool IsActionLogEnable()
Definition Debug.c:590
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto bool Read(void value_in)
static const vector Zero
Definition EnConvert.c:110
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()
const int UA_START
Definition constants.c:423
const int UA_AM_ACCEPTED
Definition constants.c:431
const int UA_AM_REJECTED
Definition constants.c:432
const int UA_AM_PENDING
Definition constants.c:430