Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
itembase.c
Go to the documentation of this file.
2 
3 class DummyItem extends ItemBase
4 {
5  override bool CanPutAsAttachment(EntityAI parent)
6  {
7  return true;
8  }
9 };
10 
11 //const bool QUANTITY_DEBUG_REMOVE_ME = false;
12 
13 class ItemBase extends InventoryItem
14 {
15  static ref map<typename, ref TInputActionMap> m_ItemTypeActionsMap = new map<typename, ref TInputActionMap>;
18 
19  static int m_DebugActionsMask;
21  // ============================================
22  // Variable Manipulation System
23  // ============================================
24  //ref map<string,string> m_ItemVarsString;
25 
26  int m_VariablesMask;//this holds information about which vars have been changed from their default values
27  // Quantity
28 
29  float m_VarQuantity;
30  float m_VarQuantityPrev;//for client to know quantity changed during synchronization
34  int m_Count;
35  float m_VarStackMax;
36  float m_StoreLoadedQuantity = float.LOWEST;
37  // Temperature
40  float m_VarTemperatureMin;
42  // Wet
43  float m_VarWet;
44  float m_VarWetPrev;//for client to know wetness changed during synchronization
45  float m_VarWetInit;
46  float m_VarWetMin;
47  float m_VarWetMax;
48  // Cleanness
53  // impact sounds
55  bool m_CanPlayImpactSound = true;
58  //
61  float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
63  int m_ItemBehaviour = -1; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
64  int m_QuickBarBonus = 0;
68  bool m_IsDeploySound;
69  bool m_IsTakeable;
71  bool m_ThrowItemOnDrop;
74  bool m_FixDamageSystemInit = false; //can be changed on storage version check
75  bool can_this_be_combined = false; //Check if item can be combined
76  bool m_CanThisBeSplit = false; //Check if item can be split
77  bool m_IsStoreLoad = false;
78  bool m_CanShowQuantity;
79  bool m_HasQuantityBar;
80  protected bool m_CanBeDigged;
81  protected bool m_IsResultOfSplit
82 
84 
86  // items color variables
91  //-------------------------------------------------------
92 
93  // light source managing
95 
99 
100  //==============================================
101  // agent system
102  private int m_AttachedAgents;
103 
106 
107 
108  // Weapons & suppressors particle effects
110  ref static map<int, ref array<ref WeaponParticlesOnBulletCasingEject>> m_OnBulletCasingEjectEffect;
112  ref static map<string, int> m_WeaponTypeToID;
113  static int m_LastRegisteredWeaponID = 0;
114 
115  // Overheating effects
117  float m_OverheatingShots;
119  int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
120  int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
121  float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
123 
125  protected bool m_HideSelectionsBySlot;
126 
127  // Admin Log
128  PluginAdminLog m_AdminLog;
129 
130  // misc
132 
133  // Attachment Locking variables
135  protected int m_LockType;
136  protected ref EffectSound m_LockingSound;
137  protected string m_LockSoundSet = "";
138 
139  protected EffectSound m_SoundPlace;
140  protected EffectSound m_SoundDeploy;
142 
143  // -------------------------------------------------------------------------
144  void ItemBase()
145  {
146  SetEventMask(EntityEvent.INIT); // Enable EOnInit event
147  InitItemVariables();
148 
152 
153  if (!GetGame().IsDedicatedServer())
154  {
155  if (HasMuzzle())
156  {
158 
159  if (m_ShotsToStartOverheating == 0)
160  {
162  }
163  }
164 
166  m_ActionsInitialize = false;
167  }
168 
169  m_OldLocation = null;
170 
171  if (GetGame().IsServer())
172  {
173  m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
174  }
175 
176  if (ConfigIsExisting("headSelectionsToHide"))
177  {
179  ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
180  }
181 
183  if (ConfigIsExisting("hideSelectionsByinventorySlot"))
184  {
185  m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
186  }
187 
188 
189 
190  m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
191 
192  m_IsResultOfSplit = false;
193  }
194 
195  void InitItemVariables()
196  {
197  m_VarQuantityInit = ConfigGetInt("varQuantityInit");
198  m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
199  m_VarQuantityMin = ConfigGetInt("varQuantityMin");
200  m_VarQuantityMax = ConfigGetInt("varQuantityMax");
201  m_VarStackMax = ConfigGetFloat("varStackMax");
202  m_Count = ConfigGetInt("count");
203 
204  m_CanShowQuantity = ConfigGetBool("quantityShow");
205  m_HasQuantityBar = ConfigGetBool("quantityBar");
206 
207  m_VarTemperatureInit = ConfigGetFloat("varTemperatureInit");
209  m_VarTemperatureMin = ConfigGetFloat("varTemperatureMin");
210  m_VarTemperatureMax = ConfigGetFloat("varTemperatureMax");
211 
212 
213  m_CleannessInit = ConfigGetInt("varCleannessInit");
215  m_CleannessMin = ConfigGetInt("varCleannessMin");
216  m_CleannessMax = ConfigGetInt("varCleannessMax");
217 
218  m_WantPlayImpactSound = false;
219  m_ImpactSpeed = 0.0;
220 
221  m_VarWetInit = ConfigGetFloat("varWetInit");
223  m_VarWetMin = ConfigGetFloat("varWetMin");
224  m_VarWetMax = ConfigGetFloat("varWetMax");
225 
227  m_IsBeingPlaced = false;
228  m_IsHologram = false;
229  m_IsPlaceSound = false;
230  m_IsDeploySound = false;
231  m_IsTakeable = true;
232  m_IsSoundSynchRemote = false;
233  m_CanBeMovedOverride = false;
237  m_CanBeDigged = ConfigGetBool("canBeDigged");
238 
239  ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
240  m_LockType = ConfigGetInt("lockType");
241 
242  //Define if item can be split and set ability to be combined accordingly
243  if (ConfigIsExisting("canBeSplit"))
244  {
245  can_this_be_combined = ConfigGetBool("canBeSplit");
247  }
248 
249  if (ConfigIsExisting("itemBehaviour"))
250  m_ItemBehaviour = ConfigGetInt("itemBehaviour");
251 
252  //RegisterNetSyncVariableInt("m_VariablesMask");
253  if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
254  RegisterNetSyncVariableFloat("m_VarTemperature", GetTemperatureMin(),GetTemperatureMax());
255  RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
256  RegisterNetSyncVariableInt("m_VarLiquidType");
257  RegisterNetSyncVariableInt("m_Cleanness",0,1);
258 
259  RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
260  RegisterNetSyncVariableFloat("m_ImpactSpeed");
261  RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
262 
263  RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
264  RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
265  RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
266  RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
267 
268  RegisterNetSyncVariableBool("m_IsBeingPlaced");
269  RegisterNetSyncVariableBool("m_IsTakeable");
270  RegisterNetSyncVariableBool("m_IsHologram");
271 
272  if (UsesGlobalDeploy())
273  {
274  RegisterNetSyncVariableBool("m_IsSoundSynchRemote");
275  RegisterNetSyncVariableBool("m_IsDeploySound");
276  }
277 
278  m_LockSoundSet = ConfigGetString("lockSoundSet");
279  }
280 
281  // allows for checking whether or not we can safely register net sync variables without causing VMEs for duplicate registration
282  protected bool UsesGlobalDeploy()
283  {
284  return false;
285  }
286 
287  override int GetQuickBarBonus()
288  {
289  return m_QuickBarBonus;
290  }
291 
292  void InitializeActions()
293  {
294  m_InputActionMap = m_ItemTypeActionsMap.Get(this.Type());
295  if (!m_InputActionMap)
296  {
298  m_InputActionMap = iam;
299  SetActions();
300  m_ItemTypeActionsMap.Insert(this.Type(), m_InputActionMap);
301  }
302  }
303 
304  override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
305  {
306  if (!m_ActionsInitialize)
307  {
308  m_ActionsInitialize = true;
310  }
311 
312  actions = m_InputActionMap.Get(action_input_type);
313  }
314 
315  void SetActions()
316  {
322  }
323 
324  void AddAction(typename actionName)
325  {
326  ActionBase action = ActionManagerBase.GetAction(actionName);
327 
328  if (!action)
329  {
330  Debug.LogError("Action " + actionName + " dosn't exist!");
331  return;
332  }
333 
334  typename ai = action.GetInputType();
335  if (!ai)
336  {
337  m_ActionsInitialize = false;
338  return;
339  }
340 
341  array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
342  if (!action_array)
343  {
344  action_array = new array<ActionBase_Basic>;
345  m_InputActionMap.Insert(ai, action_array);
346  }
347  if (LogManager.IsActionLogEnable())
348  {
349  Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
350  }
351 
352  if (action_array.Find(action) != -1)
353  {
354  Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
355  }
356  else
357  {
358  action_array.Insert(action);
359  }
360  }
361 
362  void RemoveAction(typename actionName)
363  {
364  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
365  ActionBase action = player.GetActionManager().GetAction(actionName);
366  typename ai = action.GetInputType();
368 
369  if (action_array)
370  {
371  action_array.RemoveItem(action);
372  }
373  }
374 
376 
378 
379  // Loads muzzle flash particle configuration from config and saves it to a map for faster access
380  void LoadParticleConfigOnFire(int id)
381  {
382  if (!m_OnFireEffect)
383  m_OnFireEffect = new map<int, ref array<ref WeaponParticlesOnFire>>;
384 
385  if (!m_OnBulletCasingEjectEffect)
386  m_OnBulletCasingEjectEffect = new map<int, ref array<ref WeaponParticlesOnBulletCasingEject>>;
387 
388  string config_to_search = "CfgVehicles";
389  string muzzle_owner_config;
390 
391  if (!m_OnFireEffect.Contains(id))
392  {
393  if (IsInherited(Weapon))
394  config_to_search = "CfgWeapons";
395 
396  muzzle_owner_config = config_to_search + " " + GetType() + " ";
397 
398  string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
399 
400  int config_OnFire_subclass_count = GetGame().ConfigGetChildrenCount(config_OnFire_class);
401 
402  if (config_OnFire_subclass_count > 0)
403  {
405 
406  for (int i = 0; i < config_OnFire_subclass_count; i++)
407  {
408  string particle_class = "";
409  GetGame().ConfigGetChildName(config_OnFire_class, i, particle_class);
410  string config_OnFire_entry = config_OnFire_class + particle_class;
411  WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
412  WPOF_array.Insert(WPOF);
413  }
414 
415 
416  m_OnFireEffect.Insert(id, WPOF_array);
417  }
418  }
419 
420  if (!m_OnBulletCasingEjectEffect.Contains(id))
421  {
422  config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
423  muzzle_owner_config = config_to_search + " " + GetType() + " ";
424 
425  string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
426 
427  int config_OnBulletCasingEject_count = GetGame().ConfigGetChildrenCount(config_OnBulletCasingEject_class);
428 
429  if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
430  {
432 
433  for (i = 0; i < config_OnBulletCasingEject_count; i++)
434  {
435  string particle_class2 = "";
436  GetGame().ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
437  string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
438  WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
439  WPOBE_array.Insert(WPOBE);
440  }
441 
442 
443  m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
444  }
445  }
446  }
447 
448  // Loads muzzle flash particle configuration from config and saves it to a map for faster access
450  {
453 
454  if (!m_OnOverheatingEffect.Contains(id))
455  {
456  string config_to_search = "CfgVehicles";
457 
458  if (IsInherited(Weapon))
459  config_to_search = "CfgWeapons";
460 
461  string muzzle_owner_config = config_to_search + " " + GetType() + " ";
462  string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
463 
464  if (GetGame().ConfigIsExisting(config_OnOverheating_class))
465  {
466 
467  m_ShotsToStartOverheating = GetGame().ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
468 
469  if (m_ShotsToStartOverheating == 0)
470  {
471  m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
472  string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
473  Error(error);
474  return;
475  }
476 
477  m_OverheatingDecayInterval = GetGame().ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
478  m_MaxOverheatingValue = GetGame().ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
479 
480 
481 
482  int config_OnOverheating_subclass_count = GetGame().ConfigGetChildrenCount(config_OnOverheating_class);
484 
485  for (int i = 0; i < config_OnOverheating_subclass_count; i++)
486  {
487  string particle_class = "";
488  GetGame().ConfigGetChildName(config_OnOverheating_class, i, particle_class);
489  string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
490  int entry_type = GetGame().ConfigGetType(config_OnOverheating_entry);
491 
492  if (entry_type == CT_CLASS)
493  {
494  WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
495  WPOOH_array.Insert(WPOF);
496  }
497  }
498 
499 
500  m_OnOverheatingEffect.Insert(id, WPOOH_array);
501  }
502  }
503  }
504 
505  float GetOverheatingValue()
506  {
507  return m_OverheatingShots;
508  }
509 
510  void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
511  {
512  if (m_MaxOverheatingValue > 0)
513  {
515 
516  if (!m_CheckOverheating)
518 
519  m_CheckOverheating.Stop();
520  m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
521 
522  CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
523  }
524  }
525 
526  void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
527  {
529  UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
530 
532  StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
533 
535  StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
536 
538  {
540  }
541  }
542 
544  {
546  }
547 
548  void OnOverheatingDecay()
549  {
550  if (m_MaxOverheatingValue > 0)
551  m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
552  else
554 
555  if (m_OverheatingShots <= 0)
556  {
557  m_CheckOverheating.Stop();
558  m_OverheatingShots = 0;
559  }
560  else
561  {
562  if (!m_CheckOverheating)
564 
566  m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
567  }
568 
569  CheckOverheating(this, "", this);
570  }
571 
572  void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
573  {
575  ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
576  }
577 
578  void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
579  {
581  ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
583  }
584 
585  void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
586  {
588  ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
589  }
590 
591  void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
592  {
595 
597  OP.RegisterParticle(p);
598  OP.SetOverheatingLimitMin(min_heat_coef);
599  OP.SetOverheatingLimitMax(max_heat_coef);
600  OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
601 
602  m_OverheatingParticles.Insert(OP);
603  }
604 
605  float GetOverheatingCoef()
606  {
607  if (m_MaxOverheatingValue > 0)
609 
610  return -1;
611  }
612 
614  {
616  {
617  float overheat_coef = GetOverheatingCoef();
618  int count = m_OverheatingParticles.Count();
619 
620  for (int i = count; i > 0; --i)
621  {
622  int id = i - 1;
624  Particle p = OP.GetParticle();
625 
626  float overheat_min = OP.GetOverheatingLimitMin();
627  float overheat_max = OP.GetOverheatingLimitMax();
628 
629  if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
630  {
631  if (p)
632  {
633  p.Stop();
634  OP.RegisterParticle(null);
635  }
636  }
637  }
638  }
639  }
640 
642  {
644  {
645  for (int i = m_OverheatingParticles.Count(); i > 0; i--)
646  {
647  int id = i - 1;
649 
650  if (OP)
651  {
652  Particle p = OP.GetParticle();
653 
654  if (p)
655  {
656  p.Stop();
657  }
658 
659  delete OP;
660  }
661  }
662 
663  m_OverheatingParticles.Clear();
664  delete m_OverheatingParticles;
665  }
666  }
667 
669  float GetInfectionChance(int system = 0, Param param = null)
670  {
671  return 0.0;
672  }
673 
674 
675  float GetDisinfectQuantity(int system = 0, Param param1 = null)
676  {
677  return 250;//default value
678  }
679 
680  float GetFilterDamageRatio()
681  {
682  return 0;
683  }
684 
686  bool HasMuzzle()
687  {
688  if (IsInherited(Weapon) || IsInherited(SuppressorBase))
689  return true;
690 
691  return false;
692  }
693 
695  int GetMuzzleID()
696  {
697  if (!m_WeaponTypeToID)
698  m_WeaponTypeToID = new map<string, int>;
699 
700  if (m_WeaponTypeToID.Contains(GetType()))
701  {
702  return m_WeaponTypeToID.Get(GetType());
703  }
704  else
705  {
706  // Register new weapon ID
707  m_WeaponTypeToID.Insert(GetType(), ++m_LastRegisteredWeaponID);
708  }
709 
710  return m_LastRegisteredWeaponID;
711  }
712 
718  int GetDamageSystemVersionChange()
719  {
720  return -1;
721  }
722 
723 
724 
725  // -------------------------------------------------------------------------
726  void ~ItemBase()
727  {
728  #ifndef SERVER
730  m_DeployLoopSoundEx.SoundStop();
731  #endif
732 
733  if (GetGame() && GetGame().GetPlayer() && (!GetGame().IsDedicatedServer()))
734  {
735  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
736  int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
737 
738  if (r_index >= 0)
739  {
741  player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
742 
743  player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
744  int r_type = r_il.GetType();
745  if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
746  {
747  r_il.GetParent().GetOnReleaseLock().Invoke(this);
748  }
749  else if (r_type == InventoryLocationType.ATTACHMENT)
750  {
751  r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
752  }
753 
754  }
755 
756  player.GetHumanInventory().ClearUserReservedLocation(this);
757  }
758 
759  SEffectManager.DestroyEffect(m_LockingSound);
760  }
761 
762 
763 
764  // -------------------------------------------------------------------------
765  static int GetDebugActionsMask()
766  {
767  return ItemBase.m_DebugActionsMask;
768  }
769 
770  static bool HasDebugActionsMask(int mask)
771  {
772  return ItemBase.m_DebugActionsMask & mask;
773  }
774 
775  static void SetDebugActionsMask(int mask)
776  {
777  ItemBase.m_DebugActionsMask = mask;
778  }
779 
780  static void AddDebugActionsMask(int mask)
781  {
782  ItemBase.m_DebugActionsMask |= mask;
783  }
784 
785  static void RemoveDebugActionsMask(int mask)
786  {
787  ItemBase.m_DebugActionsMask &= ~mask;
788  }
789 
790  static void ToggleDebugActionsMask(int mask)
791  {
792  if (HasDebugActionsMask(mask))
793  {
794  RemoveDebugActionsMask(mask);
795  }
796  else
797  {
798  AddDebugActionsMask(mask);
799  }
800  }
801 
802  // -------------------------------------------------------------------------
803  void SetCEBasedQuantity()
804  {
805  if (GetEconomyProfile())
806  {
807  float q_max = GetEconomyProfile().GetQuantityMax();
808  if (q_max > 0)
809  {
810  float q_min = GetEconomyProfile().GetQuantityMin();
811  float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
812 
813  if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
814  {
815  ComponentEnergyManager comp = GetCompEM();
816  if (comp && (comp.GetEnergyMaxPristine() || comp.GetEnergyAtSpawn()))//checking for a potential for energy, we need to check both values, as both are optional, only when both are set to 0, we know the item can't have energy
817  {
818  //Print("setting EM quantity for " + this + " to " + quantity_randomized);
819  comp.SetEnergy0To1(quantity_randomized);
820  }
821  /*
822  else
823  Print("NOT setting EM quantity for " + this + " to " + quantity_randomized);
824  */
825  }
826  else if (HasQuantity())
827  {
828  SetQuantityNormalized(quantity_randomized, false);
829  //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
830  }
831 
832  }
833  }
834  }
835 
838  {
839  EntityAI parent = GetHierarchyParent();
840 
841  if (parent)
842  {
843  InventoryLocation inventory_location_to_lock = new InventoryLocation;
844  GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
845  parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
846  }
847  }
848 
850  void UnlockFromParent()
851  {
852  EntityAI parent = GetHierarchyParent();
853 
854  if (parent)
855  {
856  InventoryLocation inventory_location_to_unlock = new InventoryLocation;
857  GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
858  parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
859  }
860  }
861 
862  override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
863  {
864  /*
865  ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
866  RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, GetGame().GetPlayer());
867  */
868  ItemBase item2 = ItemBase.Cast(entity2);
869 
870  if (GetGame().IsClient())
871  {
872  if (ScriptInputUserData.CanStoreInputUserData())
873  {
875  ctx.Write(INPUT_UDT_ITEM_MANIPULATION);
876  ctx.Write(-1);
877  ItemBase i1 = this; // @NOTE: workaround for correct serialization
878  ctx.Write(i1);
879  ctx.Write(item2);
880  ctx.Write(use_stack_max);
881  ctx.Write(-1);
882  ctx.Send();
883 
884  if (IsCombineAll(item2, use_stack_max))
885  {
886  GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
887  }
888  }
889  }
890  else if (!GetGame().IsMultiplayer())
891  {
892  CombineItems(item2, use_stack_max);
893  }
894  }
895 
896  bool IsLiquidPresent()
897  {
898 
899  return (GetLiquidType() != 0 && HasQuantity());
900  }
901 
902  bool IsLiquidContainer()
903  {
904  return (ConfigGetFloat("liquidContainerType") != 0);
905  }
906 
907  bool IsBloodContainer()
908  {
909  return false;
910  }
911 
912  bool IsNVG()
913  {
914  return false;
915  }
916 
919  bool IsExplosive()
920  {
921  return false;
922  }
923 
925  {
926  return "";
927  }
928 
930 
931  bool IsLightSource()
932  {
933  return false;
934  }
935 
936  bool CanBeRepairedByCrafting()
937  {
938  return true;
939  }
940 
941  //--- ACTION CONDITIONS
942  //direction
943  bool IsFacingPlayer(PlayerBase player, string selection)
944  {
945  return true;
946  }
947 
948  bool IsPlayerInside(PlayerBase player, string selection)
949  {
950  return true;
951  }
952 
953  override bool CanObstruct()
954  {
955  PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
956  return !player || !IsPlayerInside(player, "");
957  }
958 
959  override bool IsBeingPlaced()
960  {
961  return m_IsBeingPlaced;
962  }
963 
964  void SetIsBeingPlaced(bool is_being_placed)
965  {
966  m_IsBeingPlaced = is_being_placed;
967  if (!is_being_placed)
968  OnEndPlacement();
969  SetSynchDirty();
970  }
971 
972  //server-side
973  void OnEndPlacement() {}
974 
975  override bool IsHologram()
976  {
977  return m_IsHologram;
978  }
979 
980  bool CanBeDigged()
981  {
982  return m_CanBeDigged;
983  }
984 
985  bool CanMakeGardenplot()
986  {
987  return false;
988  }
989 
990  void SetIsHologram(bool is_hologram)
991  {
992  m_IsHologram = is_hologram;
993  SetSynchDirty();
994  }
995  /*
996  protected float GetNutritionalEnergy()
997  {
998  Edible_Base edible = Edible_Base.Cast(this);
999  return edible.GetFoodEnergy();
1000  }
1001 
1002  protected float GetNutritionalWaterContent()
1003  {
1004  Edible_Base edible = Edible_Base.Cast(this);
1005  return edible.GetFoodWater();
1006  }
1007 
1008  protected float GetNutritionalIndex()
1009  {
1010  Edible_Base edible = Edible_Base.Cast(this);
1011  return edible.GetFoodNutritionalIndex();
1012  }
1013 
1014  protected float GetNutritionalFullnessIndex()
1015  {
1016  Edible_Base edible = Edible_Base.Cast(this);
1017  return edible.GetFoodTotalVolume();
1018  }
1019 
1020  protected float GetNutritionalToxicity()
1021  {
1022  Edible_Base edible = Edible_Base.Cast(this);
1023  return edible.GetFoodToxicity();
1025  }
1026  */
1027 
1028 
1029  // -------------------------------------------------------------------------
1030  override void OnMovedInsideCargo(EntityAI container)
1031  {
1032  super.OnMovedInsideCargo(container);
1033 
1034  MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
1035  }
1036 
1037  override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
1038  {
1039  super.EEItemLocationChanged(oldLoc,newLoc);
1040 
1041  PlayerBase new_player = null;
1042  PlayerBase old_player = null;
1043 
1044  if (newLoc.GetParent())
1045  new_player = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
1046 
1047  if (oldLoc.GetParent())
1048  old_player = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
1049 
1050  if (old_player && oldLoc.GetType() == InventoryLocationType.HANDS)
1051  {
1052  int r_index = old_player.GetHumanInventory().FindUserReservedLocationIndex(this);
1053 
1054  if (r_index >= 0)
1055  {
1057  old_player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
1058 
1059  old_player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
1060  int r_type = r_il.GetType();
1061  if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
1062  {
1063  r_il.GetParent().GetOnReleaseLock().Invoke(this);
1064  }
1065  else if (r_type == InventoryLocationType.ATTACHMENT)
1066  {
1067  r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
1068  }
1069 
1070  }
1071  }
1072 
1073  if (newLoc.GetType() == InventoryLocationType.HANDS)
1074  {
1075  if (new_player)
1076  new_player.ForceStandUpForHeavyItems(newLoc.GetItem());
1077 
1078  if (new_player == old_player)
1079  {
1080 
1081  if (oldLoc.GetParent() && !(oldLoc.GetParent() != new_player && oldLoc.GetType() == InventoryLocationType.ATTACHMENT) && new_player.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
1082  {
1083  if (oldLoc.GetType() == InventoryLocationType.CARGO)
1084  {
1085  if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
1086  {
1087  new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
1088  }
1089  }
1090  else
1091  {
1092  new_player.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
1093  }
1094  }
1095 
1096  if (new_player.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
1097  {
1098  int type = oldLoc.GetType();
1099  if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
1100  {
1101  oldLoc.GetParent().GetOnSetLock().Invoke(this);
1102  }
1103  else if (type == InventoryLocationType.ATTACHMENT)
1104  {
1105  oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
1106  }
1107  }
1108  if (!m_OldLocation)
1109  {
1110  m_OldLocation = new InventoryLocation;
1111  }
1112  m_OldLocation.Copy(oldLoc);
1113  }
1114  else
1115  {
1116  if (m_OldLocation)
1117  {
1118  m_OldLocation.Reset();
1119  }
1120  }
1121 
1122  GetGame().GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
1123  }
1124  else
1125  {
1126  if (new_player)
1127  {
1128  int res_index = new_player.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
1129  if (res_index >= 0)
1130  {
1132  new_player.GetHumanInventory().GetUserReservedLocation(res_index,il);
1133  ItemBase it = ItemBase.Cast(il.GetItem());
1134  new_player.GetHumanInventory().ClearUserReservedLocationAtIndex(res_index);
1135  int rel_type = il.GetType();
1136  if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
1137  {
1138  il.GetParent().GetOnReleaseLock().Invoke(it);
1139  }
1140  else if (rel_type == InventoryLocationType.ATTACHMENT)
1141  {
1142  il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
1143  }
1144  //it.GetOnReleaseLock().Invoke(it);
1145  }
1146  }
1147  else if (old_player && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
1148  {
1149  //Print("---ThrowPhysically---");
1150  //ThrowPhysically(old_player, vector.Zero);
1151  m_ThrowItemOnDrop = false;
1152  }
1153 
1154  if (m_OldLocation)
1155  {
1156  m_OldLocation.Reset();
1157  }
1158  }
1159  }
1160 
1161  override void EOnContact(IEntity other, Contact extra)
1162  {
1164  {
1165  int liquidType = -1;
1166  float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
1167  if (impactSpeed > 0.0)
1168  {
1169  m_ImpactSpeed = impactSpeed;
1170  #ifndef SERVER
1171  PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
1172  #else
1173  m_WantPlayImpactSound = true;
1174  SetSynchDirty();
1175  #endif
1176  m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
1177  }
1178  }
1179 
1180  #ifdef SERVER
1181  if (GetCompEM() && GetCompEM().IsPlugged())
1182  {
1183  if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
1184  GetCompEM().UnplugThis();
1185  }
1186  #endif
1187  }
1189  void RefreshPhysics();
1190 
1191  override void OnCreatePhysics()
1192  {
1193  RefreshPhysics();
1194  }
1195 
1196  override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
1197  {
1198 
1199  }
1200  // -------------------------------------------------------------------------
1201  override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
1202  {
1203  super.OnItemLocationChanged(old_owner, new_owner);
1204 
1205  Man ownerPlayerOld = null;
1206  Man ownerPlayerNew = null;
1207 
1208  if (old_owner)
1209  {
1210  if (old_owner.IsMan())
1211  {
1212  ownerPlayerOld = Man.Cast(old_owner);
1213  }
1214  else
1215  {
1216  ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
1217  }
1218  }
1219 
1220  if (new_owner)
1221  {
1222  if (new_owner.IsMan())
1223  {
1224  ownerPlayerNew = Man.Cast(new_owner);
1225  }
1226  else
1227  {
1228  ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
1229  }
1230  }
1231 
1232  if (ownerPlayerOld != ownerPlayerNew)
1233  {
1234  if (ownerPlayerOld)
1235  {
1236  array<EntityAI> subItemsExit = new array<EntityAI>;
1237  GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
1238  for (int i = 0; i < subItemsExit.Count(); i++)
1239  {
1240  ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
1241  itemExit.OnInventoryExit(ownerPlayerOld);
1242  }
1243  }
1244 
1245  if (ownerPlayerNew)
1246  {
1247  array<EntityAI> subItemsEnter = new array<EntityAI>;
1248  GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
1249  for (int j = 0; j < subItemsEnter.Count(); j++)
1250  {
1251  ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
1252  itemEnter.OnInventoryEnter(ownerPlayerNew);
1253  }
1254  }
1255  }
1256  }
1257 
1258  // -------------------------------------------------------------------------------
1259  override void EEDelete(EntityAI parent)
1260  {
1261  super.EEDelete(parent);
1262  PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
1263  if (player)
1264  {
1265  OnInventoryExit(player);
1266 
1267  if (player.IsAlive())
1268  {
1269  int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
1270  if (r_index >= 0)
1271  {
1273  player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
1274 
1275  player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
1276  int r_type = r_il.GetType();
1277  if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
1278  {
1279  r_il.GetParent().GetOnReleaseLock().Invoke(this);
1280  }
1281  else if (r_type == InventoryLocationType.ATTACHMENT)
1282  {
1283  r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
1284  }
1285 
1286  }
1287 
1288  player.RemoveQuickBarEntityShortcut(this);
1289  }
1290  }
1291  }
1292  // -------------------------------------------------------------------------------
1293  override void EEKilled(Object killer)
1294  {
1295  super.EEKilled(killer);
1296 
1298  if (killer && killer.IsFireplace() && CanExplodeInFire())
1299  {
1300  if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
1301  {
1302  if (IsMagazine())
1303  {
1304  if (Magazine.Cast(this).GetAmmoCount() > 0)
1305  {
1306  ExplodeAmmo();
1307  }
1308  }
1309  else
1310  {
1311  Explode(DamageType.EXPLOSION);
1312  }
1313  }
1314  }
1315  }
1317  override void OnWasAttached(EntityAI parent, int slot_id)
1318  {
1319  MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
1320 
1321  super.OnWasAttached(parent, slot_id);
1322 
1323  if (HasQuantity())
1324  UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
1325 
1326  PlayAttachSound(InventorySlots.GetSlotName(slot_id));
1327  }
1328 
1329  override void OnWasDetached(EntityAI parent, int slot_id)
1330  {
1331  super.OnWasDetached(parent, slot_id);
1332 
1333  if (HasQuantity())
1334  UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
1335  }
1336 
1337  override string ChangeIntoOnAttach(string slot)
1338  {
1339  int idx;
1340  TStringArray inventory_slots = new TStringArray;
1341  TStringArray attach_types = new TStringArray;
1342 
1343  ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
1344  if (inventory_slots.Count() < 1) //is string
1345  {
1346  inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
1347  attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
1348  }
1349  else //is array
1350  {
1351  ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
1352  }
1353 
1354  idx = inventory_slots.Find(slot);
1355  if (idx < 0)
1356  return "";
1357 
1358  return attach_types.Get(idx);
1359  }
1360 
1361  override string ChangeIntoOnDetach()
1362  {
1363  int idx = -1;
1364  string slot;
1365 
1366  TStringArray inventory_slots = new TStringArray;
1367  TStringArray detach_types = new TStringArray;
1368 
1369  this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
1370  if (inventory_slots.Count() < 1) //is string
1371  {
1372  inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
1373  detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
1374  }
1375  else //is array
1376  {
1377  this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
1378  if (detach_types.Count() < 1)
1379  detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
1380  }
1381 
1382  for (int i = 0; i < inventory_slots.Count(); i++)
1383  {
1384  slot = inventory_slots.Get(i);
1385  }
1386 
1387  if (slot != "")
1388  {
1389  if (detach_types.Count() == 1)
1390  idx = 0;
1391  else
1392  idx = inventory_slots.Find(slot);
1393  }
1394  if (idx < 0)
1395  return "";
1396 
1397  return detach_types.Get(idx);
1398  }
1399 
1401  {
1402  //timer
1403  ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
1404 
1405  //min/max time
1406  float min_time = 1;
1407  float max_time = 3;
1408  float delay = Math.RandomFloat(min_time, max_time);
1409 
1410  explode_timer.Run(delay, this, "DoAmmoExplosion");
1411  }
1412 
1413  void DoAmmoExplosion()
1414  {
1415  Magazine magazine = Magazine.Cast(this);
1416  int pop_sounds_count = 6;
1417  string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
1418 
1419  //play sound
1420  int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
1421  string sound_name = pop_sounds[ sound_idx ];
1422  GetGame().CreateSoundOnObject(this, sound_name, 20, false);
1423 
1424  //remove ammo count
1425  magazine.ServerAddAmmoCount(-1);
1426 
1427  //if condition then repeat -> ExplodeAmmo
1428  float min_temp_to_explode = 100; //min temperature for item to explode
1429 
1430  if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
1431  {
1432  ExplodeAmmo();
1433  }
1434  }
1435 
1436  // -------------------------------------------------------------------------------
1437  override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
1438  {
1439  super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
1440 
1441  const int CHANCE_DAMAGE_CARGO = 4;
1442  const int CHANCE_DAMAGE_ATTACHMENT = 1;
1443  const int CHANCE_DAMAGE_NOTHING = 2;
1444 
1445  if (IsClothing() || IsContainer() || IsItemTent())
1446  {
1447  float dmg = damageResult.GetDamage("","Health") * -0.5;
1448  int chances;
1449  int rnd;
1450 
1451  if (GetInventory().GetCargo())
1452  {
1453  chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
1454  rnd = Math.RandomInt(0,chances);
1455 
1456  if (rnd < CHANCE_DAMAGE_CARGO)
1457  {
1458  DamageItemInCargo(dmg);
1459  }
1460  else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
1461  {
1462  DamageItemAttachments(dmg);
1463  }
1464  }
1465  else
1466  {
1467  chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
1468  rnd = Math.RandomInt(0,chances);
1469 
1470  if (rnd < CHANCE_DAMAGE_ATTACHMENT)
1471  {
1472  DamageItemAttachments(dmg);
1473  }
1474  }
1475  }
1476  }
1477 
1478  bool DamageItemInCargo(float damage)
1479  {
1480  if (GetInventory().GetCargo())
1481  {
1482  int item_count = GetInventory().GetCargo().GetItemCount();
1483  if (item_count > 0)
1484  {
1485  int random_pick = Math.RandomInt(0, item_count);
1486  ItemBase item = ItemBase.Cast(GetInventory().GetCargo().GetItem(random_pick));
1487  if (!item.IsExplosive())
1488  {
1489  item.AddHealth("","",damage);
1490  return true;
1491  }
1492  }
1493  }
1494  return false;
1495  }
1496 
1497  bool DamageItemAttachments(float damage)
1498  {
1499  int attachment_count = GetInventory().AttachmentCount();
1500  if (attachment_count > 0)
1501  {
1502  int random_pick = Math.RandomInt(0, attachment_count);
1503  ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(random_pick));
1504  if (!attachment.IsExplosive())
1505  {
1506  attachment.AddHealth("","",damage);
1507  return true;
1508  }
1509  }
1510  return false;
1511  }
1512 
1513  //----------------
1514  override bool CanBeSplit()
1515  {
1516  if (m_CanThisBeSplit)
1517  return (GetQuantity() > 1);
1518 
1519  return false;
1520  }
1521 
1522  void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
1523  {
1524  if (GetGame().IsClient())
1525  {
1526  if (ScriptInputUserData.CanStoreInputUserData())
1527  {
1529  ctx.Write(INPUT_UDT_ITEM_MANIPULATION);
1530  ctx.Write(1);
1531  ItemBase i1 = this; // @NOTE: workaround for correct serialization
1532  ctx.Write(i1);
1533  ctx.Write(destination_entity);
1534  ctx.Write(true);
1535  ctx.Write(slot_id);
1536  ctx.Send();
1537  }
1538  }
1539  else if (!GetGame().IsMultiplayer())
1540  {
1541  SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(GetGame().GetPlayer()));
1542  }
1543  }
1544 
1545  void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
1546  {
1547  float split_quantity_new;
1548  ref ItemBase new_item;
1549  float quantity = GetQuantity();
1550  float stack_max = GetTargetQuantityMax(slot_id);
1552 
1553  if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
1554  {
1555  if (stack_max <= GetQuantity())
1556  split_quantity_new = stack_max;
1557  else
1558  split_quantity_new = GetQuantity();
1559 
1560  new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
1561  if (new_item)
1562  {
1563  new_item.SetResultOfSplit(true);
1564  MiscGameplayFunctions.TransferItemProperties(this, new_item);
1565  AddQuantity(-split_quantity_new);
1566  new_item.SetQuantity(split_quantity_new);
1567  }
1568  }
1569  else if (destination_entity && slot_id == -1)
1570  {
1571  if (quantity > stack_max)
1572  split_quantity_new = stack_max;
1573  else
1574  split_quantity_new = quantity;
1575 
1576  if (destination_entity.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
1577  {
1578  Object o = destination_entity.GetInventory().LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
1579  new_item = ItemBase.Cast(o);
1580  }
1581 
1582  if (new_item)
1583  {
1584  new_item.SetResultOfSplit(true);
1585  MiscGameplayFunctions.TransferItemProperties(this, new_item);
1586  AddQuantity(-split_quantity_new);
1587  new_item.SetQuantity(split_quantity_new);
1588  }
1589  }
1590  else
1591  {
1592  if (stack_max != 0)
1593  {
1594  if (stack_max < GetQuantity())
1595  {
1596  split_quantity_new = GetQuantity() - stack_max;
1597  }
1598 
1599  if (split_quantity_new == 0)
1600  {
1601  if (!GetGame().IsMultiplayer())
1602  player.PhysicalPredictiveDropItem(this);
1603  else
1604  player.ServerDropEntity(this);
1605  return;
1606  }
1607 
1608  new_item = ItemBase.Cast(GetGame().CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
1610  if (new_item)
1611  {
1612  new_item.SetResultOfSplit(true);
1613  MiscGameplayFunctions.TransferItemProperties(this, new_item);
1614  SetQuantity(split_quantity_new);
1615  new_item.SetQuantity(stack_max);
1616  new_item.PlaceOnSurface();
1617  }
1618  }
1619  }
1620  }
1621 
1623  {
1624  if (GetGame().IsClient())
1625  {
1626  if (ScriptInputUserData.CanStoreInputUserData())
1627  {
1629  ctx.Write(INPUT_UDT_ITEM_MANIPULATION);
1630  ctx.Write(4);
1631  ItemBase thiz = this; // @NOTE: workaround for correct serialization
1632  ctx.Write(thiz);
1633  dst.WriteToContext(ctx);
1634  ctx.Send();
1635  }
1636  }
1637  else if (!GetGame().IsMultiplayer())
1638  {
1640  }
1641  }
1642 
1643  void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
1644  {
1645  if (GetGame().IsClient())
1646  {
1647  if (ScriptInputUserData.CanStoreInputUserData())
1648  {
1650  ctx.Write(INPUT_UDT_ITEM_MANIPULATION);
1651  ctx.Write(2);
1652  ItemBase dummy = this; // @NOTE: workaround for correct serialization
1653  ctx.Write(dummy);
1654  ctx.Write(destination_entity);
1655  ctx.Write(true);
1656  ctx.Write(idx);
1657  ctx.Write(row);
1658  ctx.Write(col);
1659  ctx.Send();
1660  }
1661  }
1662  else if (!GetGame().IsMultiplayer())
1663  {
1664  SplitIntoStackMaxCargo(destination_entity, idx, row, col);
1665  }
1666  }
1667 
1669  {
1671  }
1672 
1674  {
1675  float quantity = GetQuantity();
1676  float split_quantity_new;
1677  ItemBase new_item;
1678  if (dst.IsValid())
1679  {
1680  int slot_id = dst.GetSlot();
1681  float stack_max = GetTargetQuantityMax(slot_id);
1682 
1683  if (quantity > stack_max)
1684  split_quantity_new = stack_max;
1685  else
1686  split_quantity_new = quantity;
1687 
1688  new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
1689 
1690  if (new_item)
1691  {
1692  new_item.SetResultOfSplit(true);
1693  MiscGameplayFunctions.TransferItemProperties(this,new_item);
1694  AddQuantity(-split_quantity_new);
1695  new_item.SetQuantity(split_quantity_new);
1696  }
1697 
1698  return new_item;
1699  }
1700 
1701  return null;
1702  }
1703 
1704  void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
1705  {
1706  float quantity = GetQuantity();
1707  float split_quantity_new;
1708  ref ItemBase new_item;
1709  if (destination_entity)
1710  {
1711  float stackable = GetTargetQuantityMax();
1712  if (quantity > stackable)
1713  split_quantity_new = stackable;
1714  else
1715  split_quantity_new = quantity;
1716 
1717  new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
1718  if (new_item)
1719  {
1720  new_item.SetResultOfSplit(true);
1721  MiscGameplayFunctions.TransferItemProperties(this,new_item);
1722  AddQuantity(-split_quantity_new);
1723  new_item.SetQuantity(split_quantity_new);
1724  }
1725  }
1726  }
1727 
1729  {
1730  if (GetGame().IsClient())
1731  {
1732  if (ScriptInputUserData.CanStoreInputUserData())
1733  {
1735  ctx.Write(INPUT_UDT_ITEM_MANIPULATION);
1736  ctx.Write(3);
1737  ItemBase i1 = this; // @NOTE: workaround for correct serialization
1738  ctx.Write(i1);
1739  ItemBase destination_entity = this;
1740  ctx.Write(destination_entity);
1741  ctx.Write(true);
1742  ctx.Write(0);
1743  ctx.Send();
1744  }
1745  }
1746  else if (!GetGame().IsMultiplayer())
1747  {
1748  SplitIntoStackMaxHands(player);
1749  }
1750  }
1751 
1752  void SplitIntoStackMaxHands(PlayerBase player)
1753  {
1754  float quantity = GetQuantity();
1755  float split_quantity_new;
1756  ref ItemBase new_item;
1757  if (player)
1758  {
1759  float stackable = GetTargetQuantityMax();
1760  if (quantity > stackable)
1761  split_quantity_new = stackable;
1762  else
1763  split_quantity_new = quantity;
1765  EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
1766  new_item = ItemBase.Cast(in_hands);
1767  if (new_item)
1768  {
1769  new_item.SetResultOfSplit(true);
1770  MiscGameplayFunctions.TransferItemProperties(this,new_item);
1771  AddQuantity(-split_quantity_new);
1772  new_item.SetQuantity(split_quantity_new);
1773  }
1774  }
1775  }
1776 
1778  {
1779  if (!CanBeSplit())
1780  return;
1781 
1782  float quantity = GetQuantity();
1783  float split_quantity_new = Math.Floor(quantity * 0.5);
1784 
1785  ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
1786 
1787  if (new_item)
1788  {
1789  if (new_item.GetQuantityMax() < split_quantity_new)
1790  {
1791  split_quantity_new = new_item.GetQuantityMax();
1792  }
1793 
1794  new_item.SetResultOfSplit(true);
1795  MiscGameplayFunctions.TransferItemProperties(this, new_item);
1796 
1797  if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
1798  {
1799  AddQuantity(-1);
1800  new_item.SetQuantity(1);
1801  }
1802  else
1803  {
1804  AddQuantity(-split_quantity_new);
1805  new_item.SetQuantity(split_quantity_new);
1806  }
1807  }
1808  }
1809 
1810  void SplitItem(PlayerBase player)
1811  {
1812  if (!CanBeSplit())
1813  {
1814  return;
1815  }
1816 
1817  float quantity = GetQuantity();
1818  float split_quantity_new = Math.Floor(quantity / 2);
1819 
1820  InventoryLocation invloc = new InventoryLocation;
1821  bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
1822 
1823  ItemBase new_item;
1824  new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
1825 
1826  if (new_item)
1827  {
1828  if (new_item.GetQuantityMax() < split_quantity_new)
1829  {
1830  split_quantity_new = new_item.GetQuantityMax();
1831  }
1832  if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
1833  {
1834  AddQuantity(-1);
1835  new_item.SetQuantity(1);
1836  }
1837  else
1838  {
1839  AddQuantity(-split_quantity_new);
1840  new_item.SetQuantity(split_quantity_new);
1841  }
1842  }
1843  }
1844 
1846  void OnQuantityChanged(float delta)
1847  {
1848  SetWeightDirty();
1849  ItemBase parent = ItemBase.Cast(GetHierarchyParent());
1850 
1851  if (parent)
1852  {
1853  parent.OnAttachmentQuantityChangedEx(this, delta);
1854  }
1855  }
1859  {
1860  // insert code here
1861  }
1862 
1864  void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
1865  {
1867  }
1868 
1869  override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
1870  {
1871  super.EEHealthLevelChanged(oldLevel,newLevel,zone);
1872 
1873  if (GetGame().IsServer())
1874  {
1875  if (newLevel == GameConstants.STATE_RUINED)
1876  {
1878  EntityAI parent = GetHierarchyParent();
1879  if (parent && parent.IsFireplace())
1880  {
1881  CargoBase cargo = GetInventory().GetCargo();
1882  if (cargo)
1883  {
1884  for (int i = 0; i < cargo.GetItemCount(); ++i)
1885  {
1886  parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
1887  }
1888  }
1889  }
1890  }
1891 
1892  if (IsResultOfSplit())
1893  {
1894  // reset the splitting result flag, return to normal item behavior
1895  SetResultOfSplit(false);
1896  return;
1897  }
1898 
1899  if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
1900  {
1901  SetCleanness(0);//unclean the item upon damage dealt
1902  }
1903  }
1904  }
1905 
1906  // just the split? TODO: verify
1907  override void OnRightClick()
1908  {
1909  super.OnRightClick();
1910 
1911  if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !GetGame().GetPlayer().GetInventory().HasInventoryReservation(this,null))
1912  {
1913  if (GetGame().IsClient())
1914  {
1915  if (ScriptInputUserData.CanStoreInputUserData())
1916  {
1917  vector m4[4];
1918  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
1919 
1920  EntityAI root = GetHierarchyRoot();
1921 
1923  if (!player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.CARGO, dst))
1924  {
1925  if (root)
1926  {
1927  root.GetTransform(m4);
1928  dst.SetGround(this, m4);
1929  }
1930  else
1931  GetInventory().GetCurrentInventoryLocation(dst);
1932  }
1933  else
1934  {
1935  dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
1936  if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(null, dst))
1937  {
1938  if (root)
1939  {
1940  root.GetTransform(m4);
1941  dst.SetGround(this, m4);
1942  }
1943  else
1944  GetInventory().GetCurrentInventoryLocation(dst);
1945  }
1946  else
1947  {
1948  GetGame().GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
1949  }
1950  }
1951 
1953  ctx.Write(INPUT_UDT_ITEM_MANIPULATION);
1954  ctx.Write(4);
1955  ItemBase thiz = this; // @NOTE: workaround for correct serialization
1956  ctx.Write(thiz);
1957  dst.WriteToContext(ctx);
1958  ctx.Write(true); // dummy
1959  ctx.Send();
1960  }
1961  }
1962  else if (!GetGame().IsMultiplayer())
1963  {
1965  }
1966  }
1967  }
1968 
1969  override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
1970  {
1971  //Print("CanBeCombined - " + this + ": " + GetQuantity() + " + " + other_item + ": " + other_item.GetQuantity());
1972  //TODO: delete check zero quantity check after fix double posts hands fsm events
1973  if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
1974  return false;
1975 
1976  if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
1977  return false;
1978 
1979  //can_this_be_combined = ConfigGetBool("canBeSplit");
1980  if (!can_this_be_combined)
1981  return false;
1982 
1983 
1984  Magazine mag = Magazine.Cast(this);
1985  if (mag)
1986  {
1987  if (mag.GetAmmoCount() >= mag.GetAmmoMax())
1988  return false;
1989 
1990  if (stack_max_limit)
1991  {
1992  Magazine other_mag = Magazine.Cast(other_item);
1993  if (other_item)
1994  {
1995  if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
1996  return false;
1997  }
1998 
1999  }
2000  }
2001  else
2002  {
2003  //TODO: delete check zero quantity check after fix double posts hands fsm events
2004  if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
2005  return false;
2006 
2007  if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
2008  return false;
2009  }
2010 
2011  PlayerBase player = null;
2012  if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
2013  {
2014  if (player.GetInventory().HasAttachment(this))
2015  return false;
2016 
2017  if (player.IsItemsToDelete())
2018  return false;
2019  }
2020 
2021  if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
2022  return false;
2023 
2024  int slotID;
2025  string slotName;
2026  if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
2027  return false;
2028 
2029  return true;
2030  }
2031 
2032  bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
2033  {
2034  return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
2035  }
2036 
2037  bool IsResultOfSplit()
2038  {
2039  return m_IsResultOfSplit;
2040  }
2041 
2042  void SetResultOfSplit(bool value)
2043  {
2044  m_IsResultOfSplit = value;
2045  }
2046 
2047  int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
2048  {
2049  return ComputeQuantityUsedEx(other_item, use_stack_max);
2050  }
2051 
2052  float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
2053  {
2054  float other_item_quantity = other_item.GetQuantity();
2055  float this_free_space;
2056 
2057  float stack_max = GetQuantityMax();
2059  this_free_space = stack_max - GetQuantity();
2060 
2061  if (other_item_quantity > this_free_space)
2062  {
2063  return this_free_space;
2064  }
2065  else
2066  {
2067  return other_item_quantity;
2068  }
2069  }
2070 
2071  void CombineItems(ItemBase other_item, bool use_stack_max = true)
2072  {
2073  if (!CanBeCombined(other_item, false))
2074  return;
2075 
2076  if (!IsMagazine() && other_item)
2077  {
2078  float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
2079  if (quantity_used != 0)
2080  {
2081  float hp1 = GetHealth01("","");
2082  float hp2 = other_item.GetHealth01("","");
2083  float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
2084  hpResult = hpResult / (GetQuantity() + quantity_used);
2085 
2086  hpResult *= GetMaxHealth();
2087  Math.Round(hpResult);
2088  SetHealth("", "Health", hpResult);
2089 
2090  AddQuantity(quantity_used);
2091  other_item.AddQuantity(-quantity_used);
2092  }
2093  }
2094  OnCombine(other_item);
2095  }
2096 
2097  void OnCombine(ItemBase other_item)
2098  {
2099  #ifdef SERVER
2100  if (!GetHierarchyRootPlayer() && GetHierarchyParent())
2101  GetHierarchyParent().IncreaseLifetimeUp();
2102  #endif
2103  };
2104 
2105  void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
2106  {
2107  PlayerBase p = PlayerBase.Cast(player);
2108 
2109  array<int> recipesIds = p.m_Recipes;
2110  PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
2111  if (moduleRecipesManager)
2112  {
2113  EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
2114  moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
2115  }
2116 
2117  for (int i = 0;i < recipesIds.Count(); i++)
2118  {
2119  int key = recipesIds.Get(i);
2120  string recipeName = moduleRecipesManager.GetRecipeName(key);
2121  outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
2122  }
2123  }
2124 
2125  // -------------------------------------------------------------------------
2126  override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
2127  {
2128  super.GetDebugActions(outputList);
2129 
2130  //quantity
2131  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
2132  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
2133  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
2134  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
2135 
2136  //health
2137  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
2138  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
2139  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
2140  //temperature
2141  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
2142  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
2143 
2144  //wet
2145  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
2146  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
2147 
2148  //liquidtype
2149  if (IsLiquidContainer())
2150  {
2151  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
2152  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
2153  }
2154 
2155  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
2156  // watch
2157  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
2158  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
2159 
2160  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "", FadeColors.RED));
2161  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
2162  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "", FadeColors.RED));
2163  }
2164 
2165  // -------------------------------------------------------------------------
2166  // -------------------------------------------------------------------------
2167  // -------------------------------------------------------------------------
2168  override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
2169  {
2170  super.OnAction(action_id, player, ctx);
2171  if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
2172  {
2173  PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
2174  int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
2175  PlayerBase p = PlayerBase.Cast(player);
2176  if (EActions.RECIPES_RANGE_START < 1000)
2177  {
2178  float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
2179  float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
2180  }
2181  }
2182  #ifndef SERVER
2183  else if (action_id == EActions.WATCH_PLAYER)
2184  {
2185  PluginDeveloper.SetDeveloperItemClientEx(player);
2186  }
2187  #endif
2188  if (GetGame().IsServer())
2189  {
2190  if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
2191  {
2192  int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
2193  OnDebugButtonPressServer(id + 1);
2194  }
2195 
2196  else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
2197  {
2198  int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
2199  InsertAgent(agent_id,100);
2200  }
2201 
2202  else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
2203  {
2204  int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
2205  RemoveAgent(agent_id2);
2206  }
2207 
2208  else if (action_id == EActions.ADD_QUANTITY)
2209  {
2210  if (IsMagazine())
2211  {
2212  Magazine mag = Magazine.Cast(this);
2213  mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
2214  }
2215  else
2216  {
2217  AddQuantity(GetQuantityMax() * 0.2);
2218  }
2219 
2220  if (m_EM)
2221  {
2222  m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
2223  }
2224  //PrintVariables();
2225  }
2226 
2227  else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
2228  {
2229  if (IsMagazine())
2230  {
2231  Magazine mag2 = Magazine.Cast(this);
2232  mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
2233  }
2234  else
2235  {
2236  AddQuantity(- GetQuantityMax() * 0.2);
2237  }
2238  if (m_EM)
2239  {
2240  m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
2241  }
2242  //PrintVariables();
2243  }
2244 
2245  else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
2246  {
2247  SetQuantity(0);
2248 
2249  if (m_EM)
2250  {
2251  m_EM.SetEnergy(0);
2252  }
2253  }
2254 
2255  else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
2256  {
2257  SetQuantityMax();
2258 
2259  if (m_EM)
2260  {
2261  m_EM.SetEnergy(m_EM.GetEnergyMax());
2262  }
2263  }
2264 
2265  else if (action_id == EActions.ADD_HEALTH)
2266  {
2267  AddHealth("","",GetMaxHealth("","Health")/5);
2268  }
2269  else if (action_id == EActions.REMOVE_HEALTH)
2270  {
2271  AddHealth("","",-GetMaxHealth("","Health")/5);
2272  }
2273  else if (action_id == EActions.DESTROY_HEALTH)
2274  {
2275  SetHealth01("","",0);
2276  }
2277  else if (action_id == EActions.WATCH_ITEM)
2278  {
2280  mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
2281  #ifdef DEVELOPER
2282  SetDebugDeveloper_item(this);
2283  #endif
2284  }
2285 
2286  else if (action_id == EActions.ADD_TEMPERATURE)
2287  {
2288  AddTemperature(20);
2289  //PrintVariables();
2290  }
2291 
2292  else if (action_id == EActions.REMOVE_TEMPERATURE)
2293  {
2294  AddTemperature(-20);
2295  //PrintVariables();
2296  }
2297 
2298  else if (action_id == EActions.ADD_WETNESS)
2299  {
2300  AddWet(GetWetMax()/5);
2301  //PrintVariables();
2302  }
2303 
2304  else if (action_id == EActions.REMOVE_WETNESS)
2305  {
2306  AddWet(-GetWetMax()/5);
2307  //PrintVariables();
2308  }
2309 
2310  else if (action_id == EActions.LIQUIDTYPE_UP)
2311  {
2312  int curr_type = GetLiquidType();
2313  SetLiquidType(curr_type * 2);
2314  //AddWet(1);
2315  //PrintVariables();
2316  }
2317 
2318  else if (action_id == EActions.LIQUIDTYPE_DOWN)
2319  {
2320  int curr_type2 = GetLiquidType();
2321  SetLiquidType(curr_type2 / 2);
2322  }
2323 
2324  else if (action_id == EActions.MAKE_SPECIAL)
2325  {
2326  auto debugParams = DebugSpawnParams.WithPlayer(player);
2327  OnDebugSpawnEx(debugParams);
2328  }
2329 
2330  else if (action_id == EActions.DELETE)
2331  {
2332  Delete();
2333  }
2334 
2335  }
2336 
2337 
2338  return false;
2339  }
2341  // -------------------------------------------------------------------------
2342 
2343 
2347 
2349  void OnActivatedByItem(notnull ItemBase item);
2350 
2351  //----------------------------------------------------------------
2352  //returns true if item is able to explode when put in fire
2353  bool CanExplodeInFire()
2354  {
2355  return false;
2356  }
2357 
2358  //----------------------------------------------------------------
2359  bool CanEat()
2360  {
2361  return true;
2362  }
2363 
2364  //----------------------------------------------------------------
2365  override bool IsIgnoredByConstruction()
2366  {
2367  return true;
2368  }
2369 
2370  //----------------------------------------------------------------
2371  //has FoodStages in config?
2372  bool HasFoodStage()
2373  {
2374  string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
2375  return GetGame().ConfigIsExisting(config_path);
2376  }
2377 
2378  bool CanBeCooked()
2379  {
2380  return false;
2381  }
2382 
2384  {
2385  return false;
2386  }
2387 
2388  //----------------------------------------------------------------
2389  bool CanRepair(ItemBase item_repair_kit)
2390  {
2391  PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
2392  return module_repairing.CanRepair(this, item_repair_kit);
2393  }
2394 
2395  //----------------------------------------------------------------
2396  bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
2397  {
2398  PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
2399  return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
2400  }
2401 
2402  //----------------------------------------------------------------
2403  int GetItemSize()
2404  {
2405  /*
2406  vector v_size = this.ConfigGetVector("itemSize");
2407  int v_size_x = v_size[0];
2408  int v_size_y = v_size[1];
2409  int size = v_size_x * v_size_y;
2410  return size;
2411  */
2413  return 1;
2414  }
2415 
2416  //----------------------------------------------------------------
2417  //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
2418  bool CanBeMovedOverride()
2419  {
2420  return m_CanBeMovedOverride;
2421  }
2422 
2423  //----------------------------------------------------------------
2424  //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
2425  void SetCanBeMovedOverride(bool setting)
2426  {
2427  m_CanBeMovedOverride = setting;
2428  }
2429 
2430  //----------------------------------------------------------------
2438  void MessageToOwnerStatus(string text)
2439  {
2440  PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
2441 
2442  if (player)
2443  {
2444  player.MessageStatus(text);
2445  }
2446  }
2447 
2448  //----------------------------------------------------------------
2456  void MessageToOwnerAction(string text)
2457  {
2458  PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
2459 
2460  if (player)
2461  {
2462  player.MessageAction(text);
2463  }
2464  }
2465 
2466  //----------------------------------------------------------------
2474  void MessageToOwnerFriendly(string text)
2475  {
2476  PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
2477 
2478  if (player)
2479  {
2480  player.MessageFriendly(text);
2481  }
2482  }
2483 
2484  //----------------------------------------------------------------
2492  void MessageToOwnerImportant(string text)
2493  {
2494  PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
2496  if (player)
2497  {
2498  player.MessageImportant(text);
2499  }
2500  }
2501 
2502  override bool IsItemBase()
2503  {
2504  return true;
2505  }
2506 
2507  // Checks if item is of questioned kind
2508  override bool KindOf(string tag)
2509  {
2510  bool found = false;
2511  string item_name = this.GetType();
2512  ref TStringArray item_tag_array = new TStringArray;
2513  GetGame().ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
2514 
2515  int array_size = item_tag_array.Count();
2516  for (int i = 0; i < array_size; i++)
2517  {
2518  if (item_tag_array.Get(i) == tag)
2519  {
2520  found = true;
2521  break;
2522  }
2523  }
2524  return found;
2525  }
2526 
2527 
2528  override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
2529  {
2530  //Debug.Log("OnRPC called");
2531  super.OnRPC(sender, rpc_type,ctx);
2532 
2533  //Play soundset for attachment locking (ActionLockAttachment.c)
2534  switch (rpc_type)
2535  {
2536  #ifndef SERVER
2537  case ERPCs.RPC_SOUND_LOCK_ATTACH:
2538  Param2<bool, string> p = new Param2<bool, string>(false, "");
2539 
2540  if (!ctx.Read(p))
2541  return;
2542 
2543  bool play = p.param1;
2544  string soundSet = p.param2;
2545 
2546  if (play)
2547  {
2548  if (m_LockingSound)
2549  {
2550  if (!m_LockingSound.IsSoundPlaying())
2551  {
2552  m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
2553  }
2554  }
2555  else
2556  {
2557  m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
2558  }
2559  }
2560  else
2561  {
2562  SEffectManager.DestroyEffect(m_LockingSound);
2563  }
2564 
2565  break;
2566  #endif
2568  }
2569 
2570  if (GetWrittenNoteData())
2571  {
2572  GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
2573  }
2574  }
2575 
2576  //-----------------------------
2577  // VARIABLE MANIPULATION SYSTEM
2578  //-----------------------------
2580  void TransferVariablesFloat(array<float> float_vars)
2581  {
2582  DeSerializeNumericalVars(float_vars);
2583  }
2584 
2586  {
2587  CachedObjectsArrays.ARRAY_FLOAT.Clear();
2589  return CachedObjectsArrays.ARRAY_FLOAT;
2590  }
2592  int NameToID(string name)
2593  {
2594  PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
2595  return plugin.GetID(name);
2596  }
2597 
2598  string IDToName(int id)
2599  {
2600  PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
2601  return plugin.GetName(id);
2602  }
2603 
2604  void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
2605  {
2606  //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
2607  //read the flags
2608  //ref Param1<int> pflags = new Param1<int>(0);
2609  int varFlags;
2610  if (!ctx.Read(varFlags))
2611  return;
2612 
2613  //ctx.Read(CachedObjectsParams.PARAM1_INT);
2614 
2615  //int varFlags = CachedObjectsParams.PARAM1_INT.param1;
2616  //--------------
2617 
2619  if (varFlags & ItemVariableFlags.FLOAT)
2620  {
2621  ReadVarsFromCTX(ctx);
2622  }
2623  /*
2624  if (varFlags & ItemVariableFlags.STRING)
2625  {
2626  OnSyncStrings(ctx);
2627  }
2628  */
2629  }
2630 
2631  void SerializeNumericalVars(array<float> floats_out)
2632  {
2633  // the order of serialization must be the same as the order of de-serialization
2634  floats_out.Insert(m_VariablesMask);
2635  //--------------------------------------------
2637  {
2638  floats_out.Insert(m_VarQuantity);
2639  }
2640  //--------------------------------------------
2642  {
2643  floats_out.Insert(m_VarTemperature);
2644  }
2645  //--------------------------------------------
2647  {
2648  floats_out.Insert(m_VarWet);
2649  }
2650  //--------------------------------------------
2652  {
2653  floats_out.Insert(m_VarLiquidType);
2654  }
2655  //--------------------------------------------
2657  {
2658  floats_out.Insert(m_ColorComponentR);
2659  floats_out.Insert(m_ColorComponentG);
2660  floats_out.Insert(m_ColorComponentB);
2661  floats_out.Insert(m_ColorComponentA);
2662  }
2663  //--------------------------------------------
2665  {
2666  floats_out.Insert(m_Cleanness);
2667  }
2668  //--------------------------------------------
2669  }
2670 
2672  {
2673  // the order of serialization must be the same as the order of de-serialization
2674  int index = 0;
2675  int mask = Math.Round(floats.Get(index));
2676 
2677  index++;
2678  //--------------------------------------------
2679  if (mask & VARIABLE_QUANTITY)
2680  {
2681  if (m_IsStoreLoad)
2682  {
2683  m_StoreLoadedQuantity = floats.Get(index);
2684  }
2685  else
2686  {
2687  float quantity = floats.Get(index);
2688  SetQuantity(quantity, true, false, false, false);
2689  }
2690  index++;
2691  }
2692  //--------------------------------------------
2693  if (mask & VARIABLE_TEMPERATURE)
2694  {
2695  float temperature = floats.Get(index);
2696  SetTemperature(temperature);
2697  index++;
2698  }
2699  //--------------------------------------------
2700  if (mask & VARIABLE_WET)
2701  {
2702  float wet = floats.Get(index);
2703  SetWet(wet);
2704  index++;
2705  }
2706  //--------------------------------------------
2707  if (mask & VARIABLE_LIQUIDTYPE)
2708  {
2709  int liquidtype = Math.Round(floats.Get(index));
2710  SetLiquidType(liquidtype);
2711  index++;
2712  }
2713  //--------------------------------------------
2714  if (mask & VARIABLE_COLOR)
2715  {
2716  m_ColorComponentR = Math.Round(floats.Get(index));
2717  index++;
2718  m_ColorComponentG = Math.Round(floats.Get(index));
2719  index++;
2720  m_ColorComponentB = Math.Round(floats.Get(index));
2721  index++;
2722  m_ColorComponentA = Math.Round(floats.Get(index));
2723  index++;
2724  }
2725  if (mask & VARIABLE_CLEANNESS)
2726  {
2727  int cleanness = Math.Round(floats.Get(index));
2728  SetCleanness(cleanness);
2729  index++;
2730  }
2731  //--------------------------------------------
2732  }
2733 
2734 
2736  {
2737  ctx.Write(m_VariablesMask);
2738 
2739  //--------------------------------------------
2741  {
2742  ctx.Write(m_VarQuantity);
2743  }
2744  //--------------------------------------------
2746  {
2747  ctx.Write(m_VarTemperature);
2748  }
2749  //--------------------------------------------
2751  {
2752  ctx.Write(m_VarWet);
2753  }
2754  //--------------------------------------------
2756  {
2757  ctx.Write(m_VarLiquidType);
2758  }
2759  //--------------------------------------------
2761  {
2762  ctx.Write(m_ColorComponentR);
2763  ctx.Write(m_ColorComponentG);
2764  ctx.Write(m_ColorComponentB);
2765  ctx.Write(m_ColorComponentA);
2766  }
2767  //--------------------------------------------
2769  {
2770  ctx.Write(m_Cleanness);
2771  }
2772  }
2773 
2774  bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
2775  {
2776  int numOfItems;
2777  int intValue;
2778  float value;
2779  if (version <= 108 && version!= -1)
2780  {
2781  if (!ctx.Read(CachedObjectsParams.PARAM1_INT))
2782  return false;
2783 
2784  numOfItems = CachedObjectsParams.PARAM1_INT.param1;
2785  CachedObjectsArrays.ARRAY_FLOAT.Clear();
2786 
2787  for (int i = 0; i < numOfItems; i++)
2788  {
2789  if (!ctx.Read(CachedObjectsParams.PARAM1_FLOAT))
2790  return false;
2791  value = CachedObjectsParams.PARAM1_FLOAT.param1;
2792 
2793  CachedObjectsArrays.ARRAY_FLOAT.Insert(value);
2794  }
2795 
2797  return true;
2798  }
2799  else if (version <= 116 && version!= -1)
2800  {
2801  if (!ctx.Read(numOfItems))
2802  return false;
2803 
2804  CachedObjectsArrays.ARRAY_FLOAT.Clear();
2805 
2806  for (int j = 0; j < numOfItems; j++)
2807  {
2808  if (!ctx.Read(value))
2809  return false;
2810  CachedObjectsArrays.ARRAY_FLOAT.Insert(value);
2811  }
2812 
2814  return true;
2815  }
2816  else
2817  {
2818  int mask;
2819  if (!ctx.Read(mask))
2820  return false;
2821 
2822  if (mask & VARIABLE_QUANTITY)
2823  {
2824  if (!ctx.Read(value))
2825  return false;
2826 
2827  if (m_IsStoreLoad)
2828  {
2829  m_StoreLoadedQuantity = value;
2830  }
2831  else
2832  {
2833  SetQuantity(value, true, false, false, false);
2834  }
2835  }
2836  //--------------------------------------------
2837  if (mask & VARIABLE_TEMPERATURE)
2838  {
2839  if (!ctx.Read(value))
2840  return false;
2841  SetTemperature(value);
2842  }
2843  //--------------------------------------------
2844  if (mask & VARIABLE_WET)
2845  {
2846  if (!ctx.Read(value))
2847  return false;
2848  SetWet(value);
2849  }
2850  //--------------------------------------------
2851  if (mask & VARIABLE_LIQUIDTYPE)
2852  {
2853  if (!ctx.Read(intValue))
2854  return false;
2855  SetLiquidType(intValue);
2856  }
2857  //--------------------------------------------
2858  if (mask & VARIABLE_COLOR)
2859  {
2860  if (!ctx.Read(intValue))
2861  return false;
2862 
2863  m_ColorComponentR = intValue;
2864  if (!ctx.Read(value))
2865  return false;
2866 
2867  m_ColorComponentG = intValue;
2868  if (!ctx.Read(value))
2869  return false;
2870 
2871  m_ColorComponentB = intValue;
2872  if (!ctx.Read(value))
2873  return false;
2874 
2875  m_ColorComponentA = intValue;
2876  }
2877  //--------------------------------------------
2878  if (mask & VARIABLE_CLEANNESS)
2879  {
2880  if (!ctx.Read(intValue))
2881  return false;
2882  SetCleanness(intValue);
2883  }
2884  }
2885  return true;
2886  }
2887 
2889  {
2890  //Debug.Log("Saving Item Stage 0 "+ClassName(this)+" " + ToString(this));
2891 
2892  //first set the flags
2893 
2894  int varFlags = 0;
2895 
2896  if (m_VariablesMask)
2897  varFlags = ItemVariableFlags.FLOAT;
2899  ctx.Write(varFlags);
2900  //-------------------
2901 
2902  //now serialize the variables
2903 
2904  //floats
2905  if (m_VariablesMask)
2906  WriteVarsToCTX(ctx);
2907  }
2908 
2909 
2910  //----------------------------------------------------------------
2911  bool LoadVariables(ParamsReadContext ctx, int version = -1)
2912  {
2913  int varFlags;
2914  if (version <= 108 && version != -1)
2915  {
2916  //read the flags
2917  if (!ctx.Read(CachedObjectsParams.PARAM1_INT))
2918  {
2919  return false;
2920  }
2921  else
2922  {
2923  varFlags = CachedObjectsParams.PARAM1_INT.param1;
2924  //--------------
2925  if (varFlags & ItemVariableFlags.FLOAT)
2926  {
2927  if (!ReadVarsFromCTX(ctx, version))
2928  return false;
2929  }
2930  }
2931  }
2932  else
2933  {
2934  //read the flags
2935  if (!ctx.Read(varFlags))
2936  {
2937  return false;
2938  }
2939  else
2940  {
2941  //--------------
2942  if (varFlags & ItemVariableFlags.FLOAT)
2943  {
2944  if (!ReadVarsFromCTX(ctx, version))
2945  return false;
2946  }
2947  }
2948  }
2949  return true;
2950  }
2951 
2952 
2953  //----------------------------------------------------------------
2954  override bool OnStoreLoad(ParamsReadContext ctx, int version)
2955  {
2956  m_IsStoreLoad = true;
2957 
2958  if (GetDamageSystemVersionChange() != -1 && version < GetDamageSystemVersionChange())
2959  {
2960  m_FixDamageSystemInit = true;
2961  }
2962 
2963  if (!super.OnStoreLoad(ctx, version))
2964  {
2965  m_IsStoreLoad = false;
2966  return false;
2967  }
2968 
2969  if (version >= 114)
2970  {
2971  bool hasQuickBarIndexSaved;
2972 
2973  if (!ctx.Read(hasQuickBarIndexSaved))
2974  {
2975  m_IsStoreLoad = false;
2976  return false;
2977  }
2978 
2979  if (hasQuickBarIndexSaved)
2980  {
2981  int itmQBIndex;
2982 
2983  //Load quickbar item bind
2984  if (!ctx.Read(itmQBIndex))
2985  {
2986  m_IsStoreLoad = false;
2987  return false;
2988  }
2989 
2990  PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
2991  if (itmQBIndex != -1 && parentPlayer)
2992  parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
2993  }
2994  }
2995  else
2996  {
2997  // Backup of how it used to be
2998  PlayerBase player;
2999  int itemQBIndex;
3000  if (version == int.MAX)
3001  {
3002  if (!ctx.Read(itemQBIndex))
3003  {
3004  m_IsStoreLoad = false;
3005  return false;
3006  }
3007  }
3008  else if (Class.CastTo(player, GetHierarchyRootPlayer()))
3009  {
3010  //Load quickbar item bind
3011  if (!ctx.Read(itemQBIndex))
3012  {
3013  m_IsStoreLoad = false;
3014  return false;
3015  }
3016  if (itemQBIndex != -1 && player)
3017  player.SetLoadedQuickBarItemBind(this,itemQBIndex);
3018  }
3019  }
3020 
3021  // variable management system
3022  if (!LoadVariables(ctx, version))
3023  {
3024  m_IsStoreLoad = false;
3025  return false;
3026  }
3027 
3028  //agent trasmission system
3029  if (!LoadAgents(ctx, version))
3030  {
3031  m_IsStoreLoad = false;
3032  return false;
3033  }
3034  if (version >= 132)
3035  {
3037  if (raib)
3038  {
3039  if (!raib.OnStoreLoad(ctx,version))
3040  {
3041  m_IsStoreLoad = false;
3042  return false;
3043  }
3044  }
3045  }
3046 
3047  m_IsStoreLoad = false;
3048  return true;
3049  }
3050 
3051  //----------------------------------------------------------------
3052 
3053  override void OnStoreSave(ParamsWriteContext ctx)
3054  {
3055  super.OnStoreSave(ctx);
3056  PlayerBase player;
3057  if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
3058  {
3059  ctx.Write(true); // Keep track of if we should actually read this in or not
3060  //Save quickbar item bind
3061  int itemQBIndex = -1;
3062  itemQBIndex = player.FindQuickBarEntityIndex(this);
3063  ctx.Write(itemQBIndex);
3064  }
3065  else
3066  {
3067  ctx.Write(false); // Keep track of if we should actually read this in or not
3068  }
3069 
3070  SaveVariables(ctx);// variable management system
3071  SaveAgents(ctx);//agent trasmission system
3072 
3074  if (raib)
3075  {
3076  raib.OnStoreSave(ctx);
3077  }
3078  }
3079  //----------------------------------------------------------------
3080 
3081  override void AfterStoreLoad()
3082  {
3083  super.AfterStoreLoad();
3086  {
3088  }
3089 
3090  if (m_StoreLoadedQuantity != float.LOWEST)
3091  {
3093  m_StoreLoadedQuantity = float.LOWEST;//IMPORTANT to do this !! we use 'm_StoreLoadedQuantity' inside SetQuantity to distinguish between initial quantity setting and the consequent(normal gameplay) calls
3094  }
3095  }
3096 
3097  override void EEOnAfterLoad()
3098  {
3099  super.EEOnAfterLoad();
3100 
3102  {
3103  m_FixDamageSystemInit = false;
3104  }
3105 
3107  GetRemotelyActivatedItemBehaviour().OnAfterLoad();
3108  }
3109 
3110  bool CanBeDisinfected()
3111  {
3112  return false;
3113  }
3114 
3115 
3116  //----------------------------------------------------------------
3117  override void OnVariablesSynchronized()
3118  {
3119  if (m_Initialized)
3120  {
3121  #ifdef PLATFORM_CONSOLE
3122  //bruteforce it is
3123  if (m_CanThisBeSplit)
3124  {
3125  UIScriptedMenu menu = GetGame().GetUIManager().FindMenu(MENU_INVENTORY);
3126  if (menu)
3127  {
3128  menu.Refresh();
3129  }
3130  }
3131  #endif
3132  }
3133 
3134  if (CanPlayDeployLoopSound())
3135  {
3137  }
3138 
3140  {
3142  }
3143 
3144  if (IsDeploySound())
3145  {
3146  PlayDeploySound();
3147  }
3148 
3149  if (!dBodyIsDynamic(this) && m_WantPlayImpactSound)
3150  {
3151  PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
3152  m_WantPlayImpactSound = false;
3153  }
3154 
3156  {
3157  SetWeightDirty();
3159  }
3160  if (m_VarWet != m_VarWetPrev)
3161  {
3164  }
3165 
3166  super.OnVariablesSynchronized();
3167  }
3168 
3169  //------------------------- Quantity
3170  //----------------------------------------------------------------
3172  bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
3173  {
3174  if (!IsServerCheck(allow_client))
3175  return false;
3176 
3177  if (!HasQuantity())
3178  return false;
3179 
3180  if (IsLiquidContainer() && GetLiquidType() == 0)
3181  {
3182  Debug.LogError("No LiquidType specified, try setting 'varLiquidTypeInit' to a particular liquid type");
3183  return false;
3184  }
3185 
3186  float min = GetQuantityMin();
3187  float max = GetQuantityMax();
3188 
3189  if (value <= (min + 0.001))
3190  value = min;
3191 
3192  if (value == min)
3193  {
3194  if (destroy_config)
3195  {
3196  bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
3197  if (dstr)
3198  {
3199  m_VarQuantity = Math.Clamp(value, min, max);
3200  this.Delete();
3201  return true;
3202  }
3203  }
3204  else if (destroy_forced)
3205  {
3206  m_VarQuantity = Math.Clamp(value, min, max);
3207  this.Delete();
3208  return true;
3209  }
3210  // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
3211  RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
3212  }
3213 
3214  float delta = m_VarQuantity;
3215  m_VarQuantity = Math.Clamp(value, min, max);
3216 
3217  if (m_StoreLoadedQuantity == float.LOWEST)//any other value means we are setting quantity from storage
3218  {
3219  delta = m_VarQuantity - delta;
3220 
3221  if (delta)
3222  {
3223  OnQuantityChanged(delta);
3224  }
3225  }
3228 
3229  return false;
3230  }
3231 
3232  //----------------------------------------------------------------
3234  bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
3235  {
3236  return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
3237  }
3238  //----------------------------------------------------------------
3240  {
3241  float max = GetQuantityMax();
3242  SetQuantity(max);
3243  }
3244 
3245  override void SetQuantityToMinimum()
3246  {
3247  float min = GetQuantityMin();
3249  }
3250  //----------------------------------------------------------------
3252  void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
3253  {
3254  float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
3255  int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
3256  SetQuantity(result, destroy_config, destroy_forced);
3257  }
3258 
3259  //----------------------------------------------------------------
3261  float GetQuantityNormalized()
3262  {
3263  return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
3264  }
3265 
3266  /*void SetAmmoNormalized(float value)
3267  {
3268  float value_clamped = Math.Clamp(value, 0, 1);
3269  Magazine this_mag = Magazine.Cast(this);
3270  int max_rounds = this_mag.GetAmmoMax();
3271  int result = value * max_rounds;//can the rounded if higher precision is required
3272  this_mag.SetAmmoCount(result);
3273  }*/
3274  //----------------------------------------------------------------
3275  override int GetQuantityMax()
3276  {
3277  float max = 0;
3278 
3280  if (GetInventory())
3281  GetInventory().GetCurrentInventoryLocation(il);
3282 
3283  int slot = il.GetSlot();
3285  if (slot != -1)
3286  max = InventorySlots.GetStackMaxForSlotId(slot);
3287 
3288  if (max <= 0)
3289  max = m_VarStackMax;
3290 
3291  if (max <= 0)
3292  max = m_VarQuantityMax;
3293 
3294  return max;
3295  }
3296 
3297  override int GetTargetQuantityMax(int attSlotID = -1)
3298  {
3299  float quantity_max = 0;
3301  if (attSlotID != -1)
3302  quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
3303 
3304  if (quantity_max <= 0)
3305  quantity_max = m_VarStackMax;
3306 
3307  if (quantity_max <= 0)
3308  quantity_max = m_VarQuantityMax;
3309 
3310  return quantity_max;
3311  }
3312  //----------------------------------------------------------------
3313  int GetQuantityMin()
3314  {
3315  return m_VarQuantityMin;
3316  }
3317  //----------------------------------------------------------------
3318  int GetQuantityInit()
3319  {
3320  return m_VarQuantityInit;
3321  }
3322 
3323  //----------------------------------------------------------------
3324  bool HasQuantity()
3325  {
3326  return !(GetQuantityMax() - GetQuantityMin() == 0);
3327  }
3328 
3329  override float GetQuantity()
3330  {
3331  return m_VarQuantity;
3332  }
3333 
3334  bool IsFullQuantity()
3335  {
3337  }
3338 
3339  //Calculates weight of single item without attachments and cargo
3340  override float GetSingleInventoryItemWeightEx()
3341  {
3342  //this needs to be first stored inside local variables, when returned directly during inside return call, the result is completely different due to enforce script bug
3343  float weightEx = GetWeightEx();//overall weight of the item
3344  float special = GetInventoryAndCargoWeight();//cargo and attachment weight
3345  return weightEx - special;
3346  }
3347 
3348  // Obsolete, use GetSingleInventoryItemWeightEx() instead
3350  {
3352  }
3353 
3354  override protected float GetWeightSpecialized(bool forceRecalc = false)
3355  {
3356  if (m_CanThisBeSplit) //quantity determines size of the stack
3357  {
3358  #ifdef DEVELOPER
3359  if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
3360  {
3361  WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
3362  data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
3363  }
3364  #endif
3365 
3366  return GetQuantity() * GetConfigWeightModified();
3367  }
3368  else if (HasEnergyManager())// items with energy manager
3369  {
3370  #ifdef DEVELOPER
3371  if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
3372  {
3373  WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
3374  data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
3375  }
3376  #endif
3377  return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified());
3378  }
3379  else//everything else
3380  {
3381  #ifdef DEVELOPER
3382  if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
3383  {
3384  WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
3385  data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
3386  }
3387  #endif
3388  return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified());
3389  }
3390  }
3391 
3393  int GetNumberOfItems()
3394  {
3395  int item_count = 0;
3396  ItemBase item;
3397 
3398  if (GetInventory().GetCargo() != NULL)
3399  {
3400  item_count = GetInventory().GetCargo().GetItemCount();
3401  }
3402 
3403  for (int i = 0; i < GetInventory().AttachmentCount(); i++)
3404  {
3405  Class.CastTo(item,GetInventory().GetAttachmentFromIndex(i));
3406  if (item)
3407  item_count += item.GetNumberOfItems();
3408  }
3409  return item_count;
3410  }
3411 
3413  float GetUnitWeight(bool include_wetness = true)
3414  {
3415  float weight = 0;
3416  float wetness = 1;
3417  if (include_wetness)
3418  wetness += GetWet();
3419  if (m_CanThisBeSplit) //quantity determines size of the stack
3420  {
3421  weight = wetness * m_ConfigWeight;
3422  }
3423  else if (ConfigGetFloat("liquidContainerType") > 0) //is a liquid container, default liquid weight is set to 1. May revisit later?
3424  {
3425  weight = 1;
3426  }
3427  return weight;
3428  }
3429 
3430  void SetVariableMask(int variable)
3431  {
3432  m_VariablesMask = variable | m_VariablesMask;
3433  if (GetGame().IsServer())
3434  {
3435  SetSynchDirty();
3436  }
3437  }
3438 
3440  void RemoveItemVariable(int variable)
3441  {
3442  m_VariablesMask = ~variable & m_VariablesMask;
3443  }
3444 
3446  bool IsVariableSet(int variable)
3447  {
3448  return (variable & m_VariablesMask);
3449  }
3450 
3451  //-----------------------------------------------------------------
3452 
3453  override void ClearInventory()
3454  {
3455  if ((GetGame().IsServer() || !GetGame().IsMultiplayer()) && GetInventory())
3456  {
3457  GameInventory inv = GetInventory();
3458  array<EntityAI> items = new array<EntityAI>;
3459  inv.EnumerateInventory(InventoryTraversalType.INORDER, items);
3460  for (int i = 0; i < items.Count(); i++)
3461  {
3462  ItemBase item = ItemBase.Cast(items.Get(i));
3463  if (item)
3464  {
3465  GetGame().ObjectDelete(item);
3466  }
3467  }
3468  }
3469  }
3470 
3471  //------------------------- Energy
3473  //----------------------------------------------------------------
3474  float GetEnergy()
3475  {
3476  float energy = 0;
3477  if (HasEnergyManager())
3478  {
3479  energy = GetCompEM().GetEnergy();
3480  }
3481  return energy;
3482  }
3483 
3484 
3485  override void OnEnergyConsumed()
3486  {
3487  super.OnEnergyConsumed();
3488 
3490  }
3491 
3492  override void OnEnergyAdded()
3493  {
3494  super.OnEnergyAdded();
3495 
3497  }
3498 
3499  // Converts energy (from Energy Manager) to quantity, if enabled.
3501  {
3502  if (GetGame().IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
3503  {
3504  if (HasQuantity())
3505  {
3506  float energy_0to1 = GetCompEM().GetEnergy0To1();
3507  SetQuantityNormalized(energy_0to1);
3508  }
3509  }
3510  }
3511 
3512  override void SetTemperature(float value, bool allow_client = false)
3513  {
3514  if (!IsServerCheck(allow_client))
3515  return;
3516 
3517  float min = GetTemperatureMin();
3518  float max = GetTemperatureMax();
3519 
3520  float previousValue = m_VarTemperature;
3521 
3522  m_VarTemperature = Math.Clamp(value, min, max);
3523 
3524  if (previousValue != m_VarTemperature)
3526  }
3527  //----------------------------------------------------------------
3528  override void AddTemperature(float value)
3529  {
3531  }
3532  //----------------------------------------------------------------
3533  override void SetTemperatureMax()
3534  {
3536  }
3537  //----------------------------------------------------------------
3538  override float GetTemperature()
3539  {
3541  }
3542 
3543  override float GetTemperatureInit()
3544  {
3546  }
3547 
3548  override float GetTemperatureMin()
3549  {
3551  }
3552 
3553  override float GetTemperatureMax()
3554  {
3556  }
3557  //----------------------------------------------------------------
3558  float GetHeatIsolationInit()
3559  {
3560  return ConfigGetFloat("heatIsolation");
3561  }
3562 
3563  float GetHeatIsolation()
3564  {
3565  return m_HeatIsolation;
3566  }
3567 
3568  float GetDryingIncrement(string pIncrementName)
3569  {
3570  string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
3571  if (GetGame().ConfigIsExisting(paramPath))
3572  return GetGame().ConfigGetFloat(paramPath);
3574  return 0.0;
3575  }
3576 
3577  float GetSoakingIncrement(string pIncrementName)
3578  {
3579  string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
3580  if (GetGame().ConfigIsExisting(paramPath))
3581  return GetGame().ConfigGetFloat(paramPath);
3582 
3583  return 0.0;
3584  }
3585  //----------------------------------------------------------------
3586  override void SetWet(float value, bool allow_client = false)
3587  {
3588  if (!IsServerCheck(allow_client))
3589  return;
3590 
3591  float min = GetWetMin();
3592  float max = GetWetMax();
3593 
3594  float previousValue = m_VarWet;
3595 
3596  m_VarWet = Math.Clamp(value, min, max);
3598  if (previousValue != m_VarWet)
3599  {
3601  OnWetChanged(m_VarWet, previousValue);
3602  }
3603  }
3604  //----------------------------------------------------------------
3605  override void AddWet(float value)
3606  {
3607  SetWet(GetWet() + value);
3608  }
3609  //----------------------------------------------------------------
3610  override void SetWetMax()
3611  {
3613  }
3614  //----------------------------------------------------------------
3615  override float GetWet()
3616  {
3617  return m_VarWet;
3618  }
3619  //----------------------------------------------------------------
3620  override float GetWetMax()
3621  {
3622  return m_VarWetMax;
3623  }
3624  //----------------------------------------------------------------
3625  override float GetWetMin()
3626  {
3627  return m_VarWetMin;
3628  }
3629  //----------------------------------------------------------------
3630  override float GetWetInit()
3631  {
3633  }
3634  //----------------------------------------------------------------
3635  override void OnWetChanged(float newVal, float oldVal)
3636  {
3637  EWetnessLevel newLevel = GetWetLevelInternal(newVal);
3638  EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
3639  if (newLevel != oldLevel)
3640  {
3641  OnWetLevelChanged(newLevel,oldLevel);
3642  }
3643  }
3644 
3645  override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
3646  {
3647  SetWeightDirty();
3648  }
3649 
3650  override EWetnessLevel GetWetLevel()
3651  {
3652  return GetWetLevelInternal(m_VarWet);
3653  }
3654 
3655  //----------------------------------------------------------------
3656  bool IsServerCheck(bool allow_client)
3657  {
3658  if (g_Game.IsServer())
3659  return true;
3661  if (allow_client)
3662  return true;
3663 
3664  if (GetGame().IsClient() && GetGame().IsMultiplayer())
3665  {
3666  Error("Attempting to change variable client side, variables are supposed to be changed on server only !!");
3667  return false;
3668  }
3670  return true;
3671  }
3672 
3673  float GetItemModelLength()
3674  {
3675  if (ConfigIsExisting("itemModelLength"))
3676  {
3677  return ConfigGetFloat("itemModelLength");
3678  }
3679  return 0;
3680  }
3681 
3682  float GetItemAttachOffset()
3683  {
3684  if (ConfigIsExisting("itemAttachOffset"))
3685  {
3686  return ConfigGetFloat("itemAttachOffset");
3687  }
3688  return 0;
3689  }
3690 
3691  void SetCleanness(int value, bool allow_client = false)
3692  {
3693  if (!IsServerCheck(allow_client))
3694  return;
3695 
3696  int previousValue = m_Cleanness;
3697 
3698  m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
3699 
3700  if (previousValue != m_Cleanness)
3702  }
3703 
3704 
3706  {
3707  return true;
3708  }
3709 
3710  //----------------------------------------------------------------
3711  // ATTACHMENT LOCKING
3712  // Getters relevant to generic ActionLockAttachment
3714  {
3715  return m_LockType;
3716  }
3717 
3718  string GetLockSoundSet()
3719  {
3720  return m_LockSoundSet;
3721  }
3723  //----------------------------------------------------------------
3724  //------------------------- Color
3725  // sets items color variable given color components
3726  void SetColor(int r, int g, int b, int a)
3727  {
3728  m_ColorComponentR = r;
3729  m_ColorComponentG = g;
3731  m_ColorComponentA = a;
3733  }
3735  void GetColor(out int r,out int g,out int b,out int a)
3736  {
3737  r = m_ColorComponentR;
3738  g = m_ColorComponentG;
3739  b = m_ColorComponentB;
3740  a = m_ColorComponentA;
3741  }
3742 
3743  bool IsColorSet()
3744  {
3745  return IsVariableSet(VARIABLE_COLOR);
3746  }
3747 
3750  {
3751  int r,g,b,a;
3752  GetColor(r,g,b,a);
3753  r = r/255;
3754  g = g/255;
3755  b = b/255;
3756  a = a/255;
3757  return MiscGameplayFunctions.GetColorString(r, g, b, a);
3758  }
3759  //----------------------------------------------------------------
3760  //------------------------- LiquidType
3761 
3762  void SetLiquidType(int value, bool allow_client = false)
3763  {
3764  if (!IsServerCheck(allow_client))
3765  return;
3766 
3767  m_VarLiquidType = value;
3769  }
3771  int GetLiquidTypeInit()
3772  {
3773  return ConfigGetInt("varLiquidTypeInit");
3774  }
3775 
3776  int GetLiquidType()
3777  {
3778  return m_VarLiquidType;
3779  }
3780 
3781  // -------------------------------------------------------------------------
3783  void OnInventoryEnter(Man player)
3784  {
3785  PlayerBase nplayer;
3786  if (PlayerBase.CastTo(nplayer, player))
3787  {
3788  m_CanPlayImpactSound = true;
3789  //nplayer.OnItemInventoryEnter(this);
3790  nplayer.SetEnableQuickBarEntityShortcut(this,true);
3791  }
3792  }
3793 
3794  // -------------------------------------------------------------------------
3796  void OnInventoryExit(Man player)
3797  {
3798  PlayerBase nplayer;
3799  if (PlayerBase.CastTo(nplayer,player))
3800  {
3801  //nplayer.OnItemInventoryExit(this);
3802  nplayer.SetEnableQuickBarEntityShortcut(this,false);
3803 
3804  }
3805 
3806  //if (!GetGame().IsDedicatedServer())
3807  player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
3808 
3809 
3810  if (HasEnergyManager())
3811  {
3812  GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
3813  }
3814  }
3815 
3816  // ADVANCED PLACEMENT EVENTS
3817  override void OnPlacementStarted(Man player)
3818  {
3819  super.OnPlacementStarted(player);
3820 
3821  SetTakeable(false);
3822  }
3823 
3824  override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
3825  {
3826  if (m_AdminLog)
3827  {
3828  m_AdminLog.OnPlacementComplete(player, this);
3829  }
3830  if (GetGame().IsServer())
3831  {
3832  SetIsDeploySound(true);
3833  }
3834  super.OnPlacementComplete(player, position, orientation);
3835  }
3836 
3837  //-----------------------------
3838  // AGENT SYSTEM
3839  //-----------------------------
3840  //--------------------------------------------------------------------------
3841  bool ContainsAgent(int agent_id)
3842  {
3843  if (agent_id & m_AttachedAgents)
3844  {
3845  return true;
3846  }
3847  else
3848  {
3849  return false;
3850  }
3851  }
3852 
3853  //--------------------------------------------------------------------------
3854  override void RemoveAgent(int agent_id)
3855  {
3856  if (ContainsAgent(agent_id))
3857  {
3858  m_AttachedAgents = ~agent_id & m_AttachedAgents;
3859  }
3860  }
3861 
3862  //--------------------------------------------------------------------------
3863  override void RemoveAllAgents()
3864  {
3865  m_AttachedAgents = 0;
3866  }
3867  //--------------------------------------------------------------------------
3868  override void RemoveAllAgentsExcept(int agents_to_keep_mask)
3869  {
3870  m_AttachedAgents = m_AttachedAgents & agent_to_keep;
3871  }
3872  // -------------------------------------------------------------------------
3873  override void InsertAgent(int agent, float count = 1)
3874  {
3875  if (count < 1)
3876  return;
3877  //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
3878  m_AttachedAgents = (agent | m_AttachedAgents);
3879  }
3880 
3882  void TransferAgents(int agents)
3883  {
3884  m_AttachedAgents = (m_AttachedAgents | agents);
3885  }
3886 
3887  // -------------------------------------------------------------------------
3888  override int GetAgents()
3889  {
3890  return m_AttachedAgents;
3891  }
3892  //----------------------------------------------------------------------
3893 
3894  /*int GetContaminationType()
3895  {
3896  int contamination_type;
3897 
3898  const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
3899  const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
3900  const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
3901  const int DIRTY_MASK = eAgents.WOUND_AGENT;
3902 
3903  Edible_Base edible = Edible_Base.Cast(this);
3904  int agents = GetAgents();
3905  if (edible)
3906  {
3907  NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
3908  if (profile)
3909  {
3910  //Print("profile agents:" +profile.GetAgents());
3911  agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
3912  }
3913  }
3914  if (agents & CONTAMINATED_MASK)
3915  {
3916  contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
3917  }
3918  if (agents & POISONED_MASK)
3919  {
3920  contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
3921  }
3922  if (agents & NERVE_GAS_MASK)
3923  {
3924  contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
3925  }
3926  if (agents & DIRTY_MASK)
3927  {
3928  contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
3929  }
3930 
3931  return agents;
3932  }*/
3933 
3934  // -------------------------------------------------------------------------
3935  bool LoadAgents(ParamsReadContext ctx, int version)
3936  {
3937  if (!ctx.Read(m_AttachedAgents))
3938  return false;
3939  return true;
3940  }
3941  // -------------------------------------------------------------------------
3942  void SaveAgents(ParamsWriteContext ctx)
3943  {
3944 
3945  ctx.Write(m_AttachedAgents);
3946  }
3947  // -------------------------------------------------------------------------
3948 
3949 
3950  // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
3951  float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
3952  {
3953  if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
3954  {
3955  return 0;
3956  }
3957 
3958  if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
3959  {
3960  ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
3961  if (filter)
3962  return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
3963  else
3964  return 0;//otherwise return 0 when no filter attached
3965  }
3966 
3967  string subclassPath, entryName;
3968 
3969  switch (type)
3970  {
3971  case DEF_BIOLOGICAL:
3972  entryName = "biological";
3973  break;
3974  case DEF_CHEMICAL:
3975  entryName = "chemical";
3976  break;
3977  default:
3978  entryName = "biological";
3979  break;
3980  }
3981 
3982  subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
3983 
3984  return GetGame().ConfigGetFloat(subclassPath + entryName);
3985  }
3986 
3987 
3988 
3990  override void EEOnCECreate()
3991  {
3992  //Print("EEOnCECreate");
3993  if (!IsMagazine())
3995 
3997  }
3999 
4000  //-------------------------
4001  // OPEN/CLOSE USER ACTIONS
4002  //-------------------------
4004  void Open();
4005  void Close();
4006  bool IsOpen()
4007  {
4008  return true;
4009  }
4010 
4011  override bool CanDisplayCargo()
4012  {
4013  return IsOpen();
4014  }
4015 
4016 
4017  // ------------------------------------------------------------
4018  // CONDITIONS
4019  // ------------------------------------------------------------
4020  override bool CanPutInCargo(EntityAI parent)
4021  {
4022  if (parent)
4023  {
4024  if (parent.IsInherited(DayZInfected))
4025  return true;
4026 
4027  if (!parent.IsRuined())
4028  return true;
4029  }
4030 
4031  return true;
4032  }
4033 
4034  override bool CanPutAsAttachment(EntityAI parent)
4035  {
4036  if (!super.CanPutAsAttachment(parent))
4037  {
4038  return false;
4039  }
4040 
4041  if (!IsRuined() && !parent.IsRuined())
4042  {
4043  return true;
4044  }
4046  return false;
4047  }
4048 
4049  override bool CanReceiveItemIntoCargo(EntityAI item)
4050  {
4051  //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
4052  //if (GetHealthLevel() == GameConstants.STATE_RUINED)
4053  // return false;
4054 
4055  return super.CanReceiveItemIntoCargo(item);
4056  }
4057 
4058  override bool CanReceiveAttachment(EntityAI attachment, int slotId)
4059  {
4060  //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
4061  //if (GetHealthLevel() == GameConstants.STATE_RUINED)
4062  // return false;
4063 
4064  GameInventory attachmentInv = attachment.GetInventory();
4065  if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
4066  {
4067  if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
4068  return false;
4069  }
4070 
4071  return super.CanReceiveAttachment(attachment, slotId);
4072  }
4073 
4074  /*override bool CanLoadAttachment(EntityAI attachment)
4075  {
4076  //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
4077  //if (GetHealthLevel() == GameConstants.STATE_RUINED)
4078  // return false;
4079 
4080  GameInventory attachmentInv = attachment.GetInventory();
4081  if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
4082  {
4083  bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
4084  ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
4085 
4086  if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
4087  return false;
4088  }
4089 
4090  return super.CanLoadAttachment(attachment);
4091  }*/
4092 
4093  // Plays muzzle flash particle effects
4094  static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
4095  {
4096  int id = muzzle_owner.GetMuzzleID();
4097  array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
4098 
4099  if (WPOF_array)
4100  {
4101  for (int i = 0; i < WPOF_array.Count(); i++)
4102  {
4103  WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
4104 
4105  if (WPOF)
4106  {
4107  WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
4108  }
4109  }
4110  }
4111  }
4112 
4113  // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
4114  static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
4115  {
4116  int id = muzzle_owner.GetMuzzleID();
4117  array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
4118 
4119  if (WPOBE_array)
4120  {
4121  for (int i = 0; i < WPOBE_array.Count(); i++)
4122  {
4123  WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
4124 
4125  if (WPOBE)
4126  {
4127  WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
4128  }
4129  }
4130  }
4131  }
4132 
4133  // Plays all weapon overheating particles
4134  static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
4135  {
4136  int id = muzzle_owner.GetMuzzleID();
4137  array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
4138 
4139  if (WPOOH_array)
4140  {
4141  for (int i = 0; i < WPOOH_array.Count(); i++)
4142  {
4143  WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
4144 
4145  if (WPOOH)
4146  {
4147  WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
4148  }
4149  }
4150  }
4151  }
4152 
4153  // Updates all weapon overheating particles
4154  static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
4155  {
4156  int id = muzzle_owner.GetMuzzleID();
4157  array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
4158 
4159  if (WPOOH_array)
4160  {
4161  for (int i = 0; i < WPOOH_array.Count(); i++)
4162  {
4163  WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
4164 
4165  if (WPOOH)
4166  {
4167  WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
4168  }
4169  }
4170  }
4171  }
4172 
4173  // Stops overheating particles
4174  static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
4175  {
4176  int id = muzzle_owner.GetMuzzleID();
4177  array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
4178 
4179  if (WPOOH_array)
4180  {
4181  for (int i = 0; i < WPOOH_array.Count(); i++)
4182  {
4183  WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
4184 
4185  if (WPOOH)
4186  {
4187  WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
4188  }
4189  }
4190  }
4191  }
4193  //----------------------------------------------------------------
4194  //Item Behaviour - unified approach
4195  override bool IsHeavyBehaviour()
4196  {
4197  if (m_ItemBehaviour == 0)
4198  {
4199  return true;
4200  }
4201 
4202  return false;
4203  }
4204 
4205  override bool IsOneHandedBehaviour()
4206  {
4207  if (m_ItemBehaviour == 1)
4208  {
4209  return true;
4210  }
4211 
4212  return false;
4213  }
4214 
4215  override bool IsTwoHandedBehaviour()
4216  {
4217  if (m_ItemBehaviour == 2)
4218  {
4219  return true;
4220  }
4221 
4222  return false;
4223  }
4224 
4225  bool IsDeployable()
4226  {
4227  return false;
4228  }
4229 
4231  float GetDeployTime()
4232  {
4233  return UATimeSpent.DEFAULT_DEPLOY;
4234  }
4235 
4236 
4237  //----------------------------------------------------------------
4238  // Item Targeting (User Actions)
4239  override void SetTakeable(bool pState)
4240  {
4241  m_IsTakeable = pState;
4242  SetSynchDirty();
4243  }
4244 
4245  override bool IsTakeable()
4246  {
4247  return m_IsTakeable;
4248  }
4249 
4251  protected void PreLoadSoundAttachmentType()
4252  {
4253  string att_type = "None";
4254 
4255  if (ConfigIsExisting("soundAttType"))
4256  {
4257  att_type = ConfigGetString("soundAttType");
4258  }
4260  m_SoundAttType = att_type;
4261  }
4262 
4263  override string GetAttachmentSoundType()
4264  {
4265  return m_SoundAttType;
4266  }
4267 
4268  //----------------------------------------------------------------
4269  //SOUNDS FOR ADVANCED PLACEMNT
4270  //----------------------------------------------------------------
4271 
4272  void SoundSynchRemoteReset()
4273  {
4274  m_IsSoundSynchRemote = false;
4275 
4276  SetSynchDirty();
4277  }
4278 
4279  void SoundSynchRemote()
4280  {
4281  m_IsSoundSynchRemote = true;
4282 
4283  SetSynchDirty();
4284  }
4285 
4286  bool IsSoundSynchRemote()
4287  {
4289  }
4290 
4291  string GetDeploySoundset();
4292  string GetPlaceSoundset();
4293  string GetLoopDeploySoundset();
4294  string GetDeployFinishSoundset();
4295 
4296  void SetIsPlaceSound(bool is_place_sound)
4297  {
4298  m_IsPlaceSound = is_place_sound;
4299  }
4300 
4301  bool IsPlaceSound()
4302  {
4304  }
4305 
4306  void SetIsDeploySound(bool is_deploy_sound)
4307  {
4308  m_IsDeploySound = is_deploy_sound;
4309  }
4310 
4311  bool IsDeploySound()
4312  {
4313  return m_IsDeploySound;
4314  }
4316  void PlayDeployLoopSoundEx()
4317  {
4318  if (!GetGame().IsDedicatedServer() && !m_DeployLoopSoundEx)
4319  {
4320  m_DeployLoopSoundEx = SEffectManager.PlaySound(GetLoopDeploySoundset(), GetPosition());
4321  if (m_DeployLoopSoundEx)
4322  m_DeployLoopSoundEx.SetAutodestroy(true);
4323  else
4324  Debug.Log("dbgSounds | null m_DeployLoopSoundEx from sound set: " + GetLoopDeploySoundset());
4325  }
4326  }
4327 
4328  void StopDeployLoopSoundEx()
4329  {
4330  if (!GetGame().IsDedicatedServer())
4331  {
4332  m_DeployLoopSoundEx.SetSoundFadeOut(0.5);
4333  m_DeployLoopSoundEx.SoundStop();
4334  }
4335  }
4337  void PlayDeploySound()
4338  {
4339  if (!GetGame().IsDedicatedServer() && !m_SoundDeploy)
4340  {
4341  m_SoundDeploy = SEffectManager.PlaySound(GetDeploySoundset(), GetPosition());
4342  if (m_SoundDeploy)
4343  m_SoundDeploy.SetAutodestroy(true);
4344  else
4345  Debug.Log("dbgSounds | null m_SoundDeploy from sound set: " + GetDeploySoundset());
4346  }
4347  }
4349  void PlayDeployFinishSound()
4350  {
4351  if (!GetGame().IsDedicatedServer() && !m_SoundDeployFinish)
4352  {
4353  m_SoundDeployFinish = SEffectManager.PlaySound(GetDeployFinishSoundset(), GetPosition());
4354  if (m_SoundDeployFinish)
4355  m_SoundDeployFinish.SetAutodestroy(true);
4356  else
4357  Debug.Log("dbgSounds | null m_SoundDeployFinish from sound set: " + GetDeployFinishSoundset());
4358  }
4359  }
4361  void PlayPlaceSound()
4362  {
4363  if (!GetGame().IsDedicatedServer() && !m_SoundPlace)
4364  {
4365  m_SoundPlace = SEffectManager.PlaySound(GetPlaceSoundset(), GetPosition());
4367  m_SoundPlace.SetAutodestroy(true);
4368  else
4369  Debug.Log("dbgSounds | null m_SoundPlace from sound set: " + GetPlaceSoundset());
4370  }
4371  }
4372 
4373  bool CanPlayDeployLoopSound()
4374  {
4375  return IsBeingPlaced() && IsSoundSynchRemote();
4376  }
4377 
4379  void PlayAttachSound(string slot_type)
4380  {
4381  if (!GetGame().IsDedicatedServer())
4382  {
4383  if (ConfigIsExisting("attachSoundSet"))
4384  {
4385  string cfg_path = "";
4386  string soundset = "";
4387  string type_name = GetType();
4388 
4389  TStringArray cfg_soundset_array = new TStringArray;
4390  TStringArray cfg_slot_array = new TStringArray;
4391  ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
4392  ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
4393 
4394  if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
4395  {
4396  for (int i = 0; i < cfg_soundset_array.Count(); i++)
4397  {
4398  if (cfg_slot_array[i] == slot_type)
4399  {
4400  soundset = cfg_soundset_array[i];
4401  break;
4402  }
4403  }
4404  }
4405 
4406  if (soundset != "")
4407  {
4408  EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
4409  sound.SetAutodestroy(true);
4410  }
4411  }
4412  }
4413  }
4415  void PlayDetachSound(string slot_type)
4416  {
4417  //TODO - evaluate if needed and devise universal config structure if so
4418  }
4420  void OnApply(PlayerBase player);
4421 
4422  float GetBandagingEffectivity()
4423  {
4424  return 1.0;
4425  };
4426  //returns applicable selection
4428  {
4429  return m_HeadHidingSelections;
4430  }
4431 
4433  {
4434  return m_HideSelectionsBySlot;
4435  }
4436 
4437  WrittenNoteData GetWrittenNoteData() {};
4438 
4439  void StopItemDynamicPhysics()
4440  {
4441  SetDynamicPhysicsLifeTime(0.01);
4442  m_ItemBeingDroppedPhys = false;
4443  }
4446  {
4447  array<string> zone_names = new array<string>;
4448  GetDamageZones(zone_names);
4449  for (int i = 0; i < zone_names.Count(); i++)
4450  {
4451  SetHealthMax(zone_names.Get(i),"Health");
4452  }
4453  SetHealthMax("","Health");
4454  }
4455 
4458  {
4459  float global_health = GetHealth01("","Health");
4460  array<string> zones = new array<string>;
4461  GetDamageZones(zones);
4462  //set damage of all zones to match global health level
4463  for (int i = 0; i < zones.Count(); i++)
4464  {
4465  SetHealth01(zones.Get(i),"Health",global_health);
4466  }
4467  }
4468 
4470  bool IsCoverFaceForShave(string slot_name)
4471  {
4472  return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
4473  }
4474 
4475  void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
4476  {
4477  if (!hasRootAsPlayer)
4478  {
4479  if (refParentIB)
4480  {
4481  // parent is wet
4482  if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
4483  AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
4484  // parent has liquid inside
4485  else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
4486  AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
4487  // drying
4488  else if (m_VarWet > m_VarWetMin)
4489  AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
4490  }
4491  else
4492  {
4493  // drying on ground or inside non-itembase (car, ...)
4494  if (m_VarWet > m_VarWetMin)
4495  AddWet(-1 * delta * GetDryingIncrement("ground"));
4496  }
4497  }
4498  }
4499 
4500  void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
4501  {
4502  if (!hasRootAsPlayer && GetTemperature() > GetTemperatureMin() && !IsFireplace())
4503  {
4504  if (refParentIB)
4505  {
4506  // cooling of an item inside other
4507  if (GetTemperature() > refParentIB.GetTemperature())
4508  AddTemperature(delta * GameConstants.TEMPERATURE_RATE_COOLING_INSIDE);
4509  }
4510  else
4511  {
4512  // cooling of an item on ground or inside non-itembase (car, ...)
4513  AddTemperature(delta * GameConstants.TEMPERATURE_RATE_COOLING_INSIDE);
4514  }
4515  }
4516  }
4517 
4518  // Backwards compatibility
4519  void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
4520  {
4521  ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
4522  ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
4523  }
4524 
4525  void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
4526  {
4527  // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
4528  EntityAI parent = GetHierarchyParent();
4529  if (!parent)
4530  {
4531  hasParent = false;
4532  hasRootAsPlayer = false;
4533  }
4534  else
4535  {
4536  hasParent = true;
4537  hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
4538  refParentIB = ItemBase.Cast(parent);
4539  }
4540  }
4541 
4542  protected void ProcessDecay(float delta, bool hasRootAsPlayer)
4543  {
4544  // this is stub, implemented on Edible_Base
4545  }
4546 
4547  bool CanDecay() //Was protected, changed for access from TransferItemVariables method
4548  {
4549  // return true used on selected food clases so they can decay
4550  return false;
4551  }
4552 
4553  protected bool CanProcessDecay()
4554  {
4555  // this is stub, implemented on Edible_Base class
4556  // used to determine whether it is still necessary for the food to decay
4557  return false;
4558  }
4560  protected bool CanHaveWetness()
4561  {
4562  // return true used on selected items that have a wetness effect
4563  return false;
4564  }
4565 
4566  protected bool CanHaveTemperature()
4567  {
4568  // return true used on selected items that have a temperature effect
4569  return false;
4570  }
4571 
4572  override void OnCEUpdate()
4573  {
4574  super.OnCEUpdate();
4575 
4576  bool hasParent = false, hasRootAsPlayer = false;
4577  ItemBase refParentIB;
4578 
4579  bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
4580  bool foodDecay = g_Game.IsFoodDecayEnabled();
4581 
4582  if (wwtu || foodDecay)
4583  {
4584  bool processWetness = wwtu && CanHaveWetness();
4585  bool processTemperature = wwtu && CanHaveTemperature();
4586  bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
4587 
4588  if (processWetness || processTemperature || processDecay)
4589  {
4590  HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
4592  if (processWetness)
4593  ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
4594 
4595  if (processTemperature)
4596  ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
4597 
4598  if (processDecay)
4599  ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
4600  }
4601  }
4602  }
4603 
4604  bool IsCargoException4x3(EntityAI item)
4605  {
4606  return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
4607  }
4608 
4609  void CopyScriptPropertiesFrom(EntityAI oldItem)
4610  {
4611  MiscGameplayFunctions.TransferItemProperties(oldItem, this);
4612  }
4613 
4615  void AddLightSourceItem(ItemBase lightsource)
4616  {
4617  m_LightSourceItem = lightsource;
4618  }
4619 
4620  void RemoveLightSourceItem()
4621  {
4622  m_LightSourceItem = null;
4623  }
4626  {
4627  return m_LightSourceItem;
4628  }
4632  {
4633  return null;
4634  }
4635 
4637  bool GetActionWidgetOverride(out typename name)
4638  {
4639  return false;
4640  }
4641 
4642  bool PairWithDevice(notnull ItemBase otherDevice)
4643  {
4644  if (GetGame().IsServer())
4645  {
4646  ItemBase explosive = otherDevice;
4648  if (!trg)
4649  {
4650  trg = RemoteDetonatorTrigger.Cast(otherDevice);
4651  explosive = this;
4652  }
4653 
4654  explosive.PairRemote(trg);
4655  trg.SetControlledDevice(explosive);
4656 
4657  int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
4658  trg.SetPersistentPairID(persistentID);
4659  explosive.SetPersistentPairID(persistentID);
4660 
4661  return true;
4662  }
4663  return false;
4664  }
4665 
4666  #ifdef DEVELOPER
4667  override void SetDebugItem()
4668  {
4669  super.SetDebugItem();
4670  _itemBase = this;
4671  }
4672  #endif
4673 
4674  bool CanBeUsedForSuicide()
4675  {
4676  return true;
4677  }
4678 }
4679 
4680 EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
4681 {
4682  EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
4683  if (entity)
4684  {
4685  bool is_item = entity.IsInherited(ItemBase);
4686  if (is_item && full_quantity)
4687  {
4688  ItemBase item = ItemBase.Cast(entity);
4689  item.SetQuantity(item.GetQuantityInit());
4690  }
4691  }
4692  else
4693  {
4694  Print("Cannot spawn entity: " + object_name);
4695  return NULL;
4696  }
4697  return entity;
4698 }
4699 
4700 void SetupSpawnedItem(ItemBase item, float health, float quantity)
4701 {
4702  if (item)
4703  {
4704  if (health > 0)
4705  item.SetHealth("", "", health);
4706 
4707 
4708  if (item.HasEnergyManager())
4709  {
4710  if (quantity >= 0)
4711  {
4712  item.GetCompEM().SetEnergy0To1(quantity);
4713  }
4714  else
4715  {
4716  item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
4717  }
4718  }
4719  else if (item.IsMagazine())
4720  {
4721  Magazine mag = Magazine.Cast(item);
4722  if (quantity >= 0)
4723  {
4724  mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
4725  }
4726  else
4727  {
4728  mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
4729  }
4730 
4731  }
4732  else
4733  {
4734  if (quantity >= 0)
4735  {
4736  item.SetQuantityNormalized(quantity, false);
4737  }
4738  else
4739  {
4740  item.SetQuantity(Math.AbsFloat(quantity));
4741  }
4742 
4743  }
4744  }
4745 }
4746 
4747 #ifdef DEVELOPER
4748 ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
4749 #endif
ItemBase
Definition: inventoryitem.c:730
Param2
Definition: ppeconstants.c:66
m_VarTemperatureInit
float m_VarTemperatureInit
Definition: itembase.c:26
RF_DEFAULT
const int RF_DEFAULT
Definition: centraleconomy.c:65
TransferAgents
void TransferAgents(int agents)
transfer agents from another item
Definition: itembase.c:3869
SetResultOfSplit
void SetResultOfSplit(bool value)
Definition: itembase.c:2029
GetGame
proto native CGame GetGame()
GetSoakingIncrement
float GetSoakingIncrement(string pIncrementName)
Definition: itembase.c:3564
UIScriptedMenu
Definition: dayzgame.c:63
IsExplosive
bool IsExplosive()
Definition: itembase.c:906
GetDisinfectQuantity
float GetDisinfectQuantity(int system=0, Param param1=null)
Definition: itembase.c:662
CALL_CATEGORY_SYSTEM
const int CALL_CATEGORY_SYSTEM
Definition: tools.c:8
GetTemperatureInit
override float GetTemperatureInit()
Definition: itembase.c:3530
GetWet
override float GetWet()
Definition: itembase.c:3602
CanEat
bool CanEat()
Definition: itembase.c:2346
MessageToOwnerFriendly
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Definition: itembase.c:2461
m_MaxOverheatingValue
int m_MaxOverheatingValue
Definition: itembase.c:107
SetQuantity
bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Set item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Definition: itembase.c:3159
OnSyncVariables
void OnSyncVariables(ParamsReadContext ctx)
Definition: itembase.c:2591
m_VarTemperatureMax
float m_VarTemperatureMax
Definition: itembase.c:28
StartOverheating
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Definition: itembase.c:559
m_IsBeingPlaced
bool m_IsBeingPlaced
Definition: itembase.c:52
OnActivatedByItem
void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Definition: remotedetonator.c:115
GetSingleInventoryItemWeight
float GetSingleInventoryItemWeight()
Definition: itembase.c:3336
GetWeightSpecialized
override protected float GetWeightSpecialized(bool forceRecalc=false)
Definition: itembase.c:3341
OverheatingParticle
Definition: weaponparticles.c:381
RemoveAgent
override void RemoveAgent(int agent_id)
Definition: itembase.c:3841
ActionTakeItemToHands
Definition: actiontakeitemtohands.c:1
ComponentEnergyManager
Definition: componentenergymanager.c:18
GetRecipesActions
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Definition: itembase.c:2092
GetActions
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Definition: itembase.c:291
WrittenNoteData
Definition: writtennotedata.c:1
LoadParticleConfigOnOverheating
void LoadParticleConfigOnOverheating(int id)
Definition: itembase.c:436
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
SetupSpawnedItem
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Definition: itembase.c:4700
OnEnergyAdded
override void OnEnergyAdded()
Definition: itembase.c:3479
m_IsStoreLoad
bool m_IsStoreLoad
Definition: itembase.c:64
particle_id
int particle_id
Definition: smokesimulation.c:3
SplitIntoStackMaxToInventoryLocationClient
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Definition: itembase.c:1609
CALL_CATEGORY_GAMEPLAY
const int CALL_CATEGORY_GAMEPLAY
Definition: tools.c:10
OnAction
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Definition: itembase.c:2155
HidesSelectionBySlot
bool HidesSelectionBySlot()
Definition: itembase.c:4419
INPUT_UDT_ITEM_MANIPULATION
const int INPUT_UDT_ITEM_MANIPULATION
Definition: _constants.c:8
m_AdminLog
PluginAdminLog m_AdminLog
Definition: itembase.c:115
Particle
Legacy way of using particles in the game.
Definition: particle.c:6
GetColor
void GetColor(out int r, out int g, out int b, out int a)
gets item's color variable as components
Definition: itembase.c:3722
GetValidFinishers
array< int > GetValidFinishers()
returns an array of possible finishers
Definition: itembase.c:4618
LogManager
Definition: debug.c:734
SuppressorBase
Definition: groza_barrel_grip.c:1
SetCanBeMovedOverride
void SetCanBeMovedOverride(bool setting)
Definition: itembase.c:2412
can_this_be_combined
bool can_this_be_combined
Definition: itembase.c:62
m_IsTakeable
bool m_IsTakeable
Definition: itembase.c:56
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
GetItemSize
int GetItemSize()
Definition: itembase.c:2390
m_CleannessMax
int m_CleannessMax
Definition: itembase.c:39
m_CompatibleLocks
ref array< int > m_CompatibleLocks
Definition: itembase.c:121
IsNVG
bool IsNVG()
Definition: itembase.c:899
IsFireplace
override bool IsFireplace()
Definition: fireplacebase.c:504
SplitIntoStackMaxCargo
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Definition: itembase.c:1691
m_VarQuantityPrev
float m_VarQuantityPrev
Definition: itembase.c:17
m_ItemModelLength
float m_ItemModelLength
Definition: itembase.c:47
InventorySlots
provides access to slot configuration
Definition: inventoryslots.c:5
m_VarLiquidType
int m_VarLiquidType
Definition: itembase.c:49
IsLiquidContainer
bool IsLiquidContainer()
Definition: itembase.c:889
AddAction
void AddAction(typename actionName)
Definition: itembase.c:311
VARIABLE_CLEANNESS
const int VARIABLE_CLEANNESS
Definition: constants.c:587
SAT_CRAFTING
const int SAT_CRAFTING
Definition: constants.c:423
SetTemperatureMax
override void SetTemperatureMax()
Definition: itembase.c:3520
GetHeadHidingSelection
array< string > GetHeadHidingSelection()
Definition: itembase.c:4414
PlayDeployLoopSoundEx
void PlayDeployLoopSoundEx()
Definition: itembase.c:4303
LOWEST
@ LOWEST
Definition: ppeconstants.c:53
m_ColorComponentA
int m_ColorComponentA
Definition: itembase.c:77
GetDayZGame
DayZGame GetDayZGame()
Definition: dayzgame.c:3729
AddLightSourceItem
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Definition: itembase.c:4602
SetZoneDamageCEInit
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Definition: itembase.c:4444
ContainsAgent
bool ContainsAgent(int agent_id)
Definition: itembase.c:3828
SetVariableMask
void SetVariableMask(int variable)
Definition: itembase.c:3417
KillAllOverheatingParticles
void KillAllOverheatingParticles()
Definition: itembase.c:628
GetActionWidgetOverride
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Definition: itembase.c:4624
IsCargoException4x3
bool IsCargoException4x3(EntityAI item)
Definition: itembase.c:4591
ActionTakeItem
Definition: actiontakeitem.c:6
SplitItemToInventoryLocation
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Definition: itembase.c:1764
TStringArray
array< string > TStringArray
Definition: enscript.c:685
ConvertEnergyToQuantity
void ConvertEnergyToQuantity()
Definition: itembase.c:3487
IsOverheatingEffectActive
bool IsOverheatingEffectActive()
Definition: itembase.c:530
m_HasQuantityBar
bool m_HasQuantityBar
Definition: itembase.c:66
VARIABLE_COLOR
const int VARIABLE_COLOR
Definition: constants.c:586
DamageItemAttachments
bool DamageItemAttachments(float damage)
Definition: itembase.c:1484
UpdateOverheating
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Definition: itembase.c:565
m_OverheatingDecayInterval
float m_OverheatingDecayInterval
Definition: itembase.c:108
TransferVariablesFloat
void TransferVariablesFloat(array< float > float_vars)
Definition: itembase.c:2567
IsDamageDestroyed
protected bool IsDamageDestroyed(ActionTarget target)
Definition: actionbase.c:913
m_Cleanness
int m_Cleanness
Definition: itembase.c:36
m_OnOverheatingEffect
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Definition: itembase.c:98
SpawnEntity
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
MessageToOwnerImportant
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Definition: itembase.c:2479
WeightDebugData
Definition: debug.c:939
StopDeployLoopSoundEx
void StopDeployLoopSoundEx()
Definition: itembase.c:4315
ScriptInputUserData
Definition: gameplay.c:120
PairWithDevice
bool PairWithDevice(notnull ItemBase otherDevice)
Definition: itembase.c:4629
IDToName
string IDToName(int id)
Definition: itembase.c:2585
m_ItemBeingDroppedPhys
bool m_ItemBeingDroppedPhys
Definition: itembase.c:59
m_LockSoundSet
protected string m_LockSoundSet
Definition: itembase.c:124
m_HideSelectionsBySlot
protected bool m_HideSelectionsBySlot
Definition: itembase.c:112
CanBeSplit
override bool CanBeSplit()
Definition: itembase.c:1501
GetLightSourceItem
ItemBase GetLightSourceItem()
Definition: itembase.c:4612
LoadParticleConfigOnFire
void LoadParticleConfigOnFire(int id)
Definition: itembase.c:367
VARIABLE_LIQUIDTYPE
const int VARIABLE_LIQUIDTYPE
Definition: constants.c:584
Close
void Close()
Weapon
script counterpart to engine's class Weapon
Definition: inventoryitem.c:48
SetIsDeploySound
void SetIsDeploySound(bool is_deploy_sound)
Definition: itembase.c:4293
IsCoverFaceForShave
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Definition: itembase.c:4457
SplitIntoStackMaxToInventoryLocationEx
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Definition: itembase.c:1660
DeSerializeNumericalVars
void DeSerializeNumericalVars(array< float > floats)
Definition: itembase.c:2658
ActionAttachWithSwitch
Definition: actionattachwithswich.c:1
m_PhysDropTimer
ref Timer m_PhysDropTimer
Definition: itembase.c:118
EEHitBy
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Definition: itembase.c:1424
NameToID
int NameToID(string name)
Definition: itembase.c:2579
SetCleanness
void SetCleanness(int value, bool allow_client=false)
Definition: itembase.c:3678
Print
proto void Print(void var)
Prints content of variable to console/log.
HasFoodStage
bool HasFoodStage()
Definition: itembase.c:2359
ItemVariableFlags
Definition: utilityclasses.c:1
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
CanPutAsAttachment
override bool CanPutAsAttachment(EntityAI parent)
Definition: itembase.c:4021
IsTwoHandedBehaviour
override bool IsTwoHandedBehaviour()
Definition: itembase.c:4202
PreLoadSoundAttachmentType
protected void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Definition: itembase.c:4238
m_CleannessMin
int m_CleannessMin
Definition: itembase.c:38
HasQuantity
bool HasQuantity()
Definition: itembase.c:3311
m_HeatIsolation
float m_HeatIsolation
Definition: itembase.c:46
m_CleannessInit
int m_CleannessInit
Definition: itembase.c:37
SaveVariables
void SaveVariables(ParamsWriteContext ctx)
Definition: itembase.c:2875
m_VarTemperatureMin
float m_VarTemperatureMin
Definition: itembase.c:27
ECE_PLACE_ON_SURFACE
const int ECE_PLACE_ON_SURFACE
Definition: centraleconomy.c:37
AddQuantity
bool AddQuantity(float value, bool destroy_config=true, bool destroy_forced=false)
add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Definition: itembase.c:3221
m_VarWetInit
float m_VarWetInit
Definition: itembase.c:32
UpdateAllOverheatingParticles
void UpdateAllOverheatingParticles()
Definition: itembase.c:600
PlayDeploySound
void PlayDeploySound()
Definition: itembase.c:4324
GetQuantityMax
override int GetQuantityMax()
Definition: itembase.c:3262
GetQuantity
override float GetQuantity()
Definition: itembase.c:3316
OnApply
void OnApply(PlayerBase player)
m_IsDeploySound
bool m_IsDeploySound
Definition: itembase.c:55
CanDecay
bool CanDecay()
Definition: itembase.c:4534
SetCEBasedQuantity
void SetCEBasedQuantity()
Definition: itembase.c:790
ComputeQuantityUsed
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Definition: itembase.c:2034
CachedObjectsParams
Definition: utilityclasses.c:9
DayZInfected
Definition: zombiebase.c:1
m_InteractActions
ref TIntArray m_InteractActions
Definition: itembase.c:85
m_RecipesInitialized
bool m_RecipesInitialized
Definition: itembase.c:7
Explode
override void Explode(int damageType, string ammoType="")
Definition: trap_landmine.c:220
m_LockType
protected int m_LockType
Definition: itembase.c:122
GetLiquidTypeInit
int GetLiquidTypeInit()
Definition: itembase.c:3758
IsPlaceSound
bool IsPlaceSound()
Definition: itembase.c:4288
RemotelyActivatedItemBehaviour
Definition: remotelyactivateditembehaviour.c:1
component
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
ActionManagerBase
void ActionManagerBase(PlayerBase player)
Definition: actionmanagerbase.c:62
m_VarWetMax
float m_VarWetMax
Definition: itembase.c:34
UnlockFromParent
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Definition: itembase.c:837
PlayDeployFinishSound
void PlayDeployFinishSound()
Definition: itembase.c:4336
InventoryItem
Definition: itembase.c:13
PlayDetachSound
void PlayDetachSound(string slot_type)
Definition: itembase.c:4402
IsCombineAll
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Definition: itembase.c:2019
CanHaveWetness
protected bool CanHaveWetness()
Definition: itembase.c:4547
ActionWorldCraft
Definition: actionworldcraft.c:32
InsertAgent
override void InsertAgent(int agent, float count=1)
Definition: itembase.c:3860
GetUnitWeight
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Definition: itembase.c:3400
SetIsHologram
void SetIsHologram(bool is_hologram)
Definition: itembase.c:977
GetLiquidType
int GetLiquidType()
Definition: itembase.c:3763
LoadVariables
bool LoadVariables(ParamsReadContext ctx, int version=-1)
Definition: itembase.c:2898
OnEnergyConsumed
override void OnEnergyConsumed()
Definition: itembase.c:3472
UsesGlobalDeploy
protected bool UsesGlobalDeploy()
Definition: itembase.c:269
GetMuzzleID
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Definition: itembase.c:682
m_OverheatingParticles
ref array< ref OverheatingParticle > m_OverheatingParticles
Definition: itembase.c:109
DoAmmoExplosion
void DoAmmoExplosion()
Definition: itembase.c:1400
IEntity
Definition: enentity.c:164
MENU_INVENTORY
const int MENU_INVENTORY
Definition: constants.c:170
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
m_ItemAttachOffset
float m_ItemAttachOffset
Definition: itembase.c:48
GetLockSoundSet
string GetLockSoundSet()
Definition: itembase.c:3705
ProcessDecay
protected void ProcessDecay(float delta, bool hasRootAsPlayer)
Definition: itembase.c:4529
IsServerCheck
bool IsServerCheck(bool allow_client)
Definition: itembase.c:3643
CombineItemsClient
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Definition: itembase.c:849
IsColorSet
bool IsColorSet()
Definition: itembase.c:3730
OnItemInHandsPlayerSwimStart
void OnItemInHandsPlayerSwimStart(PlayerBase player)
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition: pluginmanager.c:316
IsDeploySound
bool IsDeploySound()
Definition: itembase.c:4298
MessageToOwnerAction
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Definition: itembase.c:2443
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
GetTemperature
override float GetTemperature()
Definition: itembase.c:3525
TIntArray
array< int > TIntArray
Definition: enscript.c:687
PerformDamageSystemReinit
void PerformDamageSystemReinit()
Definition: itembase.c:4432
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
CopyScriptPropertiesFrom
void CopyScriptPropertiesFrom(EntityAI oldItem)
Definition: itembase.c:4596
m_LightSourceItem
ItemBase m_LightSourceItem
Definition: itembase.c:81
SoundSynchRemoteReset
void SoundSynchRemoteReset()
Definition: itembase.c:4259
m_ColorComponentB
int m_ColorComponentB
Definition: itembase.c:76
m_SoundDeploy
protected EffectSound m_SoundDeploy
Definition: itembase.c:127
SplitItem
void SplitItem(PlayerBase player)
Definition: itembase.c:1797
m_HeadHidingSelections
protected ref TStringArray m_HeadHidingSelections
Definition: itembase.c:111
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
OnCreatePhysics
override void OnCreatePhysics()
Definition: itembase.c:1178
EffectSound
Wrapper class for managing sound through SEffectManager.
Definition: effectsound.c:4
RemoveAction
void RemoveAction(typename actionName)
Definition: itembase.c:349
m_SingleUseActions
ref TIntArray m_SingleUseActions
Definition: itembase.c:83
GetAttachmentSoundType
override string GetAttachmentSoundType()
Definition: itembase.c:4250
IsFullQuantity
bool IsFullQuantity()
Definition: itembase.c:3321
m_VarTemperature
float m_VarTemperature
Definition: itembase.c:25
GetHeatIsolationInit
float GetHeatIsolationInit()
Definition: itembase.c:3545
IncreaseOverheating
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Definition: itembase.c:497
PlayerBase
Definition: playerbaseclient.c:1
GetDryingIncrement
float GetDryingIncrement(string pIncrementName)
Definition: itembase.c:3555
DamageItemInCargo
bool DamageItemInCargo(float damage)
Definition: itembase.c:1465
map
map
Definition: controlsxboxnew.c:3
GetSingleInventoryItemWeightEx
override float GetSingleInventoryItemWeightEx()
Definition: itembase.c:3327
vector
Definition: enconvert.c:105
HasMuzzle
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Definition: itembase.c:673
SpawnItemOnLocation
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Definition: itembase.c:4680
ChangeIntoOnDetach
override string ChangeIntoOnDetach()
Definition: itembase.c:1348
CanBeCooked
bool CanBeCooked()
Definition: itembase.c:2365
GetWetMax
override float GetWetMax()
Definition: itembase.c:3607
SerializeNumericalVars
void SerializeNumericalVars(array< float > floats_out)
Definition: itembase.c:2618
LockToParent
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Definition: itembase.c:824
InventoryMode
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition: inventory.c:21
Repair
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Definition: itembase.c:2383
IsHeavyBehaviour
override bool IsHeavyBehaviour()
Definition: itembase.c:4182
m_AttachedAgents
private int m_AttachedAgents
Definition: itembase.c:89
ItemBase
void ItemBase()
Definition: itembase.c:131
TotalDamageResult
Definition: damagesystem.c:1
m_CanBeDigged
protected bool m_CanBeDigged
Definition: itembase.c:67
m_ItemBehaviour
int m_ItemBehaviour
Definition: itembase.c:50
m_Count
int m_Count
Definition: itembase.c:21
InventoryLocationType
InventoryLocationType
types of Inventory Location
Definition: inventorylocation.c:3
GetItem
EntityAI GetItem()
Definition: radialquickbarmenu.c:37
m_WantPlayImpactSound
bool m_WantPlayImpactSound
Definition: itembase.c:41
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
ComputeQuantityUsedEx
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Definition: itembase.c:2039
GetColorString
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Definition: itembase.c:3736
GetHeatIsolation
float GetHeatIsolation()
Definition: itembase.c:3550
SetLiquidType
void SetLiquidType(int value, bool allow_client=false)
Definition: itembase.c:3749
PlayPlaceSound
void PlayPlaceSound()
Definition: itembase.c:4348
SaveAgents
void SaveAgents(ParamsWriteContext ctx)
Definition: itembase.c:3929
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
MessageToOwnerStatus
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Definition: itembase.c:2425
OnItemAttachmentSlotChanged
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Definition: itembase.c:1183
GetTemperatureMax
override float GetTemperatureMax()
Definition: itembase.c:3540
m_SoundPlace
protected EffectSound m_SoundPlace
Definition: itembase.c:126
Object
Definition: objecttyped.c:1
DEF_BIOLOGICAL
const int DEF_BIOLOGICAL
Definition: constants.c:478
slotName
PlayerSpawnPreset slotName
SetIsBeingPlaced
void SetIsBeingPlaced(bool is_being_placed)
Definition: itembase.c:951
ScriptedLightBase
Definition: pointlightbase.c:1
OnCEUpdate
override void OnCEUpdate()
Definition: itembase.c:4559
m_CanThisBeSplit
bool m_CanThisBeSplit
Definition: itembase.c:63
SplitIntoStackMaxHandsClient
void SplitIntoStackMaxHandsClient(PlayerBase player)
Definition: itembase.c:1715
m_IsOverheatingEffectActive
bool m_IsOverheatingEffectActive
Definition: itembase.c:103
AddWet
override void AddWet(float value)
Definition: itembase.c:3592
GetProtectionLevel
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Definition: itembase.c:3938
DummyItem
Definition: magnum.c:404
GetDeployTime
float GetDeployTime()
how long it takes to deploy this item in seconds
Definition: itembase.c:4218
GetRemotelyActivatedItemBehaviour
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Definition: remotedetonator.c:82
PlayAttachSound
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Definition: itembase.c:4366
SetQuantityToMinimum
override void SetQuantityToMinimum()
Definition: itembase.c:3232
m_ContinuousActions
ref TIntArray m_ContinuousActions
Definition: itembase.c:84
Contact
Definition: enphysics.c:300
SetIsPlaceSound
void SetIsPlaceSound(bool is_place_sound)
Definition: itembase.c:4283
dBodyIsDynamic
proto native bool dBodyIsDynamic(notnull IEntity ent)
GetQuantityInit
int GetQuantityInit()
Definition: itembase.c:3305
OnQuantityChanged
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Definition: itembase.c:1833
SplitIntoStackMaxCargoClient
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Definition: itembase.c:1630
RemoveAllAgentsExcept
override void RemoveAllAgentsExcept(int agents_to_keep_mask)
Definition: itembase.c:3855
RemoteDetonatorTrigger
Definition: remotedetonator.c:46
CanRepair
bool CanRepair(ItemBase item_repair_kit)
Definition: itembase.c:2376
LoadAgents
bool LoadAgents(ParamsReadContext ctx, int version)
Definition: itembase.c:3922
m_SoundAttType
string m_SoundAttType
Definition: itembase.c:72
EWetnessLevel
EWetnessLevel
Definition: entityai.c:1
Inventory_Base
ItemBase Inventory_Base
Definition: itembase.c:1
SetWetMax
override void SetWetMax()
Definition: itembase.c:3597
~ItemBase
void ~ItemBase()
Definition: itembase.c:713
UATimeSpent
Definition: actionconstants.c:26
FindInventoryLocationType
FindInventoryLocationType
flags for searching locations in inventory
Definition: inventorylocation.c:15
SplitIntoStackMaxHands
void SplitIntoStackMaxHands(PlayerBase player)
Definition: itembase.c:1739
SplitIntoStackMaxToInventoryLocation
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Definition: itembase.c:1655
GetOverheatingCoef
float GetOverheatingCoef()
Definition: itembase.c:592
EActions
EActions
Definition: eactions.c:1
IsLightSource
bool IsLightSource()
Definition: itembase.c:918
ReadVarsFromCTX
bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Definition: itembase.c:2761
IsOneHandedBehaviour
override bool IsOneHandedBehaviour()
Definition: itembase.c:4192
GetLockType
int GetLockType()
Definition: itembase.c:3700
HierarchyCheck
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Definition: itembase.c:4512
CheckOverheating
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Definition: itembase.c:513
GetTargetQuantityMax
override int GetTargetQuantityMax(int attSlotID=-1)
Definition: itembase.c:3284
Bolt_Base
Definition: ammunitionpiles.c:90
m_IsSoundSynchRemote
bool m_IsSoundSynchRemote
Definition: itembase.c:57
m_ActionsInitialize
bool m_ActionsInitialize
Definition: itembase.c:4
GetQuantityNormalized
float GetQuantityNormalized()
Gets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Definition: itembase.c:3248
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
m_IsPlaceSound
bool m_IsPlaceSound
Definition: itembase.c:54
IsOpen
bool IsOpen()
Definition: itembase.c:3993
SetQuantityNormalized
void SetQuantityNormalized(float value, bool destroy_config=true, bool destroy_forced=false)
Sets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Definition: itembase.c:3239
CanHaveTemperature
protected bool CanHaveTemperature()
Definition: itembase.c:4553
OnRightClick
override void OnRightClick()
Definition: itembase.c:1894
StopItemDynamicPhysics
void StopItemDynamicPhysics()
Definition: itembase.c:4426
Open
void Open()
Implementations only.
Definition: cannedfood.c:2
m_FixDamageSystemInit
bool m_FixDamageSystemInit
Definition: itembase.c:61
m_VarStackMax
float m_VarStackMax
Definition: itembase.c:22
m_DeployLoopSoundEx
protected bool m_IsResultOfSplit protected EffectSound m_DeployLoopSoundEx
distinguish if item has been created as new or it came from splitting (server only flag)
Definition: itembase.c:70
m_CanPlayImpactSound
bool m_CanPlayImpactSound
Definition: itembase.c:42
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
m_CanShowQuantity
bool m_CanShowQuantity
Definition: itembase.c:65
ActionBase
void ActionBase()
Definition: actionbase.c:73
GetWetInit
override float GetWetInit()
Definition: itembase.c:3617
VARIABLE_QUANTITY
const int VARIABLE_QUANTITY
Definition: constants.c:580
m_VarQuantityMax
int m_VarQuantityMax
Definition: itembase.c:20
StopOverheating
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Definition: itembase.c:572
IsBeingPlaced
override bool IsBeingPlaced()
Definition: itembase.c:946
OnMovedInsideCargo
override void OnMovedInsideCargo(EntityAI container)
Definition: itembase.c:1017
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
IsHologram
override bool IsHologram()
Definition: itembase.c:962
m_VarQuantity
float m_VarQuantity
Definition: itembase.c:16
TInputActionMap
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Definition: actionmanagerclient.c:1
IsItemBase
override bool IsItemBase()
Definition: itembase.c:2489
GetItemModelLength
float GetItemModelLength()
Definition: itembase.c:3660
m_LockingSound
protected ref EffectSound m_LockingSound
Definition: itembase.c:123
m_ThrowItemOnDrop
bool m_ThrowItemOnDrop
Definition: itembase.c:58
GetDebugActions
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Definition: itembase.c:2113
GameConstants
Definition: constants.c:612
Debug
Definition: debug.c:13
GetItemAttachOffset
float GetItemAttachOffset()
Definition: itembase.c:3669
InventoryTraversalType
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Definition: gameplay.c:5
RemoveLightSourceItem
void RemoveLightSourceItem()
Definition: itembase.c:4607
GetNumberOfItems
int GetNumberOfItems()
Returns the number of items in cargo, otherwise returns 0(non-cargo objects). Recursive.
Definition: itembase.c:3380
GetQuickBarBonus
override int GetQuickBarBonus()
Definition: itembase.c:274
OnActivatedByTripWire
void OnActivatedByTripWire()
m_ColorComponentG
int m_ColorComponentG
Definition: itembase.c:75
CanBeUsedForSuicide
bool CanBeUsedForSuicide()
Definition: itembase.c:4661
SetTemperature
override void SetTemperature(float value, bool allow_client=false)
Definition: itembase.c:3499
PluginItemDiagnostic
void PluginItemDiagnostic()
Definition: pluginitemdiagnostic.c:83
Type
string Type
Definition: jsondatacontaminatedarea.c:11
CanPlayDeployLoopSound
bool CanPlayDeployLoopSound()
Definition: itembase.c:4360
SetColor
void SetColor(int r, int g, int b, int a)
Definition: itembase.c:3713
DEF_CHEMICAL
const int DEF_CHEMICAL
Definition: constants.c:479
m_Initialized
protected bool m_Initialized
Definition: uihintpanel.c:23
CanBeCookedOnStick
bool CanBeCookedOnStick()
Definition: itembase.c:2370
SplitIntoStackMax
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Definition: itembase.c:1532
m_CanBeMovedOverride
bool m_CanBeMovedOverride
Definition: itembase.c:60
m_IsHologram
bool m_IsHologram
Definition: itembase.c:53
ERPCs
ERPCs
Definition: erpcs.c:1
Timer
Definition: dayzplayerimplement.c:62
ChangeIntoOnAttach
override string ChangeIntoOnAttach(string slot)
Definition: itembase.c:1324
SetQuantityMax
void SetQuantityMax()
Definition: itembase.c:3226
GetEnergy
float GetEnergy()
Definition: itembase.c:3461
m_ImpactSoundSurfaceHash
int m_ImpactSoundSurfaceHash
Definition: itembase.c:44
WriteVarsToCTX
void WriteVarsToCTX(ParamsWriteContext ctx)
Definition: itembase.c:2722
m_VarWet
float m_VarWet
Definition: itembase.c:30
m_VarQuantityMin
int m_VarQuantityMin
Definition: itembase.c:19
SAT_DEBUG_ACTION
const int SAT_DEBUG_ACTION
Definition: constants.c:424
m_VariablesMask
int m_VariablesMask
Definition: itembase.c:13
OnAttachmentQuantityChangedEx
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Definition: itembase.c:1851
m_ColorComponentR
int m_ColorComponentR
Definition: itembase.c:74
GetExplosiveTriggerSlotName
string GetExplosiveTriggerSlotName()
Definition: itembase.c:911
IsResultOfSplit
bool IsResultOfSplit()
Definition: itembase.c:2024
RemoveItemVariable
void RemoveItemVariable(int variable)
Removes variable from variable mask, making it appear as though the variable has never been changed f...
Definition: itembase.c:3427
m_ImpactSpeed
float m_ImpactSpeed
Definition: itembase.c:43
ActionDropItem
void ActionDropItem()
Definition: actiondropitem.c:14
TransferModifiers
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
OnWetLevelChanged
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Definition: itembase.c:3632
TSelectableActionInfo
Param3 TSelectableActionInfo
m_VarWetMin
float m_VarWetMin
Definition: itembase.c:33
EEOnCECreate
override void EEOnCECreate()
Called when entity is being created as new by CE/ Debug.
Definition: itembase.c:3977
CanProcessDecay
protected bool CanProcessDecay()
Definition: itembase.c:4540
m_CheckOverheating
ref Timer m_CheckOverheating
Definition: itembase.c:105
AllowFoodConsumption
bool AllowFoodConsumption()
Definition: itembase.c:3692
GetWetLevel
override EWetnessLevel GetWetLevel()
Definition: itembase.c:3637
Math
Definition: enmath.c:6
ClearInventory
override void ClearInventory()
Definition: itembase.c:3440
CanBeMovedOverride
bool CanBeMovedOverride()
Definition: itembase.c:2405
GetLight
ScriptedLightBase GetLight()
ProcessItemWetnessAndTemperature
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Definition: itembase.c:4506
EntityEvent
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition: enentity.c:44
m_QuickBarBonus
int m_QuickBarBonus
Definition: itembase.c:51
GetOverheatingValue
float GetOverheatingValue()
Definition: itembase.c:492
IsVariableSet
bool IsVariableSet(int variable)
'true' if this variable has ever been changed from default
Definition: itembase.c:3433
GetVariablesFloat
array< float > GetVariablesFloat()
Definition: itembase.c:2572
GetQuantityMin
int GetQuantityMin()
Definition: itembase.c:3300
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
TSelectableActionInfoWithColor
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition: entityai.c:97
OnAttachmentQuantityChanged
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Definition: itembase.c:1845
SEffectManager
Manager class for managing Effect (EffectParticle, EffectSound)
Definition: effectmanager.c:5
m_VarWetPrev
float m_VarWetPrev
Definition: itembase.c:31
CanBeDigged
bool CanBeDigged()
Definition: itembase.c:967
RegisterOverheatingParticle
void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
Definition: itembase.c:578
MAX
const int MAX
Definition: enconvert.c:27
m_VarQuantityInit
int m_VarQuantityInit
Definition: itembase.c:18
SplitIntoStackMaxClient
void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Definition: itembase.c:1509
EntityAI
Definition: building.c:5
SetWet
override void SetWet(float value, bool allow_client=false)
Definition: itembase.c:3573
IsLiquidPresent
bool IsLiquidPresent()
Definition: itembase.c:883
GetFilterDamageRatio
float GetFilterDamageRatio()
Definition: itembase.c:667
GetAgents
override int GetAgents()
Definition: itembase.c:3875
GetType
override int GetType()
Definition: huddebugwincharagents.c:49
KindOf
override bool KindOf(string tag)
Definition: itembase.c:2495
EOnContact
override void EOnContact(IEntity other, Contact extra)
Definition: itembase.c:1148
m_SoundDeployFinish
protected EffectSound m_SoundDeployFinish
Definition: itembase.c:128
m_OverheatingShots
float m_OverheatingShots
Definition: itembase.c:104
ExplodeAmmo
void ExplodeAmmo()
Definition: itembase.c:1387
OnOverheatingDecay
void OnOverheatingDecay()
Definition: itembase.c:535
InitializeActions
void InitializeActions()
Definition: itembase.c:279
GetWetMin
override float GetWetMin()
Definition: itembase.c:3612
CachedObjectsArrays
Definition: utilityclasses.c:40
IsSoundSynchRemote
bool IsSoundSynchRemote()
Definition: itembase.c:4273
ProcessItemWetness
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Definition: itembase.c:4462
GameInventory
script counterpart to engine's class Inventory
Definition: inventory.c:78
ECE_IN_INVENTORY
const int ECE_IN_INVENTORY
Definition: centraleconomy.c:36
CombineItems
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Definition: itembase.c:2058
VARIABLE_TEMPERATURE
const int VARIABLE_TEMPERATURE
Definition: constants.c:582
SoundSynchRemote
void SoundSynchRemote()
Definition: itembase.c:4266
m_InputActionMap
TInputActionMap m_InputActionMap
Definition: itembase.c:3
m_StoreLoadedQuantity
float m_StoreLoadedQuantity
Definition: itembase.c:23
VARIABLE_WET
const int VARIABLE_WET
Definition: constants.c:583
m_ShotsToStartOverheating
int m_ShotsToStartOverheating
Definition: itembase.c:106
ProcessItemTemperature
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Definition: itembase.c:4487