DayZ 1.24
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
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 GetGame().ObjectDelete(m_SoundObject);
31 {
32 if (pCanceled)
34
36
37 if (action)
39 }
40 }
41
46
47 //---------------------------------------------------------------
48 //Action Component handlers
53
55 {
56 }
57
63
65 {
66 }
67
69 void Interrupt()
70 {
71 if (GetGame().IsServer())
72 {
74 Debug.ActionLog("n/a", this.ToString(), "n/a", "Interrupt", m_ActionData.m_Player.ToString());
75 if (GetGame().IsMultiplayer())
77 }
78 else
79 {
81 {
84 ctx.Write(DayZPlayerConstants.CMD_ACTIONINT_INTERRUPT);
85 ctx.Send();
86 }
87 }
88 m_Interrupted = true;
89 }
90
95
96 override bool IsUserActionCallback()
97 {
98 return true;
99 }
100
102 {
104 return m_ActionData.m_ActionComponent.GetProgress();
105 return 0;
106 }
107
109 {
110 return m_ActionData.m_State;
111 }
112
113 ActionTarget GetTarget()
114 {
115 return m_ActionData.m_Target;
116 }
117};
118
119
120class AnimatedActionBase : ActionBase
121{
122 protected int m_CommandUID; //tells which command should be used for callback
123 protected int m_CommandUIDProne;
124 protected typename m_CallbackClass; //tells which callback should be instantiated
125
126
127 //-----------------------------------------------------
128 // Action events and methods
129 //-----------------------------------------------------
131 {
132 // definable
134 }
135
136 protected void OnAlternativeEndServer(PlayerBase player) //method called when action has not met conditions in action component
137 {
138 }
139 protected void OnAlternativeEndClient(PlayerBase player) //method called when action has not met conditions in action component
140 {
141 }
142
143 protected void OnInterruptServer(PlayerBase player) //method called when action has not met conditions in action component
144 {
145 }
146 protected void OnInterruptClient(PlayerBase player) //method called when action has not met conditions in action component
147 {
148 }
149
151 {
152 }
153
155 {
156 }
157
159 {
160 }
161
162 //TODO MW - add comment
164 {
165 if (action_data && !action_data.m_WasExecuted)
166 {
167 ActionBase action = action_data.m_Action;
168
169 if (action && (!action.UseMainItem() || action_data.m_MainItem) && (!action.HasTarget() || action_data.m_Target))
170 {
172 Debug.ActionLog("Time stamp: " + action_data.m_Player.GetSimulationTimeStamp(), this.ToString(), "n/a", "OnExecute", action_data.m_Player.ToString());
174
175 if (GetGame().IsServer())
177 else
179
180 action_data.m_WasExecuted = true;
181 action_data.m_WasActionStarted = true;
182 }
183 }
184 }
185
186 override bool ActionConditionContinue(ActionData action_data) //condition for action
187 {
188 return ActionCondition(action_data.m_Player, action_data.m_Target, action_data.m_MainItem);
189 }
190
191 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item) //condition for action
192 {
193 return true;
194 }
195
196 //TODO MW - add comment
198 {
199 if (HasProneException())
200 {
201 if (player.IsPlayerInStance(DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT))
202 return m_CommandUID;
203 else
204 return m_CommandUIDProne;
205 }
206 return m_CommandUID;
207 }
208
209 protected typename GetCallbackClassTypename()
210 {
211 return m_CallbackClass;
212 }
213
214 // if it is set to true if action have special fullbody animation for prone and additive for crouch and erect
215 override bool HasProneException()
216 {
217 return false;
218 }
219
220 //TODO MW - add comment
222 {
223 //Print("ActionBase.c | CreateAndSetupActionCallback | DBG ACTION CALLBACK CREATION CALLED");
225 if (IsFullBody(action_data.m_Player))
226 {
227 Class.CastTo(callback, action_data.m_Player.StartCommand_Action(GetActionCommand(action_data.m_Player), GetCallbackClassTypename(), GetStanceMask(action_data.m_Player)));
228 //Print("ActionBase.c | CreateAndSetupActionCallback | DBG command starter");
229 }
230 else
231 {
232 Class.CastTo(callback, action_data.m_Player.AddCommandModifier_Action(GetActionCommand(action_data.m_Player), GetCallbackClassTypename()));
233 //Print("ActionBase.c | CreateAndSetupActionCallback | DBG command modif starter: "+callback.ToString()+" id:"+GetActionCommand().ToString());
234
235 }
236 callback.SetActionData(action_data);
237 callback.InitActionComponent(); //jtomasik - tohle mozna patri do constructoru callbacku?
238 action_data.m_Callback = callback;
239 }
240
241
242 // ACTION LOGIC -------------------------------------------------------------------
243 // called from actionmanager.c
244 override void Start(ActionData action_data) //Setup on start of action
245 {
246 super.Start(action_data);
247 //Debug.Log("[Action DEBUG] Start time stamp: " + action_data.m_Player.GetSimulationTimeStamp());
248
249 if (!IsInstant())
251 /*Debug
252 SendMessageToClient( player, "ActionBase.c : Start");
253 Print("ActionBase.c : Start");
254 */
255 }
256
257 // THIS Interrupt is use for ACTUAL handling of intrrupt on action side - WARNING Interrupt without parametr is used for initialize interrupt
259 {
260 if (action_data.m_Callback)
261 action_data.m_Callback.Cancel();
262 else
264 }
265
267 {
268
269 }
270
271 // called from ActionBaseCB.c
273 {
274 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?
275 {
276#ifdef DIAG_DEVELOPER
278 Debug.ActionLog("ABRUPT CANCEL, CONDITIONS NOT MET", this.ToString(), "n/a", "Do", action_data.m_Player.ToString());
279#endif
280 if (action_data.m_Callback && action_data.m_Player)
281 action_data.m_Callback.Interrupt();
282 else
283 Debug.ActionLog("PLAYER LOST", this.ToString(), "n/a", "Do", action_data.m_Player.ToString());
284 }
285 else
286 {
287 switch (state)
288 {
289 case UA_PROCESSING:
291 {
292 action_data.m_Callback.ProgressActionComponent();
294 }
295 else
296 {
297 action_data.m_Callback.Interrupt();
298 InformPlayers(action_data.m_Player, action_data.m_Target, UA_CANCEL);
300 }
301 break;
302
303 case UA_FINISHED:
305 action_data.m_Callback.EndActionComponent();
306 break;
307
308 case UA_CANCEL:
309 InformPlayers(action_data.m_Player, action_data.m_Target, UA_CANCEL);
310 action_data.m_Callback.EndActionComponent();
311 break;
312
313 case UA_INITIALIZE:
315 {
316 action_data.m_Callback.Interrupt();
317 InformPlayers(action_data.m_Player, action_data.m_Target, UA_CANCEL);
319 }
320 default:
321 Debug.ActionLog("Action component returned wrong value", this.ToString(), "n/a", "Do", action_data.m_Player.ToString());
322 action_data.m_Callback.Interrupt();
323 break;
324 }
325 }
326 }
327
328 // called from ActionBaseCB.c
330 {
331 if (action_data.m_Player)
332 {
333 if (GetGame().IsServer())
334 {
336 action_data.m_Player.SetSoundCategoryHash(0);
337 }
338 else
341
342 // Xbox Achievemnts
343 if (action_data.m_WasActionStarted)
344 {
345 if (IsEat())
346 GetGame().GetAnalyticsClient().OnActionEat();
347 else if (IsDrink())
348 GetGame().GetAnalyticsClient().OnActionDrink();
349
350 action_data.m_WasActionStarted = false;
351 }
352
353 action_data.m_Player.GetActionManager().OnActionEnd();
354
355
356 }
357 else
358 {
360 Debug.ActionLog("Ation could not be finished right at the end", this.ToString(), "n/a", "End", action_data.m_Player.ToString());
361 action_data.m_Callback.Interrupt();
362 }
363 }
364
366 {
367 if (action_data.m_ActionComponent)
368 return action_data.m_ActionComponent.GetProgress();
369 return 0;
370 }
371};
const int INPUT_UDT_STANDARD_ACTION_END_REQUEST
Definition _constants.c:3
void OnEndServer(ActionData action_data)
Definition ActionBase.c:962
void InformPlayers(PlayerBase player, ActionTarget target, int state)
DEPRECATED delivers message ids to clients based on given context.
bool CanContinue(ActionData action_data)
Definition ActionBase.c:686
bool IsDrink()
Definition ActionBase.c:254
bool IsInstant()
Definition ActionBase.c:228
bool IsEat()
Definition ActionBase.c:249
void OnEndClient(ActionData action_data)
Definition ActionBase.c:959
void End()
called on surrender end request end
proto string ToString()
override void OnEnd()
Definition JumpEvents.c:53
bool IsFullBody()
int GetStanceMask()
void ProgressActionComponent()
void CreateActionComponent()
void SetCommand(int command_uid)
SoundOnVehicle m_SoundObject
ActionTarget GetTarget()
float GetActionComponentProgress()
ActionData m_ActionData
override bool IsUserActionCallback()
override void OnFinish(bool pCanceled)
void SetActionData(ActionData action_data)
PlayerBase m_Player
Definition ActionBase.c:33
int m_PossibleStanceMask
Definition ActionBase.c:34
ref ActionTarget m_Target
Definition ActionBase.c:32
ref CABase m_ActionComponent
Definition ActionBase.c:30
ref ActionBase m_Action
Definition ActionBase.c:27
void Do(ActionData action_data, int state)
void CreateAndSetupActionCallback(ActionData action_data)
override bool ActionConditionContinue(ActionData action_data)
void OnAnimationEvent(ActionData action_data)
override float GetProgress(ActionData action_data)
override void Interrupt(ActionData action_data)
void OnAlternativeEndClient(PlayerBase player)
void OnInterruptClient(PlayerBase player)
void OnInterruptServer(PlayerBase player)
void OnAlternativeEndServer(PlayerBase player)
int GetActionCommand(PlayerBase player)
override void Start(ActionData action_data)
override bool HasProneException()
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void End(ActionData action_data)
void OnExecute(ActionData action_data)
void OnExecuteServer(ActionData action_data)
void OnExecuteClient(ActionData action_data)
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:143
static bool IsActionLogEnable()
Definition Debug.c:719
proto static native bool CanStoreInputUserData()
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.
const int UA_FINISHED
Definition constants.c:436
const int UA_ERROR
Definition constants.c:455
const int UA_INITIALIZE
Definition constants.c:444
const int UA_PROCESSING
Definition constants.c:434
const int UA_CANCEL
Definition constants.c:437
proto native void InternalCommand(int pInternalCommandId)