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

◆ GetTargetQuantityMax()

override int SpawnItemOnLocation::GetTargetQuantityMax ( int attSlotID = -1)
protected

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

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

Используется в InventoryItem::GetQuantityMax(), InventoryItem::SplitIntoStackMax(), InventoryItem::SplitIntoStackMaxCargo(), InventoryItem::SplitIntoStackMaxEx(), InventoryItem::SplitIntoStackMaxHands() и InventoryItem::SplitIntoStackMaxToInventoryLocationEx().