DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
AnimatedActionBase.c
Go to the documentation of this file.
2{
4 protected SoundOnVehicle m_SoundObject;//object of sound playing on entity
5 protected bool m_Canceled;//helps prevent doubled calling of actionbase End method
6 protected bool m_Interrupted;//force callback to wait till action syncs its interruption
7
8
10 {
11 }
12
14 {
16 }
17
18 //Command events
19 override void OnFinish(bool pCanceled)
20 {
22 {
23 if ( m_ActionData)
24 Debug.ActionLog("Time stamp: " + m_ActionData.m_Player.GetSimulationTimeStamp(), m_ActionData.m_Action.ToString() , "n/a", "OnFinish", m_ActionData.m_Player.ToString() );
25 else
26 Debug.ActionLog("n/a", this.ToString() , "n/a", "OnFinish", "n/a" );
27 }
28 if ( m_SoundObject )
29 {
31 }
33 {
34 if ( pCanceled )
35 {
37 }
38
40
41 if(action)
42 action.End(m_ActionData);
43 }
44 }
45
46 void SetCommand( int command_uid )
47 {
48 InternalCommand(command_uid);
49 }
50
51 //---------------------------------------------------------------
52 //Action Component handlers
54 {
56 }
57
59 {
60 }
61
63 {
65 {
67 }
68 }
69
71 {
72 }
73
75 void Interrupt()
76 {
77 if ( GetGame().IsServer() )
78 {
80 {
81 Debug.ActionLog("n/a", this.ToString() , "n/a", "Interrupt", m_ActionData.m_Player.ToString() );
82 }
83 if ( GetGame().IsMultiplayer() )
84 {
86 }
87 }
88 else
89 {
91 {
94 ctx.Write(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
95 ctx.Send();
96 }
97 }
98 m_Interrupted = true;
99 }
100
101 void SetActionData(ActionData action_data )
102 {
103 m_ActionData = action_data;
104 }
105
106 override bool IsUserActionCallback()
107 {
108 return true;
109 }
110
112 {
114 {
116 }
117 return 0;
118 }
119
121 {
122 return m_ActionData.m_State;
123 }
124
126 {
127 return m_ActionData.m_Target;
128 }
129};
130
131
132
134{
135 protected int m_CommandUID; //tells which command should be used for callback
136 protected int m_CommandUIDProne;
137 protected typename m_CallbackClass; //tells which callback should be instantiated
138
139
140 //-----------------------------------------------------
141 // Action events and methods
142 //-----------------------------------------------------
144 {
145 // definable
147 }
148
149 protected void OnAlternativeEndServer( PlayerBase player ) //method called when action has not met conditions in action component
150 {
151 }
152 protected void OnAlternativeEndClient( PlayerBase player ) //method called when action has not met conditions in action component
153 {
154 }
155
156 protected void OnInterruptServer( PlayerBase player ) //method called when action has not met conditions in action component
157 {
158 }
159 protected void OnInterruptClient( PlayerBase player ) //method called when action has not met conditions in action component
160 {
161 }
162
163 protected void OnExecute( ActionData action_data )
164 {
165 }
166
167 protected void OnExecuteServer( ActionData action_data )
168 {
169 }
170
171 protected void OnExecuteClient( ActionData action_data )
172 {
173 }
174
175 //TODO MW - add comment
176 void OnAnimationEvent( ActionData action_data )
177 {
178 if (action_data && !action_data.m_WasExecuted)
179 {
180 ActionBase action = action_data.m_Action;
181
182 if (action && ( !action.UseMainItem() || action_data.m_MainItem ) && ( !action.HasTarget() || action_data.m_Target ))
183 {
185 {
186 Debug.ActionLog("Time stamp: " + action_data.m_Player.GetSimulationTimeStamp(), this.ToString() , "n/a", "OnExecute", action_data.m_Player.ToString() );
187 }
188 OnExecute(action_data);
189
190 if (GetGame().IsServer())
191 OnExecuteServer(action_data);
192 else
193 OnExecuteClient(action_data);
194
195 action_data.m_WasExecuted = true;
196 action_data.m_WasActionStarted = true;
197 }
198 }
199 }
200
201 override bool ActionConditionContinue( ActionData action_data ) //condition for action
202 {
203 return ActionCondition(action_data.m_Player,action_data.m_Target,action_data.m_MainItem);
204 }
205
206 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item ) //condition for action
207 {
208 return true;
209 }
210
211 //TODO MW - add comment
212 protected int GetActionCommand( PlayerBase player )
213 {
214 if ( HasProneException() )
215 {
216 if ( player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT))
217 return m_CommandUID;
218 else
219 return m_CommandUIDProne;
220 }
221 return m_CommandUID;
222 }
223
224 protected typename GetCallbackClassTypename()
225 {
226 return m_CallbackClass;
227 }
228
229 // if it is set to true if action have special fullbody animation for prone and additive for crouch and erect
230 override bool HasProneException()
231 {
232 return false;
233 }
234
235 //TODO MW - add comment
236 protected void CreateAndSetupActionCallback( ActionData action_data )
237 {
238 //Print("ActionBase.c | CreateAndSetupActionCallback | DBG ACTION CALLBACK CREATION CALLED");
239 ActionBaseCB callback;
240 if ( IsFullBody(action_data.m_Player) )
241 {
242 Class.CastTo(callback, action_data.m_Player.StartCommand_Action(GetActionCommand(action_data.m_Player),GetCallbackClassTypename(),GetStanceMask(action_data.m_Player)));
243 //Print("ActionBase.c | CreateAndSetupActionCallback | DBG command starter");
244 }
245 else
246 {
247 Class.CastTo(callback, action_data.m_Player.AddCommandModifier_Action(GetActionCommand(action_data.m_Player),GetCallbackClassTypename()));
248 //Print("ActionBase.c | CreateAndSetupActionCallback | DBG command modif starter: "+callback.ToString()+" id:"+GetActionCommand().ToString());
249
250 }
251 callback.SetActionData(action_data);
252 callback.InitActionComponent(); //jtomasik - tohle mozna patri do constructoru callbacku?
253 action_data.m_Callback = callback;
254 }
255
256
257
258 // ACTION LOGIC -------------------------------------------------------------------
259 // called from actionmanager.c
260 override void Start( ActionData action_data ) //Setup on start of action
261 {
262 super.Start( action_data );
263 //Debug.Log("[Action DEBUG] Start time stamp: " + action_data.m_Player.GetSimulationTimeStamp());
264
265 if( !IsInstant() )
266 {
267 CreateAndSetupActionCallback(action_data);
268 }
269 /*Debug
270 SendMessageToClient( player, "ActionBase.c : Start");
271 Print("ActionBase.c : Start");
272 */
273 }
274
275 // THIS Interrupt is use for ACTUAL handling of intrrupt on action side - WARNING Interrupt without parametr is used for initialize interrupt
276 override void Interrupt( ActionData action_data )
277 {
278 if ( action_data.m_Callback )
279 {
280 action_data.m_Callback.Cancel();
281 }
282 else
283 {
284 End( action_data );
285 }
286 }
287
289 {
290
291 }
292
293 // called from ActionBaseCB.c
294 void Do( ActionData action_data, int state )
295 {
296 if ( state == UA_ERROR || !action_data.m_Callback || !action_data.m_Player || !action_data.m_ActionComponent ) //jtomasik - tohle mozna muze byt v CancelCondtion metodu callbacku?
297 {
298#ifdef DIAG_DEVELOPER
300 {
301 Debug.ActionLog("ABRUPT CANCEL, CONDITIONS NOT MET", this.ToString() , "n/a", "Do", action_data.m_Player.ToString() );
302 }
303#endif
304 if ( action_data.m_Callback && action_data.m_Player )
305 {
306 action_data.m_Callback.Interrupt();
307 }
308 else
309 {
310 Debug.ActionLog("PLAYER LOST", this.ToString() , "n/a", "Do", action_data.m_Player.ToString() );
311 }
312 }
313 else
314 {
315 switch ( state )
316 {
317 case UA_PROCESSING:
318 if ( CanContinue(action_data) )
319 {
321 InformPlayers(action_data.m_Player, action_data.m_Target, UA_PROCESSING);
322 }
323 else
324 {
325 action_data.m_Callback.Interrupt();
326 InformPlayers(action_data.m_Player, action_data.m_Target, UA_CANCEL);
327 Do(action_data, UA_CANCEL);
328 }
329 break;
330
331 case UA_FINISHED:
332 InformPlayers(action_data.m_Player,action_data.m_Target,UA_FINISHED);
333 action_data.m_Callback.EndActionComponent();
334 break;
335
336 case UA_CANCEL:
337 InformPlayers(action_data.m_Player,action_data.m_Target,UA_CANCEL);
338 action_data.m_Callback.EndActionComponent();
339 break;
340
341 case UA_INITIALIZE:
342 if ( !CanContinue(action_data) )
343 {
344 action_data.m_Callback.Interrupt();
345 InformPlayers(action_data.m_Player, action_data.m_Target, UA_CANCEL);
346 Do(action_data, UA_CANCEL);
347 }
348 default:
349 Debug.ActionLog("Action component returned wrong value", this.ToString() , "n/a", "Do", action_data.m_Player.ToString() );
350 action_data.m_Callback.Interrupt();
351 break;
352 }
353 }
354 }
355
356 // called from ActionBaseCB.c
357 override void End( ActionData action_data )
358 {
359 if ( action_data.m_Player )
360 {
361 if ( GetGame().IsServer() )
362 {
363 OnEndServer(action_data);
364 action_data.m_Player.SetSoundCategoryHash(0);
365 }
366 else
367 {
368 OnEndClient(action_data);
369 }
370 OnEnd(action_data);
371
372 // Xbox Achievemnts
373 if ( action_data.m_WasActionStarted )
374 {
375 if ( IsEat() )
376 {
378 }
379 else if ( IsDrink() )
380 {
382 }
383
384 action_data.m_WasActionStarted = false;
385 }
386
387 action_data.m_Player.GetActionManager().OnActionEnd();
388
389
390 }
391 else
392 {
394 {
395 Debug.ActionLog("Ation could not be finished right at the end", this.ToString() , "n/a", "End", action_data.m_Player.ToString() );
396 }
397 action_data.m_Callback.Interrupt();
398 }
399 }
400
401 override float GetProgress( ActionData action_data )
402 {
403 if ( action_data.m_ActionComponent )
404 {
405 return action_data.m_ActionComponent.GetProgress();
406 }
407 return 0;
408 }
409};
const int INPUT_UDT_STANDARD_ACTION_END_REQUEST
Definition _constants.c:3
void OnEndServer(ActionData action_data)
protected bool CanContinue(ActionData action_data)
Definition ActionBase.c:747
bool IsDrink()
Definition ActionBase.c:276
void ActionBase()
Definition ActionBase.c:73
bool IsInstant()
Definition ActionBase.c:250
bool IsEat()
Definition ActionBase.c:271
void OnEndClient(ActionData action_data)
protected void InformPlayers(PlayerBase player, ActionTarget target, int state)
DEPRECATED delivers message ids to clients based on given context.
class ActionTargets ActionTarget
void End()
called on surrender end request end
proto string ToString()
override void OnEnd()
Definition JumpEvents.c:57
int GetStanceMask()
bool IsFullBody()
void SetCommand(int command_uid)
void ProgressActionComponent()
protected bool m_Interrupted
override bool IsUserActionCallback()
protected bool m_Canceled
void CreateActionComponent()
ActionTarget GetTarget()
override void OnFinish(bool pCanceled)
float GetActionComponentProgress()
protected ActionData m_ActionData
protected SoundOnVehicle m_SoundObject
void SetActionData(ActionData action_data)
int m_PossibleStanceMask
Definition ActionBase.c:34
ItemBase m_MainItem
Definition ActionBase.c:28
PlayerBase m_Player
Definition ActionBase.c:33
ref ActionBase m_Action
Definition ActionBase.c:27
bool m_WasActionStarted
Definition ActionBase.c:39
bool m_WasExecuted
Definition ActionBase.c:38
ActionBaseCB m_Callback
Definition ActionBase.c:29
ref CABase m_ActionComponent
Definition ActionBase.c:30
ref ActionTarget m_Target
Definition ActionBase.c:32
protected void OnExecuteServer(ActionData action_data)
protected void OnInterruptClient(PlayerBase player)
override bool ActionConditionContinue(ActionData action_data)
override void Interrupt(ActionData action_data)
protected void OnAlternativeEndServer(PlayerBase player)
override float GetProgress(ActionData action_data)
override void Start(ActionData action_data)
void OnAnimationEvent(ActionData action_data)
protected void OnExecute(ActionData action_data)
void Do(ActionData action_data, int state)
protected int GetActionCommand(PlayerBase player)
protected int m_CommandUIDProne
protected GetCallbackClassTypename()
protected void OnExecuteClient(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
protected void OnAlternativeEndClient(PlayerBase player)
override void End(ActionData action_data)
override bool HasProneException()
protected void OnInterruptServer(PlayerBase player)
protected void CreateAndSetupActionCallback(ActionData action_data)
int Interrupt(ActionData action_data)
Definition CABase.c:34
int Execute(ActionData action_data)
Definition CABase.c:24
float GetProgress()
Definition CABase.c:62
proto native void ObjectDelete(Object obj)
AnalyticsManagerClient GetAnalyticsClient()
Definition Game.c:1412
Super root of all classes in Enforce script.
Definition EnScript.c:11
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
proto static native bool CanStoreInputUserData()
proto native void Send()
proto bool Write(void value_out)
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.
const int UA_FINISHED
Definition constants.c:420
const int UA_ERROR
Definition constants.c:439
const int UA_INITIALIZE
Definition constants.c:428
const int UA_PROCESSING
Definition constants.c:418
const int UA_CANCEL
Definition constants.c:421
proto native void InternalCommand(int pInternalCommandId)