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

◆ HasQuantity()

override bool SpawnItemOnLocation::HasQuantity ( )
protected

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

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

Используется в Mask_Base::ConsumeQuantity(), InventoryItem::ConvertEnergyToQuantity(), CAContinuousMineWood::CreatePrimaryItems(), InventoryItem::GetBaitEffectivity(), Mask_Base::GetFilterQuantityMax(), InventoryItem::GetProtectionLevel(), InventoryItem::GetTemperatureFreezeTime(), InventoryItem::GetTemperatureThawTime(), Mask_Base::HasIntegratedFilter(), InventoryItem::InitItemVariables(), InventoryItem::IsLiquidPresent(), InventoryItem::OnWasAttached(), InventoryItem::OnWasDetached(), InventoryItem::SetCEBasedQuantity() и InventoryItem::SetQuantity().