DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ SetQuantityToMinimum()

override void SpawnItemOnLocation::SetQuantityToMinimum ( )
protected

См. определение в файле ItemBase.c строка 8314

8319{
8320 override bool CanPutAsAttachment(EntityAI parent)
8321 {
8322 return true;
8323 }
8324};
8325
8327{
8328
8329};
8330
8331//const bool QUANTITY_DEBUG_REMOVE_ME = false;
8332
8333class ItemBase extends InventoryItem
8334{
8338
8340
8341 static int m_DebugActionsMask;
8343 // ============================================
8344 // Variable Manipulation System
8345 // ============================================
8346 // Quantity
8347
8348 float m_VarQuantity;
8349 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
8351 int m_VarQuantityMin;
8352 int m_VarQuantityMax;
8353 int m_Count;
8354 float m_VarStackMax;
8355 float m_StoreLoadedQuantity = float.LOWEST;
8356 // Wet
8357 float m_VarWet;
8358 float m_VarWetPrev;//for client to know wetness changed during synchronization
8359 float m_VarWetInit;
8360 float m_VarWetMin;
8361 float m_VarWetMax;
8362 // Cleanness
8363 int m_Cleanness;
8364 int m_CleannessInit;
8365 int m_CleannessMin;
8366 int m_CleannessMax;
8367 // impact sounds
8369 bool m_CanPlayImpactSound = true;
8370 float m_ImpactSpeed;
8372 //
8373 float m_HeatIsolation;
8374 float m_ItemModelLength;
8375 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
8377 int m_VarLiquidType;
8378 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
8379 int m_QuickBarBonus;
8380 bool m_IsBeingPlaced;
8381 bool m_IsHologram;
8382 bool m_IsTakeable;
8383 bool m_ThrowItemOnDrop;
8386 bool m_FixDamageSystemInit = false; //can be changed on storage version check
8387 bool can_this_be_combined; //Check if item can be combined
8388 bool m_CanThisBeSplit; //Check if item can be split
8389 bool m_IsStoreLoad = false;
8390 bool m_CanShowQuantity;
8391 bool m_HasQuantityBar;
8392 protected bool m_CanBeDigged;
8393 protected bool m_IsResultOfSplit
8394
8395 string m_SoundAttType;
8396 // items color variables
8401 //-------------------------------------------------------
8402
8403 // light source managing
8405
8409
8410 //==============================================
8411 // agent system
8412 private int m_AttachedAgents;
8413
8415 void TransferModifiers(PlayerBase reciever);
8416
8417
8418 // Weapons & suppressors particle effects
8422 ref static map<string, int> m_WeaponTypeToID;
8423 static int m_LastRegisteredWeaponID = 0;
8424
8425 // Overheating effects
8427 float m_OverheatingShots;
8428 ref Timer m_CheckOverheating;
8429 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
8430 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
8431 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
8432 ref array <ref OverheatingParticle> m_OverheatingParticles;
8433
8435 protected bool m_HideSelectionsBySlot;
8436
8437 // Admin Log
8438 PluginAdminLog m_AdminLog;
8439
8440 // misc
8441 ref Timer m_PhysDropTimer;
8442
8443 // Attachment Locking variables
8444 ref array<int> m_CompatibleLocks;
8445 protected int m_LockType;
8446 protected ref EffectSound m_LockingSound;
8447 protected string m_LockSoundSet;
8448
8449 // ItemSoundHandler variables
8450 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
8451 protected int m_SoundSyncPlay; // id for sound to play
8452 protected int m_SoundSyncStop; // id for sound to stop
8453 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
8454
8456
8457 //temperature
8458 private float m_TemperaturePerQuantityWeight;
8459
8460 // -------------------------------------------------------------------------
8461 void ItemBase()
8462 {
8463 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
8467
8468 if (!g_Game.IsDedicatedServer())
8469 {
8470 if (HasMuzzle())
8471 {
8473
8475 {
8477 }
8478 }
8479
8481 m_ActionsInitialize = false;
8482 }
8483
8484 m_OldLocation = null;
8485
8486 if (g_Game.IsServer())
8487 {
8488 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
8489 }
8490
8491 if (ConfigIsExisting("headSelectionsToHide"))
8492 {
8494 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
8495 }
8496
8497 m_HideSelectionsBySlot = false;
8498 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
8499 {
8500 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
8501 }
8502
8503 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
8504
8505 m_IsResultOfSplit = false;
8506
8508 }
8509
8510 override void InitItemVariables()
8511 {
8512 super.InitItemVariables();
8513
8514 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
8515 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
8516 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
8517 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
8518 m_VarStackMax = ConfigGetFloat("varStackMax");
8519 m_Count = ConfigGetInt("count");
8520
8521 m_CanShowQuantity = ConfigGetBool("quantityShow");
8522 m_HasQuantityBar = ConfigGetBool("quantityBar");
8523
8524 m_CleannessInit = ConfigGetInt("varCleannessInit");
8526 m_CleannessMin = ConfigGetInt("varCleannessMin");
8527 m_CleannessMax = ConfigGetInt("varCleannessMax");
8528
8529 m_WantPlayImpactSound = false;
8530 m_ImpactSpeed = 0.0;
8531
8532 m_VarWetInit = ConfigGetFloat("varWetInit");
8534 m_VarWetMin = ConfigGetFloat("varWetMin");
8535 m_VarWetMax = ConfigGetFloat("varWetMax");
8536
8537 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
8538 if (IsLiquidContainer() && GetQuantity() != 0)
8540 m_IsBeingPlaced = false;
8541 m_IsHologram = false;
8542 m_IsTakeable = true;
8543 m_CanBeMovedOverride = false;
8547 m_CanBeDigged = ConfigGetBool("canBeDigged");
8548
8549 m_CompatibleLocks = new array<int>();
8550 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
8551 m_LockType = ConfigGetInt("lockType");
8552
8553 //Define if item can be split and set ability to be combined accordingly
8554 m_CanThisBeSplit = false;
8555 can_this_be_combined = false;
8556 if (ConfigIsExisting("canBeSplit"))
8557 {
8558 can_this_be_combined = ConfigGetBool("canBeSplit");
8560 }
8561
8562 m_ItemBehaviour = -1;
8563 if (ConfigIsExisting("itemBehaviour"))
8564 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
8565
8566 //RegisterNetSyncVariableInt("m_VariablesMask");
8567 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
8568 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
8569 RegisterNetSyncVariableInt("m_VarLiquidType");
8570 RegisterNetSyncVariableInt("m_Cleanness",0,1);
8571
8572 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
8573 RegisterNetSyncVariableFloat("m_ImpactSpeed");
8574 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
8575
8576 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
8577 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
8578 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
8579 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
8580
8581 RegisterNetSyncVariableBool("m_IsBeingPlaced");
8582 RegisterNetSyncVariableBool("m_IsTakeable");
8583 RegisterNetSyncVariableBool("m_IsHologram");
8584
8587 {
8588 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
8589 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
8590 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
8591 }
8592
8593 m_LockSoundSet = ConfigGetString("lockSoundSet");
8594
8596 if (ConfigIsExisting("temperaturePerQuantityWeight"))
8597 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
8598
8599 m_SoundSyncSlotID = -1;
8600 }
8601
8602 override int GetQuickBarBonus()
8603 {
8604 return m_QuickBarBonus;
8605 }
8606
8607 void InitializeActions()
8608 {
8610 if (!m_InputActionMap)
8611 {
8613 m_InputActionMap = iam;
8614 SetActions();
8616 }
8617 }
8618
8619 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
8620 {
8622 {
8623 m_ActionsInitialize = true;
8625 }
8626
8627 actions = m_InputActionMap.Get(action_input_type);
8628 }
8629
8630 void SetActions()
8631 {
8632 AddAction(ActionTakeItem);
8633 AddAction(ActionTakeItemToHands);
8634 AddAction(ActionWorldCraft);
8636 AddAction(ActionAttachWithSwitch);
8637 }
8638
8639 void SetActionAnimOverrides(); // Override action animation for specific item
8640
8641 void AddAction(typename actionName)
8642 {
8643 ActionBase action = ActionManagerBase.GetAction(actionName);
8644
8645 if (!action)
8646 {
8647 Debug.LogError("Action " + actionName + " dosn't exist!");
8648 return;
8649 }
8650
8651 typename ai = action.GetInputType();
8652 if (!ai)
8653 {
8654 m_ActionsInitialize = false;
8655 return;
8656 }
8657
8658 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8659 if (!action_array)
8660 {
8661 action_array = new array<ActionBase_Basic>;
8662 m_InputActionMap.Insert(ai, action_array);
8663 }
8664 if (LogManager.IsActionLogEnable())
8665 {
8666 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
8667 }
8668
8669 if (action_array.Find(action) != -1)
8670 {
8671 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
8672 }
8673 else
8674 {
8675 action_array.Insert(action);
8676 }
8677 }
8678
8679 void RemoveAction(typename actionName)
8680 {
8681 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
8682 ActionBase action = player.GetActionManager().GetAction(actionName);
8683 typename ai = action.GetInputType();
8684 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
8685
8686 if (action_array)
8687 {
8688 action_array.RemoveItem(action);
8689 }
8690 }
8691
8692 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
8693 // Set -1 for params which should stay in default state
8694 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
8695 {
8696 ActionOverrideData overrideData = new ActionOverrideData();
8697 overrideData.m_CommandUID = commandUID;
8698 overrideData.m_CommandUIDProne = commandUIDProne;
8699 overrideData.m_StanceMask = stanceMask;
8700
8701 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
8702 if (!actionMap) // create new map of action > overidables map
8703 {
8704 actionMap = new TActionAnimOverrideMap();
8705 m_ItemActionOverrides.Insert(action, actionMap);
8706 }
8707
8708 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
8709
8710 }
8711
8712 void OnItemInHandsPlayerSwimStart(PlayerBase player);
8713
8714 ScriptedLightBase GetLight();
8715
8716 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
8717 void LoadParticleConfigOnFire(int id)
8718 {
8719 if (!m_OnFireEffect)
8721
8724
8725 string config_to_search = "CfgVehicles";
8726 string muzzle_owner_config;
8727
8728 if (!m_OnFireEffect.Contains(id))
8729 {
8730 if (IsInherited(Weapon))
8731 config_to_search = "CfgWeapons";
8732
8733 muzzle_owner_config = config_to_search + " " + GetType() + " ";
8734
8735 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
8736
8737 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
8738
8739 if (config_OnFire_subclass_count > 0)
8740 {
8741 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
8742
8743 for (int i = 0; i < config_OnFire_subclass_count; i++)
8744 {
8745 string particle_class = "";
8746 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
8747 string config_OnFire_entry = config_OnFire_class + particle_class;
8748 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
8749 WPOF_array.Insert(WPOF);
8750 }
8751
8752
8753 m_OnFireEffect.Insert(id, WPOF_array);
8754 }
8755 }
8756
8757 if (!m_OnBulletCasingEjectEffect.Contains(id))
8758 {
8759 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
8760 muzzle_owner_config = config_to_search + " " + GetType() + " ";
8761
8762 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
8763
8764 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
8765
8766 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
8767 {
8768 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
8769
8770 for (i = 0; i < config_OnBulletCasingEject_count; i++)
8771 {
8772 string particle_class2 = "";
8773 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
8774 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
8775 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
8776 WPOBE_array.Insert(WPOBE);
8777 }
8778
8779
8780 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
8781 }
8782 }
8783 }
8784
8785 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
8787 {
8790
8791 if (!m_OnOverheatingEffect.Contains(id))
8792 {
8793 string config_to_search = "CfgVehicles";
8794
8795 if (IsInherited(Weapon))
8796 config_to_search = "CfgWeapons";
8797
8798 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
8799 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
8800
8801 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
8802 {
8803
8804 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
8805
8807 {
8808 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
8809 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
8810 Error(error);
8811 return;
8812 }
8813
8814 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
8815 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
8816
8817
8818
8819 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
8820 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
8821
8822 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
8823 {
8824 string particle_class = "";
8825 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
8826 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
8827 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
8828
8829 if (entry_type == CT_CLASS)
8830 {
8831 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
8832 WPOOH_array.Insert(WPOF);
8833 }
8834 }
8835
8836
8837 m_OnOverheatingEffect.Insert(id, WPOOH_array);
8838 }
8839 }
8840 }
8841
8842 float GetOverheatingValue()
8843 {
8844 return m_OverheatingShots;
8845 }
8846
8847 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
8848 {
8849 if (m_MaxOverheatingValue > 0)
8850 {
8852
8853 if (!m_CheckOverheating)
8855
8857 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8858
8859 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8860 }
8861 }
8862
8863 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8864 {
8866 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8867
8869 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8870
8872 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8873
8875 {
8877 }
8878 }
8879
8881 {
8883 }
8884
8885 void OnOverheatingDecay()
8886 {
8887 if (m_MaxOverheatingValue > 0)
8888 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
8889 else
8891
8892 if (m_OverheatingShots <= 0)
8893 {
8896 }
8897 else
8898 {
8899 if (!m_CheckOverheating)
8901
8903 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
8904 }
8905
8906 CheckOverheating(this, "", this);
8907 }
8908
8909 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8910 {
8912 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8913 }
8914
8915 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8916 {
8918 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
8920 }
8921
8922 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
8923 {
8925 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
8926 }
8927
8928 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
8929 {
8931 m_OverheatingParticles = new array<ref OverheatingParticle>;
8932
8933 OverheatingParticle OP = new OverheatingParticle();
8934 OP.RegisterParticle(p);
8935 OP.SetOverheatingLimitMin(min_heat_coef);
8936 OP.SetOverheatingLimitMax(max_heat_coef);
8937 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
8938
8939 m_OverheatingParticles.Insert(OP);
8940 }
8941
8942 float GetOverheatingCoef()
8943 {
8944 if (m_MaxOverheatingValue > 0)
8946
8947 return -1;
8948 }
8949
8951 {
8953 {
8954 float overheat_coef = GetOverheatingCoef();
8955 int count = m_OverheatingParticles.Count();
8956
8957 for (int i = count; i > 0; --i)
8958 {
8959 int id = i - 1;
8960 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8961 Particle p = OP.GetParticle();
8962
8963 float overheat_min = OP.GetOverheatingLimitMin();
8964 float overheat_max = OP.GetOverheatingLimitMax();
8965
8966 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
8967 {
8968 if (p)
8969 {
8970 p.Stop();
8971 OP.RegisterParticle(null);
8972 }
8973 }
8974 }
8975 }
8976 }
8977
8979 {
8981 {
8982 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
8983 {
8984 int id = i - 1;
8985 OverheatingParticle OP = m_OverheatingParticles.Get(id);
8986
8987 if (OP)
8988 {
8989 Particle p = OP.GetParticle();
8990
8991 if (p)
8992 {
8993 p.Stop();
8994 }
8995
8996 delete OP;
8997 }
8998 }
8999
9000 m_OverheatingParticles.Clear();
9002 }
9003 }
9004
9006 float GetInfectionChance(int system = 0, Param param = null)
9007 {
9008 return 0.0;
9009 }
9010
9011
9012 float GetDisinfectQuantity(int system = 0, Param param1 = null)
9013 {
9014 return 250;//default value
9015 }
9016
9017 float GetFilterDamageRatio()
9018 {
9019 return 0;
9020 }
9021
9023 bool HasMuzzle()
9024 {
9025 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
9026 return true;
9027
9028 return false;
9029 }
9030
9032 int GetMuzzleID()
9033 {
9034 if (!m_WeaponTypeToID)
9035 m_WeaponTypeToID = new map<string, int>;
9036
9037 if (m_WeaponTypeToID.Contains(GetType()))
9038 {
9039 return m_WeaponTypeToID.Get(GetType());
9040 }
9041 else
9042 {
9043 // Register new weapon ID
9045 }
9046
9048 }
9049
9056 {
9057 return -1;
9058 }
9059
9060
9061
9062 // -------------------------------------------------------------------------
9063 void ~ItemBase()
9064 {
9065 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
9066 {
9067 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9068 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9069
9070 if (r_index >= 0)
9071 {
9072 InventoryLocation r_il = new InventoryLocation;
9073 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9074
9075 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9076 int r_type = r_il.GetType();
9077 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9078 {
9079 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9080 }
9081 else if (r_type == InventoryLocationType.ATTACHMENT)
9082 {
9083 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9084 }
9085
9086 }
9087
9088 player.GetHumanInventory().ClearUserReservedLocation(this);
9089 }
9090
9091 if (m_LockingSound)
9092 SEffectManager.DestroyEffect(m_LockingSound);
9093 }
9094
9095
9096
9097 // -------------------------------------------------------------------------
9098 static int GetDebugActionsMask()
9099 {
9100 return ItemBase.m_DebugActionsMask;
9101 }
9102
9103 static bool HasDebugActionsMask(int mask)
9104 {
9105 return ItemBase.m_DebugActionsMask & mask;
9106 }
9107
9108 static void SetDebugActionsMask(int mask)
9109 {
9110 ItemBase.m_DebugActionsMask = mask;
9111 }
9112
9113 static void AddDebugActionsMask(int mask)
9114 {
9115 ItemBase.m_DebugActionsMask |= mask;
9116 }
9117
9118 static void RemoveDebugActionsMask(int mask)
9119 {
9120 ItemBase.m_DebugActionsMask &= ~mask;
9121 }
9122
9123 static void ToggleDebugActionsMask(int mask)
9124 {
9125 if (HasDebugActionsMask(mask))
9126 {
9128 }
9129 else
9130 {
9131 AddDebugActionsMask(mask);
9132 }
9133 }
9134
9135 // -------------------------------------------------------------------------
9136 void SetCEBasedQuantity()
9137 {
9138 if (GetEconomyProfile())
9139 {
9140 float q_max = GetEconomyProfile().GetQuantityMax();
9141 if (q_max > 0)
9142 {
9143 float q_min = GetEconomyProfile().GetQuantityMin();
9144 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
9145
9146 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
9147 {
9148 ComponentEnergyManager comp = GetCompEM();
9149 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
9150 {
9151 comp.SetEnergy0To1(quantity_randomized);
9152 }
9153 }
9154 else if (HasQuantity())
9155 {
9156 SetQuantityNormalized(quantity_randomized, false);
9157 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
9158 }
9159
9160 }
9161 }
9162 }
9163
9165 void LockToParent()
9166 {
9167 EntityAI parent = GetHierarchyParent();
9168
9169 if (parent)
9170 {
9171 InventoryLocation inventory_location_to_lock = new InventoryLocation;
9172 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
9173 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
9174 }
9175 }
9176
9178 void UnlockFromParent()
9179 {
9180 EntityAI parent = GetHierarchyParent();
9181
9182 if (parent)
9183 {
9184 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
9185 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
9186 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
9187 }
9188 }
9189
9190 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
9191 {
9192 /*
9193 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
9194 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
9195 */
9196 ItemBase item2 = ItemBase.Cast(entity2);
9197
9198 if (g_Game.IsClient())
9199 {
9200 if (ScriptInputUserData.CanStoreInputUserData())
9201 {
9202 ScriptInputUserData ctx = new ScriptInputUserData;
9204 ctx.Write(-1);
9205 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9206 ctx.Write(i1);
9207 ctx.Write(item2);
9208 ctx.Write(use_stack_max);
9209 ctx.Write(-1);
9210 ctx.Send();
9211
9212 if (IsCombineAll(item2, use_stack_max))
9213 {
9214 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
9215 }
9216 }
9217 }
9218 else if (!g_Game.IsMultiplayer())
9219 {
9220 CombineItems(item2, use_stack_max);
9221 }
9222 }
9223
9224 bool IsLiquidPresent()
9225 {
9226 return (GetLiquidType() != 0 && HasQuantity());
9227 }
9228
9229 bool IsLiquidContainer()
9230 {
9231 return m_LiquidContainerMask != 0;
9232 }
9233
9235 {
9236 return m_LiquidContainerMask;
9237 }
9238
9239 bool IsBloodContainer()
9240 {
9241 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
9242 return false;
9243 }
9244
9245 bool IsNVG()
9246 {
9247 return false;
9248 }
9249
9252 bool IsExplosive()
9253 {
9254 return false;
9255 }
9256
9258 {
9259 return "";
9260 }
9261
9263
9264 bool IsLightSource()
9265 {
9266 return false;
9267 }
9268
9270 {
9271 return true;
9272 }
9273
9274 //--- ACTION CONDITIONS
9275 //direction
9276 bool IsFacingPlayer(PlayerBase player, string selection)
9277 {
9278 return true;
9279 }
9280
9281 bool IsPlayerInside(PlayerBase player, string selection)
9282 {
9283 return true;
9284 }
9285
9286 override bool CanObstruct()
9287 {
9288 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
9289 return !player || !IsPlayerInside(player, "");
9290 }
9291
9292 override bool IsBeingPlaced()
9293 {
9294 return m_IsBeingPlaced;
9295 }
9296
9297 void SetIsBeingPlaced(bool is_being_placed)
9298 {
9299 m_IsBeingPlaced = is_being_placed;
9300 if (!is_being_placed)
9302 SetSynchDirty();
9303 }
9304
9305 //server-side
9306 void OnEndPlacement() {}
9307
9308 override bool IsHologram()
9309 {
9310 return m_IsHologram;
9311 }
9312
9313 bool CanBeDigged()
9314 {
9315 return m_CanBeDigged;
9316 }
9317
9319 {
9320 return 1;
9321 }
9322
9323 bool CanMakeGardenplot()
9324 {
9325 return false;
9326 }
9327
9328 void SetIsHologram(bool is_hologram)
9329 {
9330 m_IsHologram = is_hologram;
9331 SetSynchDirty();
9332 }
9333 /*
9334 protected float GetNutritionalEnergy()
9335 {
9336 Edible_Base edible = Edible_Base.Cast(this);
9337 return edible.GetFoodEnergy();
9338 }
9339
9340 protected float GetNutritionalWaterContent()
9341 {
9342 Edible_Base edible = Edible_Base.Cast(this);
9343 return edible.GetFoodWater();
9344 }
9345
9346 protected float GetNutritionalIndex()
9347 {
9348 Edible_Base edible = Edible_Base.Cast(this);
9349 return edible.GetFoodNutritionalIndex();
9350 }
9351
9352 protected float GetNutritionalFullnessIndex()
9353 {
9354 Edible_Base edible = Edible_Base.Cast(this);
9355 return edible.GetFoodTotalVolume();
9356 }
9357
9358 protected float GetNutritionalToxicity()
9359 {
9360 Edible_Base edible = Edible_Base.Cast(this);
9361 return edible.GetFoodToxicity();
9362
9363 }
9364 */
9365
9366
9367 // -------------------------------------------------------------------------
9368 override void OnMovedInsideCargo(EntityAI container)
9369 {
9370 super.OnMovedInsideCargo(container);
9371
9372 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9373 }
9374
9375 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9376 {
9377 super.EEItemLocationChanged(oldLoc, newLoc);
9378
9379 PlayerBase newPlayer = null;
9380 PlayerBase oldPlayer = null;
9381
9382 if (newLoc.GetParent())
9383 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
9384
9385 if (oldLoc.GetParent())
9386 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
9387
9388 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
9389 {
9390 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
9391
9392 if (rIndex >= 0)
9393 {
9394 InventoryLocation rIl = new InventoryLocation;
9395 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
9396
9397 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
9398 int rType = rIl.GetType();
9399 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
9400 {
9401 rIl.GetParent().GetOnReleaseLock().Invoke(this);
9402 }
9403 else if (rType == InventoryLocationType.ATTACHMENT)
9404 {
9405 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
9406 }
9407
9408 }
9409 }
9410
9411 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
9412 {
9413 if (newPlayer)
9414 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
9415
9416 if (newPlayer == oldPlayer)
9417 {
9418 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
9419 {
9420 if (oldLoc.GetType() == InventoryLocationType.CARGO)
9421 {
9422 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
9423 {
9424 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9425 }
9426 }
9427 else
9428 {
9429 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
9430 }
9431 }
9432
9433 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
9434 {
9435 int type = oldLoc.GetType();
9436 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
9437 {
9438 oldLoc.GetParent().GetOnSetLock().Invoke(this);
9439 }
9440 else if (type == InventoryLocationType.ATTACHMENT)
9441 {
9442 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
9443 }
9444 }
9445 if (!m_OldLocation)
9446 {
9447 m_OldLocation = new InventoryLocation;
9448 }
9449 m_OldLocation.Copy(oldLoc);
9450 }
9451 else
9452 {
9453 if (m_OldLocation)
9454 {
9455 m_OldLocation.Reset();
9456 }
9457 }
9458
9459 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
9460 }
9461 else
9462 {
9463 if (newPlayer)
9464 {
9465 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
9466 if (resIndex >= 0)
9467 {
9468 InventoryLocation il = new InventoryLocation;
9469 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
9470 ItemBase it = ItemBase.Cast(il.GetItem());
9471 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
9472 int rel_type = il.GetType();
9473 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
9474 {
9475 il.GetParent().GetOnReleaseLock().Invoke(it);
9476 }
9477 else if (rel_type == InventoryLocationType.ATTACHMENT)
9478 {
9479 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
9480 }
9481 //it.GetOnReleaseLock().Invoke(it);
9482 }
9483 }
9484 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
9485 {
9486 //ThrowPhysically(oldPlayer, vector.Zero);
9487 m_ThrowItemOnDrop = false;
9488 }
9489
9490 if (m_OldLocation)
9491 {
9492 m_OldLocation.Reset();
9493 }
9494 }
9495
9496 if (oldLoc.GetType() == InventoryLocationType.TEMP)
9497 {
9498 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
9499 }
9500
9501 if (newLoc.GetType() == InventoryLocationType.TEMP)
9502 {
9503 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
9504 }
9505 }
9506
9507 override void EOnContact(IEntity other, Contact extra)
9508 {
9510 {
9511 int liquidType = -1;
9512 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
9513 if (impactSpeed > 0.0)
9514 {
9515 m_ImpactSpeed = impactSpeed;
9516 #ifndef SERVER
9517 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
9518 #else
9519 m_WantPlayImpactSound = true;
9520 SetSynchDirty();
9521 #endif
9522 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
9523 }
9524 }
9525
9526 #ifdef SERVER
9527 if (GetCompEM() && GetCompEM().IsPlugged())
9528 {
9529 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
9530 GetCompEM().UnplugThis();
9531 }
9532 #endif
9533 }
9534
9535 void RefreshPhysics();
9536
9537 override void OnCreatePhysics()
9538 {
9540 }
9541
9542 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
9543 {
9544
9545 }
9546 // -------------------------------------------------------------------------
9547 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
9548 {
9549 super.OnItemLocationChanged(old_owner, new_owner);
9550
9551 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
9552 PlayerBase playerNew = PlayerBase.Cast(new_owner);
9553
9554 if (!relatedPlayer && playerNew)
9555 relatedPlayer = playerNew;
9556
9557 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
9558 {
9559 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
9560 if (actionMgr)
9561 {
9562 ActionBase currentAction = actionMgr.GetRunningAction();
9563 if (currentAction)
9564 currentAction.OnItemLocationChanged(this);
9565 }
9566 }
9567
9568 Man ownerPlayerOld = null;
9569 Man ownerPlayerNew = null;
9570
9571 if (old_owner)
9572 {
9573 if (old_owner.IsMan())
9574 {
9575 ownerPlayerOld = Man.Cast(old_owner);
9576 }
9577 else
9578 {
9579 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
9580 }
9581 }
9582 else
9583 {
9584 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
9585 {
9586 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
9587
9588 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
9589 {
9590 GetCompEM().UnplugThis();
9591 }
9592 }
9593 }
9594
9595 if (new_owner)
9596 {
9597 if (new_owner.IsMan())
9598 {
9599 ownerPlayerNew = Man.Cast(new_owner);
9600 }
9601 else
9602 {
9603 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
9604 }
9605 }
9606
9607 if (ownerPlayerOld != ownerPlayerNew)
9608 {
9609 if (ownerPlayerOld)
9610 {
9611 array<EntityAI> subItemsExit = new array<EntityAI>;
9612 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
9613 for (int i = 0; i < subItemsExit.Count(); i++)
9614 {
9615 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
9616 itemExit.OnInventoryExit(ownerPlayerOld);
9617 }
9618 }
9619
9620 if (ownerPlayerNew)
9621 {
9622 array<EntityAI> subItemsEnter = new array<EntityAI>;
9623 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
9624 for (int j = 0; j < subItemsEnter.Count(); j++)
9625 {
9626 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
9627 itemEnter.OnInventoryEnter(ownerPlayerNew);
9628 }
9629 }
9630 }
9631 else if (ownerPlayerNew != null)
9632 {
9633 PlayerBase nplayer;
9634 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
9635 {
9636 array<EntityAI> subItemsUpdate = new array<EntityAI>;
9637 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
9638 for (int k = 0; k < subItemsUpdate.Count(); k++)
9639 {
9640 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
9641 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
9642 }
9643 }
9644 }
9645
9646 if (old_owner)
9647 old_owner.OnChildItemRemoved(this);
9648 if (new_owner)
9649 new_owner.OnChildItemReceived(this);
9650 }
9651
9652 // -------------------------------------------------------------------------------
9653 override void EEDelete(EntityAI parent)
9654 {
9655 super.EEDelete(parent);
9656 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
9657 if (player)
9658 {
9659 OnInventoryExit(player);
9660
9661 if (player.IsAlive())
9662 {
9663 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
9664 if (r_index >= 0)
9665 {
9666 InventoryLocation r_il = new InventoryLocation;
9667 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
9668
9669 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
9670 int r_type = r_il.GetType();
9671 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
9672 {
9673 r_il.GetParent().GetOnReleaseLock().Invoke(this);
9674 }
9675 else if (r_type == InventoryLocationType.ATTACHMENT)
9676 {
9677 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
9678 }
9679
9680 }
9681
9682 player.RemoveQuickBarEntityShortcut(this);
9683 }
9684 }
9685 }
9686 // -------------------------------------------------------------------------------
9687 override void EEKilled(Object killer)
9688 {
9689 super.EEKilled(killer);
9690
9692 if (killer && killer.IsFireplace() && CanExplodeInFire())
9693 {
9694 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
9695 {
9696 if (IsMagazine())
9697 {
9698 if (Magazine.Cast(this).GetAmmoCount() > 0)
9699 {
9700 ExplodeAmmo();
9701 }
9702 }
9703 else
9704 {
9705 Explode(DamageType.EXPLOSION);
9706 }
9707 }
9708 }
9709 }
9710
9711 override void OnWasAttached(EntityAI parent, int slot_id)
9712 {
9713 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
9714
9715 super.OnWasAttached(parent, slot_id);
9716
9717 if (HasQuantity())
9718 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9719
9720 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
9721 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
9722 }
9723
9724 override void OnWasDetached(EntityAI parent, int slot_id)
9725 {
9726 super.OnWasDetached(parent, slot_id);
9727
9728 if (HasQuantity())
9729 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
9730
9731 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
9732 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
9733 }
9734
9735 override string ChangeIntoOnAttach(string slot)
9736 {
9737 int idx;
9738 TStringArray inventory_slots = new TStringArray;
9739 TStringArray attach_types = new TStringArray;
9740
9741 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
9742 if (inventory_slots.Count() < 1) //is string
9743 {
9744 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
9745 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
9746 }
9747 else //is array
9748 {
9749 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
9750 }
9751
9752 idx = inventory_slots.Find(slot);
9753 if (idx < 0)
9754 return "";
9755
9756 return attach_types.Get(idx);
9757 }
9758
9759 override string ChangeIntoOnDetach()
9760 {
9761 int idx = -1;
9762 string slot;
9763
9764 TStringArray inventory_slots = new TStringArray;
9765 TStringArray detach_types = new TStringArray;
9766
9767 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
9768 if (inventory_slots.Count() < 1) //is string
9769 {
9770 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
9771 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
9772 }
9773 else //is array
9774 {
9775 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
9776 if (detach_types.Count() < 1)
9777 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
9778 }
9779
9780 for (int i = 0; i < inventory_slots.Count(); i++)
9781 {
9782 slot = inventory_slots.Get(i);
9783 }
9784
9785 if (slot != "")
9786 {
9787 if (detach_types.Count() == 1)
9788 idx = 0;
9789 else
9790 idx = inventory_slots.Find(slot);
9791 }
9792 if (idx < 0)
9793 return "";
9794
9795 return detach_types.Get(idx);
9796 }
9797
9798 void ExplodeAmmo()
9799 {
9800 //timer
9801 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
9802
9803 //min/max time
9804 float min_time = 1;
9805 float max_time = 3;
9806 float delay = Math.RandomFloat(min_time, max_time);
9807
9808 explode_timer.Run(delay, this, "DoAmmoExplosion");
9809 }
9810
9811 void DoAmmoExplosion()
9812 {
9813 Magazine magazine = Magazine.Cast(this);
9814 int pop_sounds_count = 6;
9815 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
9816
9817 //play sound
9818 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
9819 string sound_name = pop_sounds[ sound_idx ];
9820 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
9821
9822 //remove ammo count
9823 magazine.ServerAddAmmoCount(-1);
9824
9825 //if condition then repeat -> ExplodeAmmo
9826 float min_temp_to_explode = 100; //min temperature for item to explode
9827
9828 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
9829 {
9830 ExplodeAmmo();
9831 }
9832 }
9833
9834 // -------------------------------------------------------------------------------
9835 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
9836 {
9837 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
9838
9839 const int CHANCE_DAMAGE_CARGO = 4;
9840 const int CHANCE_DAMAGE_ATTACHMENT = 1;
9841 const int CHANCE_DAMAGE_NOTHING = 2;
9842
9843 if (IsClothing() || IsContainer() || IsItemTent())
9844 {
9845 float dmg = damageResult.GetDamage("","Health") * -0.5;
9846 int chances;
9847 int rnd;
9848
9849 if (GetInventory().GetCargo())
9850 {
9851 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9852 rnd = Math.RandomInt(0,chances);
9853
9854 if (rnd < CHANCE_DAMAGE_CARGO)
9855 {
9856 DamageItemInCargo(dmg);
9857 }
9858 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
9859 {
9861 }
9862 }
9863 else
9864 {
9865 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
9866 rnd = Math.RandomInt(0,chances);
9867
9868 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
9869 {
9871 }
9872 }
9873 }
9874 }
9875
9876 bool DamageItemInCargo(float damage)
9877 {
9878 CargoBase cargo = GetInventory().GetCargo();
9879 if (cargo)
9880 {
9881 int item_count = cargo.GetItemCount();
9882 if (item_count > 0)
9883 {
9884 int random_pick = Math.RandomInt(0, item_count);
9885 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
9886 if (!item.IsExplosive())
9887 {
9888 item.AddHealth("","",damage);
9889 return true;
9890 }
9891 }
9892 }
9893 return false;
9894 }
9895
9896 bool DamageItemAttachments(float damage)
9897 {
9898 GameInventory inventory = GetInventory();
9899 int attachment_count = inventory.AttachmentCount();
9900 if (attachment_count > 0)
9901 {
9902 int random_pick = Math.RandomInt(0, attachment_count);
9903 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
9904 if (!attachment.IsExplosive())
9905 {
9906 attachment.AddHealth("","",damage);
9907 return true;
9908 }
9909 }
9910 return false;
9911 }
9912
9913 override bool IsSplitable()
9914 {
9915 return m_CanThisBeSplit;
9916 }
9917 //----------------
9918 override bool CanBeSplit()
9919 {
9920 if (IsSplitable() && (GetQuantity() > 1))
9921 return GetInventory().CanRemoveEntity();
9922
9923 return false;
9924 }
9925
9926 protected bool ShouldSplitQuantity(float quantity)
9927 {
9928 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
9929 if (!IsSplitable())
9930 return false;
9931
9932 // nothing to split?
9933 if (GetQuantity() <= 1)
9934 return false;
9935
9936 // check if we should re-use the item instead of creating a new copy?
9937 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
9938 int delta = GetQuantity() - quantity;
9939 if (delta == 0)
9940 return false;
9941
9942 // valid to split
9943 return true;
9944 }
9945
9946 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
9947 {
9948 if (g_Game.IsClient())
9949 {
9950 if (ScriptInputUserData.CanStoreInputUserData())
9951 {
9952 ScriptInputUserData ctx = new ScriptInputUserData;
9954 ctx.Write(1);
9955 ItemBase i1 = this; // @NOTE: workaround for correct serialization
9956 ctx.Write(i1);
9957 ctx.Write(destination_entity);
9958 ctx.Write(true);
9959 ctx.Write(slot_id);
9960 ctx.Send();
9961 }
9962 }
9963 else if (!g_Game.IsMultiplayer())
9964 {
9965 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
9966 }
9967 }
9968
9969 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
9970 {
9971 float split_quantity_new;
9972 ItemBase new_item;
9973 float quantity = GetQuantity();
9974 float stack_max = GetTargetQuantityMax(slot_id);
9975 InventoryLocation loc = new InventoryLocation;
9976
9977 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
9978 {
9979 if (stack_max <= GetQuantity())
9980 split_quantity_new = stack_max;
9981 else
9982 split_quantity_new = GetQuantity();
9983
9984 if (ShouldSplitQuantity(split_quantity_new))
9985 {
9986 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
9987 if (new_item)
9988 {
9989 new_item.SetResultOfSplit(true);
9990 MiscGameplayFunctions.TransferItemProperties(this, new_item);
9991 AddQuantity(-split_quantity_new, false, true);
9992 new_item.SetQuantity(split_quantity_new, false, true);
9993 }
9994 }
9995 }
9996 else if (destination_entity && slot_id == -1)
9997 {
9998 if (quantity > stack_max)
9999 split_quantity_new = stack_max;
10000 else
10001 split_quantity_new = quantity;
10002
10003 if (ShouldSplitQuantity(split_quantity_new))
10004 {
10005 GameInventory destinationInventory = destination_entity.GetInventory();
10006 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10007 {
10008 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10009 new_item = ItemBase.Cast(o);
10010 }
10011
10012 if (new_item)
10013 {
10014 new_item.SetResultOfSplit(true);
10015 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10016 AddQuantity(-split_quantity_new, false, true);
10017 new_item.SetQuantity(split_quantity_new, false, true);
10018 }
10019 }
10020 }
10021 else
10022 {
10023 if (stack_max != 0)
10024 {
10025 if (stack_max < GetQuantity())
10026 {
10027 split_quantity_new = GetQuantity() - stack_max;
10028 }
10029
10030 if (split_quantity_new == 0)
10031 {
10032 if (!g_Game.IsMultiplayer())
10033 player.PhysicalPredictiveDropItem(this);
10034 else
10035 player.ServerDropEntity(this);
10036 return;
10037 }
10038
10039 if (ShouldSplitQuantity(split_quantity_new))
10040 {
10041 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10042
10043 if (new_item)
10044 {
10045 new_item.SetResultOfSplit(true);
10046 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10047 SetQuantity(split_quantity_new, false, true);
10048 new_item.SetQuantity(stack_max, false, true);
10049 new_item.PlaceOnSurface();
10050 }
10051 }
10052 }
10053 }
10054 }
10055
10056 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
10057 {
10058 float split_quantity_new;
10059 ItemBase new_item;
10060 float quantity = GetQuantity();
10061 float stack_max = GetTargetQuantityMax(slot_id);
10062 InventoryLocation loc = new InventoryLocation;
10063
10064 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
10065 {
10066 if (stack_max <= GetQuantity())
10067 split_quantity_new = stack_max;
10068 else
10069 split_quantity_new = GetQuantity();
10070
10071 if (ShouldSplitQuantity(split_quantity_new))
10072 {
10073 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
10074 if (new_item)
10075 {
10076 new_item.SetResultOfSplit(true);
10077 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10078 AddQuantity(-split_quantity_new, false, true);
10079 new_item.SetQuantity(split_quantity_new, false, true);
10080 }
10081 }
10082 }
10083 else if (destination_entity && slot_id == -1)
10084 {
10085 if (quantity > stack_max)
10086 split_quantity_new = stack_max;
10087 else
10088 split_quantity_new = quantity;
10089
10090 if (ShouldSplitQuantity(split_quantity_new))
10091 {
10092 GameInventory destinationInventory = destination_entity.GetInventory();
10093 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
10094 {
10095 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
10096 new_item = ItemBase.Cast(o);
10097 }
10098
10099 if (new_item)
10100 {
10101 new_item.SetResultOfSplit(true);
10102 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10103 AddQuantity(-split_quantity_new, false, true);
10104 new_item.SetQuantity(split_quantity_new, false, true);
10105 }
10106 }
10107 }
10108 else
10109 {
10110 if (stack_max != 0)
10111 {
10112 if (stack_max < GetQuantity())
10113 {
10114 split_quantity_new = GetQuantity() - stack_max;
10115 }
10116
10117 if (ShouldSplitQuantity(split_quantity_new))
10118 {
10119 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
10120
10121 if (new_item)
10122 {
10123 new_item.SetResultOfSplit(true);
10124 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10125 SetQuantity(split_quantity_new, false, true);
10126 new_item.SetQuantity(stack_max, false, true);
10127 new_item.PlaceOnSurface();
10128 }
10129 }
10130 }
10131 }
10132 }
10133
10134 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
10135 {
10136 if (g_Game.IsClient())
10137 {
10138 if (ScriptInputUserData.CanStoreInputUserData())
10139 {
10140 ScriptInputUserData ctx = new ScriptInputUserData;
10142 ctx.Write(4);
10143 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10144 ctx.Write(thiz);
10145 dst.WriteToContext(ctx);
10146 ctx.Send();
10147 }
10148 }
10149 else if (!g_Game.IsMultiplayer())
10150 {
10152 }
10153 }
10154
10155 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
10156 {
10157 if (g_Game.IsClient())
10158 {
10159 if (ScriptInputUserData.CanStoreInputUserData())
10160 {
10161 ScriptInputUserData ctx = new ScriptInputUserData;
10163 ctx.Write(2);
10164 ItemBase dummy = this; // @NOTE: workaround for correct serialization
10165 ctx.Write(dummy);
10166 ctx.Write(destination_entity);
10167 ctx.Write(true);
10168 ctx.Write(idx);
10169 ctx.Write(row);
10170 ctx.Write(col);
10171 ctx.Send();
10172 }
10173 }
10174 else if (!g_Game.IsMultiplayer())
10175 {
10176 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
10177 }
10178 }
10179
10180 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
10181 {
10183 }
10184
10185 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
10186 {
10187 float quantity = GetQuantity();
10188 float split_quantity_new;
10189 ItemBase new_item;
10190 if (dst.IsValid())
10191 {
10192 int slot_id = dst.GetSlot();
10193 float stack_max = GetTargetQuantityMax(slot_id);
10194
10195 if (quantity > stack_max)
10196 split_quantity_new = stack_max;
10197 else
10198 split_quantity_new = quantity;
10199
10200 if (ShouldSplitQuantity(split_quantity_new))
10201 {
10202 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10203
10204 if (new_item)
10205 {
10206 new_item.SetResultOfSplit(true);
10207 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10208 AddQuantity(-split_quantity_new, false, true);
10209 new_item.SetQuantity(split_quantity_new, false, true);
10210 }
10211
10212 return new_item;
10213 }
10214 }
10215
10216 return null;
10217 }
10218
10219 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
10220 {
10221 float quantity = GetQuantity();
10222 float split_quantity_new;
10223 ItemBase new_item;
10224 if (destination_entity)
10225 {
10226 float stackable = GetTargetQuantityMax();
10227 if (quantity > stackable)
10228 split_quantity_new = stackable;
10229 else
10230 split_quantity_new = quantity;
10231
10232 if (ShouldSplitQuantity(split_quantity_new))
10233 {
10234 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
10235 if (new_item)
10236 {
10237 new_item.SetResultOfSplit(true);
10238 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10239 AddQuantity(-split_quantity_new, false, true);
10240 new_item.SetQuantity(split_quantity_new, false, true);
10241 }
10242 }
10243 }
10244 }
10245
10246 void SplitIntoStackMaxHandsClient(PlayerBase player)
10247 {
10248 if (g_Game.IsClient())
10249 {
10250 if (ScriptInputUserData.CanStoreInputUserData())
10251 {
10252 ScriptInputUserData ctx = new ScriptInputUserData;
10254 ctx.Write(3);
10255 ItemBase i1 = this; // @NOTE: workaround for correct serialization
10256 ctx.Write(i1);
10257 ItemBase destination_entity = this;
10258 ctx.Write(destination_entity);
10259 ctx.Write(true);
10260 ctx.Write(0);
10261 ctx.Send();
10262 }
10263 }
10264 else if (!g_Game.IsMultiplayer())
10265 {
10266 SplitIntoStackMaxHands(player);
10267 }
10268 }
10269
10270 void SplitIntoStackMaxHands(PlayerBase player)
10271 {
10272 float quantity = GetQuantity();
10273 float split_quantity_new;
10274 ref ItemBase new_item;
10275 if (player)
10276 {
10277 float stackable = GetTargetQuantityMax();
10278 if (quantity > stackable)
10279 split_quantity_new = stackable;
10280 else
10281 split_quantity_new = quantity;
10282
10283 if (ShouldSplitQuantity(split_quantity_new))
10284 {
10285 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
10286 new_item = ItemBase.Cast(in_hands);
10287 if (new_item)
10288 {
10289 new_item.SetResultOfSplit(true);
10290 MiscGameplayFunctions.TransferItemProperties(this,new_item);
10291 AddQuantity(-split_quantity_new, false, true);
10292 new_item.SetQuantity(split_quantity_new, false, true);
10293 }
10294 }
10295 }
10296 }
10297
10298 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
10299 {
10300 float quantity = GetQuantity();
10301 float split_quantity_new = Math.Floor(quantity * 0.5);
10302
10303 if (!ShouldSplitQuantity(split_quantity_new))
10304 return;
10305
10306 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
10307
10308 if (new_item)
10309 {
10310 if (new_item.GetQuantityMax() < split_quantity_new)
10311 {
10312 split_quantity_new = new_item.GetQuantityMax();
10313 }
10314
10315 new_item.SetResultOfSplit(true);
10316 MiscGameplayFunctions.TransferItemProperties(this, new_item);
10317
10318 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10319 {
10320 AddQuantity(-1, false, true);
10321 new_item.SetQuantity(1, false, true);
10322 }
10323 else
10324 {
10325 AddQuantity(-split_quantity_new, false, true);
10326 new_item.SetQuantity(split_quantity_new, false, true);
10327 }
10328 }
10329 }
10330
10331 void SplitItem(PlayerBase player)
10332 {
10333 float quantity = GetQuantity();
10334 float split_quantity_new = Math.Floor(quantity / 2);
10335
10336 if (!ShouldSplitQuantity(split_quantity_new))
10337 return;
10338
10339 InventoryLocation invloc = new InventoryLocation;
10340 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
10341
10342 ItemBase new_item;
10343 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
10344
10345 if (new_item)
10346 {
10347 if (new_item.GetQuantityMax() < split_quantity_new)
10348 {
10349 split_quantity_new = new_item.GetQuantityMax();
10350 }
10351 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
10352 {
10353 AddQuantity(-1, false, true);
10354 new_item.SetQuantity(1, false, true);
10355 }
10356 else if (split_quantity_new > 1)
10357 {
10358 AddQuantity(-split_quantity_new, false, true);
10359 new_item.SetQuantity(split_quantity_new, false, true);
10360 }
10361 }
10362 }
10363
10365 void OnQuantityChanged(float delta)
10366 {
10367 SetWeightDirty();
10368 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
10369
10370 if (parent)
10371 parent.OnAttachmentQuantityChangedEx(this, delta);
10372
10373 if (IsLiquidContainer())
10374 {
10375 if (GetQuantityNormalized() <= 0.0)
10376 {
10378 }
10379 else if (GetLiquidType() == LIQUID_NONE)
10380 {
10381 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
10383 }
10384 }
10385 }
10386
10389 {
10390 // insert code here
10391 }
10392
10394 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
10395 {
10397 }
10398
10399 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
10400 {
10401 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
10402
10403 if (g_Game.IsServer())
10404 {
10405 if (newLevel == GameConstants.STATE_RUINED)
10406 {
10408 EntityAI parent = GetHierarchyParent();
10409 if (parent && parent.IsFireplace())
10410 {
10411 CargoBase cargo = GetInventory().GetCargo();
10412 if (cargo)
10413 {
10414 for (int i = 0; i < cargo.GetItemCount(); ++i)
10415 {
10416 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
10417 }
10418 }
10419 }
10420 }
10421
10422 if (IsResultOfSplit())
10423 {
10424 // reset the splitting result flag, return to normal item behavior
10425 SetResultOfSplit(false);
10426 return;
10427 }
10428
10429 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
10430 {
10431 SetCleanness(0);//unclean the item upon damage dealt
10432 }
10433 }
10434 }
10435
10436 // just the split? TODO: verify
10437 override void OnRightClick()
10438 {
10439 super.OnRightClick();
10440
10441 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
10442 {
10443 if (g_Game.IsClient())
10444 {
10445 if (ScriptInputUserData.CanStoreInputUserData())
10446 {
10447 EntityAI root = GetHierarchyRoot();
10448 Man playerOwner = GetHierarchyRootPlayer();
10449 InventoryLocation dst = new InventoryLocation;
10450
10451 // If we have no hierarchy root player and the root is the same as this item the source item is in the vicinity so we want to create the new split item there also
10452 if (!playerOwner && root && root == this)
10453 {
10455 }
10456 else
10457 {
10458 // Check if we can place the new split item in the same parent where the source item is placed in or otherwise drop it in vicinity
10459 GetInventory().GetCurrentInventoryLocation(dst);
10460 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
10461 {
10462 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
10463 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
10464 {
10466 }
10467 else
10468 {
10469 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
10470 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
10471 this shouldnt cause issues within this scope*/
10472 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
10473 {
10475 }
10476 else
10477 {
10478 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
10479 }
10480 }
10481 }
10482 }
10483
10484 ScriptInputUserData ctx = new ScriptInputUserData;
10486 ctx.Write(4);
10487 ItemBase thiz = this; // @NOTE: workaround for correct serialization
10488 ctx.Write(thiz);
10489 dst.WriteToContext(ctx);
10490 ctx.Write(true); // dummy
10491 ctx.Send();
10492 }
10493 }
10494 else if (!g_Game.IsMultiplayer())
10495 {
10496 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
10497 }
10498 }
10499 }
10500
10501 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
10502 {
10503 if (root)
10504 {
10505 vector m4[4];
10506 root.GetTransform(m4);
10507 dst.SetGround(this, m4);
10508 }
10509 else
10510 {
10511 GetInventory().GetCurrentInventoryLocation(dst);
10512 }
10513 }
10514
10515 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
10516 {
10517 //TODO: delete check zero quantity check after fix double posts hands fsm events
10518 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
10519 return false;
10520
10521 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
10522 return false;
10523
10524 //can_this_be_combined = ConfigGetBool("canBeSplit");
10526 return false;
10527
10528
10529 Magazine mag = Magazine.Cast(this);
10530 if (mag)
10531 {
10532 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
10533 return false;
10534
10535 if (stack_max_limit)
10536 {
10537 Magazine other_mag = Magazine.Cast(other_item);
10538 if (other_item)
10539 {
10540 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
10541 return false;
10542 }
10543
10544 }
10545 }
10546 else
10547 {
10548 //TODO: delete check zero quantity check after fix double posts hands fsm events
10549 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
10550 return false;
10551
10552 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
10553 return false;
10554 }
10555
10556 PlayerBase player = null;
10557 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
10558 {
10559 if (player.GetInventory().HasAttachment(this))
10560 return false;
10561
10562 if (player.IsItemsToDelete())
10563 return false;
10564 }
10565
10566 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
10567 return false;
10568
10569 int slotID;
10570 string slotName;
10571 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
10572 return false;
10573
10574 return true;
10575 }
10576
10577 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
10578 {
10579 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
10580 }
10581
10582 bool IsResultOfSplit()
10583 {
10584 return m_IsResultOfSplit;
10585 }
10586
10587 void SetResultOfSplit(bool value)
10588 {
10589 m_IsResultOfSplit = value;
10590 }
10591
10592 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
10593 {
10594 return ComputeQuantityUsedEx(other_item, use_stack_max);
10595 }
10596
10597 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
10598 {
10599 float other_item_quantity = other_item.GetQuantity();
10600 float this_free_space;
10601
10602 float stack_max = GetQuantityMax();
10603
10604 this_free_space = stack_max - GetQuantity();
10605
10606 if (other_item_quantity > this_free_space)
10607 {
10608 return this_free_space;
10609 }
10610 else
10611 {
10612 return other_item_quantity;
10613 }
10614 }
10615
10616 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
10617 {
10618 CombineItems(ItemBase.Cast(entity2),use_stack_max);
10619 }
10620
10621 void CombineItems(ItemBase other_item, bool use_stack_max = true)
10622 {
10623 if (!CanBeCombined(other_item, false))
10624 return;
10625
10626 if (!IsMagazine() && other_item)
10627 {
10628 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
10629 if (quantity_used != 0)
10630 {
10631 float hp1 = GetHealth01("","");
10632 float hp2 = other_item.GetHealth01("","");
10633 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
10634 hpResult = hpResult / (GetQuantity() + quantity_used);
10635
10636 hpResult *= GetMaxHealth();
10637 Math.Round(hpResult);
10638 SetHealth("", "Health", hpResult);
10639
10640 AddQuantity(quantity_used);
10641 other_item.AddQuantity(-quantity_used);
10642 }
10643 }
10644 OnCombine(other_item);
10645 }
10646
10647 void OnCombine(ItemBase other_item)
10648 {
10649 #ifdef SERVER
10650 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
10651 GetHierarchyParent().IncreaseLifetimeUp();
10652 #endif
10653 };
10654
10655 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
10656 {
10657 PlayerBase p = PlayerBase.Cast(player);
10658
10659 array<int> recipesIds = p.m_Recipes;
10660 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
10661 if (moduleRecipesManager)
10662 {
10663 EntityAI itemInHands = player.GetEntityInHands();
10664 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
10665 }
10666
10667 for (int i = 0;i < recipesIds.Count(); i++)
10668 {
10669 int key = recipesIds.Get(i);
10670 string recipeName = moduleRecipesManager.GetRecipeName(key);
10671 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
10672 }
10673 }
10674
10675 // -------------------------------------------------------------------------
10676 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
10677 {
10678 super.GetDebugActions(outputList);
10679
10680 //quantity
10681 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
10682 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
10683 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
10684 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
10685 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10686
10687 //health
10688 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
10689 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
10690 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
10691 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10692 //temperature
10693 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
10694 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
10695 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
10696 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10697
10698 //wet
10699 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
10700 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
10701 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10702
10703 //liquidtype
10704 if (IsLiquidContainer())
10705 {
10706 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
10707 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
10708 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10709 }
10710
10711 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
10712 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10713
10714 // watch
10715 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
10716 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
10717 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10718
10719 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
10720
10721 InventoryLocation loc = new InventoryLocation();
10722 GetInventory().GetCurrentInventoryLocation(loc);
10723 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
10724 {
10725 if (Gizmo_IsSupported())
10726 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
10727 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
10728 }
10729
10730 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
10731 }
10732
10733 // -------------------------------------------------------------------------
10734 // -------------------------------------------------------------------------
10735 // -------------------------------------------------------------------------
10736 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
10737 {
10738 super.OnAction(action_id, player, ctx);
10739
10740 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
10741 {
10742 switch (action_id)
10743 {
10744 case EActions.GIZMO_OBJECT:
10745 if (GetGizmoApi())
10746 GetGizmoApi().SelectObject(this);
10747 return true;
10748 case EActions.GIZMO_PHYSICS:
10749 if (GetGizmoApi())
10750 GetGizmoApi().SelectPhysics(GetPhysics());
10751 return true;
10752 }
10753 }
10754
10755 if (g_Game.IsServer())
10756 {
10757 switch (action_id)
10758 {
10759 case EActions.DELETE:
10760 Delete();
10761 return true;
10762 }
10763 }
10764
10765 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
10766 {
10767 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
10768 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
10769 PlayerBase p = PlayerBase.Cast(player);
10770 if (EActions.RECIPES_RANGE_START < 1000)
10771 {
10772 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
10773 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
10774 }
10775 }
10776 #ifndef SERVER
10777 else if (action_id == EActions.WATCH_PLAYER)
10778 {
10779 PluginDeveloper.SetDeveloperItemClientEx(player);
10780 }
10781 #endif
10782 if (g_Game.IsServer())
10783 {
10784 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
10785 {
10786 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
10787 OnDebugButtonPressServer(id + 1);
10788 }
10789
10790 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
10791 {
10792 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
10793 InsertAgent(agent_id,100);
10794 }
10795
10796 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
10797 {
10798 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
10799 RemoveAgent(agent_id2);
10800 }
10801
10802 else if (action_id == EActions.ADD_QUANTITY)
10803 {
10804 if (IsMagazine())
10805 {
10806 Magazine mag = Magazine.Cast(this);
10807 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
10808 }
10809 else
10810 {
10811 AddQuantity(GetQuantityMax() * 0.2);
10812 }
10813
10814 if (m_EM)
10815 {
10816 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
10817 }
10818 //PrintVariables();
10819 }
10820
10821 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
10822 {
10823 if (IsMagazine())
10824 {
10825 Magazine mag2 = Magazine.Cast(this);
10826 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
10827 }
10828 else
10829 {
10830 AddQuantity(- GetQuantityMax() * 0.2);
10831 }
10832 if (m_EM)
10833 {
10834 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
10835 }
10836 //PrintVariables();
10837 }
10838
10839 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
10840 {
10841 SetQuantity(0);
10842
10843 if (m_EM)
10844 {
10845 m_EM.SetEnergy(0);
10846 }
10847 }
10848
10849 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
10850 {
10852
10853 if (m_EM)
10854 {
10855 m_EM.SetEnergy(m_EM.GetEnergyMax());
10856 }
10857 }
10858
10859 else if (action_id == EActions.ADD_HEALTH)
10860 {
10861 AddHealth("","",GetMaxHealth("","Health")/5);
10862 }
10863 else if (action_id == EActions.REMOVE_HEALTH)
10864 {
10865 AddHealth("","",-GetMaxHealth("","Health")/5);
10866 }
10867 else if (action_id == EActions.DESTROY_HEALTH)
10868 {
10869 SetHealth01("","",0);
10870 }
10871 else if (action_id == EActions.WATCH_ITEM)
10872 {
10874 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
10875 #ifdef DEVELOPER
10876 SetDebugDeveloper_item(this);
10877 #endif
10878 }
10879
10880 else if (action_id == EActions.ADD_TEMPERATURE)
10881 {
10882 AddTemperature(20);
10883 //PrintVariables();
10884 }
10885
10886 else if (action_id == EActions.REMOVE_TEMPERATURE)
10887 {
10888 AddTemperature(-20);
10889 //PrintVariables();
10890 }
10891
10892 else if (action_id == EActions.FLIP_FROZEN)
10893 {
10894 SetFrozen(!GetIsFrozen());
10895 //PrintVariables();
10896 }
10897
10898 else if (action_id == EActions.ADD_WETNESS)
10899 {
10900 AddWet(GetWetMax()/5);
10901 //PrintVariables();
10902 }
10903
10904 else if (action_id == EActions.REMOVE_WETNESS)
10905 {
10906 AddWet(-GetWetMax()/5);
10907 //PrintVariables();
10908 }
10909
10910 else if (action_id == EActions.LIQUIDTYPE_UP)
10911 {
10912 int curr_type = GetLiquidType();
10913 SetLiquidType(curr_type * 2);
10914 //AddWet(1);
10915 //PrintVariables();
10916 }
10917
10918 else if (action_id == EActions.LIQUIDTYPE_DOWN)
10919 {
10920 int curr_type2 = GetLiquidType();
10921 SetLiquidType(curr_type2 / 2);
10922 }
10923
10924 else if (action_id == EActions.MAKE_SPECIAL)
10925 {
10926 auto debugParams = DebugSpawnParams.WithPlayer(player);
10927 OnDebugSpawnEx(debugParams);
10928 }
10929
10930 }
10931
10932
10933 return false;
10934 }
10935
10936 // -------------------------------------------------------------------------
10937
10938
10941 void OnActivatedByTripWire();
10942
10944 void OnActivatedByItem(notnull ItemBase item);
10945
10946 //----------------------------------------------------------------
10947 //returns true if item is able to explode when put in fire
10948 bool CanExplodeInFire()
10949 {
10950 return false;
10951 }
10952
10953 //----------------------------------------------------------------
10954 bool CanEat()
10955 {
10956 return true;
10957 }
10958
10959 //----------------------------------------------------------------
10960 override bool IsIgnoredByConstruction()
10961 {
10962 return true;
10963 }
10964
10965 //----------------------------------------------------------------
10966 //has FoodStages in config?
10967 bool HasFoodStage()
10968 {
10969 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
10970 return g_Game.ConfigIsExisting(config_path);
10971 }
10972
10974 FoodStage GetFoodStage()
10975 {
10976 return null;
10977 }
10978
10979 bool CanBeCooked()
10980 {
10981 return false;
10982 }
10983
10984 bool CanBeCookedOnStick()
10985 {
10986 return false;
10987 }
10988
10990 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
10992
10993 //----------------------------------------------------------------
10994 bool CanRepair(ItemBase item_repair_kit)
10995 {
10996 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
10997 return module_repairing.CanRepair(this, item_repair_kit);
10998 }
10999
11000 //----------------------------------------------------------------
11001 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
11002 {
11003 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
11004 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
11005 }
11006
11007 //----------------------------------------------------------------
11008 int GetItemSize()
11009 {
11010 /*
11011 vector v_size = this.ConfigGetVector("itemSize");
11012 int v_size_x = v_size[0];
11013 int v_size_y = v_size[1];
11014 int size = v_size_x * v_size_y;
11015 return size;
11016 */
11017
11018 return 1;
11019 }
11020
11021 //----------------------------------------------------------------
11022 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11023 bool CanBeMovedOverride()
11024 {
11025 return m_CanBeMovedOverride;
11026 }
11027
11028 //----------------------------------------------------------------
11029 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
11030 void SetCanBeMovedOverride(bool setting)
11031 {
11032 m_CanBeMovedOverride = setting;
11033 }
11034
11035 //----------------------------------------------------------------
11043 void MessageToOwnerStatus(string text)
11044 {
11045 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11046
11047 if (player)
11048 {
11049 player.MessageStatus(text);
11050 }
11051 }
11052
11053 //----------------------------------------------------------------
11061 void MessageToOwnerAction(string text)
11062 {
11063 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11064
11065 if (player)
11066 {
11067 player.MessageAction(text);
11068 }
11069 }
11070
11071 //----------------------------------------------------------------
11079 void MessageToOwnerFriendly(string text)
11080 {
11081 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11082
11083 if (player)
11084 {
11085 player.MessageFriendly(text);
11086 }
11087 }
11088
11089 //----------------------------------------------------------------
11097 void MessageToOwnerImportant(string text)
11098 {
11099 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
11100
11101 if (player)
11102 {
11103 player.MessageImportant(text);
11104 }
11105 }
11106
11107 override bool IsItemBase()
11108 {
11109 return true;
11110 }
11111
11112 // Checks if item is of questioned kind
11113 override bool KindOf(string tag)
11114 {
11115 bool found = false;
11116 string item_name = this.GetType();
11117 ref TStringArray item_tag_array = new TStringArray;
11118 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
11119
11120 int array_size = item_tag_array.Count();
11121 for (int i = 0; i < array_size; i++)
11122 {
11123 if (item_tag_array.Get(i) == tag)
11124 {
11125 found = true;
11126 break;
11127 }
11128 }
11129 return found;
11130 }
11131
11132
11133 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
11134 {
11135 //Debug.Log("OnRPC called");
11136 super.OnRPC(sender, rpc_type,ctx);
11137
11138 //Play soundset for attachment locking (ActionLockAttachment.c)
11139 switch (rpc_type)
11140 {
11141 #ifndef SERVER
11142 case ERPCs.RPC_SOUND_LOCK_ATTACH:
11143 Param2<bool, string> p = new Param2<bool, string>(false, "");
11144
11145 if (!ctx.Read(p))
11146 return;
11147
11148 bool play = p.param1;
11149 string soundSet = p.param2;
11150
11151 if (play)
11152 {
11153 if (m_LockingSound)
11154 {
11156 {
11157 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11158 }
11159 }
11160 else
11161 {
11162 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
11163 }
11164 }
11165 else
11166 {
11167 SEffectManager.DestroyEffect(m_LockingSound);
11168 }
11169
11170 break;
11171 #endif
11172
11173 }
11174
11175 if (GetWrittenNoteData())
11176 {
11177 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
11178 }
11179 }
11180
11181 //-----------------------------
11182 // VARIABLE MANIPULATION SYSTEM
11183 //-----------------------------
11184 int NameToID(string name)
11185 {
11186 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11187 return plugin.GetID(name);
11188 }
11189
11190 string IDToName(int id)
11191 {
11192 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
11193 return plugin.GetName(id);
11194 }
11195
11197 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
11198 {
11199 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
11200 //read the flags
11201 int varFlags;
11202 if (!ctx.Read(varFlags))
11203 return;
11204
11205 if (varFlags & ItemVariableFlags.FLOAT)
11206 {
11207 ReadVarsFromCTX(ctx);
11208 }
11209 }
11210
11211 override void SerializeNumericalVars(array<float> floats_out)
11212 {
11213 //some variables handled on EntityAI level already!
11214 super.SerializeNumericalVars(floats_out);
11215
11216 // the order of serialization must be the same as the order of de-serialization
11217 //--------------------------------------------
11218 if (IsVariableSet(VARIABLE_QUANTITY))
11219 {
11220 floats_out.Insert(m_VarQuantity);
11221 }
11222 //--------------------------------------------
11223 if (IsVariableSet(VARIABLE_WET))
11224 {
11225 floats_out.Insert(m_VarWet);
11226 }
11227 //--------------------------------------------
11228 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11229 {
11230 floats_out.Insert(m_VarLiquidType);
11231 }
11232 //--------------------------------------------
11233 if (IsVariableSet(VARIABLE_COLOR))
11234 {
11235 floats_out.Insert(m_ColorComponentR);
11236 floats_out.Insert(m_ColorComponentG);
11237 floats_out.Insert(m_ColorComponentB);
11238 floats_out.Insert(m_ColorComponentA);
11239 }
11240 //--------------------------------------------
11241 if (IsVariableSet(VARIABLE_CLEANNESS))
11242 {
11243 floats_out.Insert(m_Cleanness);
11244 }
11245 }
11246
11247 override void DeSerializeNumericalVars(array<float> floats)
11248 {
11249 //some variables handled on EntityAI level already!
11250 super.DeSerializeNumericalVars(floats);
11251
11252 // the order of serialization must be the same as the order of de-serialization
11253 int index = 0;
11254 int mask = Math.Round(floats.Get(index));
11255
11256 index++;
11257 //--------------------------------------------
11258 if (mask & VARIABLE_QUANTITY)
11259 {
11260 if (m_IsStoreLoad)
11261 {
11262 SetStoreLoadedQuantity(floats.Get(index));
11263 }
11264 else
11265 {
11266 float quantity = floats.Get(index);
11267 SetQuantity(quantity, true, false, false, false);
11268 }
11269 index++;
11270 }
11271 //--------------------------------------------
11272 if (mask & VARIABLE_WET)
11273 {
11274 float wet = floats.Get(index);
11275 SetWet(wet);
11276 index++;
11277 }
11278 //--------------------------------------------
11279 if (mask & VARIABLE_LIQUIDTYPE)
11280 {
11281 int liquidtype = Math.Round(floats.Get(index));
11282 SetLiquidType(liquidtype);
11283 index++;
11284 }
11285 //--------------------------------------------
11286 if (mask & VARIABLE_COLOR)
11287 {
11288 m_ColorComponentR = Math.Round(floats.Get(index));
11289 index++;
11290 m_ColorComponentG = Math.Round(floats.Get(index));
11291 index++;
11292 m_ColorComponentB = Math.Round(floats.Get(index));
11293 index++;
11294 m_ColorComponentA = Math.Round(floats.Get(index));
11295 index++;
11296 }
11297 //--------------------------------------------
11298 if (mask & VARIABLE_CLEANNESS)
11299 {
11300 int cleanness = Math.Round(floats.Get(index));
11301 SetCleanness(cleanness);
11302 index++;
11303 }
11304 }
11305
11306 override void WriteVarsToCTX(ParamsWriteContext ctx)
11307 {
11308 super.WriteVarsToCTX(ctx);
11309
11310 //--------------------------------------------
11311 if (IsVariableSet(VARIABLE_QUANTITY))
11312 {
11313 ctx.Write(GetQuantity());
11314 }
11315 //--------------------------------------------
11316 if (IsVariableSet(VARIABLE_WET))
11317 {
11318 ctx.Write(GetWet());
11319 }
11320 //--------------------------------------------
11321 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
11322 {
11323 ctx.Write(GetLiquidType());
11324 }
11325 //--------------------------------------------
11326 if (IsVariableSet(VARIABLE_COLOR))
11327 {
11328 int r,g,b,a;
11329 GetColor(r,g,b,a);
11330 ctx.Write(r);
11331 ctx.Write(g);
11332 ctx.Write(b);
11333 ctx.Write(a);
11334 }
11335 //--------------------------------------------
11336 if (IsVariableSet(VARIABLE_CLEANNESS))
11337 {
11338 ctx.Write(GetCleanness());
11339 }
11340 }
11341
11342 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
11343 {
11344 if (!super.ReadVarsFromCTX(ctx,version))
11345 return false;
11346
11347 int intValue;
11348 float value;
11349
11350 if (version < 140)
11351 {
11352 if (!ctx.Read(intValue))
11353 return false;
11354
11355 m_VariablesMask = intValue;
11356 }
11357
11358 if (m_VariablesMask & VARIABLE_QUANTITY)
11359 {
11360 if (!ctx.Read(value))
11361 return false;
11362
11363 if (IsStoreLoad())
11364 {
11366 }
11367 else
11368 {
11369 SetQuantity(value, true, false, false, false);
11370 }
11371 }
11372 //--------------------------------------------
11373 if (version < 140)
11374 {
11375 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11376 {
11377 if (!ctx.Read(value))
11378 return false;
11379 SetTemperatureDirect(value);
11380 }
11381 }
11382 //--------------------------------------------
11383 if (m_VariablesMask & VARIABLE_WET)
11384 {
11385 if (!ctx.Read(value))
11386 return false;
11387 SetWet(value);
11388 }
11389 //--------------------------------------------
11390 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
11391 {
11392 if (!ctx.Read(intValue))
11393 return false;
11394 SetLiquidType(intValue);
11395 }
11396 //--------------------------------------------
11397 if (m_VariablesMask & VARIABLE_COLOR)
11398 {
11399 int r,g,b,a;
11400 if (!ctx.Read(r))
11401 return false;
11402 if (!ctx.Read(g))
11403 return false;
11404 if (!ctx.Read(b))
11405 return false;
11406 if (!ctx.Read(a))
11407 return false;
11408
11409 SetColor(r,g,b,a);
11410 }
11411 //--------------------------------------------
11412 if (m_VariablesMask & VARIABLE_CLEANNESS)
11413 {
11414 if (!ctx.Read(intValue))
11415 return false;
11416 SetCleanness(intValue);
11417 }
11418 //--------------------------------------------
11419 if (version >= 138 && version < 140)
11420 {
11421 if (m_VariablesMask & VARIABLE_TEMPERATURE)
11422 {
11423 if (!ctx.Read(intValue))
11424 return false;
11425 SetFrozen(intValue);
11426 }
11427 }
11428
11429 return true;
11430 }
11431
11432 //----------------------------------------------------------------
11433 override bool OnStoreLoad(ParamsReadContext ctx, int version)
11434 {
11435 m_IsStoreLoad = true;
11437 {
11438 m_FixDamageSystemInit = true;
11439 }
11440
11441 if (!super.OnStoreLoad(ctx, version))
11442 {
11443 m_IsStoreLoad = false;
11444 return false;
11445 }
11446
11447 if (version >= 114)
11448 {
11449 bool hasQuickBarIndexSaved;
11450
11451 if (!ctx.Read(hasQuickBarIndexSaved))
11452 {
11453 m_IsStoreLoad = false;
11454 return false;
11455 }
11456
11457 if (hasQuickBarIndexSaved)
11458 {
11459 int itmQBIndex;
11460
11461 //Load quickbar item bind
11462 if (!ctx.Read(itmQBIndex))
11463 {
11464 m_IsStoreLoad = false;
11465 return false;
11466 }
11467
11468 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
11469 if (itmQBIndex != -1 && parentPlayer)
11470 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
11471 }
11472 }
11473 else
11474 {
11475 // Backup of how it used to be
11476 PlayerBase player;
11477 int itemQBIndex;
11478 if (version == int.MAX)
11479 {
11480 if (!ctx.Read(itemQBIndex))
11481 {
11482 m_IsStoreLoad = false;
11483 return false;
11484 }
11485 }
11486 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
11487 {
11488 //Load quickbar item bind
11489 if (!ctx.Read(itemQBIndex))
11490 {
11491 m_IsStoreLoad = false;
11492 return false;
11493 }
11494 if (itemQBIndex != -1 && player)
11495 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
11496 }
11497 }
11498
11499 if (version < 140)
11500 {
11501 // variable management system
11502 if (!LoadVariables(ctx, version))
11503 {
11504 m_IsStoreLoad = false;
11505 return false;
11506 }
11507 }
11508
11509 //agent trasmission system
11510 if (!LoadAgents(ctx, version))
11511 {
11512 m_IsStoreLoad = false;
11513 return false;
11514 }
11515 if (version >= 132)
11516 {
11517 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11518 if (raib)
11519 {
11520 if (!raib.OnStoreLoad(ctx,version))
11521 {
11522 m_IsStoreLoad = false;
11523 return false;
11524 }
11525 }
11526 }
11527
11528 m_IsStoreLoad = false;
11529 return true;
11530 }
11531
11532 //----------------------------------------------------------------
11533
11534 override void OnStoreSave(ParamsWriteContext ctx)
11535 {
11536 super.OnStoreSave(ctx);
11537
11538 PlayerBase player;
11539 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
11540 {
11541 ctx.Write(true); // Keep track of if we should actually read this in or not
11542 //Save quickbar item bind
11543 int itemQBIndex = -1;
11544 itemQBIndex = player.FindQuickBarEntityIndex(this);
11545 ctx.Write(itemQBIndex);
11546 }
11547 else
11548 {
11549 ctx.Write(false); // Keep track of if we should actually read this in or not
11550 }
11551
11552 SaveAgents(ctx);//agent trasmission system
11553
11554 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
11555 if (raib)
11556 {
11557 raib.OnStoreSave(ctx);
11558 }
11559 }
11560 //----------------------------------------------------------------
11561
11562 override void AfterStoreLoad()
11563 {
11564 super.AfterStoreLoad();
11565
11567 {
11569 }
11570
11571 if (GetStoreLoadedQuantity() != float.LOWEST)
11572 {
11574 SetStoreLoadedQuantity(float.LOWEST);//IMPORTANT to do this !! we use 'm_StoreLoadedQuantity' inside SetQuantity to distinguish between initial quantity setting and the consequent(normal gameplay) calls
11575 }
11576 }
11577
11578 override void EEOnAfterLoad()
11579 {
11580 super.EEOnAfterLoad();
11581
11583 {
11584 m_FixDamageSystemInit = false;
11585 }
11586
11589 }
11590
11591 bool CanBeDisinfected()
11592 {
11593 return false;
11594 }
11595
11596
11597 //----------------------------------------------------------------
11598 override void OnVariablesSynchronized()
11599 {
11600 if (m_Initialized)
11601 {
11602 #ifdef PLATFORM_CONSOLE
11603 //bruteforce it is
11604 if (IsSplitable())
11605 {
11606 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
11607 if (menu)
11608 {
11609 menu.Refresh();
11610 }
11611 }
11612 #endif
11613 }
11614
11616 {
11617 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
11618 m_WantPlayImpactSound = false;
11619 }
11620
11622 {
11623 SetWeightDirty();
11625 }
11626 if (m_VarWet != m_VarWetPrev)
11627 {
11630 }
11631
11632 if (m_SoundSyncPlay != 0)
11633 {
11636
11637 m_SoundSyncPlay = 0;
11638 m_SoundSyncSlotID = -1;
11639 }
11640 if (m_SoundSyncStop != 0)
11641 {
11643 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
11644 m_SoundSyncStop = 0;
11645 }
11646
11647 super.OnVariablesSynchronized();
11648 }
11649
11650 //------------------------- Quantity
11651 //----------------------------------------------------------------
11653 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
11654 {
11655 if (!IsServerCheck(allow_client))
11656 return false;
11657
11658 if (!HasQuantity())
11659 return false;
11660
11661 float min = GetQuantityMin();
11662 float max = GetQuantityMax();
11663
11664 if (value <= (min + 0.001))
11665 value = min;
11666
11667 if (value == min)
11668 {
11669 if (destroy_config)
11670 {
11671 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
11672 if (dstr)
11673 {
11674 m_VarQuantity = Math.Clamp(value, min, max);
11675 this.Delete();
11676 return true;
11677 }
11678 }
11679 else if (destroy_forced)
11680 {
11681 m_VarQuantity = Math.Clamp(value, min, max);
11682 this.Delete();
11683 return true;
11684 }
11685 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
11686 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
11687 }
11688
11689 float delta = m_VarQuantity;
11690 m_VarQuantity = Math.Clamp(value, min, max);
11691
11692 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
11693 {
11694 EntityAI parent = GetHierarchyRoot();
11695 InventoryLocation iLoc = new InventoryLocation();
11696 GetInventory().GetCurrentInventoryLocation(iLoc);
11697 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
11698 {
11699 int iLocSlot = iLoc.GetSlot();
11700 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
11701 {
11702 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
11703 }
11704 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
11705 {
11706 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
11707 }
11708 }
11709 }
11710
11711 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
11712 {
11713 delta = m_VarQuantity - delta;
11714
11715 if (delta)
11716 OnQuantityChanged(delta);
11717 }
11718
11719 SetVariableMask(VARIABLE_QUANTITY);
11720
11721 return false;
11722 }
11723
11724 //----------------------------------------------------------------
11726 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
11727 {
11728 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
11729 }
11730 //----------------------------------------------------------------
11731 void SetQuantityMax()
11732 {
11733 float max = GetQuantityMax();
11734 SetQuantity(max);
11735 }
11736
11737 override void SetQuantityToMinimum()
11738 {
11739 float min = GetQuantityMin();
11740 SetQuantity(min);
11741 }
11742 //----------------------------------------------------------------
11744 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
11745 {
11746 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
11747 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
11748 SetQuantity(result, destroy_config, destroy_forced);
11749 }
11750
11751 //----------------------------------------------------------------
11753 override float GetQuantityNormalized()
11754 {
11755 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
11756 }
11757
11759 {
11760 return GetQuantityNormalized();
11761 }
11762
11763 /*void SetAmmoNormalized(float value)
11764 {
11765 float value_clamped = Math.Clamp(value, 0, 1);
11766 Magazine this_mag = Magazine.Cast(this);
11767 int max_rounds = this_mag.GetAmmoMax();
11768 int result = value * max_rounds;//can the rounded if higher precision is required
11769 this_mag.SetAmmoCount(result);
11770 }*/
11771 //----------------------------------------------------------------
11772 override int GetQuantityMax()
11773 {
11774 int slot = -1;
11775 GameInventory inventory = GetInventory();
11776 if (inventory)
11777 {
11778 InventoryLocation il = new InventoryLocation;
11779 inventory.GetCurrentInventoryLocation(il);
11780 slot = il.GetSlot();
11781 }
11782
11783 return GetTargetQuantityMax(slot);
11784 }
11785
11786 override int GetTargetQuantityMax(int attSlotID = -1)
11787 {
11788 float quantity_max = 0;
11789
11790 if (IsSplitable()) //only stackable/splitable items can check for stack size
11791 {
11792 if (attSlotID != -1)
11793 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
11794
11795 if (quantity_max <= 0)
11796 quantity_max = m_VarStackMax;
11797 }
11798
11799 if (quantity_max <= 0)
11800 quantity_max = m_VarQuantityMax;
11801
11802 return quantity_max;
11803 }
11804 //----------------------------------------------------------------
11805 override int GetQuantityMin()
11806 {
11807 return m_VarQuantityMin;
11808 }
11809 //----------------------------------------------------------------
11810 int GetQuantityInit()
11811 {
11812 return m_VarQuantityInit;
11813 }
11814
11815 //----------------------------------------------------------------
11816 override bool HasQuantity()
11817 {
11818 return !(GetQuantityMax() - GetQuantityMin() == 0);
11819 }
11820
11821 override float GetQuantity()
11822 {
11823 return m_VarQuantity;
11824 }
11825
11826 bool IsFullQuantity()
11827 {
11828 return GetQuantity() >= GetQuantityMax();
11829 }
11830
11831 //Calculates weight of single item without attachments and cargo
11832 override float GetSingleInventoryItemWeightEx()
11833 {
11834 //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
11835 float weightEx = GetWeightEx();//overall weight of the item
11836 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
11837 return weightEx - special;
11838 }
11839
11840 // Obsolete, use GetSingleInventoryItemWeightEx() instead
11842 {
11844 }
11845
11846 override protected float GetWeightSpecialized(bool forceRecalc = false)
11847 {
11848 if (IsSplitable()) //quantity determines size of the stack
11849 {
11850 #ifdef DEVELOPER
11851 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11852 {
11853 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
11854 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
11855 }
11856 #endif
11857
11858 return GetQuantity() * GetConfigWeightModified();
11859 }
11860 else if (HasEnergyManager())// items with energy manager
11861 {
11862 #ifdef DEVELOPER
11863 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11864 {
11865 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
11866 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
11867 }
11868 #endif
11869 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
11870 }
11871 else//everything else
11872 {
11873 #ifdef DEVELOPER
11874 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
11875 {
11876 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
11877 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
11878 }
11879 #endif
11880 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
11881 }
11882 }
11883
11885 int GetNumberOfItems()
11886 {
11887 int item_count = 0;
11888 ItemBase item;
11889
11890 GameInventory inventory = GetInventory();
11891 CargoBase cargo = inventory.GetCargo();
11892 if (cargo != NULL)
11893 {
11894 item_count = cargo.GetItemCount();
11895 }
11896
11897 int nAttachments = inventory.AttachmentCount();
11898 for (int i = 0; i < nAttachments; ++i)
11899 {
11900 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
11901 if (item)
11902 item_count += item.GetNumberOfItems();
11903 }
11904 return item_count;
11905 }
11906
11908 float GetUnitWeight(bool include_wetness = true)
11909 {
11910 float weight = 0;
11911 float wetness = 1;
11912 if (include_wetness)
11913 wetness += GetWet();
11914 if (IsSplitable()) //quantity determines size of the stack
11915 {
11916 weight = wetness * m_ConfigWeight;
11917 }
11918 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
11919 {
11920 weight = 1;
11921 }
11922 return weight;
11923 }
11924
11925 //-----------------------------------------------------------------
11926
11927 override void ClearInventory()
11928 {
11929 GameInventory inventory = GetInventory();
11930 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
11931 {
11932 array<EntityAI> items = new array<EntityAI>;
11933 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
11934 for (int i = 0; i < items.Count(); ++i)
11935 {
11936 ItemBase item = ItemBase.Cast(items.Get(i));
11937 if (item)
11938 {
11939 g_Game.ObjectDelete(item);
11940 }
11941 }
11942 }
11943 }
11944
11945 //------------------------- Energy
11946
11947 //----------------------------------------------------------------
11948 float GetEnergy()
11949 {
11950 float energy = 0;
11951 if (HasEnergyManager())
11952 {
11953 energy = GetCompEM().GetEnergy();
11954 }
11955 return energy;
11956 }
11957
11958
11959 override void OnEnergyConsumed()
11960 {
11961 super.OnEnergyConsumed();
11962
11964 }
11965
11966 override void OnEnergyAdded()
11967 {
11968 super.OnEnergyAdded();
11969
11971 }
11972
11973 // Converts energy (from Energy Manager) to quantity, if enabled.
11975 {
11976 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
11977 {
11978 if (HasQuantity())
11979 {
11980 float energy_0to1 = GetCompEM().GetEnergy0To1();
11981 SetQuantityNormalized(energy_0to1);
11982 }
11983 }
11984 }
11985
11986 //----------------------------------------------------------------
11987 float GetHeatIsolationInit()
11988 {
11989 return ConfigGetFloat("heatIsolation");
11990 }
11991
11992 float GetHeatIsolation()
11993 {
11994 return m_HeatIsolation;
11995 }
11996
11997 float GetDryingIncrement(string pIncrementName)
11998 {
11999 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
12000 if (g_Game.ConfigIsExisting(paramPath))
12001 return g_Game.ConfigGetFloat(paramPath);
12002
12003 return 0.0;
12004 }
12005
12006 float GetSoakingIncrement(string pIncrementName)
12007 {
12008 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
12009 if (g_Game.ConfigIsExisting(paramPath))
12010 return g_Game.ConfigGetFloat(paramPath);
12011
12012 return 0.0;
12013 }
12014 //----------------------------------------------------------------
12015 override void SetWet(float value, bool allow_client = false)
12016 {
12017 if (!IsServerCheck(allow_client))
12018 return;
12019
12020 float min = GetWetMin();
12021 float max = GetWetMax();
12022
12023 float previousValue = m_VarWet;
12024
12025 m_VarWet = Math.Clamp(value, min, max);
12026
12027 if (previousValue != m_VarWet)
12028 {
12029 SetVariableMask(VARIABLE_WET);
12030 OnWetChanged(m_VarWet, previousValue);
12031 }
12032 }
12033 //----------------------------------------------------------------
12034 override void AddWet(float value)
12035 {
12036 SetWet(GetWet() + value);
12037 }
12038 //----------------------------------------------------------------
12039 override void SetWetMax()
12040 {
12042 }
12043 //----------------------------------------------------------------
12044 override float GetWet()
12045 {
12046 return m_VarWet;
12047 }
12048 //----------------------------------------------------------------
12049 override float GetWetMax()
12050 {
12051 return m_VarWetMax;
12052 }
12053 //----------------------------------------------------------------
12054 override float GetWetMin()
12055 {
12056 return m_VarWetMin;
12057 }
12058 //----------------------------------------------------------------
12059 override float GetWetInit()
12060 {
12061 return m_VarWetInit;
12062 }
12063 //----------------------------------------------------------------
12064 override void OnWetChanged(float newVal, float oldVal)
12065 {
12066 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
12067 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
12068 if (newLevel != oldLevel)
12069 {
12070 OnWetLevelChanged(newLevel,oldLevel);
12071 }
12072 }
12073
12074 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
12075 {
12076 SetWeightDirty();
12077 }
12078
12079 override EWetnessLevel GetWetLevel()
12080 {
12081 return GetWetLevelInternal(m_VarWet);
12082 }
12083
12084 //----------------------------------------------------------------
12085
12086 override void SetStoreLoad(bool value)
12087 {
12088 m_IsStoreLoad = value;
12089 }
12090
12091 override bool IsStoreLoad()
12092 {
12093 return m_IsStoreLoad;
12094 }
12095
12096 override void SetStoreLoadedQuantity(float value)
12097 {
12098 m_StoreLoadedQuantity = value;
12099 }
12100
12101 override float GetStoreLoadedQuantity()
12102 {
12103 return m_StoreLoadedQuantity;
12104 }
12105
12106 //----------------------------------------------------------------
12107
12108 float GetItemModelLength()
12109 {
12110 if (ConfigIsExisting("itemModelLength"))
12111 {
12112 return ConfigGetFloat("itemModelLength");
12113 }
12114 return 0;
12115 }
12116
12117 float GetItemAttachOffset()
12118 {
12119 if (ConfigIsExisting("itemAttachOffset"))
12120 {
12121 return ConfigGetFloat("itemAttachOffset");
12122 }
12123 return 0;
12124 }
12125
12126 override void SetCleanness(int value, bool allow_client = false)
12127 {
12128 if (!IsServerCheck(allow_client))
12129 return;
12130
12131 int previousValue = m_Cleanness;
12132
12133 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
12134
12135 if (previousValue != m_Cleanness)
12136 SetVariableMask(VARIABLE_CLEANNESS);
12137 }
12138
12139 override int GetCleanness()
12140 {
12141 return m_Cleanness;
12142 }
12143
12145 {
12146 return true;
12147 }
12148
12149 //----------------------------------------------------------------
12150 // ATTACHMENT LOCKING
12151 // Getters relevant to generic ActionLockAttachment
12152 int GetLockType()
12153 {
12154 return m_LockType;
12155 }
12156
12157 string GetLockSoundSet()
12158 {
12159 return m_LockSoundSet;
12160 }
12161
12162 //----------------------------------------------------------------
12163 //------------------------- Color
12164 // sets items color variable given color components
12165 override void SetColor(int r, int g, int b, int a)
12166 {
12171 SetVariableMask(VARIABLE_COLOR);
12172 }
12174 override void GetColor(out int r,out int g,out int b,out int a)
12175 {
12180 }
12181
12182 bool IsColorSet()
12183 {
12184 return IsVariableSet(VARIABLE_COLOR);
12185 }
12186
12188 string GetColorString()
12189 {
12190 int r,g,b,a;
12191 GetColor(r,g,b,a);
12192 r = r/255;
12193 g = g/255;
12194 b = b/255;
12195 a = a/255;
12196 return MiscGameplayFunctions.GetColorString(r, g, b, a);
12197 }
12198 //----------------------------------------------------------------
12199 //------------------------- LiquidType
12200
12201 override void SetLiquidType(int value, bool allow_client = false)
12202 {
12203 if (!IsServerCheck(allow_client))
12204 return;
12205
12206 int old = m_VarLiquidType;
12207 m_VarLiquidType = value;
12208 OnLiquidTypeChanged(old,value);
12209 SetVariableMask(VARIABLE_LIQUIDTYPE);
12210 }
12211
12212 int GetLiquidTypeInit()
12213 {
12214 return ConfigGetInt("varLiquidTypeInit");
12215 }
12216
12217 override int GetLiquidType()
12218 {
12219 return m_VarLiquidType;
12220 }
12221
12222 protected void OnLiquidTypeChanged(int oldType, int newType)
12223 {
12224 if (newType == LIQUID_NONE && GetIsFrozen())
12225 SetFrozen(false);
12226 }
12227
12229 void UpdateQuickbarShortcutVisibility(PlayerBase player)
12230 {
12231 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12232 }
12233
12234 // -------------------------------------------------------------------------
12236 void OnInventoryEnter(Man player)
12237 {
12238 PlayerBase nplayer;
12239 if (PlayerBase.CastTo(nplayer, player))
12240 {
12241 m_CanPlayImpactSound = true;
12242 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
12243 }
12244 }
12245
12246 // -------------------------------------------------------------------------
12248 void OnInventoryExit(Man player)
12249 {
12250 PlayerBase nplayer;
12251 if (PlayerBase.CastTo(nplayer,player))
12252 {
12253 nplayer.SetEnableQuickBarEntityShortcut(this, false);
12254 }
12255
12256 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
12257
12258 if (HasEnergyManager())
12259 {
12260 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
12261 }
12262 }
12263
12264 // ADVANCED PLACEMENT EVENTS
12265 override void OnPlacementStarted(Man player)
12266 {
12267 super.OnPlacementStarted(player);
12268
12269 SetTakeable(false);
12270 }
12271
12272 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
12273 {
12274 if (m_AdminLog)
12275 {
12276 m_AdminLog.OnPlacementComplete(player, this);
12277 }
12278
12279 super.OnPlacementComplete(player, position, orientation);
12280 }
12281
12282 //-----------------------------
12283 // AGENT SYSTEM
12284 //-----------------------------
12285 //--------------------------------------------------------------------------
12286 bool ContainsAgent(int agent_id)
12287 {
12288 if (agent_id & m_AttachedAgents)
12289 {
12290 return true;
12291 }
12292 else
12293 {
12294 return false;
12295 }
12296 }
12297
12298 //--------------------------------------------------------------------------
12299 override void RemoveAgent(int agent_id)
12300 {
12301 if (ContainsAgent(agent_id))
12302 {
12303 m_AttachedAgents = ~agent_id & m_AttachedAgents;
12304 }
12305 }
12306
12307 //--------------------------------------------------------------------------
12308 override void RemoveAllAgents()
12309 {
12310 m_AttachedAgents = 0;
12311 }
12312 //--------------------------------------------------------------------------
12313 override void RemoveAllAgentsExcept(int agent_to_keep)
12314 {
12315 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
12316 }
12317 // -------------------------------------------------------------------------
12318 override void InsertAgent(int agent, float count = 1)
12319 {
12320 if (count < 1)
12321 return;
12322 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
12324 }
12325
12327 void TransferAgents(int agents)
12328 {
12330 }
12331
12332 // -------------------------------------------------------------------------
12333 override int GetAgents()
12334 {
12335 return m_AttachedAgents;
12336 }
12337 //----------------------------------------------------------------------
12338
12339 /*int GetContaminationType()
12340 {
12341 int contamination_type;
12342
12343 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
12344 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
12345 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
12346 const int DIRTY_MASK = eAgents.WOUND_AGENT;
12347
12348 Edible_Base edible = Edible_Base.Cast(this);
12349 int agents = GetAgents();
12350 if (edible)
12351 {
12352 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
12353 if (profile)
12354 {
12355 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
12356 }
12357 }
12358 if (agents & CONTAMINATED_MASK)
12359 {
12360 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
12361 }
12362 if (agents & POISONED_MASK)
12363 {
12364 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
12365 }
12366 if (agents & NERVE_GAS_MASK)
12367 {
12368 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
12369 }
12370 if (agents & DIRTY_MASK)
12371 {
12372 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
12373 }
12374
12375 return agents;
12376 }*/
12377
12378 // -------------------------------------------------------------------------
12379 bool LoadAgents(ParamsReadContext ctx, int version)
12380 {
12381 if (!ctx.Read(m_AttachedAgents))
12382 return false;
12383 return true;
12384 }
12385 // -------------------------------------------------------------------------
12387 {
12388
12390 }
12391 // -------------------------------------------------------------------------
12392
12394 override void CheckForRoofLimited(float timeTresholdMS = 3000)
12395 {
12396 super.CheckForRoofLimited(timeTresholdMS);
12397
12398 float time = g_Game.GetTime();
12399 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
12400 {
12401 m_PreviousRoofTestTime = time;
12402 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
12403 }
12404 }
12405
12406 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
12407 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
12408 {
12409 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
12410 {
12411 return 0;
12412 }
12413
12414 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
12415 {
12416 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
12417 if (filter)
12418 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
12419 else
12420 return 0;//otherwise return 0 when no filter attached
12421 }
12422
12423 string subclassPath, entryName;
12424
12425 switch (type)
12426 {
12427 case DEF_BIOLOGICAL:
12428 entryName = "biological";
12429 break;
12430 case DEF_CHEMICAL:
12431 entryName = "chemical";
12432 break;
12433 default:
12434 entryName = "biological";
12435 break;
12436 }
12437
12438 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
12439
12440 return g_Game.ConfigGetFloat(subclassPath + entryName);
12441 }
12442
12443
12444
12446 override void EEOnCECreate()
12447 {
12448 if (!IsMagazine())
12450
12452 }
12453
12454
12455 //-------------------------
12456 // OPEN/CLOSE USER ACTIONS
12457 //-------------------------
12459 void Open();
12460 void Close();
12461 bool IsOpen()
12462 {
12463 return true;
12464 }
12465
12466 override bool CanDisplayCargo()
12467 {
12468 return IsOpen();
12469 }
12470
12471
12472 // ------------------------------------------------------------
12473 // CONDITIONS
12474 // ------------------------------------------------------------
12475 override bool CanPutInCargo(EntityAI parent)
12476 {
12477 if (parent)
12478 {
12479 if (parent.IsInherited(DayZInfected))
12480 return true;
12481
12482 if (!parent.IsRuined())
12483 return true;
12484 }
12485
12486 return true;
12487 }
12488
12489 override bool CanPutAsAttachment(EntityAI parent)
12490 {
12491 if (!super.CanPutAsAttachment(parent))
12492 {
12493 return false;
12494 }
12495
12496 if (!IsRuined() && !parent.IsRuined())
12497 {
12498 return true;
12499 }
12500
12501 return false;
12502 }
12503
12504 override bool CanReceiveItemIntoCargo(EntityAI item)
12505 {
12506 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12507 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12508 // return false;
12509
12510 return super.CanReceiveItemIntoCargo(item);
12511 }
12512
12513 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
12514 {
12515 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12516 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12517 // return false;
12518
12519 GameInventory attachmentInv = attachment.GetInventory();
12520 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12521 {
12522 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12523 return false;
12524 }
12525
12526 InventoryLocation loc = new InventoryLocation();
12527 attachment.GetInventory().GetCurrentInventoryLocation(loc);
12528 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
12529 return false;
12530
12531 return super.CanReceiveAttachment(attachment, slotId);
12532 }
12533
12534 override bool CanReleaseAttachment(EntityAI attachment)
12535 {
12536 if (!super.CanReleaseAttachment(attachment))
12537 return false;
12538
12539 return GetInventory().AreChildrenAccessible();
12540 }
12541
12542 /*override bool CanLoadAttachment(EntityAI attachment)
12543 {
12544 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
12545 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
12546 // return false;
12547
12548 GameInventory attachmentInv = attachment.GetInventory();
12549 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
12550 {
12551 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
12552 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
12553
12554 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
12555 return false;
12556 }
12557
12558 return super.CanLoadAttachment(attachment);
12559 }*/
12560
12561 // Plays muzzle flash particle effects
12562 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12563 {
12564 int id = muzzle_owner.GetMuzzleID();
12565 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
12566
12567 if (WPOF_array)
12568 {
12569 for (int i = 0; i < WPOF_array.Count(); i++)
12570 {
12571 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
12572
12573 if (WPOF)
12574 {
12575 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
12576 }
12577 }
12578 }
12579 }
12580
12581 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
12582 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12583 {
12584 int id = muzzle_owner.GetMuzzleID();
12585 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
12586
12587 if (WPOBE_array)
12588 {
12589 for (int i = 0; i < WPOBE_array.Count(); i++)
12590 {
12591 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
12592
12593 if (WPOBE)
12594 {
12595 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12596 }
12597 }
12598 }
12599 }
12600
12601 // Plays all weapon overheating particles
12602 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12603 {
12604 int id = muzzle_owner.GetMuzzleID();
12605 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12606
12607 if (WPOOH_array)
12608 {
12609 for (int i = 0; i < WPOOH_array.Count(); i++)
12610 {
12611 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12612
12613 if (WPOOH)
12614 {
12615 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
12616 }
12617 }
12618 }
12619 }
12620
12621 // Updates all weapon overheating particles
12622 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12623 {
12624 int id = muzzle_owner.GetMuzzleID();
12625 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12626
12627 if (WPOOH_array)
12628 {
12629 for (int i = 0; i < WPOOH_array.Count(); i++)
12630 {
12631 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12632
12633 if (WPOOH)
12634 {
12635 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
12636 }
12637 }
12638 }
12639 }
12640
12641 // Stops overheating particles
12642 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
12643 {
12644 int id = muzzle_owner.GetMuzzleID();
12645 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
12646
12647 if (WPOOH_array)
12648 {
12649 for (int i = 0; i < WPOOH_array.Count(); i++)
12650 {
12651 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
12652
12653 if (WPOOH)
12654 {
12655 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
12656 }
12657 }
12658 }
12659 }
12660
12661 //----------------------------------------------------------------
12662 //Item Behaviour - unified approach
12663 override bool IsHeavyBehaviour()
12664 {
12665 if (m_ItemBehaviour == 0)
12666 {
12667 return true;
12668 }
12669
12670 return false;
12671 }
12672
12673 override bool IsOneHandedBehaviour()
12674 {
12675 if (m_ItemBehaviour == 1)
12676 {
12677 return true;
12678 }
12679
12680 return false;
12681 }
12682
12683 override bool IsTwoHandedBehaviour()
12684 {
12685 if (m_ItemBehaviour == 2)
12686 {
12687 return true;
12688 }
12689
12690 return false;
12691 }
12692
12693 bool IsDeployable()
12694 {
12695 return false;
12696 }
12697
12699 float GetDeployTime()
12700 {
12701 return UATimeSpent.DEFAULT_DEPLOY;
12702 }
12703
12704
12705 //----------------------------------------------------------------
12706 // Item Targeting (User Actions)
12707 override void SetTakeable(bool pState)
12708 {
12709 m_IsTakeable = pState;
12710 SetSynchDirty();
12711 }
12712
12713 override bool IsTakeable()
12714 {
12715 return m_IsTakeable;
12716 }
12717
12718 // For cases where we want to show object widget which cant be taken to hands
12720 {
12721 return false;
12722 }
12723
12725 protected void PreLoadSoundAttachmentType()
12726 {
12727 string att_type = "None";
12728
12729 if (ConfigIsExisting("soundAttType"))
12730 {
12731 att_type = ConfigGetString("soundAttType");
12732 }
12733
12734 m_SoundAttType = att_type;
12735 }
12736
12737 override string GetAttachmentSoundType()
12738 {
12739 return m_SoundAttType;
12740 }
12741
12742 //----------------------------------------------------------------
12743 //SOUNDS - ItemSoundHandler
12744 //----------------------------------------------------------------
12745
12746 string GetPlaceSoundset(); // played when deploy starts
12747 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
12748 string GetDeploySoundset(); // played when deploy sucessfully finishes
12749 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
12750 string GetFoldSoundset(); // played when fold sucessfully finishes
12751
12753 {
12754 if (!m_ItemSoundHandler)
12756
12757 return m_ItemSoundHandler;
12758 }
12759
12760 // override to initialize sounds
12761 protected void InitItemSounds()
12762 {
12763 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
12764 return;
12765
12767
12768 if (GetPlaceSoundset() != string.Empty)
12769 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
12770
12771 if (GetDeploySoundset() != string.Empty)
12772 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
12773
12774 SoundParameters params = new SoundParameters();
12775 params.m_Loop = true;
12776 if (GetLoopDeploySoundset() != string.Empty)
12777 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
12778 }
12779
12780 // Start sound using ItemSoundHandler
12781 void StartItemSoundServer(int id, int slotId)
12782 {
12783 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
12784 {
12785 m_SoundSyncSlotID = slotId;
12786 m_SoundSyncPlay = id;
12787
12788 SetSynchDirty();
12789
12790 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
12791 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
12792 }
12793 }
12794
12795 void StartItemSoundServer(int id)
12796 {
12797 StartItemSoundServer(id, InventorySlots.INVALID);
12798 }
12799
12800 // Stop sound using ItemSoundHandler
12801 void StopItemSoundServer(int id)
12802 {
12803 if (!g_Game.IsServer())
12804 return;
12805
12806 m_SoundSyncStop = id;
12807 SetSynchDirty();
12808
12809 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
12810 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
12811 }
12812
12813 protected void ClearStartItemSoundServer()
12814 {
12815 m_SoundSyncPlay = 0;
12816 m_SoundSyncSlotID = InventorySlots.INVALID;
12817 }
12818
12819 protected void ClearStopItemSoundServer()
12820 {
12821 m_SoundSyncStop = 0;
12822 }
12823
12824 void OnApply(PlayerBase player);
12825
12827 {
12828 return 1.0;
12829 };
12830 //returns applicable selection
12831 array<string> GetHeadHidingSelection()
12832 {
12834 }
12835
12837 {
12839 }
12840
12841 WrittenNoteData GetWrittenNoteData() {};
12842
12844 {
12845 SetDynamicPhysicsLifeTime(0.01);
12846 m_ItemBeingDroppedPhys = false;
12847 }
12848
12850 {
12851 array<string> zone_names = new array<string>;
12852 GetDamageZones(zone_names);
12853 for (int i = 0; i < zone_names.Count(); i++)
12854 {
12855 SetHealthMax(zone_names.Get(i),"Health");
12856 }
12857 SetHealthMax("","Health");
12858 }
12859
12861 void SetZoneDamageCEInit()
12862 {
12863 float global_health = GetHealth01("","Health");
12864 array<string> zones = new array<string>;
12865 GetDamageZones(zones);
12866 //set damage of all zones to match global health level
12867 for (int i = 0; i < zones.Count(); i++)
12868 {
12869 SetHealth01(zones.Get(i),"Health",global_health);
12870 }
12871 }
12872
12874 bool IsCoverFaceForShave(string slot_name)
12875 {
12876 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
12877 }
12878
12879 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12880 {
12881 if (!hasRootAsPlayer)
12882 {
12883 if (refParentIB)
12884 {
12885 // parent is wet
12886 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
12887 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
12888 // parent has liquid inside
12889 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
12890 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
12891 // drying
12892 else if (m_VarWet > m_VarWetMin)
12893 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
12894 }
12895 else
12896 {
12897 // drying on ground or inside non-itembase (car, ...)
12898 if (m_VarWet > m_VarWetMin)
12899 AddWet(-1 * delta * GetDryingIncrement("ground"));
12900 }
12901 }
12902 }
12903
12904 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
12905 {
12907 {
12908 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
12909 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
12910 {
12911 float heatPermCoef = 1.0;
12912 EntityAI ent = this;
12913 while (ent)
12914 {
12915 heatPermCoef *= ent.GetHeatPermeabilityCoef();
12916 ent = ent.GetHierarchyParent();
12917 }
12918
12919 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
12920 }
12921 }
12922 }
12923
12924 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
12925 {
12926 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
12927 EntityAI parent = GetHierarchyParent();
12928 if (!parent)
12929 {
12930 hasParent = false;
12931 hasRootAsPlayer = false;
12932 }
12933 else
12934 {
12935 hasParent = true;
12936 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
12937 refParentIB = ItemBase.Cast(parent);
12938 }
12939 }
12940
12941 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
12942 {
12943 // this is stub, implemented on Edible_Base
12944 }
12945
12946 bool CanDecay()
12947 {
12948 // return true used on selected food clases so they can decay
12949 return false;
12950 }
12951
12952 protected bool CanProcessDecay()
12953 {
12954 // this is stub, implemented on Edible_Base class
12955 // used to determine whether it is still necessary for the food to decay
12956 return false;
12957 }
12958
12959 protected bool CanHaveWetness()
12960 {
12961 // return true used on selected items that have a wetness effect
12962 return false;
12963 }
12964
12966 bool CanBeConsumed(ConsumeConditionData data = null)
12967 {
12968 return !GetIsFrozen() && IsOpen();
12969 }
12970
12971 override void ProcessVariables()
12972 {
12973 bool hasParent = false, hasRootAsPlayer = false;
12974 ItemBase refParentIB;
12975
12976 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
12977 bool foodDecay = g_Game.IsFoodDecayEnabled();
12978
12979 if (wwtu || foodDecay)
12980 {
12981 bool processWetness = wwtu && CanHaveWetness();
12982 bool processTemperature = wwtu && CanHaveTemperature();
12983 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
12984
12985 if (processWetness || processTemperature || processDecay)
12986 {
12987 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
12988
12989 if (processWetness)
12990 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12991
12992 if (processTemperature)
12993 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
12994
12995 if (processDecay)
12996 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
12997 }
12998 }
12999 }
13000
13003 {
13004 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
13005 }
13006
13007 override float GetTemperatureFreezeThreshold()
13008 {
13010 return Liquid.GetFreezeThreshold(GetLiquidType());
13011
13012 return super.GetTemperatureFreezeThreshold();
13013 }
13014
13015 override float GetTemperatureThawThreshold()
13016 {
13018 return Liquid.GetThawThreshold(GetLiquidType());
13019
13020 return super.GetTemperatureThawThreshold();
13021 }
13022
13023 override float GetItemOverheatThreshold()
13024 {
13026 return Liquid.GetBoilThreshold(GetLiquidType());
13027
13028 return super.GetItemOverheatThreshold();
13029 }
13030
13031 override float GetTemperatureFreezeTime()
13032 {
13033 if (HasQuantity())
13034 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
13035
13036 return super.GetTemperatureFreezeTime();
13037 }
13038
13039 override float GetTemperatureThawTime()
13040 {
13041 if (HasQuantity())
13042 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
13043
13044 return super.GetTemperatureThawTime();
13045 }
13046
13048 void AffectLiquidContainerOnFill(int liquid_type, float amount);
13050 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
13051
13052 bool IsCargoException4x3(EntityAI item)
13053 {
13054 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
13055 }
13056
13058 {
13059 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
13060 }
13061
13063 void AddLightSourceItem(ItemBase lightsource)
13064 {
13065 m_LightSourceItem = lightsource;
13066 }
13067
13069 {
13070 m_LightSourceItem = null;
13071 }
13072
13074 {
13075 return m_LightSourceItem;
13076 }
13077
13079 array<int> GetValidFinishers()
13080 {
13081 return null;
13082 }
13083
13085 bool GetActionWidgetOverride(out typename name)
13086 {
13087 return false;
13088 }
13089
13090 bool PairWithDevice(notnull ItemBase otherDevice)
13091 {
13092 if (g_Game.IsServer())
13093 {
13094 ItemBase explosive = otherDevice;
13096 if (!trg)
13097 {
13098 trg = RemoteDetonatorTrigger.Cast(otherDevice);
13099 explosive = this;
13100 }
13101
13102 explosive.PairRemote(trg);
13103 trg.SetControlledDevice(explosive);
13104
13105 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
13106 trg.SetPersistentPairID(persistentID);
13107 explosive.SetPersistentPairID(persistentID);
13108
13109 return true;
13110 }
13111 return false;
13112 }
13113
13115 float GetBaitEffectivity()
13116 {
13117 float ret = 1.0;
13118 if (HasQuantity())
13119 ret *= GetQuantityNormalized();
13120 ret *= GetHealth01();
13121
13122 return ret;
13123 }
13124
13125 #ifdef DEVELOPER
13126 override void SetDebugItem()
13127 {
13128 super.SetDebugItem();
13129 _itemBase = this;
13130 }
13131
13132 override string GetDebugText()
13133 {
13134 string text = super.GetDebugText();
13135
13136 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
13137 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
13138
13139 return text;
13140 }
13141 #endif
13142
13143 bool CanBeUsedForSuicide()
13144 {
13145 return true;
13146 }
13147
13149 //DEPRECATED BELOW
13151 // Backwards compatibility
13152 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
13153 {
13154 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
13155 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
13156 }
13157
13158 // replaced by ItemSoundHandler
13159 protected EffectSound m_SoundDeployFinish;
13160 protected EffectSound m_SoundPlace;
13161 protected EffectSound m_DeployLoopSoundEx;
13162 protected EffectSound m_SoundDeploy;
13163 bool m_IsPlaceSound;
13164 bool m_IsDeploySound;
13166
13167 string GetDeployFinishSoundset();
13168 void PlayDeploySound();
13169 void PlayDeployFinishSound();
13170 void PlayPlaceSound();
13171 void PlayDeployLoopSoundEx();
13172 void StopDeployLoopSoundEx();
13173 void SoundSynchRemoteReset();
13174 void SoundSynchRemote();
13175 bool UsesGlobalDeploy(){return false;}
13176 bool CanPlayDeployLoopSound(){return false;}
13178 bool IsPlaceSound(){return m_IsPlaceSound;}
13179 bool IsDeploySound(){return m_IsDeploySound;}
13180 void SetIsPlaceSound(bool is_place_sound);
13181 void SetIsDeploySound(bool is_deploy_sound);
13182
13183 [Obsolete("Use ItemSoundHandler instead")]
13185 void PlayAttachSound(string slot_type)
13186 {
13187 if (!g_Game.IsDedicatedServer())
13188 {
13189 if (ConfigIsExisting("attachSoundSet"))
13190 {
13191 string cfg_path = "";
13192 string soundset = "";
13193 string type_name = GetType();
13194
13195 TStringArray cfg_soundset_array = new TStringArray;
13196 TStringArray cfg_slot_array = new TStringArray;
13197 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
13198 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
13199
13200 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
13201 {
13202 for (int i = 0; i < cfg_soundset_array.Count(); i++)
13203 {
13204 if (cfg_slot_array[i] == slot_type)
13205 {
13206 soundset = cfg_soundset_array[i];
13207 break;
13208 }
13209 }
13210 }
13211
13212 if (soundset != "")
13213 {
13214 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
13215 sound.SetAutodestroy(true);
13216 }
13217 }
13218 }
13219 }
13220
13221 void PlayDetachSound(string slot_type) {}
13222}
13223
13224EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
13225{
13226 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
13227 if (entity)
13228 {
13229 bool is_item = entity.IsInherited(ItemBase);
13230 if (is_item && full_quantity)
13231 {
13232 ItemBase item = ItemBase.Cast(entity);
13233 item.SetQuantity(item.GetQuantityInit());
13234 }
13235 }
13236 else
13237 {
13238 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
13239 return NULL;
13240 }
13241 return entity;
13242}
13243
13244void SetupSpawnedItem(ItemBase item, float health, float quantity)
13245{
13246 if (item)
13247 {
13248 if (health > 0)
13249 item.SetHealth("", "", health);
13250
13251 if (item.CanHaveTemperature())
13252 {
13253 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
13254 if (item.CanFreeze())
13255 item.SetFrozen(false);
13256 }
13257
13258 if (item.HasEnergyManager())
13259 {
13260 if (quantity >= 0)
13261 {
13262 item.GetCompEM().SetEnergy0To1(quantity);
13263 }
13264 else
13265 {
13266 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
13267 }
13268 }
13269 else if (item.IsMagazine())
13270 {
13271 Magazine mag = Magazine.Cast(item);
13272 if (quantity >= 0)
13273 {
13274 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
13275 }
13276 else
13277 {
13278 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
13279 }
13280
13281 }
13282 else
13283 {
13284 if (quantity >= 0)
13285 {
13286 item.SetQuantityNormalized(quantity, false);
13287 }
13288 else
13289 {
13290 item.SetQuantity(Math.AbsFloat(quantity));
13291 }
13292
13293 }
13294 }
13295}
13296
13297#ifdef DEVELOPER
13298ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
13299#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Param3 TSelectableActionInfo
EWetnessLevel
Определения 3_Game/DayZ/Entities/EntityAI.c:2
bool SetAttachSoundEvent()
void InventoryItemType()
bool SetDetachSoundEvent()
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
const int INPUT_UDT_ITEM_MANIPULATION
class LogManager EntityAI
eBleedingSourceType GetType()
ItemSuppressor SuppressorBase
void ActionDropItem()
Определения ActionDropItem.c:34
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Определения ActionManagerClient.c:1
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void RemoveAction(typename actionName)
Определения AdvancedCommunication.c:252
TInputActionMap m_InputActionMap
Определения AdvancedCommunication.c:137
bool m_ActionsInitialize
Определения AdvancedCommunication.c:138
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Определения AdvancedCommunication.c:202
void InitializeActions()
Определения AdvancedCommunication.c:190
string Debug()
Определения CachedEquipmentStorageBase.c:29
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:36
const int RF_DEFAULT
Определения CentralEconomy.c:65
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
Open
Implementations only.
override void EEOnCECreate()
Определения ContaminatedArea_Dynamic.c:42
map
Определения ControlsXboxNew.c:4
CookingMethodType
Определения Cooking.c:2
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
DayZGame g_Game
Определения DayZGame.c:3942
DayZGame GetDayZGame()
Определения DayZGame.c:3944
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
PluginAdminLog m_AdminLog
Определения EmoteManager.c:159
const int MIN
Определения EnConvert.c:28
const int MAX
Определения EnConvert.c:27
float GetTemperature()
Определения Environment.c:500
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool IsPrepareToDelete()
Определения FireplaceBase.c:643
override bool CanHaveTemperature()
Определения FireplaceBase.c:561
class GP5GasMask extends MaskBase ItemBase
proto GizmoApi GetGizmoApi()
Empty
Определения Hand_States.c:14
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool DamageItemInCargo(float damage)
Определения ItemBase.c:6453
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5680
bool HidesSelectionBySlot()
Определения ItemBase.c:9413
float m_VarWetMin
Определения ItemBase.c:4937
void SplitItem(PlayerBase player)
Определения ItemBase.c:6908
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9634
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8895
override float GetQuantityNormalized()
Gets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8330
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5685
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:9038
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6875
override bool IsHeavyBehaviour()
Определения ItemBase.c:9240
override void SetWetMax()
Определения ItemBase.c:8616
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9451
void ClearStartItemSoundServer()
Определения ItemBase.c:9390
float m_VarWet
Определения ItemBase.c:4934
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9481
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:3
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8890
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4997
bool CanBeMovedOverride()
Определения ItemBase.c:7600
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8592
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4983
void StartItemSoundServer(int id, int slotId)
Определения ItemBase.c:9358
override void ProcessVariables()
Определения ItemBase.c:9548
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:5011
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8423
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8956
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8806
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5271
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:5009
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9584
bool m_IsSoundSynchRemote
Определения ItemBase.c:9742
float m_OverheatingShots
Определения ItemBase.c:5004
void StopItemSoundServer(int id)
Определения ItemBase.c:9378
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5700
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5424
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9608
ref array< int > m_CompatibleLocks
Определения ItemBase.c:5021
bool CanBeCooked()
Определения ItemBase.c:7556
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5767
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:5035
bool m_RecipesInitialized
Определения ItemBase.c:4919
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6546
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9592
override void OnEnergyConsumed()
Определения ItemBase.c:8536
void RefreshAudioVisualsOnClient(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
cooking-related effect methods
Определения Bottle_Base.c:158
int GetNumberOfItems()
Returns the number of items in cargo, otherwise returns 0(non-cargo objects). Recursive.
Определения ItemBase.c:8462
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8656
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8418
ref TIntArray m_InteractActions
Определения ItemBase.c:4985
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7620
float m_VarQuantity
Определения ItemBase.c:4925
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9753
override float GetWetMax()
Определения ItemBase.c:8626
bool CanBeUsedForSuicide()
Определения ItemBase.c:9720
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7193
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5905
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7774
void DoAmmoExplosion()
Определения ItemBase.c:6388
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4996
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6732
int GetItemSize()
Определения ItemBase.c:7585
bool m_CanBeMovedOverride
Определения ItemBase.c:4962
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6312
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5492
bool CanDecay()
Определения ItemBase.c:9523
ScriptedLightBase GetLight()
string GetPlaceSoundset()
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...
Определения ItemBase.c:8303
void SetQuantityMax()
Определения ItemBase.c:8308
override float GetQuantity()
Определения ItemBase.c:8398
int m_ColorComponentR
Определения ItemBase.c:4974
int m_ShotsToStartOverheating
Определения ItemBase.c:5006
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8641
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5499
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9139
void OnOverheatingDecay()
Определения ItemBase.c:5462
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8574
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4940
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5600
bool UsesGlobalDeploy()
Определения ItemBase.c:9752
int m_ItemBehaviour
Определения ItemBase.c:4955
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:9111
float m_HeatIsolation
Определения ItemBase.c:4950
float m_VarWetInit
Определения ItemBase.c:4936
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5945
void SetCEBasedQuantity()
Определения ItemBase.c:5713
bool m_CanPlayImpactSound
Определения ItemBase.c:4946
override string GetAttachmentSoundType()
Определения ItemBase.c:9314
float GetOverheatingCoef()
Определения ItemBase.c:5519
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9408
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9762
override bool IsStoreLoad()
Определения ItemBase.c:8668
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7169
bool IsLightSource()
Определения ItemBase.c:5841
bool m_HasQuantityBar
Определения ItemBase.c:4968
void SetResultOfSplit(bool value)
Определения ItemBase.c:7164
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6796
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6965
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5527
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8583
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9219
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8678
int m_LockType
Определения ItemBase.c:5022
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:5027
bool m_CanBeDigged
Определения ItemBase.c:4969
float m_ItemAttachOffset
Определения ItemBase.c:4952
float GetItemModelLength()
Определения ItemBase.c:8685
bool m_ThrowItemOnDrop
Определения ItemBase.c:4960
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7919
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8971
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8569
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7198
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9579
bool CanHaveWetness()
Определения ItemBase.c:9536
int m_CleannessMin
Определения ItemBase.c:4942
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8904
string IDToName(int id)
Определения ItemBase.c:7767
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9543
float GetHeatIsolationInit()
Определения ItemBase.c:8564
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7607
override bool HasQuantity()
Определения ItemBase.c:8393
float m_VarWetPrev
Определения ItemBase.c:4935
int m_SoundSyncStop
Определения ItemBase.c:5029
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9629
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4984
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5609
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5294
int m_VarLiquidType
Определения ItemBase.c:4954
int m_QuickBarBonus
Определения ItemBase.c:4956
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9302
override float GetWetInit()
Определения ItemBase.c:8636
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4948
int m_SoundSyncPlay
Определения ItemBase.c:5028
int m_MaxOverheatingValue
Определения ItemBase.c:5007
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4931
bool m_IsTakeable
Определения ItemBase.c:4959
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:6503
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4999
string GetLockSoundSet()
Определения ItemBase.c:8734
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8765
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9656
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6971
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4911
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9329
override int GetQuantityMin()
Определения ItemBase.c:8382
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6711
override int GetQuickBarBonus()
Определения ItemBase.c:5179
override void SetTakeable(bool pState)
Определения ItemBase.c:9284
float m_OverheatingDecayInterval
Определения ItemBase.c:5008
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6523
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9501
bool CanProcessDecay()
Определения ItemBase.c:9529
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5690
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9645
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7571
bool can_this_be_combined
Определения ItemBase.c:4964
EffectSound m_SoundDeploy
Определения ItemBase.c:9739
int m_SoundSyncSlotID
Определения ItemBase.c:5030
int m_Count
Определения ItemBase.c:4930
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9692
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9276
override bool IsSplitable()
Определения ItemBase.c:6490
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6473
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7883
void ConvertEnergyToQuantity()
Определения ItemBase.c:8551
override void RemoveAllAgents()
Определения ItemBase.c:8885
override void SetQuantityToMinimum()
Определения ItemBase.c:8314
bool m_WantPlayImpactSound
Определения ItemBase.c:4945
override float GetTemperatureThawTime()
Определения ItemBase.c:9616
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4998
int m_ColorComponentG
Определения ItemBase.c:4975
float m_StoreLoadedQuantity
Определения ItemBase.c:4932
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7638
int m_ColorComponentA
Определения ItemBase.c:4977
int m_VarQuantityInit
Определения ItemBase.c:4927
float GetFilterDamageRatio()
Определения ItemBase.c:5594
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8778
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6942
void OnApply(PlayerBase player)
override 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...
Определения ItemBase.c:8321
bool m_HideSelectionsBySlot
Определения ItemBase.c:5012
bool IsOverheatingEffectActive()
Определения ItemBase.c:5457
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5874
int GetLiquidContainerMask()
Определения ItemBase.c:5811
void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
Определения ItemBase.c:7078
ref Timer m_CheckOverheating
Определения ItemBase.c:5005
void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
Определения ItemBase.c:5505
float GetEnergy()
Определения ItemBase.c:8525
bool CanBeDigged()
Определения ItemBase.c:5890
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9662
bool IsNVG()
Определения ItemBase.c:5822
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8485
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9438
bool m_IsDeploySound
Определения ItemBase.c:9741
bool CanEat()
Определения ItemBase.c:7531
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9179
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9250
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9640
bool IsLiquidContainer()
Определения ItemBase.c:5806
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7551
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8409
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8963
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8363
int m_CleannessInit
Определения ItemBase.c:4941
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5589
override int GetAgents()
Определения ItemBase.c:8910
int m_VarQuantityMax
Определения ItemBase.c:4929
override bool IsHologram()
Определения ItemBase.c:5885
float GetItemAttachOffset()
Определения ItemBase.c:8694
bool IsPlaceSound()
Определения ItemBase.c:9755
static int GetDebugActionsMask()
Определения ItemBase.c:5675
override int GetLiquidType()
Определения ItemBase.c:8794
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9518
override bool IsItemBase()
Определения ItemBase.c:7684
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9260
void ExplodeAmmo()
Определения ItemBase.c:6375
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:7154
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8984
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9159
override void OnEnergyAdded()
Определения ItemBase.c:8543
void AffectLiquidContainerOnFill(int liquid_type, float amount)
from enviro source
void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature)
from other liquid container source
string GetExplosiveTriggerSlotName()
Определения ItemBase.c:5834
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9738
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7824
void StopItemDynamicPhysics()
Определения ItemBase.c:9420
bool HasFoodStage()
Определения ItemBase.c:7544
override void SetStoreLoad(bool value)
Определения ItemBase.c:8663
float GetOverheatingValue()
Определения ItemBase.c:5419
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8863
override void AddWet(float value)
Определения ItemBase.c:8611
bool IsLiquidPresent()
Определения ItemBase.c:5801
bool IsFullQuantity()
Определения ItemBase.c:8403
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:6084
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6847
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6823
int m_CleannessMax
Определения ItemBase.c:4943
float m_VarStackMax
Определения ItemBase.c:4931
ref Timer m_PhysDropTimer
Определения ItemBase.c:5018
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7656
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8673
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4972
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5440
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5755
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7578
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8799
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5486
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8721
bool m_IsOverheatingEffectActive
Определения ItemBase.c:5003
int m_LiquidContainerMask
Определения ItemBase.c:4953
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9456
override int GetCleanness()
Определения ItemBase.c:8716
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9667
bool IsDeploySound()
Определения ItemBase.c:9756
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5695
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9199
int m_VarQuantityMin
Определения ItemBase.c:4928
void PerformDamageSystemReinit()
Определения ItemBase.c:9426
override void ClearInventory()
Определения ItemBase.c:8504
static int m_LastRegisteredWeaponID
Определения ItemBase.c:5000
ItemBase GetLightSourceItem()
Определения ItemBase.c:9650
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7674
override float GetItemOverheatThreshold()
Определения ItemBase.c:9600
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4965
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7788
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6762
float m_ItemModelLength
Определения ItemBase.c:4951
bool m_IsHologram
Определения ItemBase.c:4958
static int m_DebugActionsMask
Определения ItemBase.c:4918
void KillAllOverheatingParticles()
Определения ItemBase.c:5555
bool CanBeCookedOnStick()
Определения ItemBase.c:7561
override int GetQuantityMax()
Определения ItemBase.c:8349
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7232
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8759
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8876
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4961
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:9066
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9798
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4912
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9729
override bool IsBeingPlaced()
Определения ItemBase.c:5869
int GetQuantityInit()
Определения ItemBase.c:8387
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7174
bool IsResultOfSplit()
Определения ItemBase.c:7159
bool m_FixDamageSystemInit
Определения ItemBase.c:4963
float m_ImpactSpeed
Определения ItemBase.c:4947
bool m_IsStoreLoad
Определения ItemBase.c:4966
int GetLiquidTypeInit()
Определения ItemBase.c:8789
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4981
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5742
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6633
int m_AttachedAgents
Определения ItemBase.c:4989
string m_LockSoundSet
Определения ItemBase.c:5024
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5363
float m_VarQuantityPrev
Определения ItemBase.c:4926
bool IsSoundSynchRemote()
Определения ItemBase.c:9754
bool m_CanShowQuantity
Определения ItemBase.c:4967
override void OnRightClick()
Определения ItemBase.c:7014
int m_ColorComponentB
Определения ItemBase.c:4976
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4914
bool IsActionTargetVisible()
Определения ItemBase.c:9296
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:6119
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6412
bool m_IsBeingPlaced
Определения ItemBase.c:4957
int NameToID(string name)
Определения ItemBase.c:7761
void ~ItemBase()
Определения ItemBase.c:5640
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8651
void ClearStopItemSoundServer()
Определения ItemBase.c:9396
override string ChangeIntoOnDetach()
Определения ItemBase.c:6336
float m_VarWetMax
Определения ItemBase.c:4938
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6757
int GetLockType()
Определения ItemBase.c:8729
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9736
override float GetWet()
Определения ItemBase.c:8621
EffectSound m_SoundPlace
Определения ItemBase.c:9737
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8335
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8703
bool m_IsPlaceSound
Определения ItemBase.c:9740
override float GetWetMin()
Определения ItemBase.c:8631
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:5032
override bool KindOf(string tag)
Определения ItemBase.c:7690
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
string Type
Определения JsonDataContaminatedArea.c:11
EffectSound m_LockingSound
Определения Land_Underground_Entrance.c:336
string GetDebugText()
Определения ModifierBase.c:71
@ LOWEST
Определения PPEConstants.c:54
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:325
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Определения RemoteDetonator.c:272
void RemoteDetonatorTrigger()
Определения RemoteDetonator.c:233
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Определения RemoteDetonator.c:305
int particle_id
Определения SmokeSimulation.c:28
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
override void Explode(int damageType, string ammoType="")
Определения Trap_LandMine.c:220
bool m_Initialized
Определения UiHintPanel.c:317
int GetID()
Определения ActionBase.c:1335
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:974
GetInputType()
Определения ActionBase.c:221
int m_StanceMask
Определения ActionBase.c:25
int m_CommandUIDProne
Определения ActionBase.c:24
int m_CommandUID
Определения ActionBase.c:23
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
float GetEnergyAtSpawn()
Определения ComponentEnergyManager.c:1325
void SetEnergy0To1(float energy01)
Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value be...
Определения ComponentEnergyManager.c:550
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Определения ComponentEnergyManager.c:1320
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:603
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
Определения EffectSound.c:274
override bool IsMan()
Определения 3_Game/DayZ/Entities/Man.c:48
proto native EntityAI GetAttachmentFromIndex(int index)
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
proto native int AttachmentCount()
Returns count of attachments attached to this item.
proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
proto void SelectObject(Object object)
proto void SelectPhysics(Physics physics)
Определения ItemBase.c:21
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetCol()
returns column of cargo if current type is Cargo / ProxyCargo
proto native int GetRow()
returns row of cargo if current type is Cargo / ProxyCargo
bool WriteToContext(ParamsWriteContext ctx)
Определения InventoryLocation.c:507
proto native int GetType()
returns type of InventoryLocation
proto native int GetIdx()
returns index of cargo if current type is Cargo / ProxyCargo
proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
sets current inventory location type to Cargo with coordinates (idx, row, col)
proto native bool GetFlip()
returns flip status of cargo
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:30
override bool CanDisplayCargo()
Определения TentBase.c:91
override void OnInventoryEnter(Man player)
Определения BarbedWire.c:203
override string GetFoldSoundset()
Определения BaseBuildingBase.c:108
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:7
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:934
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения GardenBase.c:199
override void OnWasDetached(EntityAI parent, int slot_id)
override void EEOnAfterLoad()
Определения GardenBase.c:242
override void EEDelete(EntityAI parent)
Определения BaseBuildingBase.c:68
override bool CanBeRepairedByCrafting()
Определения TentBase.c:86
override void OnPlacementStarted(Man player)
Определения BatteryCharger.c:376
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Определения BarbedWire.c:357
override bool IsElectricAppliance()
Определения BatteryCharger.c:43
override bool IsItemTent()
Определения TentBase.c:81
override string GetLoopFoldSoundset()
Определения BaseBuildingBase.c:113
override bool CanMakeGardenplot()
Определения FieldShovel.c:3
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения PowerGenerator.c:397
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения HandcuffsLocked.c:12
override WrittenNoteData GetWrittenNoteData()
Определения Paper.c:30
override int GetDamageSystemVersionChange()
Определения BaseBuildingBase.c:1238
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
override void InitItemVariables()
Определения Matchbox.c:3
override void SetActionAnimOverrides()
Определения PickAxe.c:28
override void OnCreatePhysics()
Определения BaseBuildingBase.c:489
override string GetDeploySoundset()
Определения BarbedWire.c:392
override float GetBandagingEffectivity()
Определения BandageDressing.c:49
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения PowerGenerator.c:409
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения BaseBuildingBase.c:496
override void OnStoreSave(ParamsWriteContext ctx)
Определения GardenBase.c:266
override void AfterStoreLoad()
Определения BarbedWire.c:155
override int GetOnDigWormsAmount()
Определения FieldShovel.c:27
override bool IsSelfAdjustingTemperature()
Определения PortableGasStove.c:287
override bool IsPlayerInside(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1037
override void OnVariablesSynchronized()
Определения GardenBase.c:97
override void RefreshPhysics()
Определения BatteryCharger.c:359
override bool CanObstruct()
Определения BaseBuildingBase.c:84
override void OnWasAttached(EntityAI parent, int slot_id)
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения BaseBuildingBase.c:982
override bool CanPutInCargo(EntityAI parent)
Определения GardenBase.c:331
override string GetLoopDeploySoundset()
Определения BarbedWire.c:397
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Определения BarbedWire.c:372
override void OnInventoryExit(Man player)
Определения BatteryCharger.c:341
override bool IsTakeable()
Определения BaseBuildingBase.c:1008
override bool IsIgnoredByConstruction()
Определения BaseBuildingBase.c:1170
override void InitItemSounds()
Определения BaseBuildingBase.c:94
override void EEKilled(Object killer)
Определения HandcuffsLocked.c:70
override void OnCombine(ItemBase other_item)
Определения BandageDressing.c:71
override bool CanExplodeInFire()
Определения LargeGasCannister.c:3
override bool IsFacingPlayer(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1032
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Определения Rag.c:61
override bool IsBloodContainer()
Определения BloodContainerBase.c:10
override bool CanBeSplit()
Определения Rag.c:34
override bool IsDeployable()
Определения BaseBuildingBase.c:365
override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения ToolBase.c:24
override bool CanBeDisinfected()
Определения BandageDressing.c:54
override float GetInfectionChance(int system=0, Param param=null)
Определения BandageDressing.c:59
override void OnEndPlacement()
Определения KitBase.c:65
Определения ItemBase.c:14
Определения EnMath.c:7
float GetOverheatingLimitMax()
Определения WeaponParticles.c:417
void SetOverheatingLimitMax(float max)
Определения WeaponParticles.c:407
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
Определения WeaponParticles.c:422
float GetOverheatingLimitMin()
Определения WeaponParticles.c:412
Particle GetParticle()
Определения WeaponParticles.c:397
void SetOverheatingLimitMin(float min)
Определения WeaponParticles.c:402
void RegisterParticle(Particle p)
Определения WeaponParticles.c:392
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Определения Particle.c:266
void SetControlledDevice(EntityAI pDevice)
Определения RemoteDetonator.c:140
bool OnStoreLoad(ParamsReadContext ctx, int version)
void OnStoreSave(ParamsWriteContext ctx)
proto native void Send()
proto bool Write(void value_out)
proto bool Read(void value_in)
bool m_Loop
Определения ItemSoundHandler.c:5
override void Stop()
Определения DayZPlayerImplement.c:40
proto native float GetDamage(string zoneName, string healthType)
override void Refresh()
Определения ChatInputMenu.c:70
void SetCalcDetails(string details)
Определения 3_Game/DayZ/tools/Debug.c:916
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения WrittenNoteData.c:13
const float LOWEST
Определения EnConvert.c:113
Serializer ParamsReadContext
Определения gameplay.c:15
class LOD Object
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Определения gameplay.c:6
Serializer ParamsWriteContext
Определения gameplay.c:16
const int DEF_BIOLOGICAL
Определения 3_Game/DayZ/constants.c:515
const int DEF_CHEMICAL
Определения 3_Game/DayZ/constants.c:516
const int COMP_TYPE_ENERGY_MANAGER
Определения Component.c:9
ErrorExSeverity
Определения EnDebug.c:62
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
enum ShapeType ErrorEx
proto native void SetColor(int color)
array< string > TStringArray
Определения EnScript.c:712
array< int > TIntArray
Определения EnScript.c:714
void Obsolete(string msg="")
Определения EnScript.c:371
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/DayZ/constants.c:811
const int VARIABLE_LIQUIDTYPE
Определения 3_Game/DayZ/constants.c:635
const int VARIABLE_CLEANNESS
Определения 3_Game/DayZ/constants.c:638
const int VARIABLE_COLOR
Определения 3_Game/DayZ/constants.c:637
const int VARIABLE_TEMPERATURE
Определения 3_Game/DayZ/constants.c:633
const int VARIABLE_QUANTITY
Определения 3_Game/DayZ/constants.c:631
const int VARIABLE_WET
Определения 3_Game/DayZ/constants.c:634
const int LIQUID_NONE
Определения 3_Game/DayZ/constants.c:532
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения 3_Game/DayZ/constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения 3_Game/DayZ/constants.c:456
const int SAT_DEBUG_ACTION
Определения 3_Game/DayZ/constants.c:457
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
const int CALL_CATEGORY_GAMEPLAY
Определения 3_Game/DayZ/tools/tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/DayZ/tools/tools.c:8
proto native int GetColor()