Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
entityai.c
Go to the documentation of this file.
2 {
3  DRY,
4  DAMP,
5  WET,
8 }
9 
10 enum SurfaceAnimationBone
11 {
12  LeftFrontLimb = 0,
15  RightBackLimb
16 }
17 
18 enum PlantType
19 {
20  TREE_HARD = 1000,
21  TREE_SOFT = 1001,
22  BUSH_HARD = 1002,
23  BUSH_SOFT = 1003,
24 }
25 
26 enum WeightUpdateType
27 {
28  FULL = 0,
29  ADD,
30  REMOVE,
32  RECURSIVE_REMOVE
33 }
34 
35 enum EItemManipulationContext
36 {
37  UPDATE, //generic operation
38  ATTACHING,
39  DETACHING,
40 }
41 
43 enum EInventoryIconVisibility
44 {
45  ALWAYS = 0,
46  HIDE_VICINITY = 1,
47  //further values yet unused, but nice to have anyway
49  HIDE_HANDS_SLOT = 4
50 }
51 
53 enum EAttExclusions
54 {
55  OCCUPANCY_INVALID = -1,
56  //Legacy relations
57  LEGACY_EYEWEAR_HEADGEAR,
58  LEGACY_EYEWEAR_MASK,
59  LEGACY_HEADSTRAP_HEADGEAR,
60  LEGACY_HEADSTRAP_MASK,
61  LEGACY_HEADGEAR_MASK,
62  LEGACY_HEADGEAR_EYEWEWEAR,
63  LEGACY_HEADGEAR_HEADSTRAP,
64  LEGACY_MASK_HEADGEAR,
65  LEGACY_MASK_EYEWEWEAR,
66  LEGACY_MASK_HEADSTRAP,
67  //
68  EXCLUSION_HEADGEAR_HELMET_0, //full helmet
69  //EXCLUSION_HEADGEAR_HELMET_0_A, //example of another 'vector' of potential conflict, like between helmet and eyewear..otherwise the other non-helmet entities would collide through the 'EXCLUSION_HEADSTRAP_0' value.
70  EXCLUSION_HEADSTRAP_0,
71  EXCLUSION_MASK_0,
72  EXCLUSION_MASK_1,
73  EXCLUSION_MASK_2, //Mostly Gasmasks
74  EXCLUSION_MASK_3, //bandana mask special behavior
75  EXCLUSION_GLASSES_REGULAR_0,
76  EXCLUSION_GLASSES_TIGHT_0,
77  //values to solve the edge-cases with shaving action
78  SHAVING_MASK_ATT_0,
79  SHAVING_HEADGEAR_ATT_0,
80  SHAVING_EYEWEAR_ATT_0,
81 }
82 
83 class DebugSpawnParams
84 {
85  Man m_Player;
86 
87  static DebugSpawnParams WithPlayer(Man player)
88  {
89  DebugSpawnParams params = new DebugSpawnParams();
90  params.m_Player = player;
91  return params;
92  }
93 };
94 
95 class TSelectableActionInfoArrayEx extends array<ref Param> {}
97 typedef Param4<int, int, string, int> TSelectableActionInfoWithColor;
98 
99 class EntityAI extends Entity
100 {
101  bool m_DeathSyncSent;
102  bool m_KilledByHeadshot;
103  bool m_PreparedToDelete = false;
104  bool m_RefresherViable = false;
105  bool m_WeightDirty = 1;
106  private ref map<int,ref set<int>> m_AttachmentExclusionSlotMap; //own masks for different slots <slot,mask>. Kept on instance to better respond to various state changes
107  private ref set<int> m_AttachmentExclusionMaskGlobal; //additional mask values and simple item values. Independent of slot-specific behavior!
108  private ref set<int> m_AttachmentExclusionMaskChildren; //additional mask values and simple item values
109 
110  ref DestructionEffectBase m_DestructionBehaviourObj;
111 
112  ref KillerData m_KillerData;
113  private ref HiddenSelectionsData m_HiddenSelectionsData;
114 
115  const int DEAD_REPLACE_DELAY = 2000;
116  const int DELETE_CHECK_DELAY = 100;
117 
118  ref array<EntityAI> m_AttachmentsWithCargo;
119  ref array<EntityAI> m_AttachmentsWithAttachments;
120  ref InventoryLocation m_OldLocation;
121 
122  protected ref DamageZoneMap m_DamageZoneMap;
123  private ref map<int, string> m_DamageDisplayNameMap = new map<int, string>; //values are localization keys as strings, use 'Widget.TranslateString' method to get the localized one
124 
125  float m_Weight;
126  float m_WeightEx;
127  float m_ConfigWeight = ConfigGetInt("weight");
128  protected bool m_CanDisplayWeight;
129  private float m_LastUpdatedTime;
130  protected float m_ElapsedSinceLastUpdate;
131 
132  protected UTemperatureSource m_UniversalTemperatureSource;
133 
134  bool m_PendingDelete = false;
135  bool m_Initialized = false;
136  bool m_TransportHitRegistered = false;
137  vector m_TransportHitVelocity;
138 
139  //Called on item attached to this item (EntityAI item, string slot, EntityAI parent)
140  protected ref ScriptInvoker m_OnItemAttached;
141  //Called on item detached from this item (EntityAI item, string slot, EntityAI parent)
142  protected ref ScriptInvoker m_OnItemDetached;
143  //Called when an item is added to the cargo of this item (EntityAI item, EntityAI parent)
144  protected ref ScriptInvoker m_OnItemAddedIntoCargo;
145  //Called when an item is removed from the cargo of this item (EntityAI item, EntityAI parent)
146  protected ref ScriptInvoker m_OnItemRemovedFromCargo;
147  //Called when an item is moved around in the cargo of this item (EntityAI item, EntityAI parent)
148  protected ref ScriptInvoker m_OnItemMovedInCargo;
149  //Called when an item is flipped around in cargo (bool flip)
150  protected ref ScriptInvoker m_OnItemFlipped;
151  //Called when an items view index is changed
152  protected ref ScriptInvoker m_OnViewIndexChanged;
153  //Called when an location in this item is reserved (EntityAI item) - cargo
154  protected ref ScriptInvoker m_OnSetLock;
155  //Called when this item is unreserved (EntityAI item) - cargo
156  protected ref ScriptInvoker m_OnReleaseLock;
157  //Called when an location in this item is reserved (EntityAI item) - attachment
158  protected ref ScriptInvoker m_OnAttachmentSetLock;
159  //Called when this item is unreserved (EntityAI item) - attachment
160  protected ref ScriptInvoker m_OnAttachmentReleaseLock;
161  //Called when this entity is hit
162  protected ref ScriptInvoker m_OnHitByInvoker;
163  //Called when this entity is killed
164  protected ref ScriptInvoker m_OnKilledInvoker;
165 
166  void EntityAI()
167  {
168  // Set up the Energy Manager
169  string type = GetType();
170  string param_access_energy_sys = "CfgVehicles " + type + " EnergyManager ";
171  bool is_electic_device = GetGame().ConfigIsExisting(param_access_energy_sys);
172 
173  if (is_electic_device) // TO DO: Check if this instance is a hologram (advanced placement). If Yes, then do not create Energy Manager component.
174  {
175  CreateComponent(COMP_TYPE_ENERGY_MANAGER);
176  RegisterNetSyncVariableBool("m_EM.m_IsSwichedOn");
177  RegisterNetSyncVariableBool("m_EM.m_CanWork");
178  RegisterNetSyncVariableBool("m_EM.m_IsPlugged");
179  RegisterNetSyncVariableInt("m_EM.m_EnergySourceNetworkIDLow");
180  RegisterNetSyncVariableInt("m_EM.m_EnergySourceNetworkIDHigh");
181  RegisterNetSyncVariableFloat("m_EM.m_Energy");
182  }
183 
184  // Item preview index
185  RegisterNetSyncVariableInt( "m_ViewIndex", 0, 99 );
186  // Refresher signalization
187  RegisterNetSyncVariableBool("m_RefresherViable");
188 
189  m_AttachmentsWithCargo = new array<EntityAI>();
190  m_AttachmentsWithAttachments = new array<EntityAI>();
191  m_LastUpdatedTime = 0.0;
192  m_ElapsedSinceLastUpdate = 0.0;
193 
194  m_CanDisplayWeight = ConfigGetBool("displayWeight");
195 
196  InitDamageZoneMapping();
197  InitDamageZoneDisplayNameMapping();
198 
199  m_HiddenSelectionsData = new HiddenSelectionsData( GetType() );
200 
201  GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(DeferredInit,34);
202  }
203 
204  void ~EntityAI()
205  {
206 
207  }
208 
209  void DeferredInit()
210  {
211  m_Initialized = true;
212  }
213 
214  bool IsInitialized()
215  {
216  return m_Initialized;
217  }
218 
220  int GetHideIconMask()
221  {
222  return EInventoryIconVisibility.ALWAYS;
223  }
224 
225  private ref ComponentsBank m_ComponentsBank;
226  ComponentEnergyManager m_EM; // This reference is necesarry due to synchronization, since it's impossible to synchronize values from a component :(
227 
229  Component CreateComponent(int comp_type, string extended_class_name="")
230  {
231  return GetComponent(comp_type, extended_class_name);
232  }
233 
235  Component GetComponent(int comp_type, string extended_class_name="")
236  {
237  if ( m_ComponentsBank == NULL )
238  m_ComponentsBank = new ComponentsBank(this);
239 
240  return m_ComponentsBank.GetComponent(comp_type, extended_class_name);
241  }
242 
244  bool DeleteComponent(int comp_type)
245  {
246  return m_ComponentsBank.DeleteComponent(comp_type);
247  }
248 
249  string GetDestructionBehaviour()
250  {
251  return "";
252  }
253 
255  {
256  return false;
257  }
258 
260  bool HasComponent(int comp_type)
261  {
262  if ( m_ComponentsBank )
263  return m_ComponentsBank.IsComponentAlreadyExist(comp_type);
264 
265  return false;
266  }
267 
269  void MaxLifetimeRefreshCalc()
270  {
271  if ( (!GetGame().IsMultiplayer() || GetGame().IsServer()) && GetEconomyProfile() )
272  {
273  float lifetime = GetEconomyProfile().GetLifetime();
274  int frequency = GetCEApi().GetCEGlobalInt("FlagRefreshFrequency");
275  if ( frequency <= 0 )
276  {
277  frequency = GameConstants.REFRESHER_FREQUENCY_DEFAULT;
278  }
279 
280  if ( frequency <= lifetime )
281  {
282  m_RefresherViable = true;
283  SetSynchDirty();
284  }
285  }
286  }
287 
289  {
290  if (IsRuined())
291  {
292  return false;
293  }
294  return m_RefresherViable;
295  }
296 
297  #ifdef DEVELOPER
298  override void SetDebugItem()
299  {
300  super.SetDebugItem();
301  _item = this;
302  }
303  #endif
304 
305 
307  void InitDamageZoneMapping()
308  {
309  m_DamageZoneMap = new DamageZoneMap;
310  DamageSystem.GetDamageZoneMap(this,m_DamageZoneMap);
311  }
312 
314  void InitDamageZoneDisplayNameMapping()
315  {
316  string path_base;
317  string path;
318  string component_name;
319 
320  if ( IsWeapon() )
321  {
322  path_base = CFG_WEAPONSPATH;
323  }
324  else if ( IsMagazine() )
325  {
326  path_base = CFG_MAGAZINESPATH;
327  }
328  else
329  {
330  path_base = CFG_VEHICLESPATH;
331  }
332 
333  path_base = string.Format( "%1 %2 DamageSystem DamageZones", path_base, GetType() );
334 
335  if ( !GetGame().ConfigIsExisting(path_base) )
336  {
337  component_name = GetDisplayName();
338  GetGame().FormatRawConfigStringKeys(component_name);
339  m_DamageDisplayNameMap.Insert( "".Hash(), component_name );
340  }
341  else
342  {
343  TStringArray zone_names = new TStringArray;
344  GetDamageZones( zone_names );
345 
346  for ( int i = 0; i < zone_names.Count(); i++ )
347  {
348  path = string.Format( "%1 %2 displayName", path_base, zone_names[i] );
349 
350  if (GetGame().ConfigIsExisting(path) && GetGame().ConfigGetTextRaw(path,component_name))
351  {
352  GetGame().FormatRawConfigStringKeys(component_name);
353  m_DamageDisplayNameMap.Insert( zone_names[i].Hash(), component_name );
354  }
355  }
356  }
357  }
358 
359  protected float ConvertNonlethalDamage(float damage, DamageType damageType)
360  {
361  return 0.0;
362  }
363 
365  float ConvertNonlethalDamage(float damage)
366  {
367  return 0.0;
368  }
369 
370  DamageZoneMap GetEntityDamageZoneMap()
371  {
372  return m_DamageZoneMap;
373  }
374 
375  map<int, string> GetEntityDamageDisplayNameMap()
376  {
377  return m_DamageDisplayNameMap;
378  }
379 
381  bool CanDisplayWeight()
382  {
383  return m_CanDisplayWeight;
384  }
385 
387  void Log(string msg, string fnc_name = "n/a")
388  {
389  Debug.Log(msg, "Object", "n/a", fnc_name, this.GetType());
390  }
391 
393  void LogWarning(string msg, string fnc_name = "n/a")
394  {
395  Debug.LogWarning(msg, "Object", "n/a", fnc_name, this.GetType());
396  }
397 
399  void LogError(string msg, string fnc_name = "n/a")
400  {
401  Debug.LogError(msg, "Object", "n/a", fnc_name, this.GetType());
402  }
403 
405  bool IsSkinned()
406  {
407  return GetCompBS() && GetCompBS().IsSkinned();
408  }
409 
410  void SetAsSkinned()
411  {
412  if (GetCompBS())
413  GetCompBS().SetAsSkinned();
414  }
415 
416  bool CanBeSkinnedWith(EntityAI tool)
417  {
418  if ( !IsSkinned() && tool )
419  if ( !IsAlive() )
420  return true;
421  return false;
422  }
424 
425  // ITEM TO ITEM FIRE DISTRIBUTION
427  bool HasFlammableMaterial()
428  {
429  return false;
430  }
431 
433  bool CanBeIgnitedBy(EntityAI igniter = NULL)
434  {
435  return false;
436  }
437 
439  bool CanIgniteItem(EntityAI ignite_target = NULL)
440  {
441  return false;
442  }
443 
445  bool IsIgnited()
446  {
447  if (m_EM)
448  return m_EM.IsWorking();
449  return false;
450  }
451 
452  // Change return value to true if last detached item cause disassemble of item - different handlig some inventory operations
454  {
455  return false;
456  }
457 
458  bool IsBasebuildingKit()
459  {
460  return false;
461  }
462 
464  bool PlacementCanBeRotated()
465  {
466  return true;
467  }
468 
470  void OnIgnitedTarget( EntityAI target_item)
471  {
472 
473  }
474 
476  void OnIgnitedThis( EntityAI fire_source)
477  {
478 
479  }
480 
482  void OnIgnitedTargetFailed( EntityAI target_item)
483  {
484 
485  }
486 
488  void OnIgnitedThisFailed( EntityAI fire_source)
489  {
490 
491  }
492 
494  bool IsTargetIgnitionSuccessful(EntityAI item_target)
495  {
496  return true;
497  }
498 
500  bool IsThisIgnitionSuccessful(EntityAI item_source = NULL)
501  {
502  return true;
503  }
504  // End of fire distribution ^
505 
506  // ADVANCED PLACEMENT EVENTS
507  void OnPlacementStarted(Man player);
508  void OnHologramBeingPlaced(Man player);
509  void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0");
510  void OnPlacementCancelled(Man player);
511 
512  bool CanBePlaced(Man player, vector position)
513  {
514  return true;
515  }
516 
518  string CanBePlacedFailMessage( Man player, vector position )
519  {
520  return "";
521  }
522 
524  bool DoPlacingHeightCheck()
525  {
526  return false;
527  }
528 
530  float HeightCheckOverride()
531  {
532  return 0.0;
533  }
534 
536  float HeightStartCheckOverride()
537  {
538  return 0.0;
539  }
540 
542  bool IsEmpty()
543  {
544  return (!HasAnyCargo() && GetInventory().AttachmentCount() == 0);
545  }
546 
547  bool CanBeSplit()
548  {
549  return false;
550  }
551 
553  bool HasAnyCargo()
554  {
555  CargoBase cargo = GetInventory().GetCargo();
556 
557  if(!cargo) return false;//this is not a cargo container
558 
559  if( cargo.GetItemCount() > 0 )
560  {
561  return true;
562  }
563  else
564  {
565  return false;
566  }
567  }
568 
569  array<EntityAI> GetAttachmentsWithCargo()
570  {
571  return m_AttachmentsWithCargo;
572  }
573 
574  array<EntityAI> GetAttachmentsWithAttachments()
575  {
576  return m_AttachmentsWithAttachments;
577  }
578 
579  int GetAgents() { return 0; }
580  void RemoveAgent(int agent_id);
581  void RemoveAllAgents();
582  void RemoveAllAgentsExcept(int agent_to_keep);
583  void InsertAgent(int agent, float count = 1);
584 
585  override bool IsEntityAI() { return true; }
586 
587  bool IsInventoryVisible()
588  {
589  return !( GetParent() || GetHierarchyParent() );
590  }
591 
592  bool IsPlayer()
593  {
594  return false;
595  }
596 
597  bool IsAnimal()
598  {
599  return false;
600  }
601 
602  bool IsZombie()
603  {
604  return false;
605  }
606 
607  bool IsZombieMilitary()
608  {
609  return false;
610  }
611 
612  bool IsIgnoredByConstruction()
613  {
614  return IsDamageDestroyed();
615  }
616 
617  bool CanBeTargetedByAI(EntityAI ai)
618  {
619  if (ai && ai.IsBeingBackstabbed())
620  {
621  return false;
622  }
623 
624  if ( !dBodyIsActive( this ) && !IsMan() )
625  return false;
626  return !IsDamageDestroyed();
627  }
628 
629  bool CanBeBackstabbed()
630  {
631  return false;
632  }
633 
642  override void Delete()
643  {
644  m_PendingDelete = true;
645  super.Delete();
646  }
647 
648  void DeleteOnClient()
649  {
650  GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(GetGame().ObjectDeleteOnClient, this);
651  }
652 
653  // delete synchronized between server and client
654  void DeleteSafe()
655  {
656  if (GetHierarchyRootPlayer() == null)
657  {
658  Delete();
659  }
660  else
661  {
662  if (GetGame().IsServer() && GetGame().IsMultiplayer())
663  GetHierarchyRootPlayer().JunctureDeleteItem(this);
664  else
665  GetHierarchyRootPlayer().AddItemToDelete(this);
666  }
667  }
668 
669  //legacy, wrong name, use 'DeleteSafe()' instead
670  void DeleteSave()
671  {
672  DeleteSafe();
673  }
674 
675  bool IsSetForDeletion()
676  {
677  return IsPreparedToDelete() || m_PendingDelete || ToDelete() || IsPendingDeletion();
678  }
679 
680  override bool CanBeActionTarget()
681  {
682  if (super.CanBeActionTarget())
683  {
684  return !IsSetForDeletion();
685  }
686  else
687  {
688  return false;
689  }
690  }
691 
692  void SetPrepareToDelete()
693  {
694  m_PreparedToDelete = true;
695  }
696 
697  bool IsPreparedToDelete()
698  {
699  return m_PreparedToDelete;
700  }
701 
702 
703  void CheckForDestroy()
704  {
705  if (IsPrepareToDelete())
706  {
707  GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(TryDelete, DELETE_CHECK_DELAY, false);
708  }
709  }
710 
711  bool IsPrepareToDelete()
712  {
713  return false;
714  }
715 
716  bool TryDelete()
717  {
718  if (!IsPrepareToDelete())
719  {
720  Debug.Log("TryDelete - not ready for deletion");
721  return false;
722  }
723 
724  if (GetGame().HasInventoryJunctureItem(this))
725  {
726  Debug.Log("TryDelete - deferred call");
727  GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(TryDelete, DELETE_CHECK_DELAY, false);
728  return false;
729  }
730 
731  OnBeforeTryDelete();
732  Debug.Log("TryDelete - OnBeforeTryDelete end");
733  DeleteSafe();
734  Debug.Log("TryDelete - DeleteSafe end");
735 
736  return true;
737  }
738 
739  void OnBeforeTryDelete();
740 
742  proto native EntityAI GetHierarchyRoot();
743 
745  proto native Man GetHierarchyRootPlayer();
746 
748  proto native EntityAI GetHierarchyParent();
749 
751  proto native CEItemProfile GetEconomyProfile();
752 
753  // !returns the number of levels bellow the hierarchy root this entity is at
754  int GetHierarchyLevel(int lvl = 0)
755  {
756  if (!GetHierarchyParent())
757  return lvl;
758 
759  return GetHierarchyParent().GetHierarchyLevel(lvl+1);
760  }
761 
762  void OnInventoryInit()
763  {
764  InitAttachmentExclusionValues();
765  }
766 
768  void EEInit()
769  {
770  if (GetInventory())
771  {
772  GetInventory().EEInit();
773  m_AttachmentsWithCargo.Clear();
774  m_AttachmentsWithAttachments.Clear();
775  for ( int i = 0; i < GetInventory().AttachmentCount(); i++ )
776  {
777  EntityAI attachment = GetInventory().GetAttachmentFromIndex( i );
778  if ( attachment )
779  {
780  if ( attachment.GetInventory().GetCargo() )
781  {
782  m_AttachmentsWithCargo.Insert( attachment );
783  }
784 
785  if ( attachment.GetInventory().GetAttachmentSlotsCount() > 0 )
786  {
787  m_AttachmentsWithAttachments.Insert( attachment );
788  }
789  }
790  }
791  }
792 
793  MaxLifetimeRefreshCalc();
794  }
795 
797  void EEDelete(EntityAI parent)
798  {
799  m_PendingDelete = true;
800  GetInventory().EEDelete(parent);
801 
802  if (m_EM)
803  m_EM.OnDeviceDestroyed();
804  }
805 
806  override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
807  {
808  super.OnExplosionEffects(source, directHit, componentIndex, surface, pos, surfNormal, energyFactor, explosionFactor, isWater, ammoType);
809  #ifndef SERVER
810  g_Game.GetWorld().AddEnvShootingSource(pos, 1.0);
811  #endif
812  if (m_DestructionBehaviourObj && m_DestructionBehaviourObj.HasExplosionDamage())
813  {
814  m_DestructionBehaviourObj.OnExplosionEffects(source, directHit, componentIndex, surface, pos, surfNormal, energyFactor, explosionFactor, isWater, ammoType);
815  }
816  }
817 
818 
819  void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner) { }
820 
821  void OnItemAttachmentSlotChanged (notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc) {}
822 
823  void EEItemLocationChanged (notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
824  {
825  EntityAI old_owner = oldLoc.GetParent();
826  EntityAI new_owner = newLoc.GetParent();
827  OnItemLocationChanged(old_owner, new_owner);
828 
829  if (oldLoc.GetType() == InventoryLocationType.ATTACHMENT && newLoc.GetType() == InventoryLocationType.ATTACHMENT)
830  {
831  OnItemAttachmentSlotChanged(oldLoc,newLoc);
832  }
833 
834  if (oldLoc.GetType() == InventoryLocationType.ATTACHMENT)
835  {
836  if (old_owner)
837  OnWasDetached(old_owner, oldLoc.GetSlot());
838  else
839  Error("EntityAI::EEItemLocationChanged - detached, but old_owner is null");
840  }
841 
842  if (newLoc.GetType() == InventoryLocationType.ATTACHMENT)
843  {
844  if (new_owner)
845  OnWasAttached(newLoc.GetParent(), newLoc.GetSlot());
846  else
847  Error("EntityAI::EEItemLocationChanged - attached, but new_owner is null");
848  }
849  }
850 
852  void EEParentedTo(EntityAI parent)
853  {
854  }
855 
857  void EEParentedFrom(EntityAI parent)
858  {
859  }
860 
861  void EEInventoryIn (Man newParentMan, EntityAI diz, EntityAI newParent)
862  {
863  }
864  void EEInventoryOut (Man oldParentMan, EntityAI diz, EntityAI newParent)
865  {
866  m_LastUpdatedTime = 0.0;
867 
868  if (GetInventory() && newParent == null)
869  {
870  GetInventory().ResetFlipCargo();
871  }
872  }
873 
874  void EEAmmoChanged()
875  {
876  SetWeightDirty();
877  }
878 
879  void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
880  {
881  // Notify potential parent that this item was ruined
882  EntityAI parent = GetHierarchyParent();
883 
884  if (newLevel == GameConstants.STATE_RUINED)
885  {
886  if (parent)
887  {
888  parent.OnAttachmentRuined(this);
889  }
890  if (!zone)
891  {
892  OnDamageDestroyed(oldLevel);
893  }
894  AttemptDestructionBehaviour(oldLevel,newLevel, zone);
895  }
896  }
897 
899  void OnDamageDestroyed(int oldLevel);
900 
901  void AttemptDestructionBehaviour(int oldLevel, int newLevel, string zone)
902  {
904  {
905  typename destType = GetDestructionBehaviour().ToType();
906 
907  if (destType)
908  {
909  if (!m_DestructionBehaviourObj)
910  {
911  m_DestructionBehaviourObj = DestructionEffectBase.Cast(destType.Spawn());
912  }
913 
914  if (m_DestructionBehaviourObj)
915  {
916  m_DestructionBehaviourObj.OnHealthLevelChanged(this, oldLevel, newLevel, zone);
917  }
918  }
919  else
920  {
921  ErrorEx("Incorrect destruction behaviour type, make sure the class returned in 'GetDestructionBehaviour()' is a valid type inheriting from 'DestructionEffectBase'");
922  }
923  }
924  }
925 
926 
927  void SetTakeable(bool pState);
928 
930  void EEKilled(Object killer)
931  {
932  if (m_OnKilledInvoker)
933  m_OnKilledInvoker.Invoke(this, killer);
934  //analytics
935  GetGame().GetAnalyticsServer().OnEntityKilled( killer, this );
936 
937  if( ReplaceOnDeath() )
938  GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( DeathUpdate, DEAD_REPLACE_DELAY, false);
939  }
940 
941  bool ReplaceOnDeath()
942  {
943  return false;
944  }
945 
946  string GetDeadItemName()
947  {
948  return "";
949  }
950 
951  bool KeepHealthOnReplace()
952  {
953  return false;
954  }
955 
956  void DeathUpdate()
957  {
958  EntityAI dead_entity = EntityAI.Cast( GetGame().CreateObjectEx( GetDeadItemName(), GetPosition(), ECE_OBJECT_SWAP, RF_ORIGINAL ) );
959  dead_entity.SetOrientation(GetOrientation());
960  if ( KeepHealthOnReplace() )
961  dead_entity.SetHealth(GetHealth());
962  this.Delete();
963  }
964 
966  void OnAttachmentRuined(EntityAI attachment)
967  {
968  // ...
969  }
970 
971  void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
972  {
973  if (m_OnHitByInvoker)
974  m_OnHitByInvoker.Invoke(this, damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
975  #ifdef DEVELOPER
976  //Print("EEHitBy: " + this + "; damageResult:"+ damageResult.GetDamage("","") +"; damageType: "+ damageType +"; source: "+ source +"; component: "+ component +"; dmgZone: "+ dmgZone +"; ammo: "+ ammo +"; modelPos: "+ modelPos);
977  #endif
978  }
979 
980  // called only on the client who caused the hit
981  void EEHitByRemote(int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos)
982  {
983 
984  }
985 
986  // !Called on PARENT when a child is attached to it.
987  void EEItemAttached(EntityAI item, string slot_name)
988  {
989  int slotId = InventorySlots.GetSlotIdFromString(slot_name);
990  PropagateExclusionValueRecursive(item.GetAttachmentExclusionMaskAll(slotId),slotId); //Performed from parent to avoid event order issues on swap
991  SetWeightDirty();
992 
993  if ( m_ComponentsBank != NULL )
994  {
995  for ( int comp_key = 0; comp_key < COMP_TYPE_COUNT; ++comp_key )
996  {
997  if ( m_ComponentsBank.IsComponentAlreadyExist(comp_key) )
998  {
999  m_ComponentsBank.GetComponent(comp_key).Event_OnItemAttached(item, slot_name);
1000  }
1001  }
1002  }
1003 
1004  // Energy Manager
1005  if ( m_EM && item.GetCompEM())
1006  m_EM.OnAttachmentAdded(item);
1007 
1008  if ( item.GetInventory().GetCargo() )
1009  m_AttachmentsWithCargo.Insert( item );
1010 
1011  if ( item.GetInventory().GetAttachmentSlotsCount() > 0 )
1012  m_AttachmentsWithAttachments.Insert( item );
1013 
1014  if ( m_OnItemAttached )
1015  m_OnItemAttached.Invoke( item, slot_name, this );
1016  }
1017 
1018  void SwitchItemSelectionTexture(EntityAI item, string slot_name);
1019  void SwitchItemSelectionTextureEx(EItemManipulationContext context, Param par = null);
1020 
1021  // !Called on PARENT when a child is detached from it.
1022  void EEItemDetached(EntityAI item, string slot_name)
1023  {
1024  int slotId = InventorySlots.GetSlotIdFromString(slot_name);
1025  ClearExclusionValueRecursive(item.GetAttachmentExclusionMaskAll(slotId),slotId); //Performed from parent to avoid event order issues on swap
1026  SetWeightDirty();
1027 
1028  if ( m_ComponentsBank != NULL )
1029  {
1030  for ( int comp_key = 0; comp_key < COMP_TYPE_COUNT; ++comp_key )
1031  {
1032  if ( m_ComponentsBank.IsComponentAlreadyExist(comp_key) )
1033  {
1034  m_ComponentsBank.GetComponent(comp_key).Event_OnItemDetached(item, slot_name);
1035  }
1036  }
1037  }
1038 
1039  // Energy Manager
1040  if (m_EM && item.GetCompEM())
1041  m_EM.OnAttachmentRemoved(item);
1042 
1043  if ( m_AttachmentsWithCargo.Find( item ) > -1 )
1044  m_AttachmentsWithCargo.RemoveItem( item );
1045 
1046  if ( m_AttachmentsWithAttachments.Find( item ) > -1 )
1047  m_AttachmentsWithAttachments.RemoveItem( item );
1048 
1049 
1050  if ( m_OnItemDetached )
1051  m_OnItemDetached.Invoke( item, slot_name, this );
1052  }
1053 
1054  void EECargoIn(EntityAI item)
1055  {
1056  SetWeightDirty();
1057 
1058  if( m_OnItemAddedIntoCargo )
1059  m_OnItemAddedIntoCargo.Invoke( item, this );
1060 
1061  item.OnMovedInsideCargo(this);
1062  }
1063 
1064  void EECargoOut(EntityAI item)
1065  {
1066  SetWeightDirty();
1067 
1068  if( m_OnItemRemovedFromCargo )
1069  m_OnItemRemovedFromCargo.Invoke( item, this );
1070 
1071  item.OnRemovedFromCargo(this);
1072  }
1073 
1074  void EECargoMove(EntityAI item)
1075  {
1076  if( m_OnItemMovedInCargo )
1077  m_OnItemMovedInCargo.Invoke( item, this );
1078  item.OnMovedWithinCargo(this);
1079  }
1080 
1081  ScriptInvoker GetOnItemAttached()
1082  {
1083  if( !m_OnItemAttached )
1084  m_OnItemAttached = new ScriptInvoker;
1085  return m_OnItemAttached;
1086  }
1087 
1088  ScriptInvoker GetOnItemDetached()
1089  {
1090  if( !m_OnItemDetached )
1091  m_OnItemDetached = new ScriptInvoker;
1092  return m_OnItemDetached;
1093  }
1094 
1095  ScriptInvoker GetOnItemAddedIntoCargo()
1096  {
1097  if( !m_OnItemAddedIntoCargo )
1098  m_OnItemAddedIntoCargo = new ScriptInvoker;
1099  return m_OnItemAddedIntoCargo;
1100  }
1101 
1102  ScriptInvoker GetOnItemRemovedFromCargo()
1103  {
1104  if( !m_OnItemRemovedFromCargo )
1105  m_OnItemRemovedFromCargo = new ScriptInvoker;
1106  return m_OnItemRemovedFromCargo;
1107  }
1108 
1109  ScriptInvoker GetOnItemMovedInCargo()
1110  {
1111  if( !m_OnItemMovedInCargo )
1112  m_OnItemMovedInCargo = new ScriptInvoker;
1113  return m_OnItemMovedInCargo;
1114  }
1115 
1116  ScriptInvoker GetOnItemFlipped()
1117  {
1118  if( !m_OnItemFlipped )
1119  m_OnItemFlipped = new ScriptInvoker;
1120  return m_OnItemFlipped;
1121  }
1122 
1123  ScriptInvoker GetOnViewIndexChanged()
1124  {
1125  if( !m_OnViewIndexChanged )
1126  m_OnViewIndexChanged = new ScriptInvoker;
1127  return m_OnViewIndexChanged;
1128  }
1129 
1130  ScriptInvoker GetOnSetLock()
1131  {
1132  if( !m_OnSetLock )
1133  m_OnSetLock = new ScriptInvoker;
1134  return m_OnSetLock;
1135  }
1136 
1137  ScriptInvoker GetOnReleaseLock()
1138  {
1139  if( !m_OnReleaseLock )
1140  m_OnReleaseLock = new ScriptInvoker;
1141  return m_OnReleaseLock;
1142  }
1143 
1144  ScriptInvoker GetOnAttachmentSetLock()
1145  {
1146  if( !m_OnAttachmentSetLock )
1147  m_OnAttachmentSetLock = new ScriptInvoker;
1148  return m_OnAttachmentSetLock;
1149  }
1150 
1151  ScriptInvoker GetOnAttachmentReleaseLock()
1152  {
1153  if( !m_OnAttachmentReleaseLock )
1154  m_OnAttachmentReleaseLock = new ScriptInvoker;
1155  return m_OnAttachmentReleaseLock;
1156  }
1157 
1158  ScriptInvoker GetOnHitByInvoker()
1159  {
1160  if ( !m_OnHitByInvoker )
1161  m_OnHitByInvoker = new ScriptInvoker;
1162  return m_OnHitByInvoker;
1163  }
1164 
1165  ScriptInvoker GetOnKilledInvoker()
1166  {
1167  if ( !m_OnKilledInvoker )
1168  m_OnKilledInvoker = new ScriptInvoker;
1169  return m_OnKilledInvoker;
1170  }
1171 
1172 
1174  void OnMovedInsideCargo(EntityAI container)
1175  {
1176  if (m_EM)
1177  m_EM.HandleMoveInsideCargo(container);
1178  }
1179 
1181  void OnRemovedFromCargo(EntityAI container)
1182  {
1183 
1184  }
1185 
1187  void OnMovedWithinCargo(EntityAI container)
1188  {
1189 
1190  }
1191 
1193  void EEOnAfterLoad()
1194  {
1195  // ENERGY MANAGER
1196  // Restore connections between devices which were connected before server restart
1197  if ( m_EM && m_EM.GetRestorePlugState() )
1198  {
1199  int b1 = m_EM.GetEnergySourceStorageIDb1();
1200  int b2 = m_EM.GetEnergySourceStorageIDb2();
1201  int b3 = m_EM.GetEnergySourceStorageIDb3();
1202  int b4 = m_EM.GetEnergySourceStorageIDb4();
1203 
1204  // get pointer to EntityAI based on this ID
1205  EntityAI potential_energy_source = GetGame().GetEntityByPersitentID(b1, b2, b3, b4); // This function is available only in this event!
1206 
1207  // IMPORTANT!
1208  // Object IDs acquired here become INVALID when electric devices are transfered to another server while in plugged state (like Flashlight plugged into its attachment 9V battery)
1209  // To avoid issues, these items must be excluded from this system of restoring plug state so they don't unintentionally plug to incorrect devices through these invalid IDs.
1210  // Therefore their plug state is being restored withing the EEItemAttached() event while being excluded by the following 'if' conditions...
1211 
1212  bool is_attachment = false;
1213 
1214  if (potential_energy_source)
1215  is_attachment = GetInventory().HasAttachment(potential_energy_source);
1216 
1217  if ( !is_attachment && potential_energy_source )
1218  is_attachment = potential_energy_source.GetInventory().HasAttachment(this);
1219 
1220  if ( potential_energy_source && potential_energy_source.GetCompEM() /*&& potential_energy_source.HasEnergyManager()*/ && !is_attachment )
1221  m_EM.PlugThisInto(potential_energy_source); // restore connection
1222  }
1223  }
1224 
1226  void EEOnCECreate()
1227  {
1228  }
1229 
1231  void AfterStoreLoad()
1232  {
1233  }
1234 
1236  void OnBinLoadItemsDropped()
1237  {
1238  if (GetHierarchyRootPlayer())
1239  GetHierarchyRootPlayer().SetProcessUIWarning(true);
1240  }
1241 
1243  void HideAllSelections()
1244  {
1245  string cfg_path = "cfgVehicles " + GetType() + " AnimationSources";
1246 
1247  if ( GetGame().ConfigIsExisting(cfg_path) )
1248  {
1249  int selections = GetGame().ConfigGetChildrenCount(cfg_path);
1250 
1251  for (int i = 0; i < selections; i++)
1252  {
1253  string selection_name;
1254  GetGame().ConfigGetChildName(cfg_path, i, selection_name);
1255  HideSelection(selection_name);
1256  }
1257  }
1258  }
1259 
1261  void ShowAllSelections()
1262  {
1263  string cfg_path = "cfgVehicles " + GetType() + " AnimationSources";
1264 
1265  if ( GetGame().ConfigIsExisting(cfg_path) )
1266  {
1267  int selections = GetGame().ConfigGetChildrenCount(cfg_path);
1268 
1269  for (int i = 0; i < selections; i++)
1270  {
1271  string selection_name;
1272  GetGame().ConfigGetChildName(cfg_path, i, selection_name);
1273  ShowSelection(selection_name);
1274  }
1275  }
1276  }
1277 
1284  bool CanReceiveAttachment (EntityAI attachment, int slotId)
1285  {
1286  //generic occupancy check
1287  EntityAI currentAtt = GetInventory().FindAttachment(slotId);
1288  bool hasInternalConflict = attachment.HasInternalExclusionConflicts(slotId);
1289  if (currentAtt) //probably a swap or same-type swap
1290  {
1291  set<int> diff = attachment.GetAttachmentExclusionMaskAll(slotId);
1292  diff.RemoveItems(currentAtt.GetAttachmentExclusionMaskAll(slotId));
1293  if (diff.Count() == 0)
1294  {
1295  return !hasInternalConflict;
1296  }
1297  else
1298  {
1299  return !hasInternalConflict && !IsExclusionFlagPresentRecursive(diff,slotId);
1300  }
1301  }
1302  return !hasInternalConflict && !IsExclusionFlagPresentRecursive(attachment.GetAttachmentExclusionMaskAll(slotId),slotId);
1303  }
1304 
1311  bool CanLoadAttachment(EntityAI attachment)
1312  {
1313  return true;
1314  }
1315 
1323  bool CanPutAsAttachment (EntityAI parent)
1324  {
1325  return !IsHologram();
1326  }
1327 
1328  //If return true, item can be attached even from parent to this. Item will be switched during proccess. (only hands)
1329  bool CanSwitchDuringAttach(EntityAI parent)
1330  {
1331  return false;
1332  }
1339  bool CanReleaseAttachment (EntityAI attachment)
1340  {
1341  if( attachment && attachment.GetInventory() && GetInventory() )
1342  {
1344  attachment.GetInventory().GetCurrentInventoryLocation( il );
1345  if( il.IsValid() )
1346  {
1347  int slot = il.GetSlot();
1348  return !GetInventory().GetSlotLock( slot );
1349  }
1350  }
1351  return true;
1352  }
1359  bool CanDetachAttachment (EntityAI parent)
1360  {
1361  return true;
1362  }
1363 
1364  bool CanBeFSwaped()
1365  {
1366  return true;
1367  }
1368 
1369  bool CanCombineAttachment(notnull EntityAI e, int slot, bool stack_max_limit = false)
1370  {
1371  EntityAI att = GetInventory().FindAttachment(slot);
1372  if(att)
1373  return att.CanBeCombined(e, true, stack_max_limit);
1374  return false;
1375  }
1376 
1377  bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false )
1378  {
1379  return false;
1380  }
1381 
1382  void CombineItemsClient(EntityAI entity2, bool use_stack_max = false )
1383  {}
1384 
1392  {
1393  if (GetInventory() && GetInventory().GetCargo())
1394  return GetInventory().GetCargo().CanReceiveItemIntoCargo(item));
1395 
1396  return true;
1397  }
1398 
1405  bool CanLoadItemIntoCargo(EntityAI item)
1406  {
1407  return true;
1408  }
1409 
1416  bool CanPutInCargo (EntityAI parent)
1417  {
1418  return !IsHologram();
1419  }
1420 
1427  bool CanSwapItemInCargo (EntityAI child_entity, EntityAI new_entity)
1428  {
1429  if (GetInventory() && GetInventory().GetCargo())
1430  return GetInventory().GetCargo().CanSwapItemInCargo(child_entity, new_entity));
1431 
1432  return true;
1433  }
1434 
1441  bool CanReleaseCargo (EntityAI cargo)
1442  {
1443  return true;
1444  }
1445 
1452  bool CanRemoveFromCargo (EntityAI parent)
1453  {
1454  return true;
1455  }
1456 
1463  /*bool CanReceiveItemIntoInventory (EntityAI entity_ai)
1464  {
1465  return true;
1466  }*/
1467 
1474  /*bool CanPutInInventory (EntityAI parent)
1475  {
1476  return true;
1477  }*/
1478 
1485  bool CanReceiveItemIntoHands (EntityAI item_to_hands)
1486  {
1487  return true;
1488  }
1489 
1490  bool IsBeingPlaced()
1491  {
1492  return false;
1493  }
1494 
1495  override bool IsHologram()
1496  {
1497  return false;
1498  }
1499 
1500  bool CanSaveItemInHands (EntityAI item_in_hands)
1501  {
1502  return true;
1503  }
1504 
1511  bool CanPutIntoHands (EntityAI parent)
1512  {
1513  return !IsHologram();
1514  }
1515 
1522  bool CanReleaseFromHands (EntityAI handheld)
1523  {
1524  return true;
1525  }
1526 
1533  bool CanRemoveFromHands (EntityAI parent)
1534  {
1535  return true;
1536  }
1537 
1542  bool CanDisplayAttachmentSlot( string slot_name )
1543  {
1544  Debug.LogWarning("Obsolete function - use CanDisplayAttachmentSlot with slot id parameter");
1545  return InventorySlots.GetShowForSlotId(InventorySlots.GetSlotIdFromString(slot_name));
1546  }
1547 
1552  bool CanDisplayAttachmentSlot( int slot_id )
1553  {
1554  return InventorySlots.GetShowForSlotId(slot_id);
1555  }
1556 
1560  bool CanDisplayAnyAttachmentSlot()
1561  {
1562  int count = GetInventory().GetAttachmentSlotsCount();
1563  int slotID;
1564  for (int i = 0; i < count; i++)
1565  {
1566  slotID = GetInventory().GetAttachmentSlotId(i);
1567  if (CanDisplayAttachmentSlot(slotID))
1568  {
1569  return true;
1570  }
1571  }
1572 
1573  return false;
1574  }
1575 
1580  bool CanDisplayAttachmentCategory( string category_name )
1581  {
1582  return true;
1583  }
1584 
1588  bool CanDisplayCargo()
1589  {
1590  return GetInventory().GetCargo() != null;
1591  }
1592 
1596  bool CanAssignToQuickbar()
1597  {
1598  return true;
1599  }
1600 
1604  bool CanAssignAttachmentsToQuickbar()
1605  {
1606  return true;
1607  }
1608 
1613  {
1614  return GetHierarchyRootPlayer() == GetGame().GetPlayer();
1615  }
1616 
1617  // !Called on CHILD when it's attached to parent.
1618  void OnWasAttached( EntityAI parent, int slot_id );
1619 
1620  // !Called on CHILD when it's detached from parent.
1621  void OnWasDetached( EntityAI parent, int slot_id )
1622  {
1623  if (!IsFlagSet(EntityFlags.VISIBLE))
1624  {
1625  SetInvisible(false);
1626  OnInvisibleSet(false);
1627  SetInvisibleRecursive(false,parent);
1628  }
1629  }
1630 
1631  void OnCargoChanged() { }
1632 
1633  bool IsTakeable()
1634  {
1635  return false;
1636  }
1637 
1638  proto native GameInventory GetInventory();
1639  proto native void CreateAndInitInventory();
1640  proto native void DestroyInventory();
1641 
1642  int GetSlotsCountCorrect()
1643  {
1644  if (GetInventory())
1645  return GetInventory().GetAttachmentSlotsCount();
1646  else
1647  return -1;
1648  }
1649 
1650  EntityAI FindAttachmentBySlotName(string slot_name)
1651  {
1652  if ( GetGame() )
1653  {
1654  int slot_id = InventorySlots.GetSlotIdFromString(slot_name);
1655  if (slot_id != InventorySlots.INVALID)
1656  return GetInventory().FindAttachment(slot_id);
1657  }
1658  return null;
1659  }
1660 
1664  bool IsLockedInSlot()
1665  {
1666  EntityAI parent = GetHierarchyParent();
1667  if ( parent )
1668  {
1669  InventoryLocation inventory_location = new InventoryLocation();
1670  GetInventory().GetCurrentInventoryLocation( inventory_location );
1671 
1672  return parent.GetInventory().GetSlotLock( inventory_location.GetSlot() );
1673  }
1674 
1675  return false;
1676  }
1677 
1681  bool PredictiveTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item)
1682  {
1683  if ( GetGame().IsMultiplayer() )
1684  return GetInventory().TakeEntityToInventory(InventoryMode.JUNCTURE, flags, item);
1685  else
1686  return GetInventory().TakeEntityToInventory(InventoryMode.PREDICTIVE, flags, item);
1687  }
1688  bool LocalTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item)
1689  {
1690  return GetInventory().TakeEntityToInventory(InventoryMode.LOCAL, flags, item);
1691  }
1692  bool ServerTakeEntityToInventory (FindInventoryLocationType flags, notnull EntityAI item)
1693  {
1694  return GetInventory().TakeEntityToInventory(InventoryMode.SERVER, flags, item);
1695  }
1696  bool PredictiveTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
1697  {
1698  if ( GetGame().IsMultiplayer() )
1699  return GetInventory().TakeEntityToTargetInventory(InventoryMode.JUNCTURE, target, flags, item);
1700  else
1701  return GetInventory().TakeEntityToTargetInventory(InventoryMode.PREDICTIVE, target, flags, item);
1702  }
1703  bool LocalTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
1704  {
1705  return GetInventory().TakeEntityToTargetInventory(InventoryMode.LOCAL, target, flags, item);
1706  }
1707  bool ServerTakeEntityToTargetInventory (notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
1708  {
1709  return GetInventory().TakeEntityToTargetInventory(InventoryMode.SERVER, target, flags, item);
1710  }
1714  bool PredictiveTakeEntityToCargo (notnull EntityAI item)
1715  {
1716  if ( GetGame().IsMultiplayer() )
1717  return GetInventory().TakeEntityToCargo(InventoryMode.JUNCTURE, item);
1718  else
1719  return GetInventory().TakeEntityToCargo(InventoryMode.PREDICTIVE, item);
1720  }
1721  bool LocalTakeEntityToCargo (notnull EntityAI item)
1722  {
1723  return GetInventory().TakeEntityToCargo(InventoryMode.LOCAL, item);
1724  }
1725  bool ServerTakeEntityToCargo (notnull EntityAI item)
1726  {
1727  return GetInventory().TakeEntityToCargo(InventoryMode.SERVER, item);
1728  }
1729 
1730  bool PredictiveTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
1731  {
1732  if ( GetGame().IsMultiplayer() )
1733  return GetInventory().TakeEntityToTargetCargo(InventoryMode.JUNCTURE, target, item);
1734  else
1735  return GetInventory().TakeEntityToTargetCargo(InventoryMode.PREDICTIVE, target, item);
1736  }
1737  bool LocalTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
1738  {
1739  return GetInventory().TakeEntityToTargetCargo(InventoryMode.LOCAL, target, item);
1740  }
1741  bool ServerTakeEntityToTargetCargo (notnull EntityAI target, notnull EntityAI item)
1742  {
1743  return GetInventory().TakeEntityToTargetCargo(InventoryMode.SERVER, target, item);
1744  }
1748  bool PredictiveTakeEntityToCargoEx (notnull EntityAI item, int idx, int row, int col)
1749  {
1750  if ( GetGame().IsMultiplayer() )
1751  return GetInventory().TakeEntityToCargoEx(InventoryMode.JUNCTURE, item, idx, row, col);
1752  else
1753  return GetInventory().TakeEntityToCargoEx(InventoryMode.PREDICTIVE, item, idx, row, col);
1754  }
1755  bool LocalTakeEntityToCargoEx (notnull EntityAI item, int idx, int row, int col)
1756  {
1757  return GetInventory().TakeEntityToCargoEx(InventoryMode.LOCAL, item, idx, row, col);
1758  }
1759 
1760  bool PredictiveTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
1761  {
1762  if ( GetGame().IsMultiplayer() )
1763  return GetInventory().TakeEntityToTargetCargoEx(InventoryMode.JUNCTURE, cargo, item, row, col);
1764  else
1765  return GetInventory().TakeEntityToTargetCargoEx(InventoryMode.PREDICTIVE, cargo, item, row, col);
1766  }
1767  bool LocalTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
1768  {
1769  return GetInventory().TakeEntityToTargetCargoEx(InventoryMode.LOCAL, cargo, item, row, col);
1770  }
1771  bool ServerTakeEntityToTargetCargoEx (notnull CargoBase cargo, notnull EntityAI item, int row, int col)
1772  {
1773  return GetInventory().TakeEntityToTargetCargoEx(InventoryMode.SERVER, cargo, item, row, col);
1774  }
1778  bool PredictiveTakeEntityAsAttachmentEx (notnull EntityAI item, int slot)
1779  {
1780  if ( GetGame().IsMultiplayer() )
1781  return GetInventory().TakeEntityAsAttachmentEx(InventoryMode.JUNCTURE, item, slot);
1782  else
1783  return GetInventory().TakeEntityAsAttachmentEx(InventoryMode.PREDICTIVE, item, slot);
1784  }
1785  bool LocalTakeEntityAsAttachmentEx (notnull EntityAI item, int slot)
1786  {
1787  return GetInventory().TakeEntityAsAttachmentEx(InventoryMode.LOCAL, item, slot);
1788  }
1789  bool ServerTakeEntityAsAttachmentEx (notnull EntityAI item, int slot)
1790  {
1791  return GetInventory().TakeEntityAsAttachmentEx(InventoryMode.SERVER, item, slot);
1792  }
1793 
1794  bool PredictiveTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
1795  {
1796  if ( GetGame().IsMultiplayer() )
1797  return GetInventory().TakeEntityAsTargetAttachmentEx(InventoryMode.JUNCTURE, target, item, slot);
1798  else
1799  return GetInventory().TakeEntityAsTargetAttachmentEx(InventoryMode.PREDICTIVE, target, item, slot);
1800  }
1801  bool LocalTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
1802  {
1803  return GetInventory().TakeEntityAsTargetAttachmentEx(InventoryMode.LOCAL, target, item, slot);
1804  }
1805  bool ServerTakeEntityToTargetAttachmentEx (notnull EntityAI target, notnull EntityAI item, int slot)
1806  {
1807  return GetInventory().TakeEntityAsTargetAttachmentEx(InventoryMode.SERVER, target, item, slot);
1808  }
1809 
1810  bool PredictiveTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
1811  {
1812  if ( GetGame().IsMultiplayer() )
1813  return GetInventory().TakeEntityAsTargetAttachment(InventoryMode.JUNCTURE, target, item);
1814  else
1815  return GetInventory().TakeEntityAsTargetAttachment(InventoryMode.PREDICTIVE, target, item);
1816  }
1817  bool LocalTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
1818  {
1819  return GetInventory().TakeEntityAsTargetAttachment(InventoryMode.LOCAL, target, item);
1820  }
1821  bool ServerTakeEntityToTargetAttachment (notnull EntityAI target, notnull EntityAI item)
1822  {
1823  return GetInventory().TakeEntityAsTargetAttachment(InventoryMode.SERVER, target, item);
1824  }
1825 
1826  bool PredictiveTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst)
1827  {
1828  if ( GetGame().IsMultiplayer() )
1829  return GetInventory().TakeToDst(InventoryMode.JUNCTURE, src, dst);
1830  else
1831  return GetInventory().TakeToDst(InventoryMode.PREDICTIVE, src, dst);
1832  }
1833  bool LocalTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst)
1834  {
1835  return GetInventory().TakeToDst(InventoryMode.LOCAL, src, dst);
1836  }
1837  bool ServerTakeToDst (notnull InventoryLocation src, notnull InventoryLocation dst)
1838  {
1839  return GetInventory().TakeToDst(InventoryMode.SERVER, src, dst);
1840  }
1841 
1845  bool PredictiveTakeEntityAsAttachment(notnull EntityAI item)
1846  {
1847  if (GetGame().IsMultiplayer())
1848  return GetInventory().TakeEntityAsAttachment(InventoryMode.JUNCTURE, item);
1849  else
1850  return GetInventory().TakeEntityAsAttachment(InventoryMode.PREDICTIVE, item);
1851  }
1852  bool LocalTakeEntityAsAttachment (notnull EntityAI item)
1853  {
1854  return GetInventory().TakeEntityAsAttachment(InventoryMode.LOCAL, item);
1855  }
1856  bool ServerTakeEntityAsAttachment (notnull EntityAI item)
1857  {
1858  return GetInventory().TakeEntityAsAttachment(InventoryMode.SERVER, item);
1859  }
1860 
1861  bool PredictiveDropEntity(notnull EntityAI item)
1862  {
1863  return false;
1864  }
1865 
1866  bool LocalDropEntity(notnull EntityAI item)
1867  {
1868  return false;
1869  }
1870 
1871  bool ServerDropEntity(notnull EntityAI item)
1872  {
1873  return false;
1874  }
1875 
1879  EntityAI GetAttachmentByType(typename type)
1880  {
1881  for ( int i = 0; i < GetInventory().AttachmentCount(); i++ )
1882  {
1883  EntityAI attachment = GetInventory().GetAttachmentFromIndex( i );
1884  if ( attachment && attachment.IsInherited( type ) )
1885  return attachment;
1886  }
1887  return NULL;
1888  }
1889 
1893  EntityAI GetAttachmentByConfigTypeName(string type)
1894  {
1895  for ( int i = 0; i < GetInventory().AttachmentCount(); i++ )
1896  {
1897  EntityAI attachment = GetInventory().GetAttachmentFromIndex ( i );
1898  if ( attachment.IsKindOf ( type ) )
1899  return attachment;
1900  }
1901  return NULL;
1902  }
1906  bool CanDropEntity(notnull EntityAI item)
1907  {
1908  return true;
1909  }
1910 
1911  EntityAI SpawnInInventoryOrGroundPos(string object_name, GameInventory inv, vector pos)
1912  {
1913  if (inv)
1914  {
1915  EntityAI res = inv.CreateInInventory(object_name);
1916  if (res)
1917  {
1918  return res;
1919  }
1920  }
1921 
1922  return SpawnEntityOnGroundPos(object_name, pos);
1923  }
1924 
1927  EntityAI SpawnEntityOnGroundPos(string object_name, vector pos)
1928  {
1930  vector mat[4];
1931  Math3D.MatrixIdentity4(mat);
1932  mat[3] = pos;
1933  il.SetGround(NULL, mat);
1934  return SpawnEntity(object_name, il,ECE_PLACE_ON_SURFACE,RF_DEFAULT);
1935  }
1938  EntityAI SpawnEntityOnGround(string object_name, vector mat[4])
1939  {
1941  il.SetGround(NULL, mat);
1942  return SpawnEntity(object_name, il,ECE_PLACE_ON_SURFACE,RF_DEFAULT);
1943  }
1944 
1945  //----------------------------------------------------------------
1946 
1947  bool CanSwapEntities(EntityAI otherItem, InventoryLocation otherDestination, InventoryLocation destination)
1948  {
1949  return true;
1950  }
1951 
1952  // Forward declarations to allow lower modules to access properties that are modified from higher modules
1953  // These are mainly used within the ItemBase
1954  void SetWet(float value, bool allow_client = false);
1955  void AddWet(float value);
1956  void SetWetMax();
1957 
1958  float GetWet()
1959  {
1960  return 0;
1961  }
1962 
1963  float GetWetMax()
1964  {
1965  return 0;
1966  }
1967 
1968  float GetWetMin()
1969  {
1970  return 0;
1971  }
1972 
1973  float GetWetInit()
1974  {
1975  return 0;
1976  }
1977 
1978  bool HasWetness()
1979  {
1980  return GetWetMax() - GetWetMin() != 0;
1981  }
1982 
1983  void OnWetChanged(float newVal, float oldVal);
1984 
1985  void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel);
1986  // ! Returns current wet level of the entity
1988 
1989  // ! Calculates wet level from a given wetness, to get level of an entity, use 'GetWetLevel()' instead
1990  static EWetnessLevel GetWetLevelInternal(float wetness)
1991  {
1992  if (wetness < GameConstants.STATE_DAMP)
1993  {
1994  return EWetnessLevel.DRY;
1995  }
1996  else if (wetness < GameConstants.STATE_WET)
1997  {
1998  return EWetnessLevel.DAMP;
1999  }
2000  else if (wetness < GameConstants.STATE_SOAKING_WET)
2001  {
2002  return EWetnessLevel.WET;
2003  }
2004  else if (wetness < GameConstants.STATE_DRENCHED)
2005  {
2006  return EWetnessLevel.SOAKING;
2007  }
2008  return EWetnessLevel.DRENCHED;
2009  }
2010  //----------------------------------------------------------------
2011 
2012  float GetQuantity()
2013  {
2014  return 0;
2015  }
2016 
2017  int GetQuantityMax()
2018  {
2019  return 0;
2020  }
2021 
2022  void SetQuantityToMinimum();
2023 
2024  int GetTargetQuantityMax(int attSlotID = -1)
2025  {
2026  return 0;
2027  }
2028 
2029  int GetQuickBarBonus()
2030  {
2031  return 0;
2032  }
2033 
2034  //----------------------------------------------------------------
2035 
2036  void SetTemperature(float value, bool allow_client = false) {};
2037  void AddTemperature(float value) {};
2038  void SetTemperatureMax() {};
2039 
2040  float GetTemperature()
2041  {
2042  return 0;
2043  }
2044 
2045  float GetTemperatureInit()
2046  {
2047  return 0;
2048  }
2049 
2050  float GetTemperatureMin()
2051  {
2052  return 0;
2053  }
2054 
2055  float GetTemperatureMax()
2056  {
2057  return 0;
2058  }
2059 
2060  //----------------------------------------------------------------
2061 
2062  HiddenSelectionsData GetHiddenSelectionsData()
2063  {
2064  return m_HiddenSelectionsData;
2065  }
2066 
2068  int GetHiddenSelectionIndex( string selection )
2069  {
2070  if (m_HiddenSelectionsData)
2071  return m_HiddenSelectionsData.GetHiddenSelectionIndex( selection );
2072 
2073  return -1;
2074  }
2075 
2077  override TStringArray GetHiddenSelections()
2078  {
2079  if (m_HiddenSelectionsData)
2080  return m_HiddenSelectionsData.m_HiddenSelections;
2081  else
2082  return super.GetHiddenSelections();
2083  }
2084 
2086  override TStringArray GetHiddenSelectionsTextures()
2087  {
2088  if (m_HiddenSelectionsData)
2089  return m_HiddenSelectionsData.m_HiddenSelectionsTextures;
2090  else
2091  return super.GetHiddenSelectionsTextures();
2092  }
2093 
2095  override TStringArray GetHiddenSelectionsMaterials()
2096  {
2097  if (m_HiddenSelectionsData)
2098  return m_HiddenSelectionsData.m_HiddenSelectionsMaterials;
2099  else
2100  return super.GetHiddenSelectionsMaterials();
2101  }
2102 
2114  proto native void PlaceOnSurfaceRotated(out vector trans[4], vector pos, float dx = 0, float dz = 0, float fAngle = 0, bool align = false);
2115 
2122  proto native void RegisterNetSyncVariableBool(string variableName);
2123 
2130  proto native void RegisterNetSyncVariableBoolSignal(string variableName);
2131 
2140  proto native void RegisterNetSyncVariableInt(string variableName, int minValue = 0, int maxValue = 0);
2141 
2151  proto native void RegisterNetSyncVariableFloat(string variableName, float minValue = 0, float maxValue = 0, int precision = 1);
2152 
2159  proto native void RegisterNetSyncVariableObject(string variableName);
2160 
2161  proto native void UpdateNetSyncVariableInt(string variableName, float minValue = 0, float maxValue = 0);
2162  proto native void UpdateNetSyncVariableFloat(string variableName, float minValue = 0, float maxValue = 0, int precision = 1);
2163 
2164  proto native void SwitchLight(bool isOn);
2165 
2167  proto native void SetSimpleHiddenSelectionState(int index, bool state);
2168  proto native bool IsSimpleHiddenSelectionVisible(int index);
2169 
2171  proto native void SetObjectTexture(int index, string texture_name);
2172  proto native owned string GetObjectTexture(int index);
2174  proto native void SetObjectMaterial(int index, string mat_name);
2175  proto native owned string GetObjectMaterial(int index);
2176 
2177  proto native bool IsPilotLight();
2178  proto native void SetPilotLight(bool isOn);
2179 
2198  {
2199  // Saving of energy related states
2200  if ( m_EM )
2201  {
2202  // Save energy amount
2203  ctx.Write( m_EM.GetEnergy() );
2204 
2205  // Save passive/active state
2206  ctx.Write( m_EM.IsPassive() );
2207 
2208  // Save ON/OFF state
2209  ctx.Write( m_EM.IsSwitchedOn() );
2210 
2211  // Save plugged/unplugged state
2212  ctx.Write( m_EM.IsPlugged() );
2213 
2214  // ENERGY SOURCE
2215  // Save energy source IDs
2216  EntityAI energy_source = m_EM.GetEnergySource();
2217  int b1 = 0;
2218  int b2 = 0;
2219  int b3 = 0;
2220  int b4 = 0;
2221 
2222  if (energy_source)
2223  {
2224  energy_source.GetPersistentID(b1, b2, b3, b4);
2225  }
2226 
2227  ctx.Write( b1 ); // Save energy source block 1
2228  ctx.Write( b2 ); // Save energy source block 2
2229  ctx.Write( b3 ); // Save energy source block 3
2230  ctx.Write( b4 ); // Save energy source block 4
2231  }
2232  }
2233 
2258  bool OnStoreLoad (ParamsReadContext ctx, int version)
2259  {
2260  // Restoring of energy related states
2261 
2262  if ( m_EM )
2263  {
2264  // Load energy amount
2265  float f_energy = 0;
2266  if ( !ctx.Read( f_energy ) )
2267  f_energy = 0;
2268  m_EM.SetEnergy(f_energy);
2269 
2270  // Load passive/active state
2271  bool b_is_passive = false;
2272  if ( !ctx.Read( b_is_passive ) )
2273  return false;
2274  m_EM.SetPassiveState(b_is_passive);
2275 
2276  // Load ON/OFF state
2277  bool b_is_on = false;
2278  if ( !ctx.Read( b_is_on ) )
2279  {
2280  m_EM.SwitchOn();
2281  return false;
2282  }
2283 
2284  // Load plugged/unplugged state
2285  bool b_is_plugged = false;
2286  if ( !ctx.Read( b_is_plugged ) )
2287  return false;
2288 
2289  // ENERGY SOURCE
2290  if ( version <= 103 )
2291  {
2292  // Load energy source ID low
2293  int i_energy_source_ID_low = 0; // Even 0 can be valid ID!
2294  if ( !ctx.Read( i_energy_source_ID_low ) )
2295  return false;
2296 
2297  // Load energy source ID high
2298  int i_energy_source_ID_high = 0; // Even 0 can be valid ID!
2299  if ( !ctx.Read( i_energy_source_ID_high ) )
2300  return false;
2301  }
2302  else
2303  {
2304  int b1 = 0;
2305  int b2 = 0;
2306  int b3 = 0;
2307  int b4 = 0;
2308 
2309  if ( !ctx.Read(b1) ) return false;
2310  if ( !ctx.Read(b2) ) return false;
2311  if ( !ctx.Read(b3) ) return false;
2312  if ( !ctx.Read(b4) ) return false;
2313 
2314  if ( b_is_plugged )
2315  {
2316  // Because function GetEntityByPersitentID() cannot be called here, ID values must be stored and used later.
2317  m_EM.StoreEnergySourceIDs( b1, b2, b3, b4 );
2318  m_EM.RestorePlugState(true);
2319  }
2320  }
2321 
2322  if (b_is_on)
2323  {
2324  m_EM.SwitchOn();
2325  }
2326  }
2327  return true;
2328  }
2329 
2331  proto native void SetSynchDirty();
2332 
2337  {
2338  if ( m_EM )
2339  {
2340  if ( GetGame().IsMultiplayer() )
2341  {
2342  bool is_on = m_EM.IsSwitchedOn();
2343 
2344  if (is_on != m_EM.GetPreviousSwitchState())
2345  {
2346  if (is_on)
2347  m_EM.SwitchOn();
2348  else
2349  m_EM.SwitchOff();
2350  }
2351 
2352  int id_low = m_EM.GetEnergySourceNetworkIDLow();
2353  int id_High = m_EM.GetEnergySourceNetworkIDHigh();
2354 
2355  EntityAI energy_source = EntityAI.Cast( GetGame().GetObjectByNetworkId(id_low, id_High) );
2356 
2357  if (energy_source)
2358  {
2359  ComponentEnergyManager esem = energy_source.GetCompEM();
2360 
2361  if ( !esem )
2362  {
2363  string object = energy_source.GetType();
2364  Error("Synchronization error! Object " + object + " has no instance of the Energy Manager component!");
2365  }
2366 
2367  m_EM.PlugThisInto(energy_source);
2368 
2369  }
2370  else
2371  {
2372  m_EM.UnplugThis();
2373  }
2374 
2375  m_EM.DeviceUpdate();
2376  m_EM.StartUpdates();
2377  }
2378  }
2379  }
2380 
2381  proto native void SetAITargetCallbacks(AbstractAITargetCallbacks callbacks);
2382 
2383  override void EOnFrame(IEntity other, float timeSlice)
2384  {
2385  if ( m_ComponentsBank != NULL )
2386  {
2387  for ( int comp_key = 0; comp_key < COMP_TYPE_COUNT; ++comp_key )
2388  {
2389  if ( m_ComponentsBank.IsComponentAlreadyExist(comp_key) )
2390  {
2391  m_ComponentsBank.GetComponent(comp_key).Event_OnFrame(other, timeSlice);
2392  }
2393  }
2394  }
2395  }
2396 
2397  string GetDebugText()
2398  {
2399  string text = string.Empty;
2400 
2401  text += "Weight: " + GetWeightEx() + "\n";
2402  text += "Disabled: " + GetIsSimulationDisabled() + "\n";
2403  #ifdef SERVER
2404  if (GetEconomyProfile())
2405  text += "CE Lifetime default: " + (int)GetEconomyProfile().GetLifetime() + "\n";
2406  text += "CE Lifetime remaining: " + (int)GetLifetime() + "\n";
2407  #endif
2408 
2409  ComponentEnergyManager compEM = GetCompEM();
2410  if (compEM)
2411  {
2412  text += "Energy Source: " + Object.GetDebugName(compEM.GetEnergySource()) + "\n";
2413  text += "Switched On: " + compEM.IsSwitchedOn() + "\n";
2414  text += "Is Working: " + compEM.IsWorking() + "\n";
2415  }
2416 
2417  return text;
2418  }
2419 
2420 
2421  void GetDebugButtonNames(out string button1, out string button2, out string button3, out string button4){}//DEPRICATED, USE GetDebugActions / OnAction
2422  void OnDebugButtonPressClient(int button_index){}//DEPRICATED, USE GetDebugActions / OnAction
2423  void OnDebugButtonPressServer(int button_index){}//DEPRICATED, USE GetDebugActions / OnAction
2424 
2425 
2426  Shape DebugBBoxDraw()
2427  {
2428  return GetComponent(COMP_TYPE_ETITY_DEBUG).DebugBBoxDraw();
2429  }
2430 
2431  void DebugBBoxSetColor(int color)
2432  {
2433  GetComponent(COMP_TYPE_ETITY_DEBUG).DebugBBoxSetColor(color);
2434  }
2435 
2436  void DebugBBoxDelete()
2437  {
2438  GetComponent(COMP_TYPE_ETITY_DEBUG).DebugBBoxDelete();
2439  }
2440 
2441  Shape DebugDirectionDraw(float distance = 1)
2442  {
2443  return GetComponent(COMP_TYPE_ETITY_DEBUG).DebugDirectionDraw(distance);
2444  }
2445 
2446  void DebugDirectionSetColor(int color)
2447  {
2448  GetComponent(COMP_TYPE_ETITY_DEBUG).DebugDirectionSetColor(color);
2449  }
2450 
2451  void DebugDirectionDelete()
2452  {
2453  GetComponent(COMP_TYPE_ETITY_DEBUG).DebugDirectionDelete();
2454  }
2455 
2457  void HideSelection( string selection_name )
2458  {
2459  if ( !ToDelete() )
2460  {
2461  SetAnimationPhase ( selection_name, 1 ); // 1 = hide, 0 = unhide!
2462  }
2463  }
2464 
2466  void ShowSelection( string selection_name )
2467  {
2468  if ( !ToDelete() )
2469  {
2470  SetAnimationPhase ( selection_name, 0 ); // 1 = hide, 0 = unhide!
2471  }
2472  }
2473 
2476  proto void GetPersistentID( out int b1, out int b2, out int b3, out int b4 );
2477 
2479  proto native void SetLifetime( float fLifeTime );
2481  proto native float GetLifetime();
2483  proto native void IncreaseLifetime();
2484 
2486  proto native void SetLifetimeMax( float fLifeTime );
2488  proto native float GetLifetimeMax();
2489 
2491  void IncreaseLifetimeUp()
2492  {
2493  IncreaseLifetime();
2494  if (GetHierarchyParent())
2495  GetHierarchyParent().IncreaseLifetimeUp();
2496  }
2497 
2498 
2499  // BODY STAGING
2501  ComponentBodyStaging GetCompBS()
2502  {
2503  if ( HasComponent(COMP_TYPE_BODY_STAGING) )
2504  return ComponentBodyStaging.Cast( GetComponent(COMP_TYPE_BODY_STAGING) );
2505  return NULL;
2506  }
2507 
2511  ComponentEnergyManager GetCompEM()
2512  {
2513  if (m_EM)
2514  return m_EM;
2515 
2516  if ( HasComponent(COMP_TYPE_ENERGY_MANAGER) )
2517  return ComponentEnergyManager.Cast( GetComponent(COMP_TYPE_ENERGY_MANAGER) );
2518  return NULL;
2519  }
2520 
2522  bool HasEnergyManager()
2523  {
2524  return HasComponent(COMP_TYPE_ENERGY_MANAGER);
2525  }
2526 
2527  // ------ Public Events for Energy manager component. Overwrite these and put your own functionality into them. ------
2528 
2530  void OnWorkStart() {}
2531 
2533  void OnWork( float consumed_energy ) {}
2534 
2536  void OnWorkStop() {}
2537 
2539  void OnSwitchOn() {}
2540 
2542  void OnSwitchOff() {}
2543 
2545  void OnIsPlugged(EntityAI source_device) {}
2546 
2548  void OnIsUnplugged( EntityAI last_energy_source ) {}
2549 
2551  void OnOwnSocketTaken( EntityAI device ) {}
2552 
2554  void OnOwnSocketReleased( EntityAI device ) {}
2555 
2557  void OnInitEnergy() {}
2558 
2560  void OnEnergyConsumed() {}
2561 
2563  void OnEnergyAdded() {}
2565 
2566  override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
2567  {
2568  super.OnRPC(sender, rpc_type, ctx);
2569 
2570  if ( GetGame().IsClient() )
2571  {
2572  switch (rpc_type)
2573  {
2574  // BODY STAGING - server => client synchronization of skinned state.
2575  case ERPCs.RPC_BS_SKINNED_STATE:
2576  {
2577  Param1<bool> p_skinned_state= new Param1<bool>(false);
2578  if (ctx.Read(p_skinned_state))
2579  {
2580  float state = p_skinned_state.param1;
2581  if (state && GetCompBS())
2582  GetCompBS().SetAsSkinnedClient();
2583  }
2584  break;
2585  }
2586 
2587  case ERPCs.RPC_EXPLODE_EVENT:
2588  {
2589  OnExplodeClient();
2590  break;
2591  }
2592  }
2593  }
2594  }
2595 
2596  #ifdef DIAG_DEVELOPER
2597  void FixEntity()
2598  {
2599  if (!(GetGame().IsServer()))
2600  return;
2601  SetFullHealth();
2602 
2603  if (GetInventory())
2604  {
2605  int i = 0;
2606  int AttachmentsCount = GetInventory().AttachmentCount();
2607  if (AttachmentsCount > 0)
2608  {
2609  for (i = 0; i < AttachmentsCount; i++)
2610  {
2611  GetInventory().GetAttachmentFromIndex(i).FixEntity();
2612  }
2613  }
2614 
2615  CargoBase cargo = GetInventory().GetCargo();
2616  if (cargo)
2617  {
2618  int cargoCount = cargo.GetItemCount();
2619  for (i = 0; i < cargoCount; i++)
2620  {
2621  cargo.GetItem(i).FixEntity();
2622  }
2623  }
2624  }
2625  }
2626  #endif
2627 
2628  float GetWetWeightModifier()
2629  {
2630  return CfgGameplayHandler.GetWetnessWeightModifiers()[GetWetLevel()];
2631  }
2632 
2633  float GetConfigWeightModified()
2634  {
2635  return m_ConfigWeight * GetWetWeightModifier();
2636  }
2637 
2638  #ifdef DEVELOPER
2639  string GetConfigWeightModifiedDebugText()
2640  {
2641  if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
2642  {
2643  return "(" + m_ConfigWeight + "(config weight) * " + GetWetWeightModifier() + "(Wetness Modifier))";
2644  }
2645  return string.Empty;
2646  }
2647  #endif
2648 
2649 
2650  //Obsolete, use GetWeightEx()
2651  int GetWeight()
2652  {
2653  return GetWeightEx();
2654  }
2655 
2656  void ClearWeightDirty()
2657  {
2658  //Print("ent:" + this + " - ClearWeightDirty");
2659  m_WeightDirty = 0;
2660  }
2661 
2662  void SetWeightDirty()
2663  {
2664  #ifdef DEVELOPER
2665  if (WeightDebug.m_VerbosityFlags & WeightDebugType.SET_DIRTY_FLAG)
2666  {
2667  Print("---------------------------------------");
2668  Print("ent:" + this + " - SetWeightDirty");
2669  if (WeightDebug.m_VerbosityFlags & WeightDebugType.DUMP_STACK)
2670  {
2671  DumpStack();
2672  }
2673  Print("---------------------------------------");
2674  }
2675  #endif
2676  m_WeightDirty = 1;
2677  if (GetHierarchyParent())
2678  {
2679  GetHierarchyParent().SetWeightDirty();
2680  }
2681  }
2682  // returns weight of all cargo and attachments
2683  float GetInventoryAndCargoWeight(bool forceRecalc = false)
2684  {
2685  float totalWeight;
2686  if (GetInventory())
2687  {
2688  int i = 0;
2689  int AttachmentsCount = GetInventory().AttachmentCount();
2690  if (AttachmentsCount > 0)
2691  {
2692  for (i = 0; i < AttachmentsCount; i++)
2693  {
2694  totalWeight += GetInventory().GetAttachmentFromIndex(i).GetWeightEx(forceRecalc);
2695  }
2696  }
2697 
2698  CargoBase cargo = GetInventory().GetCargo();
2699  if (cargo)
2700  {
2701  int cargoCount = cargo.GetItemCount();
2702  for (i = 0; i < cargoCount; i++)
2703  {
2704  totalWeight += cargo.GetItem(i).GetWeightEx(forceRecalc);
2705  }
2706  }
2707  }
2708  return totalWeight;
2709  }
2711  protected float GetWeightSpecialized(bool forceRecalc = false)
2712  {
2713  return GetInventoryAndCargoWeight(forceRecalc);
2714  }
2715 
2717  //this method is not meant to be overriden, to adjust weight calculation for specific item type, override 'GetWeightSpecialized(bool forceRecalc = false)' instead
2718  float GetWeightEx(bool forceRecalc = false)
2719  {
2720  if (m_WeightDirty || forceRecalc)//recalculate
2721  {
2722  m_WeightEx = GetWeightSpecialized(forceRecalc);
2723  ClearWeightDirty();
2724 
2725  #ifdef DEVELOPER
2726  if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
2727  {
2728  WeightDebug.GetWeightDebug(this).SetWeight(m_WeightEx);
2729  }
2730  if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_DIRTY)
2731  {
2732  Print("ent:" + this + " - Dirty Recalc");
2733  if (WeightDebug.m_VerbosityFlags & WeightDebugType.DUMP_STACK)
2734  {
2735  DumpStack();
2736  }
2737  }
2738  #endif
2739  }
2740 
2741  return m_WeightEx;
2742  }
2743 
2744  void UpdateWeight(WeightUpdateType updateType = WeightUpdateType.FULL, float weightAdjustment = 0);
2745 
2747 
2748  void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
2749  {
2750  //fix entity
2751  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FIX_ENTITY, "Fix Entity", FadeColors.LIGHT_GREY));
2752 
2753  //weight
2754  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GET_TOTAL_WEIGHT, "Print Weight", FadeColors.LIGHT_GREY));
2755  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GET_TOTAL_WEIGHT_RECALC, "Print Weight Verbose", FadeColors.LIGHT_GREY));
2756  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GET_PLAYER_WEIGHT, "Print Player Weight", FadeColors.LIGHT_GREY));
2757  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GET_PLAYER_WEIGHT_RECALC, "Print Player Weight Verbose", FadeColors.LIGHT_GREY));
2758  }
2759  bool OnAction(int action_id, Man player, ParamsReadContext ctx)
2760  {
2761  if (action_id == EActions.FIX_ENTITY)
2762  {
2763  #ifdef DIAG_DEVELOPER
2764  FixEntity();
2765  #endif
2766  }
2767  else if (action_id == EActions.GET_TOTAL_WEIGHT) //Prints total weight of item + its contents
2768  {
2769  WeightDebug.ClearWeightDebug();
2770  #ifndef SERVER
2771  Debug.Log("======================== "+ GetType() +" =================================");
2772  #endif
2773  Debug.Log("Weight:" + GetWeightEx().ToString());
2774  Debug.Log("Weight excluding cargo and attachments:" + GetSingleInventoryItemWeightEx());
2775  Debug.Log("----------------------------------------------------------------------------------------------");
2776  }
2777  else if (action_id == EActions.GET_TOTAL_WEIGHT_RECALC) //Prints total weight of item + its contents
2778  {
2779  WeightDebug.ClearWeightDebug();
2780  WeightDebug.SetVerbosityFlags(WeightDebugType.RECALC_FORCED);
2781  #ifndef SERVER
2782  Debug.Log("======================== "+ GetType() +" RECALC ===========================");
2783  #endif
2784  Debug.Log("Weight:" + GetWeightEx(true).ToString());
2785  Debug.Log("Weight excluding cargo and attachments:" + GetSingleInventoryItemWeightEx());
2786  WeightDebug.PrintAll(this);
2787  Debug.Log("----------------------------------------------------------------------------------------------");
2788  WeightDebug.SetVerbosityFlags(0);
2789  }
2790  else if (action_id == EActions.GET_PLAYER_WEIGHT) //Prints total weight of item + its contents
2791  {
2792  WeightDebug.ClearWeightDebug();
2793  #ifndef SERVER
2794  Debug.Log("======================== PLAYER: "+player+" ===========================");
2795  #endif
2796  Debug.Log("New overall weight Player:"+player.GetWeightEx().ToString());
2797 
2798  Debug.Log("----------------------------------------------------------------------------------------------");
2799  }
2800  else if (action_id == EActions.GET_PLAYER_WEIGHT_RECALC) //Prints total weight of item + its contents
2801  {
2802  WeightDebug.ClearWeightDebug();
2803  WeightDebug.SetVerbosityFlags(WeightDebugType.RECALC_FORCED);
2804  #ifndef SERVER
2805  Debug.Log("======================== PLAYER RECALC: "+player+" ===========================");
2806  #endif
2807  Debug.Log("New overall weight Player:"+player.GetWeightEx(true).ToString());
2808  WeightDebug.PrintAll(player);
2809  Debug.Log("----------------------------------------------------------------------------------------------");
2810  WeightDebug.SetVerbosityFlags(0);
2811  }
2812  return false;
2813  }
2814 
2818  int m_ViewIndex = 0;
2819 
2821  void SetViewIndex( int index )
2822  {
2823  m_ViewIndex = index;
2824 
2825  if( GetGame().IsServer() )
2826  {
2827  SetSynchDirty();
2828  }
2829  }
2830 
2832  int GetViewIndex()
2833  {
2834  if ( MemoryPointExists( "invView2" ) )
2835  {
2836  #ifdef PLATFORM_WINDOWS
2838  GetInventory().GetCurrentInventoryLocation( il );
2839  InventoryLocationType type = il.GetType();
2840  switch ( type )
2841  {
2842  case InventoryLocationType.CARGO:
2843  {
2844  return 0;
2845  }
2846  case InventoryLocationType.ATTACHMENT:
2847  {
2848  return 1;
2849  }
2850  case InventoryLocationType.HANDS:
2851  {
2852  return 0;
2853  }
2854  case InventoryLocationType.GROUND:
2855  {
2856  return 1;
2857  }
2858  case InventoryLocationType.PROXYCARGO:
2859  {
2860  return 0;
2861  }
2862  default:
2863  {
2864  return 0;
2865  }
2866  }
2867  #endif
2868 
2869  #ifdef PLATFORM_CONSOLE
2870  return 1;
2871  #endif
2872  }
2873  return 0;
2874  }
2876 
2878  string GetHitComponentForAI()
2879  {
2880  Debug.LogError("EntityAI: HitComponentForAI not set properly for that entity (" + GetType() + ")");
2882  return "";
2883  }
2884 
2886  string GetDefaultHitComponent()
2887  {
2888  Debug.LogError("EntityAI: DefaultHitComponent not set properly for that entity (" + GetType() + ")");
2890  return "";
2891  }
2892 
2895  {
2896  Debug.LogError("EntityAI: DefaultHitPositionComponent not set for that entity (" + GetType() + ")");
2897  return "";
2898  }
2899 
2901  {
2902  Debug.LogError("EntityAI: SuitableFinisherHitComponents not set for that entity (" + GetType() + ")");
2903  return null;
2904  }
2905 
2907  {
2908  Debug.LogError("EntityAI: DefaultHitPosition not set for that entity (" + GetType() + ")");
2909  return vector.Zero;
2910  }
2911 
2913  int GetMeleeTargetType()
2914  {
2915  return EMeleeTargetType.ALIGNABLE;
2916  }
2917 
2919  string GetAttachmentSoundType()
2920  {
2921  return "None";
2922  }
2923 
2925  bool IsHeavyBehaviour()
2926  {
2927  return false;
2928  }
2929 
2931  bool IsOneHandedBehaviour()
2932  {
2933  return false;
2934  }
2935 
2937  bool IsTwoHandedBehaviour()
2938  {
2939  return false;
2940  }
2941 
2942  string ChangeIntoOnAttach(string slot) {}
2943  string ChangeIntoOnDetach() {}
2944 
2957  void OnCEUpdate()
2958  {
2959  float currentTime = GetGame().GetTickTime();
2960  if (m_LastUpdatedTime == 0)
2961  m_LastUpdatedTime = currentTime;
2962 
2963  m_ElapsedSinceLastUpdate = currentTime - m_LastUpdatedTime;
2964  m_LastUpdatedTime = currentTime;
2965  }
2966 
2967  void OnDebugSpawnEx(DebugSpawnParams params)
2968  {
2969  OnDebugSpawn();
2970  }
2971 
2972  void OnDebugSpawn()
2973  {
2974  array<string> slots = new array<string>;
2975  ConfigGetTextArray("Attachments", slots);
2976 
2977  array<string> mags = new array<string>;
2978  ConfigGetTextArray("magazines", mags);
2979 
2980  //-------
2981 
2982  TStringArray all_paths = new TStringArray;
2983 
2984  all_paths.Insert(CFG_VEHICLESPATH);
2985  all_paths.Insert(CFG_MAGAZINESPATH);
2986  all_paths.Insert(CFG_WEAPONSPATH);
2987 
2988  string config_path;
2989  string child_name;
2990  int scope;
2991  string path;
2992  int consumable_count;
2993 
2994  for (int i = 0; i < all_paths.Count(); i++)
2995  {
2996  config_path = all_paths.Get(i);
2997  int children_count = GetGame().ConfigGetChildrenCount(config_path);
2998 
2999  for (int x = 0; x < children_count; x++)
3000  {
3001  GetGame().ConfigGetChildName(config_path, x, child_name);
3002  path = config_path + " " + child_name;
3003  scope = GetGame().ConfigGetInt( config_path + " " + child_name + " scope" );
3004  bool should_check = 1;
3005  if ( config_path == "CfgVehicles" && scope == 0)
3006  {
3007  should_check = 0;
3008  }
3009 
3010  if ( should_check )
3011  {
3012  string inv_slot;
3013  GetGame().ConfigGetText( config_path + " " + child_name + " inventorySlot",inv_slot );
3014  for (int z = 0; z < slots.Count(); z++)
3015  {
3016  if (slots.Get(z) == inv_slot)
3017  {
3018  this.GetInventory().CreateInInventory( child_name );
3019  continue;
3020  //Print("matching attachment: " + child_name + " for inv. slot name:" +inv_slot);
3021  }
3022  }
3023  }
3024  }
3025  }
3026  };
3027 
3028  override EntityAI ProcessMeleeItemDamage(int mode = 0)
3029  {
3030  if (GetGame().IsServer())
3031  AddHealth("","Health",-MELEE_ITEM_DAMAGE);
3032  return this;
3033  }
3034 
3036  float GetLiquidThroughputCoef()
3037  {
3039  }
3040 
3042  {
3043  return "";
3044  }
3045 
3046  void ProcessInvulnerabilityCheck(string servercfg_param)
3047  {
3048  if ( GetGame() && GetGame().IsMultiplayer() && GetGame().IsServer() )
3049  {
3050  int invulnerability;
3051  switch (servercfg_param)
3052  {
3053  case "disableContainerDamage":
3054  invulnerability = CfgGameplayHandler.GetDisableContainerDamage();
3055  break;
3056 
3057  case "disableBaseDamage":
3058  invulnerability = CfgGameplayHandler.GetDisableBaseDamage();
3059  break;
3060  }
3061 
3062  if (invulnerability > 0)
3063  {
3064  SetAllowDamage(false);
3065  }
3066  }
3067  }
3068 
3069  void SetBayonetAttached(bool pState, int slot_idx = -1) {};
3070  bool HasBayonetAttached() {};
3071  int GetBayonetAttachmentIdx() {};
3072 
3073  void SetButtstockAttached(bool pState, int slot_idx = -1) {};
3074  bool HasButtstockAttached() {};
3075  int GetButtstockAttachmentIdx() {};
3076 
3077  void SetInvisibleRecursive(bool invisible, EntityAI parent = null, array<int> attachments = null)
3078  {
3079  array<int> childrenAtt = new array<int>;
3080  array<int> attachmentsArray = new array<int>;
3081  if (attachments)
3082  attachmentsArray.Copy(attachments);
3083  else
3084  {
3085  for (int i = 0; i < GetInventory().GetAttachmentSlotsCount(); i++)
3086  {
3087  attachmentsArray.Insert(GetInventory().GetAttachmentSlotId(i));
3088  }
3089  }
3090 
3091  EntityAI item;
3092 
3093  foreach( int slot : attachmentsArray )
3094  {
3095  if( parent )
3096  item = parent.GetInventory().FindAttachment(slot);
3097  else
3098  item = this;//GetInventory().FindAttachment(slot);
3099 
3100  if( item )
3101  {
3102  if( item.GetInventory().AttachmentCount() > 0 )
3103  {
3104  for(i = 0; i < item.GetInventory().GetAttachmentSlotsCount(); i++)
3105  {
3106  childrenAtt.Insert(item.GetInventory().GetAttachmentSlotId(i));
3107  }
3108 
3109  SetInvisibleRecursive(invisible,item,childrenAtt);
3110  }
3111 
3112  item.SetInvisible(invisible);
3113  item.OnInvisibleSet(invisible);
3114  }
3115  }
3116  }
3117 
3118  void SoundHardTreeFallingPlay()
3119  {
3120  EffectSound sound = SEffectManager.PlaySound( "hardTreeFall_SoundSet", GetPosition() );
3121  sound.SetAutodestroy( true );
3122  }
3123 
3124  void SoundSoftTreeFallingPlay()
3125  {
3126  EffectSound sound = SEffectManager.PlaySound( "softTreeFall_SoundSet", GetPosition() );
3127  sound.SetAutodestroy( true );
3128  }
3129 
3130  void SoundHardBushFallingPlay()
3131  {
3132  EffectSound sound = SEffectManager.PlaySound( "hardBushFall_SoundSet", GetPosition() );
3133  sound.SetAutodestroy( true );
3134  }
3135 
3136  void SoundSoftBushFallingPlay()
3137  {
3138  EffectSound sound = SEffectManager.PlaySound( "softBushFall_SoundSet", GetPosition() );
3139  sound.SetAutodestroy( true );
3140  }
3141 
3142  void RegisterTransportHit(Transport transport)
3143  {
3144  if (!m_TransportHitRegistered)
3145  {
3146  m_TransportHitRegistered = true;
3147  m_TransportHitVelocity = GetVelocity(transport);
3148  Car car;
3149  float damage;
3150  vector impulse;
3151 
3152  // a different attempt to solve hits from "standing" car to the players
3153  if (Car.CastTo(car, transport))
3154  {
3155  if (car.GetSpeedometerAbsolute() > 2 )
3156  {
3157  damage = m_TransportHitVelocity.Length();
3158  ProcessDirectDamage(DT_CUSTOM, transport, "", "TransportHit", "0 0 0", damage);
3159  }
3160  else
3161  {
3162  m_TransportHitRegistered = false;
3163  }
3164 
3165  // compute impulse and apply only if the body dies
3166  if (IsDamageDestroyed() && car.GetSpeedometerAbsolute() > 3)
3167  {
3168  impulse = 40 * m_TransportHitVelocity;
3169  impulse[1] = 40 * 1.5;
3170  dBodyApplyImpulse(this, impulse);
3171  }
3172  }
3173  else //old solution just in case if somebody use it
3174  {
3175  // avoid damage because of small movements
3176  if (m_TransportHitVelocity.Length() > 0.1)
3177  {
3178  damage = m_TransportHitVelocity.Length();
3179  ProcessDirectDamage(DT_CUSTOM, transport, "", "TransportHit", "0 0 0", damage);
3180  }
3181  else
3182  {
3183  m_TransportHitRegistered = false;
3184  }
3185 
3186  // compute impulse and apply only if the body dies
3187  if (IsDamageDestroyed() && m_TransportHitVelocity.Length() > 0.3)
3188  {
3189  impulse = 40 * m_TransportHitVelocity;
3190  impulse[1] = 40 * 1.5;
3191  dBodyApplyImpulse(this, impulse);
3192  }
3193  }
3194  }
3195  }
3196 
3197  bool GetInventoryHandAnimation(notnull InventoryLocation loc, out int value)
3198  {
3199  value = -1;
3200  return false;
3201  }
3202 
3203  bool TranslateSlotFromSelection(string selection_name, out int slot_id)
3204  {
3205  return false;
3206  }
3207 
3209  bool IsUniversalTemperatureSource()
3210  {
3211  return GetUniversalTemperatureSource() != null && GetUniversalTemperatureSource().IsActive();
3212  }
3213 
3214  UTemperatureSource GetUniversalTemperatureSource()
3215  {
3216  return m_UniversalTemperatureSource;
3217  }
3218 
3219  void SetUniversalTemperatureSource(UTemperatureSource uts)
3220  {
3221  m_UniversalTemperatureSource = uts;
3222  }
3223 
3224  vector GetUniversalTemperatureSourcePosition()
3225  {
3226  return GetPosition();
3227  }
3228 
3231 
3232  void PairRemote(notnull EntityAI trigger);
3233 
3234  void UnpairRemote();
3235 
3236  EntityAI GetPairDevice();
3237 
3238  void SetPersistentPairID(int id)
3239  {
3241  if (raib)
3242  {
3243  raib.SetPersistentPairID(id);
3244  }
3245  }
3246 
3248  bool HasTurnableValveBehavior();
3249  bool IsValveTurnable(int pValveIndex);
3250  int GetTurnableValveIndex(int pComponentIndex);
3251  void ExecuteActionsConnectedToValve(int pValveIndex);
3252 
3254 // attachment exclusion section //
3256  private void InitAttachmentExclusionValues()
3257  {
3258  m_AttachmentExclusionSlotMap = new map<int,ref set<int>>();
3259  m_AttachmentExclusionMaskGlobal = new set<int>;
3260  m_AttachmentExclusionMaskChildren = new set<int>();
3261 
3262  int count = GetInventory().GetSlotIdCount();
3263  //no sense in performing inits for something that cannot be attached anywhere (hand/lefthand and some other 'special' slots are the reason for creating 'new' sets above)
3264  if (count == 0)
3265  return;
3266 
3267  InitInherentSlotExclusionMap();
3268  InitGlobalExclusionValues();
3269  InitLegacyConfigExclusionValues();
3270  }
3271 
3273  private void InitInherentSlotExclusionMap()
3274  {
3275  int count = GetInventory().GetSlotIdCount();
3276  //starting with the INVALID slot, so it is always in the map of attachable items
3277  SetAttachmentExclusionMaskSlot(InventorySlots.INVALID,GetAttachmentExclusionInitSlotValue(InventorySlots.INVALID));
3278 
3279  int slotId;
3280  for (int i = 0; i < count; i++)
3281  {
3282  slotId = GetInventory().GetSlotId(i);
3283  SetAttachmentExclusionMaskSlot(slotId,GetAttachmentExclusionInitSlotValue(slotId));
3284  }
3285  }
3286 
3288  protected set<int> GetAttachmentExclusionInitSlotValue(int slotId)
3289  {
3290  set<int> dflt = new set<int>;
3291  return dflt;
3292  }
3293 
3294  //Initiated last, and only for items that do not have others defined already
3295  protected void InitLegacyConfigExclusionValues()
3296  {
3297  bool performLegacyInit = InitLegacyExclusionCheck();
3298 
3299  //adding implicit slot info AFTER the check is performed
3300  InitLegacySlotExclusionValuesImplicit();
3301 
3302  if (performLegacyInit)
3303  InitLegacySlotExclusionValuesDerived();
3304  }
3305 
3306  //returns 'false' if the script initialization
3307  protected bool InitLegacyExclusionCheck()
3308  {
3309  //first check the globals
3310  if (m_AttachmentExclusionMaskGlobal.Count() > 0)
3311  return false;
3312 
3313  //now the map
3314  int count = m_AttachmentExclusionSlotMap.Count();
3315  if (count > 1) //more than InventorySlots.INVALID
3316  {
3317  for (int i = 0; i < count; i++)
3318  {
3319  int countSet = m_AttachmentExclusionSlotMap.GetElement(i).Count();
3320  if (countSet > 0) //SOMETHING is defined
3321  {
3322  return false;
3323  }
3324  }
3325  }
3326 
3327  return true;
3328  }
3329 
3335  protected void InitLegacySlotExclusionValuesImplicit()
3336  {
3337  int slotId;
3338  int slotCount = GetInventory().GetSlotIdCount();
3339  for (int i = 0; i < slotCount; i++)
3340  {
3341  slotId = GetInventory().GetSlotId(i);
3342  set<int> tmp;
3343  switch (slotId)
3344  {
3345  case InventorySlots.HEADGEAR:
3346  {
3347  tmp = new set<int>;
3348  tmp.Copy(GetAttachmentExclusionInitSlotValue(slotId));
3349  tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_MASK);
3350  tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_HEADSTRAP);
3351  tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_EYEWEWEAR);
3352  SetAttachmentExclusionMaskSlot(slotId,tmp);
3353  break;
3354  }
3355 
3356  case InventorySlots.MASK:
3357  {
3358  tmp = new set<int>;
3359  tmp.Copy(GetAttachmentExclusionInitSlotValue(slotId));
3360  tmp.Insert(EAttExclusions.LEGACY_MASK_HEADGEAR);
3361  tmp.Insert(EAttExclusions.LEGACY_MASK_HEADSTRAP);
3362  tmp.Insert(EAttExclusions.LEGACY_MASK_EYEWEWEAR);
3363  SetAttachmentExclusionMaskSlot(slotId,tmp);
3364  break;
3365  }
3366 
3367  case InventorySlots.EYEWEAR:
3368  {
3369  tmp = new set<int>;
3370  tmp.Copy(GetAttachmentExclusionInitSlotValue(slotId));
3371  if (ConfigGetBool("isStrap"))
3372  {
3373  tmp.Insert(EAttExclusions.LEGACY_HEADSTRAP_HEADGEAR);
3374  tmp.Insert(EAttExclusions.LEGACY_HEADSTRAP_MASK);
3375  }
3376  else
3377  {
3378  tmp.Insert(EAttExclusions.LEGACY_EYEWEAR_HEADGEAR);
3379  tmp.Insert(EAttExclusions.LEGACY_EYEWEAR_MASK);
3380  }
3381  SetAttachmentExclusionMaskSlot(slotId,tmp);
3382  break;
3383  }
3384  }
3385  }
3386  }
3387 
3388  protected void InitLegacySlotExclusionValuesDerived()
3389  {
3390  int slotId;
3391  int slotCount = GetInventory().GetSlotIdCount();
3392  for (int i = 0; i < slotCount; i++)
3393  {
3394  slotId = GetInventory().GetSlotId(i);
3395  set<int> tmp;
3396  switch (slotId)
3397  {
3398  case InventorySlots.HEADGEAR:
3399  {
3400  tmp = new set<int>;
3401  tmp.Copy(GetAttachmentExclusionMaskSlot(slotId));
3402  if (ConfigGetBool("noNVStrap"))
3403  {
3404  tmp.Insert(EAttExclusions.LEGACY_HEADSTRAP_HEADGEAR);
3405  }
3406  if (ConfigGetBool("noMask"))
3407  {
3408  tmp.Insert(EAttExclusions.LEGACY_MASK_HEADGEAR);
3409  }
3410  if (ConfigGetBool("noEyewear"))
3411  {
3412  tmp.Insert(EAttExclusions.LEGACY_EYEWEAR_HEADGEAR);
3413  }
3414  SetAttachmentExclusionMaskSlot(slotId,tmp);
3415  break;
3416  }
3417 
3418  case InventorySlots.MASK:
3419  {
3420  tmp = new set<int>;
3421  tmp.Copy(GetAttachmentExclusionMaskSlot(slotId));
3422  if (ConfigGetBool("noNVStrap"))
3423  {
3424  tmp.Insert(EAttExclusions.LEGACY_HEADSTRAP_MASK);
3425  }
3426  if (ConfigGetBool("noHelmet"))
3427  {
3428  tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_MASK);
3429  }
3430  if (ConfigGetBool("noEyewear"))
3431  {
3432  tmp.Insert(EAttExclusions.LEGACY_EYEWEAR_MASK);
3433  }
3434  SetAttachmentExclusionMaskSlot(slotId,tmp);
3435  break;
3436  }
3437 
3438  case InventorySlots.EYEWEAR:
3439  {
3440  tmp = new set<int>;
3441  tmp.Copy(GetAttachmentExclusionMaskSlot(slotId));
3442  if (ConfigGetBool("isStrap"))
3443  {
3444  if (ConfigGetBool("noHelmet"))
3445  {
3446  tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_HEADSTRAP);
3447  }
3448  if (ConfigGetBool("noMask"))
3449  {
3450  tmp.Insert(EAttExclusions.LEGACY_MASK_HEADSTRAP);
3451  }
3452  }
3453  else
3454  {
3455  if (ConfigGetBool("noHelmet"))
3456  {
3457  tmp.Insert(EAttExclusions.LEGACY_HEADGEAR_EYEWEWEAR);
3458  }
3459  if (ConfigGetBool("noMask"))
3460  {
3461  tmp.Insert(EAttExclusions.LEGACY_MASK_EYEWEWEAR);
3462  }
3463  }
3464  SetAttachmentExclusionMaskSlot(slotId,tmp);
3465  break;
3466  }
3467  }
3468  }
3469  }
3470 
3472  protected void InitGlobalExclusionValues();
3473 
3475  protected void AddSingleExclusionValueGlobal(EAttExclusions value)
3476  {
3477  if (m_AttachmentExclusionMaskGlobal.Find(value) == -1)
3478  m_AttachmentExclusionMaskGlobal.Insert(value);
3479  }
3480 
3482  protected void ClearSingleExclusionValueGlobal(EAttExclusions value)
3483  {
3484  int idx = m_AttachmentExclusionMaskGlobal.Find(value);
3485  if (idx != -1)
3486  m_AttachmentExclusionMaskGlobal.Remove(idx);
3487  }
3488 
3489  protected void SetAttachmentExclusionMaskGlobal(set<int> values)
3490  {
3491  m_AttachmentExclusionMaskGlobal.Clear();
3492  m_AttachmentExclusionMaskGlobal.Copy(values);
3493  }
3494 
3496  protected void SetAttachmentExclusionMaskSlot(int slotId, set<int> values)
3497  {
3498  if (m_AttachmentExclusionSlotMap)
3499  {
3500  m_AttachmentExclusionSlotMap.Set(slotId,values);
3501  }
3502  else
3503  ErrorEx("m_AttachmentExclusionSlotMap not available! Fill the 'inventorySlot[]' in the " + this + " config file.");
3504  }
3505 
3506  private void PropagateExclusionValueRecursive(set<int> values, int slotId)
3507  {
3508  if (values && values.Count() != 0)
3509  {
3510  set<int> passThis;
3512  GetInventory().GetCurrentInventoryLocation(lcn);
3513  if (CheckExclusionAccessPropagation(lcn.GetSlot(), slotId, values, passThis))
3514  {
3515  m_AttachmentExclusionMaskChildren.InsertSet(passThis);
3516  EntityAI parent = GetHierarchyParent();
3517  if (parent)
3518  parent.PropagateExclusionValueRecursive(passThis,lcn.GetSlot());
3519  }
3520  }
3521  }
3522 
3523  private void ClearExclusionValueRecursive(set<int> values, int slotId)
3524  {
3525  if (values && values.Count() != 0)
3526  {
3527  set<int> passThis;
3529  GetInventory().GetCurrentInventoryLocation(lcn);
3530  if (CheckExclusionAccessPropagation(lcn.GetSlot(), slotId, values, passThis))
3531  {
3532  int count = passThis.Count();
3533  for (int i = 0; i < count; i++)
3534  {
3535  m_AttachmentExclusionMaskChildren.RemoveItem(passThis[i]);
3536  }
3537  EntityAI parent = GetHierarchyParent();
3538  if (parent)
3539  parent.ClearExclusionValueRecursive(passThis,lcn.GetSlot());
3540  }
3541  }
3542  }
3543 
3545  set<int> GetAttachmentExclusionMaskAll(int slotId)
3546  {
3547  set<int> values = new set<int>();
3548  set<int> slotValues = GetAttachmentExclusionMaskSlot(slotId);
3549  if (slotValues)
3550  values.InsertSet(slotValues);
3551  values.InsertSet(m_AttachmentExclusionMaskGlobal);
3552  values.InsertSet(m_AttachmentExclusionMaskChildren);
3553 
3554  return values;
3555  }
3556 
3558  set<int> GetAttachmentExclusionMaskSlot(int slotId)
3559  {
3560  return m_AttachmentExclusionSlotMap.Get(slotId);
3561  }
3562 
3564  set<int> GetAttachmentExclusionMaskGlobal()
3565  {
3566  return m_AttachmentExclusionMaskGlobal;
3567  }
3568 
3570  set<int> GetAttachmentExclusionMaskChildren()
3571  {
3572  return m_AttachmentExclusionMaskChildren;
3573  }
3574 
3576  private bool HasInternalExclusionConflicts(int targetSlot)
3577  {
3578  set<int> targetSlotValues = GetAttachmentExclusionMaskSlot(targetSlot);
3579  if (targetSlotValues) //can be null, if so, no conflict
3580  {
3581  set<int> additionalValues = new set<int>(); //NOT slot values
3582  additionalValues.InsertSet(GetAttachmentExclusionMaskGlobal());
3583  additionalValues.InsertSet(GetAttachmentExclusionMaskChildren());
3584 
3585  int countTarget = targetSlotValues.Count();
3586  for (int i = 0; i < countTarget; i++)
3587  {
3588  if (additionalValues.Find(targetSlotValues[i]) != -1)
3589  {
3590  return true;
3591  }
3592  }
3593  }
3594  return false;
3595  }
3596 
3598  protected bool IsExclusionFlagPresent(set<int> values)
3599  {
3600  int slotId;
3601  string slotName;
3602  GetInventory().GetCurrentAttachmentSlotInfo(slotId,slotName); //if currently attached, treat it accordingly
3603 
3604  set<int> currentSlotValuesAll = GetAttachmentExclusionMaskAll(slotId);
3605  int count = values.Count();
3606  for (int i = 0; i < count; i++)
3607  {
3608  if (currentSlotValuesAll.Find(values[i]) != -1)
3609  return true;
3610  }
3611  return false;
3612  }
3613 
3615  protected bool IsExclusionFlagPresentRecursive(set<int> values, int targetSlot)
3616  {
3617  if (values && values.Count() != 0)
3618  {
3620  GetInventory().GetCurrentInventoryLocation(lcn);
3621  EntityAI parent = GetHierarchyParent();
3622  set<int> passThis;
3623  if (CheckExclusionAccessCondition(lcn.GetSlot(),targetSlot, values, passThis))
3624  {
3625  if (parent && parent != this) //we reached root if false
3626  {
3627  return parent.IsExclusionFlagPresentRecursive(passThis,lcn.GetSlot());
3628  }
3629  }
3630  return IsExclusionFlagPresent(passThis);
3631  }
3632 
3633  return false;
3634  }
3635 
3637  protected bool CheckExclusionAccessCondition(int occupiedSlot, int targetSlot, set<int> value, inout set<int> adjustedValue)
3638  {
3639  bool occupiedException = occupiedSlot == InventorySlots.HANDS || occupiedSlot == InventorySlots.SHOULDER || occupiedSlot == InventorySlots.MELEE || occupiedSlot == InventorySlots.LEFTHAND;
3640  bool targetException = targetSlot == InventorySlots.HANDS || targetSlot == InventorySlots.SHOULDER || targetSlot == InventorySlots.MELEE || targetSlot == InventorySlots.LEFTHAND;
3641 
3642  if (occupiedException)
3643  {
3644  adjustedValue = value;
3645  return false;
3646  }
3647 
3648  if (targetException)
3649  {
3650  adjustedValue = null;
3651  return false;
3652  }
3653 
3654  AdjustExclusionAccessCondition(occupiedSlot,targetSlot,value,adjustedValue);
3655  return adjustedValue.Count() != 0;
3656  }
3657 
3659  protected void AdjustExclusionAccessCondition(int occupiedSlot, int testedSlot, set<int> value, inout set<int> adjustedValue)
3660  {
3661  adjustedValue = value;
3662  }
3663 
3665  protected bool CheckExclusionAccessPropagation(int occupiedSlot, int targetSlot, set<int> value, inout set<int> adjustedValue)
3666  {
3667  bool occupiedException = occupiedSlot == InventorySlots.HANDS || occupiedSlot == InventorySlots.SHOULDER || occupiedSlot == InventorySlots.MELEE || occupiedSlot == InventorySlots.LEFTHAND;
3668  bool targetException = targetSlot == InventorySlots.HANDS || targetSlot == InventorySlots.SHOULDER || targetSlot == InventorySlots.MELEE || targetSlot == InventorySlots.LEFTHAND || targetSlot == InventorySlots.INVALID;
3669 
3670  if (targetException)
3671  {
3672  adjustedValue = null;
3673  return false;
3674  }
3675 
3676  AdjustExclusionAccessPropagation(occupiedSlot,targetSlot,value,adjustedValue);
3677  return adjustedValue.Count() != 0;
3678  }
3679 
3681  protected void AdjustExclusionAccessPropagation(int occupiedSlot, int testedSlot, set<int> value, inout set<int> adjustedValue)
3682  {
3683  AdjustExclusionAccessCondition(occupiedSlot,testedSlot,value,adjustedValue);
3684  }
3685 
3686  bool IsManagingArrows()
3687  {
3688  return false;
3689  }
3690 
3692  {
3693  return null;
3694  }
3695 
3696  void SetFromProjectile(ProjectileStoppedInfo info)
3697  {
3698  }
3699 
3700  void ClearInventory();
3701 };
3702 
3703 #ifdef DEVELOPER
3704 void SetDebugDeveloper_item(Object entity)//without a setter,the place where the setting happens is near impossible to find as way too many hits for "_item" exist
3705 {
3706  if (entity)
3707  entity.SetDebugItem();
3708 
3709 }
3710 Object _item;//watched item goes here(LCTRL+RMB->Watch)
3711 #endif
RF_DEFAULT
const int RF_DEFAULT
Definition: centraleconomy.c:65
ProjectileStoppedInfo
Definition: dayzgame.c:17
GetGame
proto native CGame GetGame()
CALL_CATEGORY_SYSTEM
const int CALL_CATEGORY_SYSTEM
Definition: tools.c:8
SOAKING
@ SOAKING
Definition: entityai.c:6
DAMP
@ DAMP
Definition: entityai.c:4
GetTemperatureInit
override float GetTemperatureInit()
Definition: itembase.c:3530
GetWet
override float GetWet()
Definition: itembase.c:3602
OnPlacementStarted
override void OnPlacementStarted(Man player)
Definition: itembase.c:3804
CanBeActionTarget
override bool CanBeActionTarget()
Definition: woodbase.c:246
OnWasAttached
override void OnWasAttached(EntityAI parent, int slot_id)
Definition: torch.c:945
ReplaceOnDeath
override bool ReplaceOnDeath()
Definition: animalbase.c:217
GetWeightSpecialized
override protected float GetWeightSpecialized(bool forceRecalc=false)
Definition: itembase.c:3341
BUSH_SOFT
enum EWetnessLevel BUSH_SOFT
GetHideIconMask
override int GetHideIconMask()
Definition: basebuildingbase.c:87
HIDE_PLAYER_CONTAINER
enum EWetnessLevel HIDE_PLAYER_CONTAINER
RemoveAgent
override void RemoveAgent(int agent_id)
Definition: itembase.c:3841
ComponentEnergyManager
Definition: componentenergymanager.c:18
RF_ORIGINAL
const int RF_ORIGINAL
Definition: centraleconomy.c:63
LogError
void LogError(string message, LogTemplateID template_id=0)
Creates error log (optional) from LogTemplate which are registred.
Definition: logtemplates.c:129
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
ADD
enum EWetnessLevel ADD
OnEnergyAdded
override void OnEnergyAdded()
Definition: itembase.c:3479
OnIgnitedThis
override void OnIgnitedThis(EntityAI fire_source)
Executed on Server when some item ignited this one.
Definition: fireworksbase.c:96
TREE_HARD
enum EWetnessLevel TREE_HARD
EEOnCECreate
override void EEOnCECreate()
Definition: fireworksbase.c:23
IsManagingArrows
override bool IsManagingArrows()
Definition: dayzanimal.c:70
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
EntityFlags
EntityFlags
Entity flags.
Definition: enentity.c:114
InventorySlots
provides access to slot configuration
Definition: inventoryslots.c:5
SetTemperatureMax
override void SetTemperatureMax()
Definition: itembase.c:3520
COMP_TYPE_ETITY_DEBUG
const int COMP_TYPE_ETITY_DEBUG
Definition: component.c:8
EEItemLocationChanged
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Definition: remotedetonator.c:72
DETACHING
enum EWetnessLevel DETACHING
GetSuitableFinisherHitComponents
array< string > GetSuitableFinisherHitComponents()
Definition: dayzplayer.c:507
TStringArray
array< string > TStringArray
Definition: enscript.c:685
OnAttachmentRuined
override void OnAttachmentRuined(EntityAI attachment)
Definition: fireplacebase.c:336
CanReceiveItemIntoCargo
override bool CanReceiveItemIntoCargo(EntityAI item)
Definition: container_base.c:72
OnCEUpdate
override void OnCEUpdate()
Definition: remotedetonator.c:87
IsDamageDestroyed
protected bool IsDamageDestroyed(ActionTarget target)
Definition: actionbase.c:913
DamageZoneMap
map< string, ref array< string > > DamageZoneMap
Definition: damagesystem.c:157
SpawnEntity
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
HiddenSelectionsData
Definition: hiddenselectionsdata.c:1
DoPlacingHeightCheck
override bool DoPlacingHeightCheck()
Definition: trap_smallfish.c:186
Component
Definition: componententitydebug.c:1
dBodyApplyImpulse
proto void dBodyApplyImpulse(notnull IEntity body, vector impulse)
Applies impuls on a rigidbody (origin)
CanBeSplit
override bool CanBeSplit()
Definition: itembase.c:1501
CanReleaseAttachment
override bool CanReleaseAttachment(EntityAI attachment)
Definition: fireplacebase.c:2654
Log
class LogTemplates Log(string message, LogTemplateID template_id=0)
Creates debug log (optional) from LogTemplate which are registred.
Definition: logtemplates.c:75
OnWorkStop
override void OnWorkStop()
Definition: m18smokegrenade_colorbase.c:2
GetTurnableValveIndex
override int GetTurnableValveIndex(int pComponentIndex)
Definition: land_underground_waterreservoir.c:468
EEParentedFrom
override void EEParentedFrom(EntityAI parent)
IsInitialized
bool IsInitialized()
Definition: huddebug.c:299
Print
proto void Print(void var)
Prints content of variable to console/log.
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
CanPutAsAttachment
override bool CanPutAsAttachment(EntityAI parent)
Definition: itembase.c:4021
IsTwoHandedBehaviour
override bool IsTwoHandedBehaviour()
Definition: itembase.c:4202
IsEmpty
override bool IsEmpty()
Definition: fireplacebase.c:2454
IsTakeable
override bool IsTakeable()
Definition: explosivesbase.c:197
EEHitByRemote
override void EEHitByRemote(int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos)
Definition: clockbase.c:128
OnVariablesSynchronized
override void OnVariablesSynchronized()
Definition: anniversarymusicsource.c:42
ATTACHING
enum EWetnessLevel ATTACHING
ECE_PLACE_ON_SURFACE
const int ECE_PLACE_ON_SURFACE
Definition: centraleconomy.c:37
OnDamageDestroyed
override void OnDamageDestroyed(int oldLevel)
Definition: animalbase.c:128
GetQuantityMax
override int GetQuantityMax()
Definition: itembase.c:3262
GetQuantity
override float GetQuantity()
Definition: itembase.c:3316
COMP_TYPE_COUNT
const int COMP_TYPE_COUNT
Definition: component.c:12
LogWarning
void LogWarning(string message, LogTemplateID template_id=0)
Creates warning log (optional) from LogTemplate which are registred.
Definition: logtemplates.c:111
LIQUID_THROUGHPUT_DEFAULT
const float LIQUID_THROUGHPUT_DEFAULT
Definition: constants.c:525
RemotelyActivatedItemBehaviour
Definition: remotelyactivateditembehaviour.c:1
component
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
ECE_OBJECT_SWAP
const int ECE_OBJECT_SWAP
Definition: centraleconomy.c:38
Param3
Definition: entityai.c:95
CEItemProfile
Definition: centraleconomy.c:748
InsertAgent
override void InsertAgent(int agent, float count=1)
Definition: itembase.c:3860
ToString
proto string ToString()
OnEnergyConsumed
override void OnEnergyConsumed()
Definition: itembase.c:3472
OnPlacementComplete
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Definition: explosivesbase.c:133
GetLiquidThroughputCoef
override float GetLiquidThroughputCoef()
Definition: carscript.c:486
RightFrontLimb
enum EWetnessLevel RightFrontLimb
ErrorEx
enum ShapeType ErrorEx
IEntity
Definition: enentity.c:164
SetTakeable
override void SetTakeable(bool pState)
Definition: itembase.c:4226
COMP_TYPE_ENERGY_MANAGER
const int COMP_TYPE_ENERGY_MANAGER
Definition: component.c:9
RemoveAllAgents
override void RemoveAllAgents()
Definition: itembase.c:3850
EEDelete
override void EEDelete(EntityAI parent)
Definition: contaminatedarea.c:69
GetDeadItemName
override string GetDeadItemName()
Definition: animalbase.c:227
CombineItemsClient
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Definition: itembase.c:849
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
GetTemperature
override float GetTemperature()
Definition: itembase.c:3525
OnRPC
void OnRPC(ParamsReadContext ctx)
Definition: displaystatus.c:216
OnWetChanged
override void OnWetChanged(float newVal, float oldVal)
Definition: itembase.c:3622
PlayerIdentity
The class that will be instanced (moddable)
Definition: gameplay.c:377
AddTemperature
override void AddTemperature(float value)
Definition: itembase.c:3515
WET
@ WET
Definition: entityai.c:5
ComponentBodyStaging
Definition: bodystaging.c:9
OnDebugSpawn
class Hatchback_02_Blue extends Hatchback_02 OnDebugSpawn
Definition: hatchback_02.c:404
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
MELEE_ITEM_DAMAGE
const float MELEE_ITEM_DAMAGE
Definition: constants.c:600
EffectSound
Wrapper class for managing sound through SEffectManager.
Definition: effectsound.c:4
TREE_SOFT
enum EWetnessLevel TREE_SOFT
GetAttachmentSoundType
override string GetAttachmentSoundType()
Definition: itembase.c:4250
CanPutIntoHands
override bool CanPutIntoHands(EntityAI parent)
Definition: explosivesbase.c:257
map
map
Definition: controlsxboxnew.c:3
GetSingleInventoryItemWeightEx
override float GetSingleInventoryItemWeightEx()
Definition: itembase.c:3327
vector
Definition: enconvert.c:105
ChangeIntoOnDetach
override string ChangeIntoOnDetach()
Definition: itembase.c:1348
CanPutInCargo
override bool CanPutInCargo(EntityAI parent)
Definition: explosivesbase.c:247
HasFlammableMaterial
override bool HasFlammableMaterial()
Definition: fireworksbase.c:41
GetWetMax
override float GetWetMax()
Definition: itembase.c:3607
AfterStoreLoad
void AfterStoreLoad()
Definition: emotemanager.c:577
EECargoIn
override void EECargoIn(EntityAI item)
Definition: bottle_base.c:70
CanAssignToQuickbar
override bool CanAssignToQuickbar()
Definition: crafting.c:79
InventoryMode
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition: inventory.c:21
IsHeavyBehaviour
override bool IsHeavyBehaviour()
Definition: itembase.c:4182
CFG_VEHICLESPATH
const string CFG_VEHICLESPATH
Definition: constants.c:209
UnpairRemote
override void UnpairRemote()
Definition: remotedetonator.c:109
HasTurnableValveBehavior
override bool HasTurnableValveBehavior()
Definition: land_underground_waterreservoir.c:328
TotalDamageResult
Definition: damagesystem.c:1
HIDE_VICINITY
enum EWetnessLevel HIDE_VICINITY
InventoryLocationType
InventoryLocationType
types of Inventory Location
Definition: inventorylocation.c:3
GetHitComponentForAI
string GetHitComponentForAI()
Definition: dayzplayer.c:485
DamageType
DamageType
exposed from C++ (do not change)
Definition: damagesystem.c:10
CargoBase
represents base for cargo storage for entities
Definition: cargo.c:6
GetTemperatureMin
override float GetTemperatureMin()
Definition: itembase.c:3535
IsDestructionBehaviour
override bool IsDestructionBehaviour()
Definition: animalbase.c:109
GetArrowManager
override ArrowManagerBase GetArrowManager()
Definition: animalbase.c:9
ALWAYS
enum EWetnessLevel ALWAYS
icon visibility, meant to be used in a bitmask
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
CanRemoveFromHands
override bool CanRemoveFromHands(EntityAI parent)
Definition: explosivesbase.c:267
OnItemAttachmentSlotChanged
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Definition: itembase.c:1183
PairRemote
override void PairRemote(notnull EntityAI trigger)
Definition: remotedetonator.c:104
GetDebugText
string GetDebugText()
Definition: modifierbase.c:68
GetTemperatureMax
override float GetTemperatureMax()
Definition: itembase.c:3540
OnWork
override void OnWork(float consumed_energy)
Definition: smokegrenadebase.c:195
Object
Definition: objecttyped.c:1
m_Player
DayZPlayer m_Player
Definition: hand_events.c:42
CanBePlaced
override bool CanBePlaced(Man player, vector position)
Definition: trapbase.c:605
slotName
PlayerSpawnPreset slotName
EEKilled
override void EEKilled(Object killer)
Definition: remotedetonator.c:242
EEOnAfterLoad
override void EEOnAfterLoad()
Definition: basebuildingbase.c:497
KillerData
Definition: killerdata.c:1
AddWet
override void AddWet(float value)
Definition: itembase.c:3592
GetRemotelyActivatedItemBehaviour
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Definition: remotedetonator.c:82
Transport
Base native class for all motorized wheeled vehicles.
Definition: car.c:79
SetQuantityToMinimum
override void SetQuantityToMinimum()
Definition: itembase.c:3232
CanRemoveFromCargo
override bool CanRemoveFromCargo(EntityAI parent)
Definition: basebuildingbase.c:927
OnWasDetached
override void OnWasDetached(EntityAI parent, int slot_id)
Definition: remotedetonator.c:237
EEHitBy
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Definition: broom.c:43
RemoveAllAgentsExcept
override void RemoveAllAgentsExcept(int agents_to_keep_mask)
Definition: itembase.c:3855
KeepHealthOnReplace
override bool KeepHealthOnReplace()
Definition: animalbase.c:232
EECargoOut
override void EECargoOut(EntityAI item)
Definition: fireplacebase.c:601
CFG_MAGAZINESPATH
const string CFG_MAGAZINESPATH
Definition: constants.c:211
REMOVE
enum EWetnessLevel REMOVE
CFG_WEAPONSPATH
const string CFG_WEAPONSPATH
Definition: constants.c:210
EWetnessLevel
EWetnessLevel
Definition: entityai.c:1
SetWetMax
override void SetWetMax()
Definition: itembase.c:3597
dBodyIsActive
proto native bool dBodyIsActive(notnull IEntity ent)
FindInventoryLocationType
FindInventoryLocationType
flags for searching locations in inventory
Definition: inventorylocation.c:15
CanSwapEntities
override bool CanSwapEntities(EntityAI otherItem, InventoryLocation otherDestination, InventoryLocation destination)
Definition: fireplacebase.c:2491
EActions
EActions
Definition: eactions.c:1
DumpStack
proto void DumpStack()
Prints current call stack (stack trace)
CfgGameplayHandler
Definition: cfggameplayhandler.c:1
IsOneHandedBehaviour
override bool IsOneHandedBehaviour()
Definition: itembase.c:4192
EntityAI
class LogManager EntityAI
IsPrepareToDelete
override bool IsPrepareToDelete()
Definition: fireplacebase.c:596
GetTargetQuantityMax
override int GetTargetQuantityMax(int attSlotID=-1)
Definition: itembase.c:3284
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
GetDefaultHitPosition
override vector GetDefaultHitPosition()
Definition: carscript.c:2592
LeftBackLimb
enum EWetnessLevel LeftBackLimb
AbstractAITargetCallbacks
Definition: aitarget_callbacks.c:4
x
Icon x
DRENCHED
@ DRENCHED
Definition: entityai.c:7
GetWetInit
override float GetWetInit()
Definition: itembase.c:3617
EOnFrame
protected override void EOnFrame(IEntity other, float timeSlice)
Definition: testframework.c:240
OnStoreSave
void OnStoreSave(ParamsWriteContext ctx)
Definition: modifierbase.c:229
UPDATE
enum EWetnessLevel UPDATE
IsBeingPlaced
override bool IsBeingPlaced()
Definition: itembase.c:946
OnMovedInsideCargo
override void OnMovedInsideCargo(EntityAI container)
Definition: itembase.c:1017
GetInvulnerabilityTypeString
override string GetInvulnerabilityTypeString()
Definition: basebuildingbase.c:77
int
Param3 int
CanBeCombined
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Definition: itembase.c:1956
EEHealthLevelChanged
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Definition: basebuildingbase.c:463
IsHologram
override bool IsHologram()
Definition: itembase.c:962
DestructionEffectBase
Definition: destructioneffectbase.c:1
GameConstants
Definition: constants.c:612
Debug
Definition: debug.c:13
Entity
Definition: camera.c:1
CanDisplayCargo
override bool CanDisplayCargo()
Definition: itembase.c:3998
FULL
enum EWetnessLevel FULL
GetQuickBarBonus
override int GetQuickBarBonus()
Definition: itembase.c:274
HIDE_HANDS_SLOT
enum EWetnessLevel HIDE_HANDS_SLOT
EEInit
override void EEInit()
Definition: contaminatedarea.c:27
BUSH_HARD
enum EWetnessLevel BUSH_HARD
SetTemperature
override void SetTemperature(float value, bool allow_client=false)
Definition: itembase.c:3499
IgnoreOutOfReachCondition
override bool IgnoreOutOfReachCondition()
Definition: basebuildingbase.c:547
m_Initialized
protected bool m_Initialized
Definition: uihintpanel.c:23
GetParent
proto native Widget GetParent()
Get parent of the Effect.
Definition: effect.c:405
GetDefaultHitComponent
string GetDefaultHitComponent()
Definition: dayzplayer.c:497
GetDestructionBehaviour
class Animal_CapraHircus extends AnimalBase GetDestructionBehaviour()
Definition: animalbase.c:104
ERPCs
ERPCs
Definition: erpcs.c:1
ChangeIntoOnAttach
override string ChangeIntoOnAttach(string slot)
Definition: itembase.c:1324
CanDisplayAttachmentCategory
override bool CanDisplayAttachmentCategory(string category_name)
Definition: civiliansedan.c:135
IsPendingDeletion
bool IsPendingDeletion()
Get whether the Effect is queued up for being cleaned up.
Definition: effect.c:256
CanLoadAttachment
override bool CanLoadAttachment(EntityAI attachment)
Definition: container_base.c:64
SAT_DEBUG_ACTION
const int SAT_DEBUG_ACTION
Definition: constants.c:424
OnWetLevelChanged
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Definition: itembase.c:3632
TSelectableActionInfo
Param3 TSelectableActionInfo
DRY
@ DRY
Definition: entityai.c:3
GetDefaultHitPositionComponent
string GetDefaultHitPositionComponent()
Definition: dayzplayer.c:502
GetWetLevel
override EWetnessLevel GetWetLevel()
Definition: itembase.c:3637
ClearInventory
override void ClearInventory()
Definition: itembase.c:3440
IsValveTurnable
override bool IsValveTurnable(int pValveIndex)
Definition: land_underground_waterreservoir.c:445
GetVelocity
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
EEItemAttached
override void EEItemAttached(EntityAI item, string slot_name)
Definition: basebuildingbase.c:520
IsRefresherSignalingViable
override bool IsRefresherSignalingViable()
Definition: animalbase.c:14
TSelectableActionInfoWithColor
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition: entityai.c:97
OnItemLocationChanged
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Definition: combinationlock.c:75
CanLoadItemIntoCargo
override bool CanLoadItemIntoCargo(EntityAI item)
Definition: container_base.c:80
SEffectManager
Manager class for managing Effect (EffectParticle, EffectSound)
Definition: effectmanager.c:5
COMP_TYPE_BODY_STAGING
const int COMP_TYPE_BODY_STAGING
Definition: component.c:10
RECURSIVE_ADD
enum EWetnessLevel RECURSIVE_ADD
CanReceiveAttachment
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Definition: basebuildingbase.c:895
EEItemDetached
override void EEItemDetached(EntityAI item, string slot_name)
Definition: basebuildingbase.c:529
CanBeIgnitedBy
override protected bool CanBeIgnitedBy(EntityAI igniter=NULL)
Definition: fireworksbase.c:102
OnStoreLoad
bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition: modifiersmanager.c:270
ArrowManagerBase
Definition: arrowmanagerbase.c:1
EntityAI
Definition: building.c:5
EEParentedTo
Ammo_40mm_Base EEParentedTo
OnPlacementCancelled
override void OnPlacementCancelled(Man player)
Definition: trap_tripwire.c:361
SetWet
override void SetWet(float value, bool allow_client=false)
Definition: itembase.c:3573
GetAgents
override int GetAgents()
Definition: itembase.c:3875
GetType
override int GetType()
Definition: huddebugwincharagents.c:49
Math3D
Definition: enmath3d.c:27
Shape
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
OnWorkStart
override void OnWorkStart()
Definition: smokegrenadebase.c:175
GetWetMin
override float GetWetMin()
Definition: itembase.c:3612
CanDisplayAttachmentSlot
override bool CanDisplayAttachmentSlot(int slot_id)
Definition: trap_tripwire.c:236
GameInventory
script counterpart to engine's class Inventory
Definition: inventory.c:78
LeftFrontLimb
enum EWetnessLevel LeftFrontLimb
DisassembleOnLastDetach
override bool DisassembleOnLastDetach()
Definition: fireplacebase.c:2701
GetCEApi
proto native CEApi GetCEApi()
Get the CE API.
ComponentsBank
Definition: componentsbank.c:1
path
string path
Definition: optionselectormultistate.c:135
OnExplosionEffects
override void OnExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal, float energyFactor, float explosionFactor, bool isWater, string ammoType)
Definition: destructioneffects.c:39
EMeleeTargetType
EMeleeTargetType
Definition: emeleetargettype.c:1
GetOrientation
vector GetOrientation()
Definition: areadamagemanager.c:306
ScriptInvoker
ScriptInvoker Class provide list of callbacks usage:
Definition: tools.c:115