Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
man.c
Go to the documentation of this file.
1 class Man extends EntityAI
2 {
4  proto native UAInterface GetInputInterface();
6  proto native PlayerIdentity GetIdentity();
8  proto native EntityAI GetDrivingVehicle();
9 
10  proto native owned string GetCurrentWeaponMode();
11 
13  proto native void SetSpeechRestricted(bool state);
15  proto native bool IsSpeechRestricted();
16 
18  proto native void SetFaceTexture(string texture_name);
20  proto native void SetFaceMaterial(string material_name);
21 
22  proto native bool IsSoundInsideBuilding();
23  proto native bool IsCameraInsideVehicle();
24 
25  proto native owned string GetMasterAttenuation();
26  proto native void SetMasterAttenuation(string masterAttenuation);
27 
28  void Man()
29  {
30  SetFlags(EntityFlags.TOUCHTRIGGERS, false);
31  }
32 
33  override bool IsMan()
34  {
35  return true;
36  }
37 
38  override bool IsHealthVisible()
39  {
40  return false;
41  }
42 
44  {
45  return true;
46  }
47 
48  bool IsUnconscious();
49 
50  int GetPlayerState()
51  {
52  if (IsAlive())
53  return EPlayerStates.ALIVE;
54 
55  return EPlayerStates.DEAD;
56  }
57 
58  void AddItemToDelete(EntityAI item);
59 
61  HumanInventory GetHumanInventory()
62  {
63  HumanInventory i = HumanInventory.Cast(GetInventory());
64  return i;
65  }
66 
67  //Called when an item is removed from the cargo of this item
68  protected ref ScriptInvoker m_OnItemAddedToHands;
69  //Called when an item is moved around in the cargo of this item
70  protected ref ScriptInvoker m_OnItemRemovedFromHands;
71 
72  ScriptInvoker GetOnItemAddedToHands()
73  {
74  if (!m_OnItemAddedToHands)
75  m_OnItemAddedToHands = new ScriptInvoker();
76 
77  return m_OnItemAddedToHands;
78  }
79 
80 
81  ScriptInvoker GetOnItemRemovedFromHands()
82  {
83  if( !m_OnItemRemovedFromHands )
84  m_OnItemRemovedFromHands = new ScriptInvoker;
85 
86  return m_OnItemRemovedFromHands;
87  }
88 
89  void EEItemIntoHands(EntityAI item)
90  {
91  SetWeightDirty();
92  if( m_OnItemAddedToHands )
93  m_OnItemAddedToHands.Invoke( item, this );
94  }
95 
96  void EEItemOutOfHands(EntityAI item)
97  {
98  SetWeightDirty();
99  if( m_OnItemRemovedFromHands )
100  m_OnItemRemovedFromHands.Invoke( item, this );
101  }
102 
104  bool JunctureDropEntity (notnull EntityAI item)
105  {
106  return DropEntityImpl(InventoryMode.JUNCTURE, this, item);
107  }
108 
109  override bool PredictiveDropEntity (notnull EntityAI item)
110  {
111  if (!ScriptInputUserData.CanStoreInputUserData())
112  {
113  Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveDropEntity input data not sent yet, cannot allow another input action");
114  return false;
115  }
116 
117  if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), this))
118  return JunctureDropEntity(item);
119  else
120  return DropEntityImpl(InventoryMode.PREDICTIVE, this, item);
121  }
122 
123  override bool LocalDropEntity (notnull EntityAI item)
124  {
125  return DropEntityImpl(InventoryMode.LOCAL, this, item);
126  }
127 
128  override bool ServerDropEntity (notnull EntityAI item)
129  {
130  return DropEntityImpl(InventoryMode.SERVER, this, item);
131  }
132 
133  protected bool DropEntityImpl (InventoryMode mode, notnull EntityAI owner, notnull EntityAI item)
134  {
135  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::DropEntity(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
136  bool code = GetHumanInventory().DropEntity(mode, owner, item);
137  UpdateInventoryMenu();
138  return code;
139  }
141 
142  override bool CanDropEntity (notnull EntityAI item) { return true; }
143 
144  void OnItemInHandsChanged () { }
145 
146  bool NeedInventoryJunctureFromServer (notnull EntityAI item, EntityAI currParent, EntityAI newParent) { return false; }
147 
149  void JunctureTakeEntityToHands (notnull EntityAI item)
150  {
151  TakeEntityToHandsImpl(InventoryMode.JUNCTURE, item);
152  }
153 
154  void PredictiveTakeEntityToHands (EntityAI item)
155  {
156  if (!ScriptInputUserData.CanStoreInputUserData())
157  {
158  Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveTakeEntityToHands input data not sent yet, cannot allow another input action");
159  return;
160  }
161 
162  if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), this))
163  JunctureTakeEntityToHands(item);
164  else
165  TakeEntityToHandsImpl(InventoryMode.PREDICTIVE, item);
166  }
167 
168  void LocalTakeEntityToHands (EntityAI item)
169  {
170  TakeEntityToHandsImpl(InventoryMode.LOCAL, item);
171  }
172 
173  void ServerTakeEntityToHands (EntityAI item)
174  {
175  TakeEntityToHandsImpl(InventoryMode.SERVER, item);
176  }
177 
178  void TakeEntityToHandsImpl (InventoryMode mode, EntityAI item)
179  {
180  if (!GetGame().IsDedicatedServer() )
181  {
183  il.SetHands(this, item);
184  //GetInventory().AddInventoryReservationEx(item, il ,GameInventory.c_InventoryReservationTimeoutShortMS);
185  }
186 
187  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::Take2Hands(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
188  EntityAI itemInHands = GetHumanInventory().GetEntityInHands();
189 
190  InventoryLocation src_item = new InventoryLocation;
191  if (item.GetInventory().GetCurrentInventoryLocation(src_item))
192  {
193  if (itemInHands == null)
194  {
195  InventoryLocation hand_dst = new InventoryLocation;
196  hand_dst.SetHands(this, item);
197  GetHumanInventory().TakeToDst(mode, src_item, hand_dst);
198  }
199  else if (GetHumanInventory().CanSwapEntitiesEx(itemInHands, item))
200  GetInventory().SwapEntities(mode, itemInHands, item);
201  UpdateInventoryMenu();
202  }
203  }
205 
206  void LocalDestroyEntityInHands ()
207  {
208  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " Destroy IH=" + GetHumanInventory().GetEntityInHands());
209  GetHumanInventory().LocalDestroyEntity(GetHumanInventory().GetEntityInHands());
210  UpdateInventoryMenu();
211  }
212 
213  void PredictiveMoveItemFromHandsToInventory ()
214  {
215  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " Stash IH=" + GetHumanInventory().GetEntityInHands());
216  if (!ScriptInputUserData.CanStoreInputUserData())
217  {
218  Print("[inv] PredictiveMoveItemFromHandsToInventory input data not sent yet, cannot allow another input action");
219  return;
220  }
221 
222  InventoryMode invMode = InventoryMode.PREDICTIVE;
223 
224  if (NeedInventoryJunctureFromServer( GetHumanInventory().GetEntityInHands(), this, this))
225  invMode = InventoryMode.JUNCTURE;
226 
228  if (GetHumanInventory().GetEntityInHands().m_OldLocation && GetHumanInventory().GetEntityInHands().m_OldLocation.IsValid())
229  {
231  GetHumanInventory().GetEntityInHands().GetInventory().GetCurrentInventoryLocation(invLoc);
232  //old location is somewhere on player
233  if (GetHumanInventory().GetEntityInHands().m_OldLocation.GetParent() && GetHumanInventory().GetEntityInHands().m_OldLocation.GetParent().GetHierarchyRootPlayer())
234  {
235  if (GetHumanInventory().LocationCanMoveEntity(invLoc, GetHumanInventory().GetEntityInHands().m_OldLocation))
236  {
237  if (GetHumanInventory().TakeToDst(invMode, invLoc,GetHumanInventory().GetEntityInHands().m_OldLocation))
238  {
239  UpdateInventoryMenu();
240  return;
241  }
242  }
243  }
244  }
245 
246  GetHumanInventory().TakeEntityToInventory(invMode, FindInventoryLocationType.ATTACHMENT | FindInventoryLocationType.CARGO, GetHumanInventory().GetEntityInHands());
247  UpdateInventoryMenu();
248  }
249 
251  protected bool ReplaceItemWithNewImpl(InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
252  {
253  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " Replace !HND lambda=" + lambda.DumpToString());
254  bool code = GetHumanInventory().ReplaceItemWithNew(mode, lambda);
255  UpdateInventoryMenu();
256  return code;
257  }
258 
259  bool LocalReplaceItemWithNew(ReplaceItemWithNewLambdaBase lambda)
260  {
261  return ReplaceItemWithNewImpl(InventoryMode.LOCAL, lambda);
262  }
263 
264  bool ServerReplaceItemWithNew(ReplaceItemWithNewLambdaBase lambda)
265  {
266  return ReplaceItemWithNewImpl(InventoryMode.SERVER, lambda);
267  }
269 
271  protected bool ReplaceItemElsewhereWithNewInHandsImpl (InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
272  {
273  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " Replace !HND->HND lambda=" + lambda.DumpToString());
274  bool code = GetHumanInventory().ReplaceItemElsewhereWithNewInHands(mode, lambda);
275  UpdateInventoryMenu();
276  return code;
277  }
278 
279  bool LocalReplaceItemElsewhereWithNewInHands (ReplaceItemWithNewLambdaBase lambda)
280  {
281  return ReplaceItemElsewhereWithNewInHandsImpl(InventoryMode.LOCAL, lambda);
282  }
283 
284  bool ServerReplaceItemElsewhereWithNewInHands (ReplaceItemWithNewLambdaBase lambda)
285  {
286  return ReplaceItemElsewhereWithNewInHandsImpl(InventoryMode.SERVER, lambda);
287  }
289 
291  protected bool ReplaceItemInHandsWithNewImpl (InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
292  {
293  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " Replace HND->HND lambda=" + lambda.DumpToString());
294  bool code = GetHumanInventory().ReplaceItemInHandsWithNew(mode, lambda);
295  UpdateInventoryMenu();
296  return code;
297  }
298 
299  bool LocalReplaceItemInHandsWithNew (ReplaceItemWithNewLambdaBase lambda)
300  {
301  return ReplaceItemInHandsWithNewImpl(InventoryMode.LOCAL, lambda);
302  }
303 
304  bool ServerReplaceItemInHandsWithNew (ReplaceItemWithNewLambdaBase lambda)
305  {
306  return ReplaceItemInHandsWithNewImpl(InventoryMode.SERVER, lambda);
307  }
309 
311  protected bool ReplaceItemInHandsWithNewElsewhereImpl (InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
312  {
313  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " Replace HND->elsewhere lambda=" + lambda.DumpToString());
314  bool code = GetHumanInventory().ReplaceItemInHandsWithNewElsewhere(mode, lambda);
315  UpdateInventoryMenu();
316  return code;
317  }
318 
319  bool LocalReplaceItemInHandsWithNewElsewhere (ReplaceItemWithNewLambdaBase lambda)
320  {
321  return ReplaceItemInHandsWithNewElsewhereImpl(InventoryMode.LOCAL, lambda);
322  }
323 
324  bool ServerReplaceItemInHandsWithNewElsewhere (ReplaceItemWithNewLambdaBase lambda)
325  {
326  return ReplaceItemInHandsWithNewElsewhereImpl(InventoryMode.SERVER, lambda);
327  }
329 
331  bool JunctureTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item)
332  {
333  return TakeEntityToInventoryImpl(InventoryMode.JUNCTURE, flags, item);
334  }
335 
336  override bool PredictiveTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item)
337  {
338  if (!ScriptInputUserData.CanStoreInputUserData())
339  {
340  Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveTakeEntityToInventory input data not sent yet, cannot allow another input action");
341  return false;
342  }
343 
344  if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), this))
345  return JunctureTakeEntityToInventory(flags, item);
346  else
347  return TakeEntityToInventoryImpl(InventoryMode.PREDICTIVE, flags, item);
348  }
349 
350  override bool LocalTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item)
351  {
352  return TakeEntityToInventoryImpl(InventoryMode.LOCAL, flags, item);
353  }
354 
355  override bool ServerTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item)
356  {
357  return TakeEntityToInventoryImpl(InventoryMode.SERVER, flags, item);
358  }
359 
360  protected bool TakeEntityToInventoryImpl (InventoryMode mode, FindInventoryLocationType flags, notnull EntityAI item)
361  {
362  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::Take2Inv(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
363  bool code = GetHumanInventory().TakeEntityToInventory(mode, flags, item);
364  UpdateInventoryMenu();
365  return code;
366  }
368 
370  bool JunctureTakeEntityToCargo (notnull EntityAI item)
371  {
372  return TakeEntityToCargoImpl(InventoryMode.JUNCTURE, item);
373  }
374 
375  override bool PredictiveTakeEntityToCargo (notnull EntityAI item)
376  {
377  if (!ScriptInputUserData.CanStoreInputUserData())
378  {
379  Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveTakeEntityToCargo input data not sent yet, cannot allow another input action");
380  return false;
381  }
382 
383  if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), this))
384  return JunctureTakeEntityToCargo(item);
385  else
386  return TakeEntityToCargoImpl(InventoryMode.PREDICTIVE, item);
387  }
388 
389  override bool LocalTakeEntityToCargo (notnull EntityAI item)
390  {
391  return TakeEntityToCargoImpl(InventoryMode.LOCAL, item);
392  }
393 
394  override bool ServerTakeEntityToCargo (notnull EntityAI item)
395  {
396  return TakeEntityToCargoImpl(InventoryMode.SERVER, item);
397  }
398 
399  protected bool TakeEntityToCargoImpl (InventoryMode mode, notnull EntityAI item)
400  {
401  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::Take2Cgo(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
402  bool code = GetHumanInventory().TakeEntityToCargo(mode, item);
403  UpdateInventoryMenu();
404  return code;
405  }
407 
409  bool JunctureTakeEntityAsAttachment (notnull EntityAI item)
410  {
411  return TakeEntityAsAttachmentImpl(InventoryMode.JUNCTURE, item);
412  }
413 
414  override bool PredictiveTakeEntityAsAttachment (notnull EntityAI item)
415  {
416  if (!ScriptInputUserData.CanStoreInputUserData())
417  {
418  Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveTakeEntityAsAttachment input data not sent yet, cannot allow another input action");
419  return false;
420  }
421 
422  if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), this))
423  return JunctureTakeEntityAsAttachment(item);
424  else
425  return TakeEntityAsAttachmentImpl(InventoryMode.PREDICTIVE, item);
426  }
427 
428  override bool LocalTakeEntityAsAttachment (notnull EntityAI item)
429  {
430  return TakeEntityAsAttachmentImpl(InventoryMode.LOCAL, item);
431  }
432 
433  override bool ServerTakeEntityAsAttachment (notnull EntityAI item)
434  {
435  return TakeEntityAsAttachmentImpl(InventoryMode.SERVER, item);
436  }
437 
438  protected bool TakeEntityAsAttachmentImpl (InventoryMode mode, notnull EntityAI item)
439  {
440  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::Take2Att(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
441  bool code = GetHumanInventory().TakeEntityAsAttachment(mode, item);
442  UpdateInventoryMenu();
443  return code;
444  }
446 
448  bool JunctureTakeEntityAsAttachmentEx (notnull EntityAI item, int slot)
449  {
450  return TakeEntityAsAttachmentExImpl(InventoryMode.JUNCTURE, item, slot);
451  }
452 
453  override bool PredictiveTakeEntityAsAttachmentEx (notnull EntityAI item, int slot)
454  {
455  if (!ScriptInputUserData.CanStoreInputUserData())
456  {
457  Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveTakeEntityAsAttachmentEx input data not sent yet, cannot allow another input action");
458  return false;
459  }
460 
461  if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), this))
462  return JunctureTakeEntityAsAttachmentEx(item, slot);
463  else
464  return TakeEntityAsAttachmentExImpl(InventoryMode.PREDICTIVE, item, slot);
465  }
466 
467  override bool LocalTakeEntityAsAttachmentEx (notnull EntityAI item, int slot)
468  {
469  return TakeEntityAsAttachmentExImpl(InventoryMode.LOCAL, item, slot);
470  }
471 
472  override bool ServerTakeEntityAsAttachmentEx (notnull EntityAI item, int slot)
473  {
474  return TakeEntityAsAttachmentExImpl(InventoryMode.SERVER, item, slot);
475  }
476 
477  protected bool TakeEntityAsAttachmentExImpl (InventoryMode mode, notnull EntityAI item, int slot)
478  {
479  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::Take2AttEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
480  bool code = GetHumanInventory().TakeEntityAsAttachmentEx(mode, item, slot);
481  UpdateInventoryMenu();
482  return code;
483  }
485 
487  bool JunctureSwapEntities (notnull EntityAI item1, notnull EntityAI item2)
488  {
489  return SwapEntitiesImpl(InventoryMode.JUNCTURE, item1, item2);
490  }
491 
492  bool PredictiveSwapEntities (notnull EntityAI item1, notnull EntityAI item2)
493  {
494  if (!ScriptInputUserData.CanStoreInputUserData())
495  {
496  Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveSwapEntities input data not sent yet, cannot allow another input action");
497  return false;
498  }
499 
500  bool need_j1 = NeedInventoryJunctureFromServer(item1, item1.GetHierarchyParent(), item2.GetHierarchyParent());
501  bool need_j2 = NeedInventoryJunctureFromServer(item2, item2.GetHierarchyParent(), item1.GetHierarchyParent());
502  if (need_j1 || need_j2)
503  return SwapEntitiesImpl(InventoryMode.JUNCTURE, item1, item2);
504  else
505  return SwapEntitiesImpl(InventoryMode.PREDICTIVE, item1, item2);
506  }
507 
508  bool LocalSwapEntities (notnull EntityAI item1, notnull EntityAI item2)
509  {
510  return SwapEntitiesImpl(InventoryMode.LOCAL, item1, item2);
511  }
512 
513  bool ServerSwapEntities (notnull EntityAI item1, notnull EntityAI item2)
514  {
515  return SwapEntitiesImpl(InventoryMode.SERVER, item1, item2);
516  }
517 
518  protected bool SwapEntitiesImpl (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
519  {
520  bool code;
521  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::SwapImpl(" + typename.EnumToString(InventoryMode, mode) + ") item1=" + Object.GetDebugName(item1) + " item2=" + item2.GetDebugName(this));
522  if (!GameInventory.CanSwapEntitiesEx(item1, item2))
523  Error("[inv] (Man@" + this + ") SwapEntitiesImpl - cannot swap items!");
524 
525  code = GetHumanInventory().SwapEntities(mode, item1, item2);
526 
527  UpdateInventoryMenu();
528  if (!code)
529  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " SwapEntitiesImpl - cannot swap or forceswap");
530  return code;
531  }
533 
535  bool JunctureForceSwapEntities (notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
536  {
537  return ForceSwapEntitiesImpl(InventoryMode.JUNCTURE, item1, item2, item2_dst);
538  }
539 
540  bool PredictiveForceSwapEntities (notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
541  {
542  if (!ScriptInputUserData.CanStoreInputUserData())
543  {
544  Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveForceSwapEntities input data not sent yet, cannot allow another input action");
545  return false;
546  }
547 
548  bool need_j1 = NeedInventoryJunctureFromServer(item1, item1.GetHierarchyParent(), item2.GetHierarchyParent());
549  bool need_j2 = NeedInventoryJunctureFromServer(item2, item2.GetHierarchyParent(), item1.GetHierarchyParent());
550  if (need_j1 || need_j2)
551  return ForceSwapEntitiesImpl(InventoryMode.JUNCTURE, item1, item2, item2_dst);
552  else
553  return ForceSwapEntitiesImpl(InventoryMode.PREDICTIVE, item1, item2, item2_dst);
554  }
555 
556  bool LocalForceSwapEntities (notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
557  {
558  return ForceSwapEntitiesImpl(InventoryMode.LOCAL, item1, item2, item2_dst);
559  }
560 
561  bool ServerForceSwapEntities (notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
562  {
563  return ForceSwapEntitiesImpl(InventoryMode.SERVER, item1, item2, item2_dst);
564  }
565 
566  protected bool ForceSwapEntitiesImpl (InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
567  {
568  bool code = false;
569  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ForceSwapImpl(" + typename.EnumToString(InventoryMode, mode) + ") item1=" + Object.GetDebugName(item1) + " item2=" + item2.GetDebugName(this));
570  code = GetHumanInventory().ForceSwapEntities(mode, item1, item2, item2_dst);
571 
572  UpdateInventoryMenu();
573  if (!code)
574  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ForceSwapEntitiesImpl - cannot Forceswap");
575  return code;
576  }
578 
580  bool JunctureTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
581  {
582  return TakeEntityToTargetInventoryImpl(InventoryMode.JUNCTURE, target, flags, item);
583  }
584 
585  override bool PredictiveTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
586  {
587  if (!ScriptInputUserData.CanStoreInputUserData())
588  {
589  Print("[inv] " + GetSimulationTimeStamp() + " ::PredictiveTakeEntityToTargetInventory input data not sent yet, cannot allow another input action");
590  return false;
591  }
592 
593  if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), target))
594  return JunctureTakeEntityToTargetInventory(target, flags, item);
595  else
596  return TakeEntityToTargetInventoryImpl(InventoryMode.PREDICTIVE, target, flags, item);
597  }
598 
599  bool PredictiveTakeOrSwapAttachment( notnull EntityAI item )
600  {
601  if( GetInventory().CanAddAttachment( item ) )
602  {
603  return PredictiveTakeEntityAsAttachment( item );
604  }
605  else
606  {
607  for( int i = 0; i < item.GetInventory().GetSlotIdCount(); i++ )
608  {
609  int slot_id = item.GetInventory().GetSlotId(i);
610  EntityAI slot_item = GetInventory().FindAttachment( slot_id );
611  if( slot_item && GetInventory().CanSwapEntitiesEx( item, slot_item ) )
612  {
613  return PredictiveSwapEntities(item, slot_item);
614  }
615  }
616  }
617  return false;
618  }
619 
620  override bool LocalTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
621  {
622  return TakeEntityToTargetInventoryImpl(InventoryMode.LOCAL, target, flags, item);
623  }
624 
625  protected bool TakeEntityToTargetInventoryImpl (InventoryMode mode, notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
626  {
627  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::Take2TargetInv(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
628  bool code = GetInventory().TakeEntityToTargetInventory(mode, target, flags, item);
629  UpdateInventoryMenu();
630  return code;
631  }
633 
635  bool JunctureTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
636  {
637  return TakeEntityToTargetCargoExImpl(InventoryMode.JUNCTURE, cargo, item, row, col);
638  }
639 
640  override bool PredictiveTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
641  {
642  if (!ScriptInputUserData.CanStoreInputUserData())
643  {
644  Print("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::PredictiveTakeEntityToTargetCargoEx input data not sent yet, cannot allow another input action");
645  return false;
646  }
647 
648  if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), cargo.GetCargoOwner()))
649  return JunctureTakeEntityToTargetCargoEx(cargo, item, row, col);
650  else
651  return TakeEntityToTargetCargoExImpl(InventoryMode.PREDICTIVE, cargo, item, row, col);
652  }
653 
654  override bool LocalTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
655  {
656  return TakeEntityToTargetCargoExImpl(InventoryMode.LOCAL, cargo, item, row, col);
657  }
658 
659  override bool ServerTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
660  {
661  return TakeEntityToTargetCargoExImpl(InventoryMode.SERVER, cargo, item, row, col);
662  }
663 
664  protected bool TakeEntityToTargetCargoExImpl (InventoryMode mode, notnull CargoBase cargo, notnull EntityAI item, int row, int col)
665  {
666  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::Take2TargetCgoEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
667  bool code = GetInventory().TakeEntityToTargetCargoEx(mode, cargo, item, row, col);
668  UpdateInventoryMenu();
669  return code;
670  }
672 
674  bool JunctureTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
675  {
676  return TakeEntityToTargetCargoImpl(InventoryMode.JUNCTURE, target, item);
677  }
678 
679  override bool PredictiveTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
680  {
681  if (!ScriptInputUserData.CanStoreInputUserData())
682  {
683  Print("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::PredictiveTakeEntityToTargetCargo input data not sent yet, cannot allow another input action");
684  return false;
685  }
686 
687  if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), target))
688  return JunctureTakeEntityToTargetCargo(target, item);
689  else
690  return TakeEntityToTargetCargoImpl(InventoryMode.PREDICTIVE, target, item);
691  }
692 
693  override bool LocalTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
694  {
695  return TakeEntityToTargetCargoImpl(InventoryMode.LOCAL, target, item);
696  }
697 
698  override bool ServerTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
699  {
700  if (IsAlive())
701  return TakeEntityToTargetCargoImpl(InventoryMode.SERVER, target, item);
702  else
703  return TakeEntityToTargetCargoImpl(InventoryMode.SERVER, target, item);
704  }
705 
706  protected bool TakeEntityToTargetCargoImpl (InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
707  {
708  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " Take2TargetCgo(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
709 
710  bool code = GetInventory().TakeEntityToTargetInventory(mode, target, FindInventoryLocationType.CARGO, item);
711  UpdateInventoryMenu();
712  return code;
713  }
715 
717  bool JunctureTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
718  {
719  return TakeEntityToTargetAttachmentExImpl(InventoryMode.JUNCTURE, target, item, slot);
720  }
721 
722  override bool PredictiveTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
723  {
724  if (!ScriptInputUserData.CanStoreInputUserData())
725  {
726  Print("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::PredictiveTakeEntityToTargetAttachmentEx input data not sent yet, cannot allow another input action");
727  return false;
728  }
729 
730  if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), target))
731  return JunctureTakeEntityToTargetAttachmentEx(target, item, slot);
732  else
733  return TakeEntityToTargetAttachmentExImpl(InventoryMode.PREDICTIVE, target, item, slot);
734  }
735 
736  override bool LocalTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
737  {
738  return TakeEntityToTargetAttachmentExImpl(InventoryMode.LOCAL, target, item, slot);
739  }
740 
741  override bool ServerTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
742  {
743  return TakeEntityToTargetAttachmentExImpl(InventoryMode.SERVER, target, item, slot);
744  }
745 
746  protected bool TakeEntityToTargetAttachmentExImpl (InventoryMode mode, notnull EntityAI target, notnull EntityAI item, int slot)
747  {
748  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::Take2TargetAtt(" + typename.EnumToString(InventoryMode, mode) + ") item=" + Object.GetDebugName(item));
749  bool code = GetInventory().TakeEntityAsTargetAttachmentEx(mode, target, item, slot);
750  UpdateInventoryMenu();
751  return code;
752  }
754 
756  bool JunctureTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
757  {
758  return TakeEntityToTargetAttachmentImpl(InventoryMode.JUNCTURE, target, item);
759  }
760 
761  override bool PredictiveTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
762  {
763  if (!ScriptInputUserData.CanStoreInputUserData())
764  {
765  Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveTakeEntityToTargetAttachment input data not sent yet, cannot allow another input action");
766  return false;
767  }
768 
769  if (NeedInventoryJunctureFromServer(item, item.GetHierarchyParent(), target))
770  return JunctureTakeEntityToTargetAttachment(target, item);
771  else
772  return TakeEntityToTargetAttachmentImpl(InventoryMode.PREDICTIVE, target, item);
773  }
774 
775  override bool LocalTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
776  {
777  return TakeEntityToTargetAttachmentImpl(InventoryMode.LOCAL, target, item);
778  }
779 
780  override bool ServerTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
781  {
782  return TakeEntityToTargetAttachmentImpl(InventoryMode.SERVER, target, item);
783  }
784 
785  protected bool TakeEntityToTargetAttachmentImpl (InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
786  {
788  if( target.GetInventory().FindFreeLocationFor( item, FindInventoryLocationType.ATTACHMENT, il) )
789  {
790  return TakeEntityToTargetAttachmentExImpl(mode, target, item, il.GetSlot());
791  }
792  return false;
793  }
795 
797  bool JunctureTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst)
798  {
799  return TakeToDstImpl(InventoryMode.JUNCTURE, src, dst);
800  }
801 
802  override bool PredictiveTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst)
803  {
804  if (!ScriptInputUserData.CanStoreInputUserData())
805  {
806  Print("[inv] " + GetSimulationTimeStamp() + " Man@" + this + " ::PredictiveTakeToDst input data not sent yet, cannot allow another input action");
807  return false;
808  }
809 
810  if (NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
811  return JunctureTakeToDst(src, dst);
812  else
813  return TakeToDstImpl(InventoryMode.PREDICTIVE, src, dst);
814  }
815 
816  override bool LocalTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst)
817  {
818  return TakeToDstImpl(InventoryMode.LOCAL, src, dst);
819  }
820 
821  override bool ServerTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst)
822  {
823  return TakeToDstImpl(InventoryMode.SERVER, src, dst);
824  }
825 
826  protected bool TakeToDstImpl (InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
827  {
828  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[inv] " + GetDebugName(this) + " STS = " + GetSimulationTimeStamp() + " ::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + ") src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
829  bool code = GetHumanInventory().TakeToDst(mode, src, dst);
830  UpdateInventoryMenu();
831  return code;
832  }
835 
836  void JunctureDeleteItem(EntityAI item)
837  {
838 
839  }
840 
841  override bool CanBeSkinned()
842  {
843  return true;
844  }
845 
846  void UpdateInventoryMenu();
847 
850 
853  proto native bool StatRegister( string name );
855 
858  proto native float StatGet( string name );
860 
864  proto void StatGetCounter( string name, out string value );
866 
870  proto void StatGetAsTime( string name, out string value );
872 
876  proto native void StatUpdate( string name, float value );
878 
882  proto native void StatUpdateByTime( string name );
884 
888  proto native void StatUpdateByPosition( string name );
890 
894  proto native void StatUpdateByGivenPos( string name, vector pos );
898  proto native void StatInvokeUpdate();
902  proto native void StatSyncToClient();
904 
905  bool IsInventorySoftLocked()
906  {
907  return false;
908  }
909 
910  void SetInventorySoftLock(bool status);
911 
913  bool IsInTransport()
914  {
915  return Transport.Cast(GetParent()) != null;
916  }
917 
918  void StopDeathDarkeningEffect();
919  bool PhysicalPredictiveDropItem(EntityAI entity, bool heavy_item_only = true);
920  void SetProcessUIWarning(bool state);
921  void OnGameplayDataHandlerSync(); //depricated, sync now happens before the player is created, calling of this event still happens for legacy reasons
922  bool CanPlaceItem(EntityAI item);
923 };
GetGame
proto native CGame GetGame()
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
LogManager
Definition: debug.c:734
EntityFlags
EntityFlags
Entity flags.
Definition: enentity.c:114
ScriptInputUserData
Definition: gameplay.c:120
OnItemInHandsChanged
class HumanItemBehaviorCfg OnItemInHandsChanged(bool pInstant=false)
signalization from script to engine that item in hands changed
Print
proto void Print(void var)
Prints content of variable to console/log.
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
CanBeSkinned
override bool CanBeSkinned()
Definition: dayzanimal.c:60
PlayerIdentity
The class that will be instanced (moddable)
Definition: gameplay.c:377
vector
Definition: enconvert.c:105
InventoryMode
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition: inventory.c:21
CargoBase
represents base for cargo storage for entities
Definition: cargo.c:6
Object
Definition: objecttyped.c:1
Transport
Base native class for all motorized wheeled vehicles.
Definition: car.c:79
FindInventoryLocationType
FindInventoryLocationType
flags for searching locations in inventory
Definition: inventorylocation.c:15
EPlayerStates
EPlayerStates
Definition: eplayerstates.c:1
SetFlags
proto native void SetFlags(ShapeFlags flags)
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
GetDebugName
override string GetDebugName()
Definition: dayzplayer.c:1126
HumanInventory
inventory for plain man/human
Definition: humaninventory.c:9
GetParent
proto native Widget GetParent()
Get parent of the Effect.
Definition: effect.c:405
syncDebugPrint
void syncDebugPrint(string s)
Definition: debug.c:1
ReplaceItemWithNewLambdaBase
base class for transformation operations (creating one item from another)
Definition: replaceitemwithnewlambdabase.c:4
TakeToDst
override bool TakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
Definition: dayzplayerinventory.c:1600
UAInterface
Definition: uainput.c:95
EntityAI
Definition: building.c:5
HasFixedActionTargetCursorPosition
override bool HasFixedActionTargetCursorPosition()
Definition: dayzanimal.c:115
GameInventory
script counterpart to engine's class Inventory
Definition: inventory.c:78
ScriptInvoker
ScriptInvoker Class provide list of callbacks usage:
Definition: tools.c:115