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

◆ GetOverheatingCoef()

float SpawnItemOnLocation::GetOverheatingCoef ( )
private

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

5524{
5525 override bool CanPutAsAttachment(EntityAI parent)
5526 {
5527 return true;
5528 }
5529};
5530
5532{
5533
5534};
5535
5536//const bool QUANTITY_DEBUG_REMOVE_ME = false;
5537
5538class ItemBase extends InventoryItem
5539{
5543
5545
5546 static int m_DebugActionsMask;
5548 // ============================================
5549 // Variable Manipulation System
5550 // ============================================
5551 // Quantity
5552
5553 float m_VarQuantity;
5554 float m_VarQuantityPrev;//for client to know quantity changed during synchronization
5556 int m_VarQuantityMin;
5557 int m_VarQuantityMax;
5558 int m_Count;
5559 float m_VarStackMax;
5560 float m_StoreLoadedQuantity = float.LOWEST;
5561 // Wet
5562 float m_VarWet;
5563 float m_VarWetPrev;//for client to know wetness changed during synchronization
5564 float m_VarWetInit;
5565 float m_VarWetMin;
5566 float m_VarWetMax;
5567 // Cleanness
5568 int m_Cleanness;
5569 int m_CleannessInit;
5570 int m_CleannessMin;
5571 int m_CleannessMax;
5572 // impact sounds
5574 bool m_CanPlayImpactSound = true;
5575 float m_ImpactSpeed;
5577 //
5578 float m_HeatIsolation;
5579 float m_ItemModelLength;
5580 float m_ItemAttachOffset; // Offset length for when the item is attached e.g. to weapon
5582 int m_VarLiquidType;
5583 int m_ItemBehaviour; // -1 = not specified; 0 = heavy item; 1= onehanded item; 2 = twohanded item
5584 int m_QuickBarBonus;
5585 bool m_IsBeingPlaced;
5586 bool m_IsHologram;
5587 bool m_IsTakeable;
5588 bool m_ThrowItemOnDrop;
5591 bool m_FixDamageSystemInit = false; //can be changed on storage version check
5592 bool can_this_be_combined; //Check if item can be combined
5593 bool m_CanThisBeSplit; //Check if item can be split
5594 bool m_IsStoreLoad = false;
5595 bool m_CanShowQuantity;
5596 bool m_HasQuantityBar;
5597 protected bool m_CanBeDigged;
5598 protected bool m_IsResultOfSplit
5599
5600 string m_SoundAttType;
5601 // items color variables
5606 //-------------------------------------------------------
5607
5608 // light source managing
5610
5614
5615 //==============================================
5616 // agent system
5617 private int m_AttachedAgents;
5618
5620 void TransferModifiers(PlayerBase reciever);
5621
5622
5623 // Weapons & suppressors particle effects
5627 ref static map<string, int> m_WeaponTypeToID;
5628 static int m_LastRegisteredWeaponID = 0;
5629
5630 // Overheating effects
5632 float m_OverheatingShots;
5633 ref Timer m_CheckOverheating;
5634 int m_ShotsToStartOverheating = 0; // After these many shots, the overheating effect begins
5635 int m_MaxOverheatingValue = 0; // Limits the number of shots that will be tracked
5636 float m_OverheatingDecayInterval = 1; // Timer's interval for decrementing overheat effect's lifespan
5637 ref array <ref OverheatingParticle> m_OverheatingParticles;
5638
5640 protected bool m_HideSelectionsBySlot;
5641
5642 // Admin Log
5643 PluginAdminLog m_AdminLog;
5644
5645 // misc
5646 ref Timer m_PhysDropTimer;
5647
5648 // Attachment Locking variables
5649 ref array<int> m_CompatibleLocks;
5650 protected int m_LockType;
5651 protected ref EffectSound m_LockingSound;
5652 protected string m_LockSoundSet;
5653
5654 // ItemSoundHandler variables
5655 protected const int ITEM_SOUNDS_MAX = 63; // optimize network synch
5656 protected int m_SoundSyncPlay; // id for sound to play
5657 protected int m_SoundSyncStop; // id for sound to stop
5658 protected int m_SoundSyncSlotID = InventorySlots.INVALID; // slot id for attach/detach sound based on slot
5659
5661
5662 //temperature
5663 private float m_TemperaturePerQuantityWeight;
5664
5665 // -------------------------------------------------------------------------
5666 void ItemBase()
5667 {
5668 SetEventMask(EntityEvent.INIT); // Enable EOnInit event
5672
5673 if (!g_Game.IsDedicatedServer())
5674 {
5675 if (HasMuzzle())
5676 {
5678
5680 {
5682 }
5683 }
5684
5686 m_ActionsInitialize = false;
5687 }
5688
5689 m_OldLocation = null;
5690
5691 if (g_Game.IsServer())
5692 {
5693 m_AdminLog = PluginAdminLog.Cast(GetPlugin(PluginAdminLog));
5694 }
5695
5696 if (ConfigIsExisting("headSelectionsToHide"))
5697 {
5699 ConfigGetTextArray("headSelectionsToHide",m_HeadHidingSelections);
5700 }
5701
5702 m_HideSelectionsBySlot = false;
5703 if (ConfigIsExisting("hideSelectionsByinventorySlot"))
5704 {
5705 m_HideSelectionsBySlot = ConfigGetBool("hideSelectionsByinventorySlot");
5706 }
5707
5708 m_QuickBarBonus = Math.Max(0, ConfigGetInt("quickBarBonus"));
5709
5710 m_IsResultOfSplit = false;
5711
5713 }
5714
5715 override void InitItemVariables()
5716 {
5717 super.InitItemVariables();
5718
5719 m_VarQuantityInit = ConfigGetInt("varQuantityInit");
5720 m_VarQuantity = m_VarQuantityInit;//should be by the CE, this is just a precaution
5721 m_VarQuantityMin = ConfigGetInt("varQuantityMin");
5722 m_VarQuantityMax = ConfigGetInt("varQuantityMax");
5723 m_VarStackMax = ConfigGetFloat("varStackMax");
5724 m_Count = ConfigGetInt("count");
5725
5726 m_CanShowQuantity = ConfigGetBool("quantityShow");
5727 m_HasQuantityBar = ConfigGetBool("quantityBar");
5728
5729 m_CleannessInit = ConfigGetInt("varCleannessInit");
5731 m_CleannessMin = ConfigGetInt("varCleannessMin");
5732 m_CleannessMax = ConfigGetInt("varCleannessMax");
5733
5734 m_WantPlayImpactSound = false;
5735 m_ImpactSpeed = 0.0;
5736
5737 m_VarWetInit = ConfigGetFloat("varWetInit");
5739 m_VarWetMin = ConfigGetFloat("varWetMin");
5740 m_VarWetMax = ConfigGetFloat("varWetMax");
5741
5742 m_LiquidContainerMask = ConfigGetInt("liquidContainerType");
5743 if (IsLiquidContainer() && GetQuantity() != 0)
5745 m_IsBeingPlaced = false;
5746 m_IsHologram = false;
5747 m_IsTakeable = true;
5748 m_CanBeMovedOverride = false;
5752 m_CanBeDigged = ConfigGetBool("canBeDigged");
5753
5754 m_CompatibleLocks = new array<int>();
5755 ConfigGetIntArray("compatibleLocks", m_CompatibleLocks);
5756 m_LockType = ConfigGetInt("lockType");
5757
5758 //Define if item can be split and set ability to be combined accordingly
5759 m_CanThisBeSplit = false;
5760 can_this_be_combined = false;
5761 if (ConfigIsExisting("canBeSplit"))
5762 {
5763 can_this_be_combined = ConfigGetBool("canBeSplit");
5765 }
5766
5767 m_ItemBehaviour = -1;
5768 if (ConfigIsExisting("itemBehaviour"))
5769 m_ItemBehaviour = ConfigGetInt("itemBehaviour");
5770
5771 //RegisterNetSyncVariableInt("m_VariablesMask");
5772 if (HasQuantity()) RegisterNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
5773 RegisterNetSyncVariableFloat("m_VarWet", GetWetMin(), GetWetMax(), 2);
5774 RegisterNetSyncVariableInt("m_VarLiquidType");
5775 RegisterNetSyncVariableInt("m_Cleanness",0,1);
5776
5777 RegisterNetSyncVariableBoolSignal("m_WantPlayImpactSound");
5778 RegisterNetSyncVariableFloat("m_ImpactSpeed");
5779 RegisterNetSyncVariableInt("m_ImpactSoundSurfaceHash");
5780
5781 RegisterNetSyncVariableInt("m_ColorComponentR", 0, 255);
5782 RegisterNetSyncVariableInt("m_ColorComponentG", 0, 255);
5783 RegisterNetSyncVariableInt("m_ColorComponentB", 0, 255);
5784 RegisterNetSyncVariableInt("m_ColorComponentA", 0, 255);
5785
5786 RegisterNetSyncVariableBool("m_IsBeingPlaced");
5787 RegisterNetSyncVariableBool("m_IsTakeable");
5788 RegisterNetSyncVariableBool("m_IsHologram");
5789
5792 {
5793 RegisterNetSyncVariableInt("m_SoundSyncPlay", 0, ITEM_SOUNDS_MAX);
5794 RegisterNetSyncVariableInt("m_SoundSyncStop", 0, ITEM_SOUNDS_MAX);
5795 RegisterNetSyncVariableInt("m_SoundSyncSlotID", int.MIN, int.MAX);
5796 }
5797
5798 m_LockSoundSet = ConfigGetString("lockSoundSet");
5799
5801 if (ConfigIsExisting("temperaturePerQuantityWeight"))
5802 m_TemperaturePerQuantityWeight = ConfigGetFloat("temperaturePerQuantityWeight");
5803
5804 m_SoundSyncSlotID = -1;
5805 }
5806
5807 override int GetQuickBarBonus()
5808 {
5809 return m_QuickBarBonus;
5810 }
5811
5812 void InitializeActions()
5813 {
5815 if (!m_InputActionMap)
5816 {
5818 m_InputActionMap = iam;
5819 SetActions();
5821 }
5822 }
5823
5824 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
5825 {
5827 {
5828 m_ActionsInitialize = true;
5830 }
5831
5832 actions = m_InputActionMap.Get(action_input_type);
5833 }
5834
5835 void SetActions()
5836 {
5837 AddAction(ActionTakeItem);
5838 AddAction(ActionTakeItemToHands);
5839 AddAction(ActionWorldCraft);
5841 AddAction(ActionAttachWithSwitch);
5842 }
5843
5844 void SetActionAnimOverrides(); // Override action animation for specific item
5845
5846 void AddAction(typename actionName)
5847 {
5848 ActionBase action = ActionManagerBase.GetAction(actionName);
5849
5850 if (!action)
5851 {
5852 Debug.LogError("Action " + actionName + " dosn't exist!");
5853 return;
5854 }
5855
5856 typename ai = action.GetInputType();
5857 if (!ai)
5858 {
5859 m_ActionsInitialize = false;
5860 return;
5861 }
5862
5863 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
5864 if (!action_array)
5865 {
5866 action_array = new array<ActionBase_Basic>;
5867 m_InputActionMap.Insert(ai, action_array);
5868 }
5869 if (LogManager.IsActionLogEnable())
5870 {
5871 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action");
5872 }
5873
5874 if (action_array.Find(action) != -1)
5875 {
5876 Debug.Log("Action " + action.Type() + " already added to " + this + ", skipping!");
5877 }
5878 else
5879 {
5880 action_array.Insert(action);
5881 }
5882 }
5883
5884 void RemoveAction(typename actionName)
5885 {
5886 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
5887 ActionBase action = player.GetActionManager().GetAction(actionName);
5888 typename ai = action.GetInputType();
5889 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
5890
5891 if (action_array)
5892 {
5893 action_array.RemoveItem(action);
5894 }
5895 }
5896
5897 // Allows override of default action command per item, defined in the SetActionAnimOverrides() of the item's class
5898 // Set -1 for params which should stay in default state
5899 void OverrideActionAnimation(typename action, int commandUID, int stanceMask = -1, int commandUIDProne = -1)
5900 {
5901 ActionOverrideData overrideData = new ActionOverrideData();
5902 overrideData.m_CommandUID = commandUID;
5903 overrideData.m_CommandUIDProne = commandUIDProne;
5904 overrideData.m_StanceMask = stanceMask;
5905
5906 TActionAnimOverrideMap actionMap = m_ItemActionOverrides.Get(action);
5907 if (!actionMap) // create new map of action > overidables map
5908 {
5909 actionMap = new TActionAnimOverrideMap();
5910 m_ItemActionOverrides.Insert(action, actionMap);
5911 }
5912
5913 actionMap.Insert(this.Type(), overrideData); // insert item -> overrides
5914
5915 }
5916
5917 void OnItemInHandsPlayerSwimStart(PlayerBase player);
5918
5919 ScriptedLightBase GetLight();
5920
5921 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
5922 void LoadParticleConfigOnFire(int id)
5923 {
5924 if (!m_OnFireEffect)
5926
5929
5930 string config_to_search = "CfgVehicles";
5931 string muzzle_owner_config;
5932
5933 if (!m_OnFireEffect.Contains(id))
5934 {
5935 if (IsInherited(Weapon))
5936 config_to_search = "CfgWeapons";
5937
5938 muzzle_owner_config = config_to_search + " " + GetType() + " ";
5939
5940 string config_OnFire_class = muzzle_owner_config + "Particles " + "OnFire ";
5941
5942 int config_OnFire_subclass_count = g_Game.ConfigGetChildrenCount(config_OnFire_class);
5943
5944 if (config_OnFire_subclass_count > 0)
5945 {
5946 array<ref WeaponParticlesOnFire> WPOF_array = new array<ref WeaponParticlesOnFire>;
5947
5948 for (int i = 0; i < config_OnFire_subclass_count; i++)
5949 {
5950 string particle_class = "";
5951 g_Game.ConfigGetChildName(config_OnFire_class, i, particle_class);
5952 string config_OnFire_entry = config_OnFire_class + particle_class;
5953 WeaponParticlesOnFire WPOF = new WeaponParticlesOnFire(this, config_OnFire_entry);
5954 WPOF_array.Insert(WPOF);
5955 }
5956
5957
5958 m_OnFireEffect.Insert(id, WPOF_array);
5959 }
5960 }
5961
5962 if (!m_OnBulletCasingEjectEffect.Contains(id))
5963 {
5964 config_to_search = "CfgWeapons"; // Bullet Eject efect is supported on weapons only.
5965 muzzle_owner_config = config_to_search + " " + GetType() + " ";
5966
5967 string config_OnBulletCasingEject_class = muzzle_owner_config + "Particles " + "OnBulletCasingEject ";
5968
5969 int config_OnBulletCasingEject_count = g_Game.ConfigGetChildrenCount(config_OnBulletCasingEject_class);
5970
5971 if (config_OnBulletCasingEject_count > 0 && IsInherited(Weapon))
5972 {
5973 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = new array<ref WeaponParticlesOnBulletCasingEject>;
5974
5975 for (i = 0; i < config_OnBulletCasingEject_count; i++)
5976 {
5977 string particle_class2 = "";
5978 g_Game.ConfigGetChildName(config_OnBulletCasingEject_class, i, particle_class2);
5979 string config_OnBulletCasingEject_entry = config_OnBulletCasingEject_class + particle_class2;
5980 WeaponParticlesOnBulletCasingEject WPOBE = new WeaponParticlesOnBulletCasingEject(this, config_OnBulletCasingEject_entry);
5981 WPOBE_array.Insert(WPOBE);
5982 }
5983
5984
5985 m_OnBulletCasingEjectEffect.Insert(id, WPOBE_array);
5986 }
5987 }
5988 }
5989
5990 // Loads muzzle flash particle configuration from config and saves it to a map for faster access
5992 {
5995
5996 if (!m_OnOverheatingEffect.Contains(id))
5997 {
5998 string config_to_search = "CfgVehicles";
5999
6000 if (IsInherited(Weapon))
6001 config_to_search = "CfgWeapons";
6002
6003 string muzzle_owner_config = config_to_search + " " + GetType() + " ";
6004 string config_OnOverheating_class = muzzle_owner_config + "Particles " + "OnOverheating ";
6005
6006 if (g_Game.ConfigIsExisting(config_OnOverheating_class))
6007 {
6008
6009 m_ShotsToStartOverheating = g_Game.ConfigGetFloat(config_OnOverheating_class + "shotsToStartOverheating");
6010
6012 {
6013 m_ShotsToStartOverheating = -1; // This prevents futher readings from config for future creations of this item
6014 string error = "Error reading config " + GetType() + ">Particles>OnOverheating - Parameter shotsToStartOverheating is configured wrong or is missing! Its value must be 1 or higher!";
6015 Error(error);
6016 return;
6017 }
6018
6019 m_OverheatingDecayInterval = g_Game.ConfigGetFloat(config_OnOverheating_class + "overheatingDecayInterval");
6020 m_MaxOverheatingValue = g_Game.ConfigGetFloat(config_OnOverheating_class + "maxOverheatingValue");
6021
6022
6023
6024 int config_OnOverheating_subclass_count = g_Game.ConfigGetChildrenCount(config_OnOverheating_class);
6025 array<ref WeaponParticlesOnOverheating> WPOOH_array = new array<ref WeaponParticlesOnOverheating>;
6026
6027 for (int i = 0; i < config_OnOverheating_subclass_count; i++)
6028 {
6029 string particle_class = "";
6030 g_Game.ConfigGetChildName(config_OnOverheating_class, i, particle_class);
6031 string config_OnOverheating_entry = config_OnOverheating_class + particle_class;
6032 int entry_type = g_Game.ConfigGetType(config_OnOverheating_entry);
6033
6034 if (entry_type == CT_CLASS)
6035 {
6036 WeaponParticlesOnOverheating WPOF = new WeaponParticlesOnOverheating(this, config_OnOverheating_entry);
6037 WPOOH_array.Insert(WPOF);
6038 }
6039 }
6040
6041
6042 m_OnOverheatingEffect.Insert(id, WPOOH_array);
6043 }
6044 }
6045 }
6046
6047 float GetOverheatingValue()
6048 {
6049 return m_OverheatingShots;
6050 }
6051
6052 void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
6053 {
6054 if (m_MaxOverheatingValue > 0)
6055 {
6057
6058 if (!m_CheckOverheating)
6060
6062 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
6063
6064 CheckOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6065 }
6066 }
6067
6068 void CheckOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6069 {
6071 UpdateOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6072
6074 StartOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6075
6077 StopOverheating(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6078
6080 {
6082 }
6083 }
6084
6086 {
6088 }
6089
6090 void OnOverheatingDecay()
6091 {
6092 if (m_MaxOverheatingValue > 0)
6093 m_OverheatingShots -= 1 + m_OverheatingShots / m_MaxOverheatingValue; // The hotter a barrel is, the faster it needs to cool down.
6094 else
6096
6097 if (m_OverheatingShots <= 0)
6098 {
6101 }
6102 else
6103 {
6104 if (!m_CheckOverheating)
6106
6108 m_CheckOverheating.Run(m_OverheatingDecayInterval, this, "OnOverheatingDecay");
6109 }
6110
6111 CheckOverheating(this, "", this);
6112 }
6113
6114 void StartOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6115 {
6117 ItemBase.PlayOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
6118 }
6119
6120 void UpdateOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6121 {
6123 ItemBase.UpdateOverheatingParticles(this, ammoType, this, suppressor, "CfgWeapons");
6125 }
6126
6127 void StopOverheating(ItemBase weapon = null, string ammoType = "", ItemBase muzzle_owner = null, ItemBase suppressor = null, string config_to_search = "")
6128 {
6130 ItemBase.StopOverheatingParticles(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
6131 }
6132
6133 void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
6134 {
6136 m_OverheatingParticles = new array<ref OverheatingParticle>;
6137
6138 OverheatingParticle OP = new OverheatingParticle();
6139 OP.RegisterParticle(p);
6140 OP.SetOverheatingLimitMin(min_heat_coef);
6141 OP.SetOverheatingLimitMax(max_heat_coef);
6142 OP.SetParticleParams(particle_id, parent, local_pos, local_ori);
6143
6144 m_OverheatingParticles.Insert(OP);
6145 }
6146
6147 float GetOverheatingCoef()
6148 {
6149 if (m_MaxOverheatingValue > 0)
6151
6152 return -1;
6153 }
6154
6156 {
6158 {
6159 float overheat_coef = GetOverheatingCoef();
6160 int count = m_OverheatingParticles.Count();
6161
6162 for (int i = count; i > 0; --i)
6163 {
6164 int id = i - 1;
6165 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6166 Particle p = OP.GetParticle();
6167
6168 float overheat_min = OP.GetOverheatingLimitMin();
6169 float overheat_max = OP.GetOverheatingLimitMax();
6170
6171 if (overheat_coef < overheat_min && overheat_coef >= overheat_max)
6172 {
6173 if (p)
6174 {
6175 p.Stop();
6176 OP.RegisterParticle(null);
6177 }
6178 }
6179 }
6180 }
6181 }
6182
6184 {
6186 {
6187 for (int i = m_OverheatingParticles.Count(); i > 0; i--)
6188 {
6189 int id = i - 1;
6190 OverheatingParticle OP = m_OverheatingParticles.Get(id);
6191
6192 if (OP)
6193 {
6194 Particle p = OP.GetParticle();
6195
6196 if (p)
6197 {
6198 p.Stop();
6199 }
6200
6201 delete OP;
6202 }
6203 }
6204
6205 m_OverheatingParticles.Clear();
6207 }
6208 }
6209
6211 float GetInfectionChance(int system = 0, Param param = null)
6212 {
6213 return 0.0;
6214 }
6215
6216
6217 float GetDisinfectQuantity(int system = 0, Param param1 = null)
6218 {
6219 return 250;//default value
6220 }
6221
6222 float GetFilterDamageRatio()
6223 {
6224 return 0;
6225 }
6226
6228 bool HasMuzzle()
6229 {
6230 if (IsInherited(Weapon) || IsInherited(SuppressorBase))
6231 return true;
6232
6233 return false;
6234 }
6235
6237 int GetMuzzleID()
6238 {
6239 if (!m_WeaponTypeToID)
6240 m_WeaponTypeToID = new map<string, int>;
6241
6242 if (m_WeaponTypeToID.Contains(GetType()))
6243 {
6244 return m_WeaponTypeToID.Get(GetType());
6245 }
6246 else
6247 {
6248 // Register new weapon ID
6250 }
6251
6253 }
6254
6261 {
6262 return -1;
6263 }
6264
6265
6266
6267 // -------------------------------------------------------------------------
6268 void ~ItemBase()
6269 {
6270 if (g_Game && g_Game.GetPlayer() && (!g_Game.IsDedicatedServer()))
6271 {
6272 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
6273 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
6274
6275 if (r_index >= 0)
6276 {
6277 InventoryLocation r_il = new InventoryLocation;
6278 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
6279
6280 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
6281 int r_type = r_il.GetType();
6282 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
6283 {
6284 r_il.GetParent().GetOnReleaseLock().Invoke(this);
6285 }
6286 else if (r_type == InventoryLocationType.ATTACHMENT)
6287 {
6288 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
6289 }
6290
6291 }
6292
6293 player.GetHumanInventory().ClearUserReservedLocation(this);
6294 }
6295
6296 if (m_LockingSound)
6297 SEffectManager.DestroyEffect(m_LockingSound);
6298 }
6299
6300
6301
6302 // -------------------------------------------------------------------------
6303 static int GetDebugActionsMask()
6304 {
6305 return ItemBase.m_DebugActionsMask;
6306 }
6307
6308 static bool HasDebugActionsMask(int mask)
6309 {
6310 return ItemBase.m_DebugActionsMask & mask;
6311 }
6312
6313 static void SetDebugActionsMask(int mask)
6314 {
6315 ItemBase.m_DebugActionsMask = mask;
6316 }
6317
6318 static void AddDebugActionsMask(int mask)
6319 {
6320 ItemBase.m_DebugActionsMask |= mask;
6321 }
6322
6323 static void RemoveDebugActionsMask(int mask)
6324 {
6325 ItemBase.m_DebugActionsMask &= ~mask;
6326 }
6327
6328 static void ToggleDebugActionsMask(int mask)
6329 {
6330 if (HasDebugActionsMask(mask))
6331 {
6333 }
6334 else
6335 {
6336 AddDebugActionsMask(mask);
6337 }
6338 }
6339
6340 // -------------------------------------------------------------------------
6341 void SetCEBasedQuantity()
6342 {
6343 if (GetEconomyProfile())
6344 {
6345 float q_max = GetEconomyProfile().GetQuantityMax();
6346 if (q_max > 0)
6347 {
6348 float q_min = GetEconomyProfile().GetQuantityMin();
6349 float quantity_randomized = Math.RandomFloatInclusive(q_min, q_max);
6350
6351 if (HasComponent(COMP_TYPE_ENERGY_MANAGER))//more direct access for speed
6352 {
6353 ComponentEnergyManager comp = GetCompEM();
6354 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
6355 {
6356 comp.SetEnergy0To1(quantity_randomized);
6357 }
6358 }
6359 else if (HasQuantity())
6360 {
6361 SetQuantityNormalized(quantity_randomized, false);
6362 //PrintString("<==> Normalized quantity for item: "+ GetType()+", qmin:"+q_min.ToString()+"; qmax:"+q_max.ToString()+";quantity:" +quantity_randomized.ToString());
6363 }
6364
6365 }
6366 }
6367 }
6368
6370 void LockToParent()
6371 {
6372 EntityAI parent = GetHierarchyParent();
6373
6374 if (parent)
6375 {
6376 InventoryLocation inventory_location_to_lock = new InventoryLocation;
6377 GetInventory().GetCurrentInventoryLocation(inventory_location_to_lock);
6378 parent.GetInventory().SetSlotLock(inventory_location_to_lock.GetSlot(), true);
6379 }
6380 }
6381
6383 void UnlockFromParent()
6384 {
6385 EntityAI parent = GetHierarchyParent();
6386
6387 if (parent)
6388 {
6389 InventoryLocation inventory_location_to_unlock = new InventoryLocation;
6390 GetInventory().GetCurrentInventoryLocation(inventory_location_to_unlock);
6391 parent.GetInventory().SetSlotLock(inventory_location_to_unlock.GetSlot(), false);
6392 }
6393 }
6394
6395 override void CombineItemsClient(EntityAI entity2, bool use_stack_max = true)
6396 {
6397 /*
6398 ref Param1<EntityAI> item = new Param1<EntityAI>(entity2);
6399 RPCSingleParam(ERPCs.RPC_ITEM_COMBINE, item, g_Game.GetPlayer());
6400 */
6401 ItemBase item2 = ItemBase.Cast(entity2);
6402
6403 if (g_Game.IsClient())
6404 {
6405 if (ScriptInputUserData.CanStoreInputUserData())
6406 {
6407 ScriptInputUserData ctx = new ScriptInputUserData;
6409 ctx.Write(-1);
6410 ItemBase i1 = this; // @NOTE: workaround for correct serialization
6411 ctx.Write(i1);
6412 ctx.Write(item2);
6413 ctx.Write(use_stack_max);
6414 ctx.Write(-1);
6415 ctx.Send();
6416
6417 if (IsCombineAll(item2, use_stack_max))
6418 {
6419 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(item2,null,GameInventory.c_InventoryReservationTimeoutShortMS);
6420 }
6421 }
6422 }
6423 else if (!g_Game.IsMultiplayer())
6424 {
6425 CombineItems(item2, use_stack_max);
6426 }
6427 }
6428
6429 bool IsLiquidPresent()
6430 {
6431 return (GetLiquidType() != 0 && HasQuantity());
6432 }
6433
6434 bool IsLiquidContainer()
6435 {
6436 return m_LiquidContainerMask != 0;
6437 }
6438
6440 {
6441 return m_LiquidContainerMask;
6442 }
6443
6444 bool IsBloodContainer()
6445 {
6446 //m_LiquidContainerMask & GROUP_LIQUID_BLOOD ???
6447 return false;
6448 }
6449
6450 bool IsNVG()
6451 {
6452 return false;
6453 }
6454
6457 bool IsExplosive()
6458 {
6459 return false;
6460 }
6461
6463 {
6464 return "";
6465 }
6466
6468
6469 bool IsLightSource()
6470 {
6471 return false;
6472 }
6473
6475 {
6476 return true;
6477 }
6478
6479 //--- ACTION CONDITIONS
6480 //direction
6481 bool IsFacingPlayer(PlayerBase player, string selection)
6482 {
6483 return true;
6484 }
6485
6486 bool IsPlayerInside(PlayerBase player, string selection)
6487 {
6488 return true;
6489 }
6490
6491 override bool CanObstruct()
6492 {
6493 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
6494 return !player || !IsPlayerInside(player, "");
6495 }
6496
6497 override bool IsBeingPlaced()
6498 {
6499 return m_IsBeingPlaced;
6500 }
6501
6502 void SetIsBeingPlaced(bool is_being_placed)
6503 {
6504 m_IsBeingPlaced = is_being_placed;
6505 if (!is_being_placed)
6507 SetSynchDirty();
6508 }
6509
6510 //server-side
6511 void OnEndPlacement() {}
6512
6513 override bool IsHologram()
6514 {
6515 return m_IsHologram;
6516 }
6517
6518 bool CanBeDigged()
6519 {
6520 return m_CanBeDigged;
6521 }
6522
6524 {
6525 return 1;
6526 }
6527
6528 bool CanMakeGardenplot()
6529 {
6530 return false;
6531 }
6532
6533 void SetIsHologram(bool is_hologram)
6534 {
6535 m_IsHologram = is_hologram;
6536 SetSynchDirty();
6537 }
6538 /*
6539 protected float GetNutritionalEnergy()
6540 {
6541 Edible_Base edible = Edible_Base.Cast(this);
6542 return edible.GetFoodEnergy();
6543 }
6544
6545 protected float GetNutritionalWaterContent()
6546 {
6547 Edible_Base edible = Edible_Base.Cast(this);
6548 return edible.GetFoodWater();
6549 }
6550
6551 protected float GetNutritionalIndex()
6552 {
6553 Edible_Base edible = Edible_Base.Cast(this);
6554 return edible.GetFoodNutritionalIndex();
6555 }
6556
6557 protected float GetNutritionalFullnessIndex()
6558 {
6559 Edible_Base edible = Edible_Base.Cast(this);
6560 return edible.GetFoodTotalVolume();
6561 }
6562
6563 protected float GetNutritionalToxicity()
6564 {
6565 Edible_Base edible = Edible_Base.Cast(this);
6566 return edible.GetFoodToxicity();
6567
6568 }
6569 */
6570
6571
6572 // -------------------------------------------------------------------------
6573 override void OnMovedInsideCargo(EntityAI container)
6574 {
6575 super.OnMovedInsideCargo(container);
6576
6577 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
6578 }
6579
6580 override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
6581 {
6582 super.EEItemLocationChanged(oldLoc, newLoc);
6583
6584 PlayerBase newPlayer = null;
6585 PlayerBase oldPlayer = null;
6586
6587 if (newLoc.GetParent())
6588 newPlayer = PlayerBase.Cast(newLoc.GetParent().GetHierarchyRootPlayer());
6589
6590 if (oldLoc.GetParent())
6591 oldPlayer = PlayerBase.Cast(oldLoc.GetParent().GetHierarchyRootPlayer());
6592
6593 if (oldPlayer && oldLoc.GetType() == InventoryLocationType.HANDS)
6594 {
6595 int rIndex = oldPlayer.GetHumanInventory().FindUserReservedLocationIndex(this);
6596
6597 if (rIndex >= 0)
6598 {
6599 InventoryLocation rIl = new InventoryLocation;
6600 oldPlayer.GetHumanInventory().GetUserReservedLocation(rIndex, rIl);
6601
6602 oldPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(rIndex);
6603 int rType = rIl.GetType();
6604 if (rType == InventoryLocationType.CARGO || rType == InventoryLocationType.PROXYCARGO)
6605 {
6606 rIl.GetParent().GetOnReleaseLock().Invoke(this);
6607 }
6608 else if (rType == InventoryLocationType.ATTACHMENT)
6609 {
6610 rIl.GetParent().GetOnAttachmentReleaseLock().Invoke(this, rIl.GetSlot());
6611 }
6612
6613 }
6614 }
6615
6616 if (newLoc.GetType() == InventoryLocationType.HANDS && oldLoc.GetType() != InventoryLocationType.TEMP)
6617 {
6618 if (newPlayer)
6619 newPlayer.ForceStandUpForHeavyItems(newLoc.GetItem());
6620
6621 if (newPlayer == oldPlayer)
6622 {
6623 if (oldLoc.GetParent() && newPlayer.GetHumanInventory().LocationGetEntity(oldLoc) == NULL)
6624 {
6625 if (oldLoc.GetType() == InventoryLocationType.CARGO)
6626 {
6627 if (oldLoc.GetParent().GetInventory().TestAddEntityInCargoExLoc(oldLoc, false, false, false, true, false, false))
6628 {
6629 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
6630 }
6631 }
6632 else
6633 {
6634 newPlayer.GetHumanInventory().SetUserReservedLocation(this,oldLoc);
6635 }
6636 }
6637
6638 if (newPlayer.GetHumanInventory().FindUserReservedLocationIndex(this) >= 0)
6639 {
6640 int type = oldLoc.GetType();
6641 if (type == InventoryLocationType.CARGO || type == InventoryLocationType.PROXYCARGO)
6642 {
6643 oldLoc.GetParent().GetOnSetLock().Invoke(this);
6644 }
6645 else if (type == InventoryLocationType.ATTACHMENT)
6646 {
6647 oldLoc.GetParent().GetOnAttachmentSetLock().Invoke(this, oldLoc.GetSlot());
6648 }
6649 }
6650 if (!m_OldLocation)
6651 {
6652 m_OldLocation = new InventoryLocation;
6653 }
6654 m_OldLocation.Copy(oldLoc);
6655 }
6656 else
6657 {
6658 if (m_OldLocation)
6659 {
6660 m_OldLocation.Reset();
6661 }
6662 }
6663
6664 g_Game.GetAnalyticsClient().OnItemAttachedAtPlayer(this,"Hands");
6665 }
6666 else
6667 {
6668 if (newPlayer)
6669 {
6670 int resIndex = newPlayer.GetHumanInventory().FindCollidingUserReservedLocationIndex(this, newLoc);
6671 if (resIndex >= 0)
6672 {
6673 InventoryLocation il = new InventoryLocation;
6674 newPlayer.GetHumanInventory().GetUserReservedLocation(resIndex, il);
6675 ItemBase it = ItemBase.Cast(il.GetItem());
6676 newPlayer.GetHumanInventory().ClearUserReservedLocationAtIndex(resIndex);
6677 int rel_type = il.GetType();
6678 if (rel_type == InventoryLocationType.CARGO || rel_type == InventoryLocationType.PROXYCARGO)
6679 {
6680 il.GetParent().GetOnReleaseLock().Invoke(it);
6681 }
6682 else if (rel_type == InventoryLocationType.ATTACHMENT)
6683 {
6684 il.GetParent().GetOnAttachmentReleaseLock().Invoke(it, il.GetSlot());
6685 }
6686 //it.GetOnReleaseLock().Invoke(it);
6687 }
6688 }
6689 else if (oldPlayer && newLoc.GetType() == InventoryLocationType.GROUND && m_ThrowItemOnDrop)
6690 {
6691 //ThrowPhysically(oldPlayer, vector.Zero);
6692 m_ThrowItemOnDrop = false;
6693 }
6694
6695 if (m_OldLocation)
6696 {
6697 m_OldLocation.Reset();
6698 }
6699 }
6700
6701 if (oldLoc.GetType() == InventoryLocationType.TEMP)
6702 {
6703 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Remove(oldLoc.GetItem());
6704 }
6705
6706 if (newLoc.GetType() == InventoryLocationType.TEMP)
6707 {
6708 PluginInventoryRepair.Cast(GetPlugin(PluginInventoryRepair)).Add(oldLoc.GetItem());
6709 }
6710 }
6711
6712 override void EOnContact(IEntity other, Contact extra)
6713 {
6715 {
6716 int liquidType = -1;
6717 float impactSpeed = ProcessImpactSoundEx(other, extra, m_ConfigWeight, m_ImpactSoundSurfaceHash, liquidType);
6718 if (impactSpeed > 0.0)
6719 {
6720 m_ImpactSpeed = impactSpeed;
6721 #ifndef SERVER
6722 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
6723 #else
6724 m_WantPlayImpactSound = true;
6725 SetSynchDirty();
6726 #endif
6727 m_CanPlayImpactSound = (liquidType == -1);// prevents further playing of the sound when the surface is a liquid type
6728 }
6729 }
6730
6731 #ifdef SERVER
6732 if (GetCompEM() && GetCompEM().IsPlugged())
6733 {
6734 if (GetCompEM().GetCordLength() < vector.Distance(GetPosition(), GetCompEM().GetEnergySource().GetPosition()))
6735 GetCompEM().UnplugThis();
6736 }
6737 #endif
6738 }
6739
6740 void RefreshPhysics();
6741
6742 override void OnCreatePhysics()
6743 {
6745 }
6746
6747 override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
6748 {
6749
6750 }
6751 // -------------------------------------------------------------------------
6752 override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
6753 {
6754 super.OnItemLocationChanged(old_owner, new_owner);
6755
6756 PlayerBase relatedPlayer = PlayerBase.Cast(old_owner);
6757 PlayerBase playerNew = PlayerBase.Cast(new_owner);
6758
6759 if (!relatedPlayer && playerNew)
6760 relatedPlayer = playerNew;
6761
6762 if (relatedPlayer && relatedPlayer.GetPerformedActionID() != -1)
6763 {
6764 ActionManagerBase actionMgr = relatedPlayer.GetActionManager();
6765 if (actionMgr)
6766 {
6767 ActionBase currentAction = actionMgr.GetRunningAction();
6768 if (currentAction)
6769 currentAction.OnItemLocationChanged(this);
6770 }
6771 }
6772
6773 Man ownerPlayerOld = null;
6774 Man ownerPlayerNew = null;
6775
6776 if (old_owner)
6777 {
6778 if (old_owner.IsMan())
6779 {
6780 ownerPlayerOld = Man.Cast(old_owner);
6781 }
6782 else
6783 {
6784 ownerPlayerOld = Man.Cast(old_owner.GetHierarchyRootPlayer());
6785 }
6786 }
6787 else
6788 {
6789 if (new_owner && IsElectricAppliance() && GetCompEM() && GetCompEM().IsPlugged())
6790 {
6791 ActionBase action = ActionManagerBase.GetAction(ActionRepositionPluggedItem);
6792
6793 if (!action || !playerNew || playerNew.GetPerformedActionID() != action.GetID())
6794 {
6795 GetCompEM().UnplugThis();
6796 }
6797 }
6798 }
6799
6800 if (new_owner)
6801 {
6802 if (new_owner.IsMan())
6803 {
6804 ownerPlayerNew = Man.Cast(new_owner);
6805 }
6806 else
6807 {
6808 ownerPlayerNew = Man.Cast(new_owner.GetHierarchyRootPlayer());
6809 }
6810 }
6811
6812 if (ownerPlayerOld != ownerPlayerNew)
6813 {
6814 if (ownerPlayerOld)
6815 {
6816 array<EntityAI> subItemsExit = new array<EntityAI>;
6817 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsExit);
6818 for (int i = 0; i < subItemsExit.Count(); i++)
6819 {
6820 ItemBase itemExit = ItemBase.Cast(subItemsExit.Get(i));
6821 itemExit.OnInventoryExit(ownerPlayerOld);
6822 }
6823 }
6824
6825 if (ownerPlayerNew)
6826 {
6827 array<EntityAI> subItemsEnter = new array<EntityAI>;
6828 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsEnter);
6829 for (int j = 0; j < subItemsEnter.Count(); j++)
6830 {
6831 ItemBase itemEnter = ItemBase.Cast(subItemsEnter.Get(j));
6832 itemEnter.OnInventoryEnter(ownerPlayerNew);
6833 }
6834 }
6835 }
6836 else if (ownerPlayerNew != null)
6837 {
6838 PlayerBase nplayer;
6839 if (PlayerBase.CastTo(nplayer, ownerPlayerNew))
6840 {
6841 array<EntityAI> subItemsUpdate = new array<EntityAI>;
6842 GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER,subItemsUpdate);
6843 for (int k = 0; k < subItemsUpdate.Count(); k++)
6844 {
6845 ItemBase itemUpdate = ItemBase.Cast(subItemsUpdate.Get(k));
6846 itemUpdate.UpdateQuickbarShortcutVisibility(nplayer);
6847 }
6848 }
6849 }
6850
6851 if (old_owner)
6852 old_owner.OnChildItemRemoved(this);
6853 if (new_owner)
6854 new_owner.OnChildItemReceived(this);
6855 }
6856
6857 // -------------------------------------------------------------------------------
6858 override void EEDelete(EntityAI parent)
6859 {
6860 super.EEDelete(parent);
6861 PlayerBase player = PlayerBase.Cast(GetHierarchyRootPlayer());
6862 if (player)
6863 {
6864 OnInventoryExit(player);
6865
6866 if (player.IsAlive())
6867 {
6868 int r_index = player.GetHumanInventory().FindUserReservedLocationIndex(this);
6869 if (r_index >= 0)
6870 {
6871 InventoryLocation r_il = new InventoryLocation;
6872 player.GetHumanInventory().GetUserReservedLocation(r_index,r_il);
6873
6874 player.GetHumanInventory().ClearUserReservedLocationAtIndex(r_index);
6875 int r_type = r_il.GetType();
6876 if (r_type == InventoryLocationType.CARGO || r_type == InventoryLocationType.PROXYCARGO)
6877 {
6878 r_il.GetParent().GetOnReleaseLock().Invoke(this);
6879 }
6880 else if (r_type == InventoryLocationType.ATTACHMENT)
6881 {
6882 r_il.GetParent().GetOnAttachmentReleaseLock().Invoke(this, r_il.GetSlot());
6883 }
6884
6885 }
6886
6887 player.RemoveQuickBarEntityShortcut(this);
6888 }
6889 }
6890 }
6891 // -------------------------------------------------------------------------------
6892 override void EEKilled(Object killer)
6893 {
6894 super.EEKilled(killer);
6895
6897 if (killer && killer.IsFireplace() && CanExplodeInFire())
6898 {
6899 if (GetTemperature() >= GameConstants.ITEM_TEMPERATURE_TO_EXPLODE_MIN)
6900 {
6901 if (IsMagazine())
6902 {
6903 if (Magazine.Cast(this).GetAmmoCount() > 0)
6904 {
6905 ExplodeAmmo();
6906 }
6907 }
6908 else
6909 {
6910 Explode(DamageType.EXPLOSION);
6911 }
6912 }
6913 }
6914 }
6915
6916 override void OnWasAttached(EntityAI parent, int slot_id)
6917 {
6918 MiscGameplayFunctions.RemoveAllAttachedChildrenByTypename(this, {Bolt_Base});
6919
6920 super.OnWasAttached(parent, slot_id);
6921
6922 if (HasQuantity())
6923 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
6924
6925 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
6926 StartItemSoundServer(SoundConstants.ITEM_ATTACH, slot_id);
6927 }
6928
6929 override void OnWasDetached(EntityAI parent, int slot_id)
6930 {
6931 super.OnWasDetached(parent, slot_id);
6932
6933 if (HasQuantity())
6934 UpdateNetSyncVariableFloat("m_VarQuantity", GetQuantityMin(), m_VarQuantityMax);
6935
6936 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
6937 StartItemSoundServer(SoundConstants.ITEM_DETACH, slot_id);
6938 }
6939
6940 override string ChangeIntoOnAttach(string slot)
6941 {
6942 int idx;
6943 TStringArray inventory_slots = new TStringArray;
6944 TStringArray attach_types = new TStringArray;
6945
6946 ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
6947 if (inventory_slots.Count() < 1) //is string
6948 {
6949 inventory_slots.Insert(ConfigGetString("ChangeInventorySlot"));
6950 attach_types.Insert(ConfigGetString("ChangeIntoOnAttach"));
6951 }
6952 else //is array
6953 {
6954 ConfigGetTextArray("ChangeIntoOnAttach",attach_types);
6955 }
6956
6957 idx = inventory_slots.Find(slot);
6958 if (idx < 0)
6959 return "";
6960
6961 return attach_types.Get(idx);
6962 }
6963
6964 override string ChangeIntoOnDetach()
6965 {
6966 int idx = -1;
6967 string slot;
6968
6969 TStringArray inventory_slots = new TStringArray;
6970 TStringArray detach_types = new TStringArray;
6971
6972 this.ConfigGetTextArray("ChangeInventorySlot",inventory_slots);
6973 if (inventory_slots.Count() < 1) //is string
6974 {
6975 inventory_slots.Insert(this.ConfigGetString("ChangeInventorySlot"));
6976 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
6977 }
6978 else //is array
6979 {
6980 this.ConfigGetTextArray("ChangeIntoOnDetach",detach_types);
6981 if (detach_types.Count() < 1)
6982 detach_types.Insert(this.ConfigGetString("ChangeIntoOnDetach"));
6983 }
6984
6985 for (int i = 0; i < inventory_slots.Count(); i++)
6986 {
6987 slot = inventory_slots.Get(i);
6988 }
6989
6990 if (slot != "")
6991 {
6992 if (detach_types.Count() == 1)
6993 idx = 0;
6994 else
6995 idx = inventory_slots.Find(slot);
6996 }
6997 if (idx < 0)
6998 return "";
6999
7000 return detach_types.Get(idx);
7001 }
7002
7003 void ExplodeAmmo()
7004 {
7005 //timer
7006 ref Timer explode_timer = new Timer(CALL_CATEGORY_SYSTEM);
7007
7008 //min/max time
7009 float min_time = 1;
7010 float max_time = 3;
7011 float delay = Math.RandomFloat(min_time, max_time);
7012
7013 explode_timer.Run(delay, this, "DoAmmoExplosion");
7014 }
7015
7016 void DoAmmoExplosion()
7017 {
7018 Magazine magazine = Magazine.Cast(this);
7019 int pop_sounds_count = 6;
7020 string pop_sounds[ 6 ] = { "ammopops_1","ammopops_2","ammopops_3","ammopops_4","ammopops_5","ammopops_6" };
7021
7022 //play sound
7023 int sound_idx = Math.RandomInt(0, pop_sounds_count - 1);
7024 string sound_name = pop_sounds[ sound_idx ];
7025 g_Game.CreateSoundOnObject(this, sound_name, 20, false);
7026
7027 //remove ammo count
7028 magazine.ServerAddAmmoCount(-1);
7029
7030 //if condition then repeat -> ExplodeAmmo
7031 float min_temp_to_explode = 100; //min temperature for item to explode
7032
7033 if (magazine.GetAmmoCount() > 0 && GetTemperature() >= min_temp_to_explode) //TODO ? add check for parent -> fireplace
7034 {
7035 ExplodeAmmo();
7036 }
7037 }
7038
7039 // -------------------------------------------------------------------------------
7040 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
7041 {
7042 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
7043
7044 const int CHANCE_DAMAGE_CARGO = 4;
7045 const int CHANCE_DAMAGE_ATTACHMENT = 1;
7046 const int CHANCE_DAMAGE_NOTHING = 2;
7047
7048 if (IsClothing() || IsContainer() || IsItemTent())
7049 {
7050 float dmg = damageResult.GetDamage("","Health") * -0.5;
7051 int chances;
7052 int rnd;
7053
7054 if (GetInventory().GetCargo())
7055 {
7056 chances = CHANCE_DAMAGE_CARGO + CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
7057 rnd = Math.RandomInt(0,chances);
7058
7059 if (rnd < CHANCE_DAMAGE_CARGO)
7060 {
7061 DamageItemInCargo(dmg);
7062 }
7063 else if (rnd < (chances - CHANCE_DAMAGE_NOTHING))
7064 {
7066 }
7067 }
7068 else
7069 {
7070 chances = CHANCE_DAMAGE_ATTACHMENT + CHANCE_DAMAGE_NOTHING;
7071 rnd = Math.RandomInt(0,chances);
7072
7073 if (rnd < CHANCE_DAMAGE_ATTACHMENT)
7074 {
7076 }
7077 }
7078 }
7079 }
7080
7081 bool DamageItemInCargo(float damage)
7082 {
7083 CargoBase cargo = GetInventory().GetCargo();
7084 if (cargo)
7085 {
7086 int item_count = cargo.GetItemCount();
7087 if (item_count > 0)
7088 {
7089 int random_pick = Math.RandomInt(0, item_count);
7090 ItemBase item = ItemBase.Cast(cargo.GetItem(random_pick));
7091 if (!item.IsExplosive())
7092 {
7093 item.AddHealth("","",damage);
7094 return true;
7095 }
7096 }
7097 }
7098 return false;
7099 }
7100
7101 bool DamageItemAttachments(float damage)
7102 {
7103 GameInventory inventory = GetInventory();
7104 int attachment_count = inventory.AttachmentCount();
7105 if (attachment_count > 0)
7106 {
7107 int random_pick = Math.RandomInt(0, attachment_count);
7108 ItemBase attachment = ItemBase.Cast(inventory.GetAttachmentFromIndex(random_pick));
7109 if (!attachment.IsExplosive())
7110 {
7111 attachment.AddHealth("","",damage);
7112 return true;
7113 }
7114 }
7115 return false;
7116 }
7117
7118 override bool IsSplitable()
7119 {
7120 return m_CanThisBeSplit;
7121 }
7122 //----------------
7123 override bool CanBeSplit()
7124 {
7125 if (IsSplitable() && (GetQuantity() > 1))
7126 return GetInventory().CanRemoveEntity();
7127
7128 return false;
7129 }
7130
7131 protected bool ShouldSplitQuantity(float quantity)
7132 {
7133 // don't call 'CanBeSplit' here, too strict and will introduce a freeze-crash when dismantling fence with a fireplace nearby
7134 if (!IsSplitable())
7135 return false;
7136
7137 // nothing to split?
7138 if (GetQuantity() <= 1)
7139 return false;
7140
7141 // check if we should re-use the item instead of creating a new copy?
7142 // implicit cast to int, if 'IsSplitable' returns true, these values are assumed ints
7143 int delta = GetQuantity() - quantity;
7144 if (delta == 0)
7145 return false;
7146
7147 // valid to split
7148 return true;
7149 }
7150
7151 override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id )
7152 {
7153 if (g_Game.IsClient())
7154 {
7155 if (ScriptInputUserData.CanStoreInputUserData())
7156 {
7157 ScriptInputUserData ctx = new ScriptInputUserData;
7159 ctx.Write(1);
7160 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7161 ctx.Write(i1);
7162 ctx.Write(destination_entity);
7163 ctx.Write(true);
7164 ctx.Write(slot_id);
7165 ctx.Send();
7166 }
7167 }
7168 else if (!g_Game.IsMultiplayer())
7169 {
7170 SplitIntoStackMax(destination_entity, slot_id, PlayerBase.Cast(g_Game.GetPlayer()));
7171 }
7172 }
7173
7174 void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
7175 {
7176 float split_quantity_new;
7177 ItemBase new_item;
7178 float quantity = GetQuantity();
7179 float stack_max = GetTargetQuantityMax(slot_id);
7180 InventoryLocation loc = new InventoryLocation;
7181
7182 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7183 {
7184 if (stack_max <= GetQuantity())
7185 split_quantity_new = stack_max;
7186 else
7187 split_quantity_new = GetQuantity();
7188
7189 if (ShouldSplitQuantity(split_quantity_new))
7190 {
7191 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7192 if (new_item)
7193 {
7194 new_item.SetResultOfSplit(true);
7195 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7196 AddQuantity(-split_quantity_new, false, true);
7197 new_item.SetQuantity(split_quantity_new, false, true);
7198 }
7199 }
7200 }
7201 else if (destination_entity && slot_id == -1)
7202 {
7203 if (quantity > stack_max)
7204 split_quantity_new = stack_max;
7205 else
7206 split_quantity_new = quantity;
7207
7208 if (ShouldSplitQuantity(split_quantity_new))
7209 {
7210 GameInventory destinationInventory = destination_entity.GetInventory();
7211 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
7212 {
7213 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
7214 new_item = ItemBase.Cast(o);
7215 }
7216
7217 if (new_item)
7218 {
7219 new_item.SetResultOfSplit(true);
7220 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7221 AddQuantity(-split_quantity_new, false, true);
7222 new_item.SetQuantity(split_quantity_new, false, true);
7223 }
7224 }
7225 }
7226 else
7227 {
7228 if (stack_max != 0)
7229 {
7230 if (stack_max < GetQuantity())
7231 {
7232 split_quantity_new = GetQuantity() - stack_max;
7233 }
7234
7235 if (split_quantity_new == 0)
7236 {
7237 if (!g_Game.IsMultiplayer())
7238 player.PhysicalPredictiveDropItem(this);
7239 else
7240 player.ServerDropEntity(this);
7241 return;
7242 }
7243
7244 if (ShouldSplitQuantity(split_quantity_new))
7245 {
7246 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(), player.GetWorldPosition(), ECE_PLACE_ON_SURFACE));
7247
7248 if (new_item)
7249 {
7250 new_item.SetResultOfSplit(true);
7251 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7252 SetQuantity(split_quantity_new, false, true);
7253 new_item.SetQuantity(stack_max, false, true);
7254 new_item.PlaceOnSurface();
7255 }
7256 }
7257 }
7258 }
7259 }
7260
7261 override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
7262 {
7263 float split_quantity_new;
7264 ItemBase new_item;
7265 float quantity = GetQuantity();
7266 float stack_max = GetTargetQuantityMax(slot_id);
7267 InventoryLocation loc = new InventoryLocation;
7268
7269 if (destination_entity && slot_id != -1 && InventorySlots.IsSlotIdValid(slot_id))
7270 {
7271 if (stack_max <= GetQuantity())
7272 split_quantity_new = stack_max;
7273 else
7274 split_quantity_new = GetQuantity();
7275
7276 if (ShouldSplitQuantity(split_quantity_new))
7277 {
7278 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateAttachmentEx(this.GetType(), slot_id));
7279 if (new_item)
7280 {
7281 new_item.SetResultOfSplit(true);
7282 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7283 AddQuantity(-split_quantity_new, false, true);
7284 new_item.SetQuantity(split_quantity_new, false, true);
7285 }
7286 }
7287 }
7288 else if (destination_entity && slot_id == -1)
7289 {
7290 if (quantity > stack_max)
7291 split_quantity_new = stack_max;
7292 else
7293 split_quantity_new = quantity;
7294
7295 if (ShouldSplitQuantity(split_quantity_new))
7296 {
7297 GameInventory destinationInventory = destination_entity.GetInventory();
7298 if (destinationInventory.FindFreeLocationFor(this, FindInventoryLocationType.ANY, loc))
7299 {
7300 Object o = destinationInventory.LocationCreateEntity(loc, GetType(), ECE_IN_INVENTORY, RF_DEFAULT);
7301 new_item = ItemBase.Cast(o);
7302 }
7303
7304 if (new_item)
7305 {
7306 new_item.SetResultOfSplit(true);
7307 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7308 AddQuantity(-split_quantity_new, false, true);
7309 new_item.SetQuantity(split_quantity_new, false, true);
7310 }
7311 }
7312 }
7313 else
7314 {
7315 if (stack_max != 0)
7316 {
7317 if (stack_max < GetQuantity())
7318 {
7319 split_quantity_new = GetQuantity() - stack_max;
7320 }
7321
7322 if (ShouldSplitQuantity(split_quantity_new))
7323 {
7324 new_item = ItemBase.Cast(g_Game.CreateObjectEx(GetType(),GetWorldPosition(), ECE_PLACE_ON_SURFACE));
7325
7326 if (new_item)
7327 {
7328 new_item.SetResultOfSplit(true);
7329 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7330 SetQuantity(split_quantity_new, false, true);
7331 new_item.SetQuantity(stack_max, false, true);
7332 new_item.PlaceOnSurface();
7333 }
7334 }
7335 }
7336 }
7337 }
7338
7339 void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
7340 {
7341 if (g_Game.IsClient())
7342 {
7343 if (ScriptInputUserData.CanStoreInputUserData())
7344 {
7345 ScriptInputUserData ctx = new ScriptInputUserData;
7347 ctx.Write(4);
7348 ItemBase thiz = this; // @NOTE: workaround for correct serialization
7349 ctx.Write(thiz);
7350 dst.WriteToContext(ctx);
7351 ctx.Send();
7352 }
7353 }
7354 else if (!g_Game.IsMultiplayer())
7355 {
7357 }
7358 }
7359
7360 void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
7361 {
7362 if (g_Game.IsClient())
7363 {
7364 if (ScriptInputUserData.CanStoreInputUserData())
7365 {
7366 ScriptInputUserData ctx = new ScriptInputUserData;
7368 ctx.Write(2);
7369 ItemBase dummy = this; // @NOTE: workaround for correct serialization
7370 ctx.Write(dummy);
7371 ctx.Write(destination_entity);
7372 ctx.Write(true);
7373 ctx.Write(idx);
7374 ctx.Write(row);
7375 ctx.Write(col);
7376 ctx.Send();
7377 }
7378 }
7379 else if (!g_Game.IsMultiplayer())
7380 {
7381 SplitIntoStackMaxCargo(destination_entity, idx, row, col);
7382 }
7383 }
7384
7385 void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
7386 {
7388 }
7389
7390 ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
7391 {
7392 float quantity = GetQuantity();
7393 float split_quantity_new;
7394 ItemBase new_item;
7395 if (dst.IsValid())
7396 {
7397 int slot_id = dst.GetSlot();
7398 float stack_max = GetTargetQuantityMax(slot_id);
7399
7400 if (quantity > stack_max)
7401 split_quantity_new = stack_max;
7402 else
7403 split_quantity_new = quantity;
7404
7405 if (ShouldSplitQuantity(split_quantity_new))
7406 {
7407 new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, this.GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
7408
7409 if (new_item)
7410 {
7411 new_item.SetResultOfSplit(true);
7412 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7413 AddQuantity(-split_quantity_new, false, true);
7414 new_item.SetQuantity(split_quantity_new, false, true);
7415 }
7416
7417 return new_item;
7418 }
7419 }
7420
7421 return null;
7422 }
7423
7424 void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
7425 {
7426 float quantity = GetQuantity();
7427 float split_quantity_new;
7428 ItemBase new_item;
7429 if (destination_entity)
7430 {
7431 float stackable = GetTargetQuantityMax();
7432 if (quantity > stackable)
7433 split_quantity_new = stackable;
7434 else
7435 split_quantity_new = quantity;
7436
7437 if (ShouldSplitQuantity(split_quantity_new))
7438 {
7439 new_item = ItemBase.Cast(destination_entity.GetInventory().CreateEntityInCargoEx(this.GetType(), idx, row, col, false));
7440 if (new_item)
7441 {
7442 new_item.SetResultOfSplit(true);
7443 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7444 AddQuantity(-split_quantity_new, false, true);
7445 new_item.SetQuantity(split_quantity_new, false, true);
7446 }
7447 }
7448 }
7449 }
7450
7451 void SplitIntoStackMaxHandsClient(PlayerBase player)
7452 {
7453 if (g_Game.IsClient())
7454 {
7455 if (ScriptInputUserData.CanStoreInputUserData())
7456 {
7457 ScriptInputUserData ctx = new ScriptInputUserData;
7459 ctx.Write(3);
7460 ItemBase i1 = this; // @NOTE: workaround for correct serialization
7461 ctx.Write(i1);
7462 ItemBase destination_entity = this;
7463 ctx.Write(destination_entity);
7464 ctx.Write(true);
7465 ctx.Write(0);
7466 ctx.Send();
7467 }
7468 }
7469 else if (!g_Game.IsMultiplayer())
7470 {
7471 SplitIntoStackMaxHands(player);
7472 }
7473 }
7474
7475 void SplitIntoStackMaxHands(PlayerBase player)
7476 {
7477 float quantity = GetQuantity();
7478 float split_quantity_new;
7479 ref ItemBase new_item;
7480 if (player)
7481 {
7482 float stackable = GetTargetQuantityMax();
7483 if (quantity > stackable)
7484 split_quantity_new = stackable;
7485 else
7486 split_quantity_new = quantity;
7487
7488 if (ShouldSplitQuantity(split_quantity_new))
7489 {
7490 EntityAI in_hands = player.GetHumanInventory().CreateInHands(this.GetType());
7491 new_item = ItemBase.Cast(in_hands);
7492 if (new_item)
7493 {
7494 new_item.SetResultOfSplit(true);
7495 MiscGameplayFunctions.TransferItemProperties(this,new_item);
7496 AddQuantity(-split_quantity_new, false, true);
7497 new_item.SetQuantity(split_quantity_new, false, true);
7498 }
7499 }
7500 }
7501 }
7502
7503 void SplitItemToInventoryLocation(notnull InventoryLocation dst)
7504 {
7505 float quantity = GetQuantity();
7506 float split_quantity_new = Math.Floor(quantity * 0.5);
7507
7508 if (!ShouldSplitQuantity(split_quantity_new))
7509 return;
7510
7511 ItemBase new_item = ItemBase.Cast(GameInventory.LocationCreateEntity(dst, GetType(), ECE_IN_INVENTORY, RF_DEFAULT));
7512
7513 if (new_item)
7514 {
7515 if (new_item.GetQuantityMax() < split_quantity_new)
7516 {
7517 split_quantity_new = new_item.GetQuantityMax();
7518 }
7519
7520 new_item.SetResultOfSplit(true);
7521 MiscGameplayFunctions.TransferItemProperties(this, new_item);
7522
7523 if (dst.IsValid() && dst.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
7524 {
7525 AddQuantity(-1, false, true);
7526 new_item.SetQuantity(1, false, true);
7527 }
7528 else
7529 {
7530 AddQuantity(-split_quantity_new, false, true);
7531 new_item.SetQuantity(split_quantity_new, false, true);
7532 }
7533 }
7534 }
7535
7536 void SplitItem(PlayerBase player)
7537 {
7538 float quantity = GetQuantity();
7539 float split_quantity_new = Math.Floor(quantity / 2);
7540
7541 if (!ShouldSplitQuantity(split_quantity_new))
7542 return;
7543
7544 InventoryLocation invloc = new InventoryLocation;
7545 bool found = player.GetInventory().FindFirstFreeLocationForNewEntity(GetType(), FindInventoryLocationType.ATTACHMENT, invloc);
7546
7547 ItemBase new_item;
7548 new_item = player.CreateCopyOfItemInInventoryOrGroundEx(this, true);
7549
7550 if (new_item)
7551 {
7552 if (new_item.GetQuantityMax() < split_quantity_new)
7553 {
7554 split_quantity_new = new_item.GetQuantityMax();
7555 }
7556 if (found && invloc.IsValid() && invloc.GetType() == InventoryLocationType.ATTACHMENT && split_quantity_new > 1)
7557 {
7558 AddQuantity(-1, false, true);
7559 new_item.SetQuantity(1, false, true);
7560 }
7561 else if (split_quantity_new > 1)
7562 {
7563 AddQuantity(-split_quantity_new, false, true);
7564 new_item.SetQuantity(split_quantity_new, false, true);
7565 }
7566 }
7567 }
7568
7570 void OnQuantityChanged(float delta)
7571 {
7572 SetWeightDirty();
7573 ItemBase parent = ItemBase.Cast(GetHierarchyParent());
7574
7575 if (parent)
7576 parent.OnAttachmentQuantityChangedEx(this, delta);
7577
7578 if (IsLiquidContainer())
7579 {
7580 if (GetQuantityNormalized() <= 0.0)
7581 {
7583 }
7584 else if (GetLiquidType() == LIQUID_NONE)
7585 {
7586 ErrorEx("Undefined liquid type quantity changed, please define liquid type first! Using init value.",ErrorExSeverity.INFO);
7588 }
7589 }
7590 }
7591
7594 {
7595 // insert code here
7596 }
7597
7599 void OnAttachmentQuantityChangedEx(ItemBase item , float delta)
7600 {
7602 }
7603
7604 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
7605 {
7606 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
7607
7608 if (g_Game.IsServer())
7609 {
7610 if (newLevel == GameConstants.STATE_RUINED)
7611 {
7613 EntityAI parent = GetHierarchyParent();
7614 if (parent && parent.IsFireplace())
7615 {
7616 CargoBase cargo = GetInventory().GetCargo();
7617 if (cargo)
7618 {
7619 for (int i = 0; i < cargo.GetItemCount(); ++i)
7620 {
7621 parent.GetInventory().TakeEntityToInventory(InventoryMode.SERVER, FindInventoryLocationType.CARGO, cargo.GetItem(i));
7622 }
7623 }
7624 }
7625 }
7626
7627 if (IsResultOfSplit())
7628 {
7629 // reset the splitting result flag, return to normal item behavior
7630 SetResultOfSplit(false);
7631 return;
7632 }
7633
7634 if (m_Cleanness != 0 && oldLevel < newLevel && newLevel != 0)
7635 {
7636 SetCleanness(0);//unclean the item upon damage dealt
7637 }
7638 }
7639 }
7640
7641 // just the split? TODO: verify
7642 override void OnRightClick()
7643 {
7644 super.OnRightClick();
7645
7646 if (CanBeSplit() && !GetDayZGame().IsLeftCtrlDown() && !g_Game.GetPlayer().GetInventory().HasInventoryReservation(this,null))
7647 {
7648 if (g_Game.IsClient())
7649 {
7650 if (ScriptInputUserData.CanStoreInputUserData())
7651 {
7652 EntityAI root = GetHierarchyRoot();
7653 Man playerOwner = GetHierarchyRootPlayer();
7654 InventoryLocation dst = new InventoryLocation;
7655
7656 // 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
7657 if (!playerOwner && root && root == this)
7658 {
7660 }
7661 else
7662 {
7663 // 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
7664 GetInventory().GetCurrentInventoryLocation(dst);
7665 if (!dst.GetParent() || dst.GetParent() && !dst.GetParent().GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst))
7666 {
7667 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
7668 if (!player.GetInventory().FindFreeLocationFor(this, FindInventoryLocationType.CARGO, dst) || !playerOwner)
7669 {
7671 }
7672 else
7673 {
7674 dst.SetCargo(dst.GetParent(), this, dst.GetIdx(), dst.GetRow(), dst.GetCol(), dst.GetFlip());
7675 /* hacky solution to check reservation of "this" item instead of null since the gamecode is checking null against null and returning reservation=true incorrectly
7676 this shouldnt cause issues within this scope*/
7677 if (g_Game.GetPlayer().GetInventory().HasInventoryReservation(this, dst))
7678 {
7680 }
7681 else
7682 {
7683 g_Game.GetPlayer().GetInventory().AddInventoryReservationEx(null, dst, GameInventory.c_InventoryReservationTimeoutShortMS);
7684 }
7685 }
7686 }
7687 }
7688
7689 ScriptInputUserData ctx = new ScriptInputUserData;
7691 ctx.Write(4);
7692 ItemBase thiz = this; // @NOTE: workaround for correct serialization
7693 ctx.Write(thiz);
7694 dst.WriteToContext(ctx);
7695 ctx.Write(true); // dummy
7696 ctx.Send();
7697 }
7698 }
7699 else if (!g_Game.IsMultiplayer())
7700 {
7701 SplitItem(PlayerBase.Cast(g_Game.GetPlayer()));
7702 }
7703 }
7704 }
7705
7706 protected void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
7707 {
7708 if (root)
7709 {
7710 vector m4[4];
7711 root.GetTransform(m4);
7712 dst.SetGround(this, m4);
7713 }
7714 else
7715 {
7716 GetInventory().GetCurrentInventoryLocation(dst);
7717 }
7718 }
7719
7720 override bool CanBeCombined(EntityAI other_item, bool reservation_check = true, bool stack_max_limit = false)
7721 {
7722 //TODO: delete check zero quantity check after fix double posts hands fsm events
7723 if (!other_item || GetType() != other_item.GetType() || (IsFullQuantity() && other_item.GetQuantity() > 0) || other_item == this)
7724 return false;
7725
7726 if (GetHealthLevel() == GameConstants.STATE_RUINED || other_item.GetHealthLevel() == GameConstants.STATE_RUINED)
7727 return false;
7728
7729 //can_this_be_combined = ConfigGetBool("canBeSplit");
7731 return false;
7732
7733
7734 Magazine mag = Magazine.Cast(this);
7735 if (mag)
7736 {
7737 if (mag.GetAmmoCount() >= mag.GetAmmoMax())
7738 return false;
7739
7740 if (stack_max_limit)
7741 {
7742 Magazine other_mag = Magazine.Cast(other_item);
7743 if (other_item)
7744 {
7745 if (mag.GetAmmoCount() + other_mag.GetAmmoCount() > mag.GetAmmoMax())
7746 return false;
7747 }
7748
7749 }
7750 }
7751 else
7752 {
7753 //TODO: delete check zero quantity check after fix double posts hands fsm events
7754 if (GetQuantity() >= GetQuantityMax() && other_item.GetQuantity() > 0 )
7755 return false;
7756
7757 if (stack_max_limit && (GetQuantity() + other_item.GetQuantity() > GetQuantityMax()))
7758 return false;
7759 }
7760
7761 PlayerBase player = null;
7762 if (CastTo(player, GetHierarchyRootPlayer())) //false when attached to player's attachment slot
7763 {
7764 if (player.GetInventory().HasAttachment(this))
7765 return false;
7766
7767 if (player.IsItemsToDelete())
7768 return false;
7769 }
7770
7771 if (reservation_check && (GetInventory().HasInventoryReservation(this, null) || other_item.GetInventory().HasInventoryReservation(other_item, null)))
7772 return false;
7773
7774 int slotID;
7775 string slotName;
7776 if (GetInventory().GetCurrentAttachmentSlotInfo(slotID,slotName) && GetHierarchyParent().GetInventory().GetSlotLock(slotID))
7777 return false;
7778
7779 return true;
7780 }
7781
7782 bool IsCombineAll(ItemBase other_item, bool use_stack_max = false)
7783 {
7784 return ComputeQuantityUsed(other_item, use_stack_max) == other_item.GetQuantity();
7785 }
7786
7787 bool IsResultOfSplit()
7788 {
7789 return m_IsResultOfSplit;
7790 }
7791
7792 void SetResultOfSplit(bool value)
7793 {
7794 m_IsResultOfSplit = value;
7795 }
7796
7797 int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max = true)
7798 {
7799 return ComputeQuantityUsedEx(other_item, use_stack_max);
7800 }
7801
7802 float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max = true)
7803 {
7804 float other_item_quantity = other_item.GetQuantity();
7805 float this_free_space;
7806
7807 float stack_max = GetQuantityMax();
7808
7809 this_free_space = stack_max - GetQuantity();
7810
7811 if (other_item_quantity > this_free_space)
7812 {
7813 return this_free_space;
7814 }
7815 else
7816 {
7817 return other_item_quantity;
7818 }
7819 }
7820
7821 override void CombineItemsEx(EntityAI entity2, bool use_stack_max = true)
7822 {
7823 CombineItems(ItemBase.Cast(entity2),use_stack_max);
7824 }
7825
7826 void CombineItems(ItemBase other_item, bool use_stack_max = true)
7827 {
7828 if (!CanBeCombined(other_item, false))
7829 return;
7830
7831 if (!IsMagazine() && other_item)
7832 {
7833 float quantity_used = ComputeQuantityUsedEx(other_item,use_stack_max);
7834 if (quantity_used != 0)
7835 {
7836 float hp1 = GetHealth01("","");
7837 float hp2 = other_item.GetHealth01("","");
7838 float hpResult = ((hp1*GetQuantity()) + (hp2*quantity_used));
7839 hpResult = hpResult / (GetQuantity() + quantity_used);
7840
7841 hpResult *= GetMaxHealth();
7842 Math.Round(hpResult);
7843 SetHealth("", "Health", hpResult);
7844
7845 AddQuantity(quantity_used);
7846 other_item.AddQuantity(-quantity_used);
7847 }
7848 }
7849 OnCombine(other_item);
7850 }
7851
7852 void OnCombine(ItemBase other_item)
7853 {
7854 #ifdef SERVER
7855 if (!GetHierarchyRootPlayer() && GetHierarchyParent())
7856 GetHierarchyParent().IncreaseLifetimeUp();
7857 #endif
7858 };
7859
7860 void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
7861 {
7862 PlayerBase p = PlayerBase.Cast(player);
7863
7864 array<int> recipesIds = p.m_Recipes;
7865 PluginRecipesManager moduleRecipesManager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
7866 if (moduleRecipesManager)
7867 {
7868 EntityAI itemInHands = player.GetEntityInHands();
7869 moduleRecipesManager.GetValidRecipes(ItemBase.Cast(this), ItemBase.Cast(itemInHands), recipesIds, p);
7870 }
7871
7872 for (int i = 0;i < recipesIds.Count(); i++)
7873 {
7874 int key = recipesIds.Get(i);
7875 string recipeName = moduleRecipesManager.GetRecipeName(key);
7876 outputList.Insert(new TSelectableActionInfo(SAT_CRAFTING, key, recipeName));
7877 }
7878 }
7879
7880 // -------------------------------------------------------------------------
7881 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
7882 {
7883 super.GetDebugActions(outputList);
7884
7885 //quantity
7886 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_QUANTITY, "Quantity +20%", FadeColors.LIGHT_GREY));
7887 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_QUANTITY, "Quantity -20%", FadeColors.LIGHT_GREY));
7888 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_QUANTITY_0, "Set Quantity 0", FadeColors.LIGHT_GREY));
7889 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SET_MAX_QUANTITY, "Set Quantity Max", FadeColors.LIGHT_GREY));
7890 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7891
7892 //health
7893 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_HEALTH, "Health +20%", FadeColors.LIGHT_GREY));
7894 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_HEALTH, "Health -20%", FadeColors.LIGHT_GREY));
7895 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DESTROY_HEALTH, "Health 0", FadeColors.LIGHT_GREY));
7896 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7897 //temperature
7898 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_TEMPERATURE, "Temperature +20", FadeColors.LIGHT_GREY));
7899 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_TEMPERATURE, "Temperature -20", FadeColors.LIGHT_GREY));
7900 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.FLIP_FROZEN, "Toggle Frozen", FadeColors.LIGHT_GREY));
7901 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7902
7903 //wet
7904 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ADD_WETNESS, "Wetness +20", FadeColors.LIGHT_GREY));
7905 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.REMOVE_WETNESS, "Wetness -20", FadeColors.LIGHT_GREY));
7906 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7907
7908 //liquidtype
7909 if (IsLiquidContainer())
7910 {
7911 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_UP, "LiquidType Next", FadeColors.LIGHT_GREY));
7912 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.LIQUIDTYPE_DOWN, "LiquidType Previous", FadeColors.LIGHT_GREY));
7913 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7914 }
7915
7916 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.MAKE_SPECIAL, "Make Special", FadeColors.LIGHT_GREY));
7917 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7918
7919 // watch
7920 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_ITEM, "Watch (CTRL-Z)", FadeColors.LIGHT_GREY));
7921 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.WATCH_PLAYER, "Watch Player", FadeColors.LIGHT_GREY));
7922 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7923
7924 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
7925
7926 InventoryLocation loc = new InventoryLocation();
7927 GetInventory().GetCurrentInventoryLocation(loc);
7928 if (!loc || loc.GetType() == InventoryLocationType.GROUND)
7929 {
7930 if (Gizmo_IsSupported())
7931 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
7932 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
7933 }
7934
7935 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
7936 }
7937
7938 // -------------------------------------------------------------------------
7939 // -------------------------------------------------------------------------
7940 // -------------------------------------------------------------------------
7941 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
7942 {
7943 super.OnAction(action_id, player, ctx);
7944
7945 if (g_Game.IsClient() || !g_Game.IsMultiplayer())
7946 {
7947 switch (action_id)
7948 {
7949 case EActions.GIZMO_OBJECT:
7950 if (GetGizmoApi())
7951 GetGizmoApi().SelectObject(this);
7952 return true;
7953 case EActions.GIZMO_PHYSICS:
7954 if (GetGizmoApi())
7955 GetGizmoApi().SelectPhysics(GetPhysics());
7956 return true;
7957 }
7958 }
7959
7960 if (g_Game.IsServer())
7961 {
7962 switch (action_id)
7963 {
7964 case EActions.DELETE:
7965 Delete();
7966 return true;
7967 }
7968 }
7969
7970 if (action_id >= EActions.RECIPES_RANGE_START && action_id < EActions.RECIPES_RANGE_END)
7971 {
7972 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(GetPlugin(PluginRecipesManager));
7973 int idWithoutOffset = action_id - EActions.RECIPES_RANGE_START;
7974 PlayerBase p = PlayerBase.Cast(player);
7975 if (EActions.RECIPES_RANGE_START < 1000)
7976 {
7977 float anim_length = plugin_recipes_manager.GetRecipeLengthInSecs(idWithoutOffset);
7978 float specialty_weight = plugin_recipes_manager.GetRecipeSpecialty(idWithoutOffset);
7979 }
7980 }
7981 #ifndef SERVER
7982 else if (action_id == EActions.WATCH_PLAYER)
7983 {
7984 PluginDeveloper.SetDeveloperItemClientEx(player);
7985 }
7986 #endif
7987 if (g_Game.IsServer())
7988 {
7989 if (action_id >= EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START && action_id < EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_END)
7990 {
7991 int id = action_id - EActions.DEBUG_ITEM_WATCH_BUTTON_RANGE_START;
7992 OnDebugButtonPressServer(id + 1);
7993 }
7994
7995 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_INJECT_START && action_id < EActions.DEBUG_AGENTS_RANGE_INJECT_END)
7996 {
7997 int agent_id = action_id - EActions.DEBUG_AGENTS_RANGE_INJECT_START;
7998 InsertAgent(agent_id,100);
7999 }
8000
8001 else if (action_id >= EActions.DEBUG_AGENTS_RANGE_REMOVE_START && action_id < EActions.DEBUG_AGENTS_RANGE_REMOVE_END)
8002 {
8003 int agent_id2 = action_id - EActions.DEBUG_AGENTS_RANGE_REMOVE_START;
8004 RemoveAgent(agent_id2);
8005 }
8006
8007 else if (action_id == EActions.ADD_QUANTITY)
8008 {
8009 if (IsMagazine())
8010 {
8011 Magazine mag = Magazine.Cast(this);
8012 mag.ServerSetAmmoCount(mag.GetAmmoCount() + mag.GetAmmoMax() * 0.2);
8013 }
8014 else
8015 {
8016 AddQuantity(GetQuantityMax() * 0.2);
8017 }
8018
8019 if (m_EM)
8020 {
8021 m_EM.AddEnergy(m_EM.GetEnergyMax() * 0.2);
8022 }
8023 //PrintVariables();
8024 }
8025
8026 else if (action_id == EActions.REMOVE_QUANTITY) //Quantity -20%
8027 {
8028 if (IsMagazine())
8029 {
8030 Magazine mag2 = Magazine.Cast(this);
8031 mag2.ServerSetAmmoCount(mag2.GetAmmoCount() - mag2.GetAmmoMax() * 0.2);
8032 }
8033 else
8034 {
8035 AddQuantity(- GetQuantityMax() * 0.2);
8036 }
8037 if (m_EM)
8038 {
8039 m_EM.AddEnergy(- m_EM.GetEnergyMax() * 0.2);
8040 }
8041 //PrintVariables();
8042 }
8043
8044 else if (action_id == EActions.SET_QUANTITY_0) //SetMaxQuantity
8045 {
8046 SetQuantity(0);
8047
8048 if (m_EM)
8049 {
8050 m_EM.SetEnergy(0);
8051 }
8052 }
8053
8054 else if (action_id == EActions.SET_MAX_QUANTITY) //SetMaxQuantity
8055 {
8057
8058 if (m_EM)
8059 {
8060 m_EM.SetEnergy(m_EM.GetEnergyMax());
8061 }
8062 }
8063
8064 else if (action_id == EActions.ADD_HEALTH)
8065 {
8066 AddHealth("","",GetMaxHealth("","Health")/5);
8067 }
8068 else if (action_id == EActions.REMOVE_HEALTH)
8069 {
8070 AddHealth("","",-GetMaxHealth("","Health")/5);
8071 }
8072 else if (action_id == EActions.DESTROY_HEALTH)
8073 {
8074 SetHealth01("","",0);
8075 }
8076 else if (action_id == EActions.WATCH_ITEM)
8077 {
8079 mid.RegisterDebugItem(ItemBase.Cast(this), PlayerBase.Cast(player));
8080 #ifdef DEVELOPER
8081 SetDebugDeveloper_item(this);
8082 #endif
8083 }
8084
8085 else if (action_id == EActions.ADD_TEMPERATURE)
8086 {
8087 AddTemperature(20);
8088 //PrintVariables();
8089 }
8090
8091 else if (action_id == EActions.REMOVE_TEMPERATURE)
8092 {
8093 AddTemperature(-20);
8094 //PrintVariables();
8095 }
8096
8097 else if (action_id == EActions.FLIP_FROZEN)
8098 {
8099 SetFrozen(!GetIsFrozen());
8100 //PrintVariables();
8101 }
8102
8103 else if (action_id == EActions.ADD_WETNESS)
8104 {
8105 AddWet(GetWetMax()/5);
8106 //PrintVariables();
8107 }
8108
8109 else if (action_id == EActions.REMOVE_WETNESS)
8110 {
8111 AddWet(-GetWetMax()/5);
8112 //PrintVariables();
8113 }
8114
8115 else if (action_id == EActions.LIQUIDTYPE_UP)
8116 {
8117 int curr_type = GetLiquidType();
8118 SetLiquidType(curr_type * 2);
8119 //AddWet(1);
8120 //PrintVariables();
8121 }
8122
8123 else if (action_id == EActions.LIQUIDTYPE_DOWN)
8124 {
8125 int curr_type2 = GetLiquidType();
8126 SetLiquidType(curr_type2 / 2);
8127 }
8128
8129 else if (action_id == EActions.MAKE_SPECIAL)
8130 {
8131 auto debugParams = DebugSpawnParams.WithPlayer(player);
8132 OnDebugSpawnEx(debugParams);
8133 }
8134
8135 }
8136
8137
8138 return false;
8139 }
8140
8141 // -------------------------------------------------------------------------
8142
8143
8146 void OnActivatedByTripWire();
8147
8149 void OnActivatedByItem(notnull ItemBase item);
8150
8151 //----------------------------------------------------------------
8152 //returns true if item is able to explode when put in fire
8153 bool CanExplodeInFire()
8154 {
8155 return false;
8156 }
8157
8158 //----------------------------------------------------------------
8159 bool CanEat()
8160 {
8161 return true;
8162 }
8163
8164 //----------------------------------------------------------------
8165 override bool IsIgnoredByConstruction()
8166 {
8167 return true;
8168 }
8169
8170 //----------------------------------------------------------------
8171 //has FoodStages in config?
8172 bool HasFoodStage()
8173 {
8174 string config_path = string.Format("CfgVehicles %1 Food FoodStages", GetType());
8175 return g_Game.ConfigIsExisting(config_path);
8176 }
8177
8179 FoodStage GetFoodStage()
8180 {
8181 return null;
8182 }
8183
8184 bool CanBeCooked()
8185 {
8186 return false;
8187 }
8188
8189 bool CanBeCookedOnStick()
8190 {
8191 return false;
8192 }
8193
8195 void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned );
8197
8198 //----------------------------------------------------------------
8199 bool CanRepair(ItemBase item_repair_kit)
8200 {
8201 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8202 return module_repairing.CanRepair(this, item_repair_kit);
8203 }
8204
8205 //----------------------------------------------------------------
8206 bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
8207 {
8208 PluginRepairing module_repairing = PluginRepairing.Cast(GetPlugin(PluginRepairing));
8209 return module_repairing.Repair(player, this, item_repair_kit, specialty_weight);
8210 }
8211
8212 //----------------------------------------------------------------
8213 int GetItemSize()
8214 {
8215 /*
8216 vector v_size = this.ConfigGetVector("itemSize");
8217 int v_size_x = v_size[0];
8218 int v_size_y = v_size[1];
8219 int size = v_size_x * v_size_y;
8220 return size;
8221 */
8222
8223 return 1;
8224 }
8225
8226 //----------------------------------------------------------------
8227 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
8228 bool CanBeMovedOverride()
8229 {
8230 return m_CanBeMovedOverride;
8231 }
8232
8233 //----------------------------------------------------------------
8234 //Override for allowing seemingly unallowed moves when two clients send a conflicting message simultaneously
8235 void SetCanBeMovedOverride(bool setting)
8236 {
8237 m_CanBeMovedOverride = setting;
8238 }
8239
8240 //----------------------------------------------------------------
8248 void MessageToOwnerStatus(string text)
8249 {
8250 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8251
8252 if (player)
8253 {
8254 player.MessageStatus(text);
8255 }
8256 }
8257
8258 //----------------------------------------------------------------
8266 void MessageToOwnerAction(string text)
8267 {
8268 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8269
8270 if (player)
8271 {
8272 player.MessageAction(text);
8273 }
8274 }
8275
8276 //----------------------------------------------------------------
8284 void MessageToOwnerFriendly(string text)
8285 {
8286 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8287
8288 if (player)
8289 {
8290 player.MessageFriendly(text);
8291 }
8292 }
8293
8294 //----------------------------------------------------------------
8302 void MessageToOwnerImportant(string text)
8303 {
8304 PlayerBase player = PlayerBase.Cast(this.GetHierarchyRootPlayer());
8305
8306 if (player)
8307 {
8308 player.MessageImportant(text);
8309 }
8310 }
8311
8312 override bool IsItemBase()
8313 {
8314 return true;
8315 }
8316
8317 // Checks if item is of questioned kind
8318 override bool KindOf(string tag)
8319 {
8320 bool found = false;
8321 string item_name = this.GetType();
8322 ref TStringArray item_tag_array = new TStringArray;
8323 g_Game.ConfigGetTextArray("cfgVehicles " + item_name + " itemInfo", item_tag_array);
8324
8325 int array_size = item_tag_array.Count();
8326 for (int i = 0; i < array_size; i++)
8327 {
8328 if (item_tag_array.Get(i) == tag)
8329 {
8330 found = true;
8331 break;
8332 }
8333 }
8334 return found;
8335 }
8336
8337
8338 override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
8339 {
8340 //Debug.Log("OnRPC called");
8341 super.OnRPC(sender, rpc_type,ctx);
8342
8343 //Play soundset for attachment locking (ActionLockAttachment.c)
8344 switch (rpc_type)
8345 {
8346 #ifndef SERVER
8347 case ERPCs.RPC_SOUND_LOCK_ATTACH:
8348 Param2<bool, string> p = new Param2<bool, string>(false, "");
8349
8350 if (!ctx.Read(p))
8351 return;
8352
8353 bool play = p.param1;
8354 string soundSet = p.param2;
8355
8356 if (play)
8357 {
8358 if (m_LockingSound)
8359 {
8361 {
8362 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
8363 }
8364 }
8365 else
8366 {
8367 m_LockingSound = SEffectManager.PlaySound(soundSet, GetPosition(), 0, 0, true);
8368 }
8369 }
8370 else
8371 {
8372 SEffectManager.DestroyEffect(m_LockingSound);
8373 }
8374
8375 break;
8376 #endif
8377
8378 }
8379
8380 if (GetWrittenNoteData())
8381 {
8382 GetWrittenNoteData().OnRPC(sender, rpc_type,ctx);
8383 }
8384 }
8385
8386 //-----------------------------
8387 // VARIABLE MANIPULATION SYSTEM
8388 //-----------------------------
8389 int NameToID(string name)
8390 {
8391 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
8392 return plugin.GetID(name);
8393 }
8394
8395 string IDToName(int id)
8396 {
8397 PluginVariables plugin = PluginVariables.Cast(GetPlugin(PluginVariables));
8398 return plugin.GetName(id);
8399 }
8400
8402 void OnSyncVariables(ParamsReadContext ctx)//with ID optimization
8403 {
8404 //Debug.Log("OnSyncVariables called for item: "+ ToString(this.GetType()),"varSync");
8405 //read the flags
8406 int varFlags;
8407 if (!ctx.Read(varFlags))
8408 return;
8409
8410 if (varFlags & ItemVariableFlags.FLOAT)
8411 {
8412 ReadVarsFromCTX(ctx);
8413 }
8414 }
8415
8416 override void SerializeNumericalVars(array<float> floats_out)
8417 {
8418 //some variables handled on EntityAI level already!
8419 super.SerializeNumericalVars(floats_out);
8420
8421 // the order of serialization must be the same as the order of de-serialization
8422 //--------------------------------------------
8423 if (IsVariableSet(VARIABLE_QUANTITY))
8424 {
8425 floats_out.Insert(m_VarQuantity);
8426 }
8427 //--------------------------------------------
8428 if (IsVariableSet(VARIABLE_WET))
8429 {
8430 floats_out.Insert(m_VarWet);
8431 }
8432 //--------------------------------------------
8433 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
8434 {
8435 floats_out.Insert(m_VarLiquidType);
8436 }
8437 //--------------------------------------------
8438 if (IsVariableSet(VARIABLE_COLOR))
8439 {
8440 floats_out.Insert(m_ColorComponentR);
8441 floats_out.Insert(m_ColorComponentG);
8442 floats_out.Insert(m_ColorComponentB);
8443 floats_out.Insert(m_ColorComponentA);
8444 }
8445 //--------------------------------------------
8446 if (IsVariableSet(VARIABLE_CLEANNESS))
8447 {
8448 floats_out.Insert(m_Cleanness);
8449 }
8450 }
8451
8452 override void DeSerializeNumericalVars(array<float> floats)
8453 {
8454 //some variables handled on EntityAI level already!
8455 super.DeSerializeNumericalVars(floats);
8456
8457 // the order of serialization must be the same as the order of de-serialization
8458 int index = 0;
8459 int mask = Math.Round(floats.Get(index));
8460
8461 index++;
8462 //--------------------------------------------
8463 if (mask & VARIABLE_QUANTITY)
8464 {
8465 if (m_IsStoreLoad)
8466 {
8467 SetStoreLoadedQuantity(floats.Get(index));
8468 }
8469 else
8470 {
8471 float quantity = floats.Get(index);
8472 SetQuantity(quantity, true, false, false, false);
8473 }
8474 index++;
8475 }
8476 //--------------------------------------------
8477 if (mask & VARIABLE_WET)
8478 {
8479 float wet = floats.Get(index);
8480 SetWet(wet);
8481 index++;
8482 }
8483 //--------------------------------------------
8484 if (mask & VARIABLE_LIQUIDTYPE)
8485 {
8486 int liquidtype = Math.Round(floats.Get(index));
8487 SetLiquidType(liquidtype);
8488 index++;
8489 }
8490 //--------------------------------------------
8491 if (mask & VARIABLE_COLOR)
8492 {
8493 m_ColorComponentR = Math.Round(floats.Get(index));
8494 index++;
8495 m_ColorComponentG = Math.Round(floats.Get(index));
8496 index++;
8497 m_ColorComponentB = Math.Round(floats.Get(index));
8498 index++;
8499 m_ColorComponentA = Math.Round(floats.Get(index));
8500 index++;
8501 }
8502 //--------------------------------------------
8503 if (mask & VARIABLE_CLEANNESS)
8504 {
8505 int cleanness = Math.Round(floats.Get(index));
8506 SetCleanness(cleanness);
8507 index++;
8508 }
8509 }
8510
8511 override void WriteVarsToCTX(ParamsWriteContext ctx)
8512 {
8513 super.WriteVarsToCTX(ctx);
8514
8515 //--------------------------------------------
8516 if (IsVariableSet(VARIABLE_QUANTITY))
8517 {
8518 ctx.Write(GetQuantity());
8519 }
8520 //--------------------------------------------
8521 if (IsVariableSet(VARIABLE_WET))
8522 {
8523 ctx.Write(GetWet());
8524 }
8525 //--------------------------------------------
8526 if (IsVariableSet(VARIABLE_LIQUIDTYPE))
8527 {
8528 ctx.Write(GetLiquidType());
8529 }
8530 //--------------------------------------------
8531 if (IsVariableSet(VARIABLE_COLOR))
8532 {
8533 int r,g,b,a;
8534 GetColor(r,g,b,a);
8535 ctx.Write(r);
8536 ctx.Write(g);
8537 ctx.Write(b);
8538 ctx.Write(a);
8539 }
8540 //--------------------------------------------
8541 if (IsVariableSet(VARIABLE_CLEANNESS))
8542 {
8543 ctx.Write(GetCleanness());
8544 }
8545 }
8546
8547 override bool ReadVarsFromCTX(ParamsReadContext ctx, int version = -1)//with ID optimization
8548 {
8549 if (!super.ReadVarsFromCTX(ctx,version))
8550 return false;
8551
8552 int intValue;
8553 float value;
8554
8555 if (version < 140)
8556 {
8557 if (!ctx.Read(intValue))
8558 return false;
8559
8560 m_VariablesMask = intValue;
8561 }
8562
8563 if (m_VariablesMask & VARIABLE_QUANTITY)
8564 {
8565 if (!ctx.Read(value))
8566 return false;
8567
8568 if (IsStoreLoad())
8569 {
8571 }
8572 else
8573 {
8574 SetQuantity(value, true, false, false, false);
8575 }
8576 }
8577 //--------------------------------------------
8578 if (version < 140)
8579 {
8580 if (m_VariablesMask & VARIABLE_TEMPERATURE)
8581 {
8582 if (!ctx.Read(value))
8583 return false;
8584 SetTemperatureDirect(value);
8585 }
8586 }
8587 //--------------------------------------------
8588 if (m_VariablesMask & VARIABLE_WET)
8589 {
8590 if (!ctx.Read(value))
8591 return false;
8592 SetWet(value);
8593 }
8594 //--------------------------------------------
8595 if (m_VariablesMask & VARIABLE_LIQUIDTYPE)
8596 {
8597 if (!ctx.Read(intValue))
8598 return false;
8599 SetLiquidType(intValue);
8600 }
8601 //--------------------------------------------
8602 if (m_VariablesMask & VARIABLE_COLOR)
8603 {
8604 int r,g,b,a;
8605 if (!ctx.Read(r))
8606 return false;
8607 if (!ctx.Read(g))
8608 return false;
8609 if (!ctx.Read(b))
8610 return false;
8611 if (!ctx.Read(a))
8612 return false;
8613
8614 SetColor(r,g,b,a);
8615 }
8616 //--------------------------------------------
8617 if (m_VariablesMask & VARIABLE_CLEANNESS)
8618 {
8619 if (!ctx.Read(intValue))
8620 return false;
8621 SetCleanness(intValue);
8622 }
8623 //--------------------------------------------
8624 if (version >= 138 && version < 140)
8625 {
8626 if (m_VariablesMask & VARIABLE_TEMPERATURE)
8627 {
8628 if (!ctx.Read(intValue))
8629 return false;
8630 SetFrozen(intValue);
8631 }
8632 }
8633
8634 return true;
8635 }
8636
8637 //----------------------------------------------------------------
8638 override bool OnStoreLoad(ParamsReadContext ctx, int version)
8639 {
8640 m_IsStoreLoad = true;
8642 {
8643 m_FixDamageSystemInit = true;
8644 }
8645
8646 if (!super.OnStoreLoad(ctx, version))
8647 {
8648 m_IsStoreLoad = false;
8649 return false;
8650 }
8651
8652 if (version >= 114)
8653 {
8654 bool hasQuickBarIndexSaved;
8655
8656 if (!ctx.Read(hasQuickBarIndexSaved))
8657 {
8658 m_IsStoreLoad = false;
8659 return false;
8660 }
8661
8662 if (hasQuickBarIndexSaved)
8663 {
8664 int itmQBIndex;
8665
8666 //Load quickbar item bind
8667 if (!ctx.Read(itmQBIndex))
8668 {
8669 m_IsStoreLoad = false;
8670 return false;
8671 }
8672
8673 PlayerBase parentPlayer = PlayerBase.Cast(GetHierarchyRootPlayer());
8674 if (itmQBIndex != -1 && parentPlayer)
8675 parentPlayer.SetLoadedQuickBarItemBind(this, itmQBIndex);
8676 }
8677 }
8678 else
8679 {
8680 // Backup of how it used to be
8681 PlayerBase player;
8682 int itemQBIndex;
8683 if (version == int.MAX)
8684 {
8685 if (!ctx.Read(itemQBIndex))
8686 {
8687 m_IsStoreLoad = false;
8688 return false;
8689 }
8690 }
8691 else if (Class.CastTo(player, GetHierarchyRootPlayer()))
8692 {
8693 //Load quickbar item bind
8694 if (!ctx.Read(itemQBIndex))
8695 {
8696 m_IsStoreLoad = false;
8697 return false;
8698 }
8699 if (itemQBIndex != -1 && player)
8700 player.SetLoadedQuickBarItemBind(this,itemQBIndex);
8701 }
8702 }
8703
8704 if (version < 140)
8705 {
8706 // variable management system
8707 if (!LoadVariables(ctx, version))
8708 {
8709 m_IsStoreLoad = false;
8710 return false;
8711 }
8712 }
8713
8714 //agent trasmission system
8715 if (!LoadAgents(ctx, version))
8716 {
8717 m_IsStoreLoad = false;
8718 return false;
8719 }
8720 if (version >= 132)
8721 {
8722 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
8723 if (raib)
8724 {
8725 if (!raib.OnStoreLoad(ctx,version))
8726 {
8727 m_IsStoreLoad = false;
8728 return false;
8729 }
8730 }
8731 }
8732
8733 m_IsStoreLoad = false;
8734 return true;
8735 }
8736
8737 //----------------------------------------------------------------
8738
8739 override void OnStoreSave(ParamsWriteContext ctx)
8740 {
8741 super.OnStoreSave(ctx);
8742
8743 PlayerBase player;
8744 if (PlayerBase.CastTo(player,GetHierarchyRootPlayer()))
8745 {
8746 ctx.Write(true); // Keep track of if we should actually read this in or not
8747 //Save quickbar item bind
8748 int itemQBIndex = -1;
8749 itemQBIndex = player.FindQuickBarEntityIndex(this);
8750 ctx.Write(itemQBIndex);
8751 }
8752 else
8753 {
8754 ctx.Write(false); // Keep track of if we should actually read this in or not
8755 }
8756
8757 SaveAgents(ctx);//agent trasmission system
8758
8759 RemotelyActivatedItemBehaviour raib = GetRemotelyActivatedItemBehaviour();
8760 if (raib)
8761 {
8762 raib.OnStoreSave(ctx);
8763 }
8764 }
8765 //----------------------------------------------------------------
8766
8767 override void AfterStoreLoad()
8768 {
8769 super.AfterStoreLoad();
8770
8772 {
8774 }
8775
8776 if (GetStoreLoadedQuantity() != float.LOWEST)
8777 {
8779 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
8780 }
8781 }
8782
8783 override void EEOnAfterLoad()
8784 {
8785 super.EEOnAfterLoad();
8786
8788 {
8789 m_FixDamageSystemInit = false;
8790 }
8791
8794 }
8795
8796 bool CanBeDisinfected()
8797 {
8798 return false;
8799 }
8800
8801
8802 //----------------------------------------------------------------
8803 override void OnVariablesSynchronized()
8804 {
8805 if (m_Initialized)
8806 {
8807 #ifdef PLATFORM_CONSOLE
8808 //bruteforce it is
8809 if (IsSplitable())
8810 {
8811 UIScriptedMenu menu = g_Game.GetUIManager().FindMenu(MENU_INVENTORY);
8812 if (menu)
8813 {
8814 menu.Refresh();
8815 }
8816 }
8817 #endif
8818 }
8819
8821 {
8822 PlayImpactSound(m_ConfigWeight, m_ImpactSpeed, m_ImpactSoundSurfaceHash);
8823 m_WantPlayImpactSound = false;
8824 }
8825
8827 {
8828 SetWeightDirty();
8830 }
8831 if (m_VarWet != m_VarWetPrev)
8832 {
8835 }
8836
8837 if (m_SoundSyncPlay != 0)
8838 {
8841
8842 m_SoundSyncPlay = 0;
8843 m_SoundSyncSlotID = -1;
8844 }
8845 if (m_SoundSyncStop != 0)
8846 {
8848 m_ItemSoundHandler.StopItemSoundClient(m_SoundSyncStop);
8849 m_SoundSyncStop = 0;
8850 }
8851
8852 super.OnVariablesSynchronized();
8853 }
8854
8855 //------------------------- Quantity
8856 //----------------------------------------------------------------
8858 override bool SetQuantity(float value, bool destroy_config = true, bool destroy_forced = false, bool allow_client = false, bool clamp_to_stack_max = true)
8859 {
8860 if (!IsServerCheck(allow_client))
8861 return false;
8862
8863 if (!HasQuantity())
8864 return false;
8865
8866 float min = GetQuantityMin();
8867 float max = GetQuantityMax();
8868
8869 if (value <= (min + 0.001))
8870 value = min;
8871
8872 if (value == min)
8873 {
8874 if (destroy_config)
8875 {
8876 bool dstr = ConfigGetBool("varQuantityDestroyOnMin");
8877 if (dstr)
8878 {
8879 m_VarQuantity = Math.Clamp(value, min, max);
8880 this.Delete();
8881 return true;
8882 }
8883 }
8884 else if (destroy_forced)
8885 {
8886 m_VarQuantity = Math.Clamp(value, min, max);
8887 this.Delete();
8888 return true;
8889 }
8890 // we get here if destroy_config IS true AND dstr(config destroy param) IS false;
8891 RemoveAllAgents();//we remove all agents when we got to the min value, but the item is not getting deleted
8892 }
8893
8894 float delta = m_VarQuantity;
8895 m_VarQuantity = Math.Clamp(value, min, max);
8896
8897 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
8898 {
8899 EntityAI parent = GetHierarchyRoot();
8900 InventoryLocation iLoc = new InventoryLocation();
8901 GetInventory().GetCurrentInventoryLocation(iLoc);
8902 if (iLoc && iLoc.IsValid() && delta != m_VarQuantity)
8903 {
8904 int iLocSlot = iLoc.GetSlot();
8905 if (delta < m_VarQuantity && iLoc.GetType() != InventoryLocationType.GROUND)
8906 {
8907 StartItemSoundServer(SoundConstants.ITEM_ATTACH, iLocSlot);
8908 }
8909 if (delta > m_VarQuantity && m_VarQuantity != 0 && !IsPrepareToDelete() && iLoc.GetType() == InventoryLocationType.ATTACHMENT)
8910 {
8911 StartItemSoundServer(SoundConstants.ITEM_DETACH, iLocSlot);
8912 }
8913 }
8914 }
8915
8916 if (GetStoreLoadedQuantity() == float.LOWEST)//any other value means we are setting quantity from storage
8917 {
8918 delta = m_VarQuantity - delta;
8919
8920 if (delta)
8921 OnQuantityChanged(delta);
8922 }
8923
8924 SetVariableMask(VARIABLE_QUANTITY);
8925
8926 return false;
8927 }
8928
8929 //----------------------------------------------------------------
8931 bool AddQuantity(float value, bool destroy_config = true, bool destroy_forced = false)
8932 {
8933 return SetQuantity(GetQuantity() + value, destroy_config, destroy_forced);
8934 }
8935 //----------------------------------------------------------------
8936 void SetQuantityMax()
8937 {
8938 float max = GetQuantityMax();
8939 SetQuantity(max);
8940 }
8941
8942 override void SetQuantityToMinimum()
8943 {
8944 float min = GetQuantityMin();
8945 SetQuantity(min);
8946 }
8947 //----------------------------------------------------------------
8949 override void SetQuantityNormalized(float value, bool destroy_config = true, bool destroy_forced = false)
8950 {
8951 float value_clamped = Math.Clamp(value, 0, 1);//just to make sure
8952 int result = Math.Round(Math.Lerp(GetQuantityMin(), GetQuantityMax(), value_clamped));
8953 SetQuantity(result, destroy_config, destroy_forced);
8954 }
8955
8956 //----------------------------------------------------------------
8958 override float GetQuantityNormalized()
8959 {
8960 return Math.InverseLerp(GetQuantityMin(), GetQuantityMax(),m_VarQuantity);
8961 }
8962
8964 {
8965 return GetQuantityNormalized();
8966 }
8967
8968 /*void SetAmmoNormalized(float value)
8969 {
8970 float value_clamped = Math.Clamp(value, 0, 1);
8971 Magazine this_mag = Magazine.Cast(this);
8972 int max_rounds = this_mag.GetAmmoMax();
8973 int result = value * max_rounds;//can the rounded if higher precision is required
8974 this_mag.SetAmmoCount(result);
8975 }*/
8976 //----------------------------------------------------------------
8977 override int GetQuantityMax()
8978 {
8979 int slot = -1;
8980 GameInventory inventory = GetInventory();
8981 if (inventory)
8982 {
8983 InventoryLocation il = new InventoryLocation;
8984 inventory.GetCurrentInventoryLocation(il);
8985 slot = il.GetSlot();
8986 }
8987
8988 return GetTargetQuantityMax(slot);
8989 }
8990
8991 override int GetTargetQuantityMax(int attSlotID = -1)
8992 {
8993 float quantity_max = 0;
8994
8995 if (IsSplitable()) //only stackable/splitable items can check for stack size
8996 {
8997 if (attSlotID != -1)
8998 quantity_max = InventorySlots.GetStackMaxForSlotId(attSlotID);
8999
9000 if (quantity_max <= 0)
9001 quantity_max = m_VarStackMax;
9002 }
9003
9004 if (quantity_max <= 0)
9005 quantity_max = m_VarQuantityMax;
9006
9007 return quantity_max;
9008 }
9009 //----------------------------------------------------------------
9010 override int GetQuantityMin()
9011 {
9012 return m_VarQuantityMin;
9013 }
9014 //----------------------------------------------------------------
9015 int GetQuantityInit()
9016 {
9017 return m_VarQuantityInit;
9018 }
9019
9020 //----------------------------------------------------------------
9021 override bool HasQuantity()
9022 {
9023 return !(GetQuantityMax() - GetQuantityMin() == 0);
9024 }
9025
9026 override float GetQuantity()
9027 {
9028 return m_VarQuantity;
9029 }
9030
9031 bool IsFullQuantity()
9032 {
9033 return GetQuantity() >= GetQuantityMax();
9034 }
9035
9036 //Calculates weight of single item without attachments and cargo
9037 override float GetSingleInventoryItemWeightEx()
9038 {
9039 //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
9040 float weightEx = GetWeightEx();//overall weight of the item
9041 float special = GetInventoryAndCargoWeight();//cargo and attachment weight
9042 return weightEx - special;
9043 }
9044
9045 // Obsolete, use GetSingleInventoryItemWeightEx() instead
9047 {
9049 }
9050
9051 override protected float GetWeightSpecialized(bool forceRecalc = false)
9052 {
9053 if (IsSplitable()) //quantity determines size of the stack
9054 {
9055 #ifdef DEVELOPER
9056 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9057 {
9058 WeightDebugData data1 = WeightDebug.GetWeightDebug(this);
9059 data1.SetCalcDetails("TIB1: " + GetConfigWeightModifiedDebugText() +" * " + GetQuantity()+"(quantity)");
9060 }
9061 #endif
9062
9063 return GetQuantity() * GetConfigWeightModified();
9064 }
9065 else if (HasEnergyManager())// items with energy manager
9066 {
9067 #ifdef DEVELOPER
9068 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9069 {
9070 WeightDebugData data2 = WeightDebug.GetWeightDebug(this);
9071 data2.SetCalcDetails("TIB2: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetCompEM().GetEnergy()+"(energy) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit)");
9072 }
9073 #endif
9074 return super.GetWeightSpecialized(forceRecalc) + (GetCompEM().GetEnergy() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
9075 }
9076 else//everything else
9077 {
9078 #ifdef DEVELOPER
9079 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
9080 {
9081 WeightDebugData data3 = WeightDebug.GetWeightDebug(this);
9082 data3.SetCalcDetails("TIB3: "+super.GetWeightSpecialized(forceRecalc)+"(contents weight) + " + GetConfigWeightModifiedDebugText() +" + " + GetQuantity()+"(quantity) * " + ConfigGetFloat("weightPerQuantityUnit") +"(weightPerQuantityUnit))");
9083 }
9084 #endif
9085 return super.GetWeightSpecialized(forceRecalc) + (GetQuantity() * ConfigGetFloat("weightPerQuantityUnit")) + GetConfigWeightModified();
9086 }
9087 }
9088
9090 int GetNumberOfItems()
9091 {
9092 int item_count = 0;
9093 ItemBase item;
9094
9095 GameInventory inventory = GetInventory();
9096 CargoBase cargo = inventory.GetCargo();
9097 if (cargo != NULL)
9098 {
9099 item_count = cargo.GetItemCount();
9100 }
9101
9102 int nAttachments = inventory.AttachmentCount();
9103 for (int i = 0; i < nAttachments; ++i)
9104 {
9105 Class.CastTo(item, inventory.GetAttachmentFromIndex(i));
9106 if (item)
9107 item_count += item.GetNumberOfItems();
9108 }
9109 return item_count;
9110 }
9111
9113 float GetUnitWeight(bool include_wetness = true)
9114 {
9115 float weight = 0;
9116 float wetness = 1;
9117 if (include_wetness)
9118 wetness += GetWet();
9119 if (IsSplitable()) //quantity determines size of the stack
9120 {
9121 weight = wetness * m_ConfigWeight;
9122 }
9123 else if (IsLiquidContainer()) //is a liquid container, default liquid weight is set to 1. May revisit later?
9124 {
9125 weight = 1;
9126 }
9127 return weight;
9128 }
9129
9130 //-----------------------------------------------------------------
9131
9132 override void ClearInventory()
9133 {
9134 GameInventory inventory = GetInventory();
9135 if ((g_Game.IsServer() || !g_Game.IsMultiplayer()) && inventory)
9136 {
9137 array<EntityAI> items = new array<EntityAI>;
9138 inventory.EnumerateInventory(InventoryTraversalType.INORDER, items);
9139 for (int i = 0; i < items.Count(); ++i)
9140 {
9141 ItemBase item = ItemBase.Cast(items.Get(i));
9142 if (item)
9143 {
9144 g_Game.ObjectDelete(item);
9145 }
9146 }
9147 }
9148 }
9149
9150 //------------------------- Energy
9151
9152 //----------------------------------------------------------------
9153 float GetEnergy()
9154 {
9155 float energy = 0;
9156 if (HasEnergyManager())
9157 {
9158 energy = GetCompEM().GetEnergy();
9159 }
9160 return energy;
9161 }
9162
9163
9164 override void OnEnergyConsumed()
9165 {
9166 super.OnEnergyConsumed();
9167
9169 }
9170
9171 override void OnEnergyAdded()
9172 {
9173 super.OnEnergyAdded();
9174
9176 }
9177
9178 // Converts energy (from Energy Manager) to quantity, if enabled.
9180 {
9181 if (g_Game.IsServer() && HasEnergyManager() && GetCompEM().HasConversionOfEnergyToQuantity())
9182 {
9183 if (HasQuantity())
9184 {
9185 float energy_0to1 = GetCompEM().GetEnergy0To1();
9186 SetQuantityNormalized(energy_0to1);
9187 }
9188 }
9189 }
9190
9191 //----------------------------------------------------------------
9192 float GetHeatIsolationInit()
9193 {
9194 return ConfigGetFloat("heatIsolation");
9195 }
9196
9197 float GetHeatIsolation()
9198 {
9199 return m_HeatIsolation;
9200 }
9201
9202 float GetDryingIncrement(string pIncrementName)
9203 {
9204 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Drying %2", GetType(), pIncrementName);
9205 if (g_Game.ConfigIsExisting(paramPath))
9206 return g_Game.ConfigGetFloat(paramPath);
9207
9208 return 0.0;
9209 }
9210
9211 float GetSoakingIncrement(string pIncrementName)
9212 {
9213 string paramPath = string.Format("CfgVehicles %1 EnvironmentWetnessIncrements Soaking %2", GetType(), pIncrementName);
9214 if (g_Game.ConfigIsExisting(paramPath))
9215 return g_Game.ConfigGetFloat(paramPath);
9216
9217 return 0.0;
9218 }
9219 //----------------------------------------------------------------
9220 override void SetWet(float value, bool allow_client = false)
9221 {
9222 if (!IsServerCheck(allow_client))
9223 return;
9224
9225 float min = GetWetMin();
9226 float max = GetWetMax();
9227
9228 float previousValue = m_VarWet;
9229
9230 m_VarWet = Math.Clamp(value, min, max);
9231
9232 if (previousValue != m_VarWet)
9233 {
9234 SetVariableMask(VARIABLE_WET);
9235 OnWetChanged(m_VarWet, previousValue);
9236 }
9237 }
9238 //----------------------------------------------------------------
9239 override void AddWet(float value)
9240 {
9241 SetWet(GetWet() + value);
9242 }
9243 //----------------------------------------------------------------
9244 override void SetWetMax()
9245 {
9247 }
9248 //----------------------------------------------------------------
9249 override float GetWet()
9250 {
9251 return m_VarWet;
9252 }
9253 //----------------------------------------------------------------
9254 override float GetWetMax()
9255 {
9256 return m_VarWetMax;
9257 }
9258 //----------------------------------------------------------------
9259 override float GetWetMin()
9260 {
9261 return m_VarWetMin;
9262 }
9263 //----------------------------------------------------------------
9264 override float GetWetInit()
9265 {
9266 return m_VarWetInit;
9267 }
9268 //----------------------------------------------------------------
9269 override void OnWetChanged(float newVal, float oldVal)
9270 {
9271 EWetnessLevel newLevel = GetWetLevelInternal(newVal);
9272 EWetnessLevel oldLevel = GetWetLevelInternal(oldVal);
9273 if (newLevel != oldLevel)
9274 {
9275 OnWetLevelChanged(newLevel,oldLevel);
9276 }
9277 }
9278
9279 override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
9280 {
9281 SetWeightDirty();
9282 }
9283
9284 override EWetnessLevel GetWetLevel()
9285 {
9286 return GetWetLevelInternal(m_VarWet);
9287 }
9288
9289 //----------------------------------------------------------------
9290
9291 override void SetStoreLoad(bool value)
9292 {
9293 m_IsStoreLoad = value;
9294 }
9295
9296 override bool IsStoreLoad()
9297 {
9298 return m_IsStoreLoad;
9299 }
9300
9301 override void SetStoreLoadedQuantity(float value)
9302 {
9303 m_StoreLoadedQuantity = value;
9304 }
9305
9306 override float GetStoreLoadedQuantity()
9307 {
9308 return m_StoreLoadedQuantity;
9309 }
9310
9311 //----------------------------------------------------------------
9312
9313 float GetItemModelLength()
9314 {
9315 if (ConfigIsExisting("itemModelLength"))
9316 {
9317 return ConfigGetFloat("itemModelLength");
9318 }
9319 return 0;
9320 }
9321
9322 float GetItemAttachOffset()
9323 {
9324 if (ConfigIsExisting("itemAttachOffset"))
9325 {
9326 return ConfigGetFloat("itemAttachOffset");
9327 }
9328 return 0;
9329 }
9330
9331 override void SetCleanness(int value, bool allow_client = false)
9332 {
9333 if (!IsServerCheck(allow_client))
9334 return;
9335
9336 int previousValue = m_Cleanness;
9337
9338 m_Cleanness = Math.Clamp(value, m_CleannessMin, m_CleannessMax);
9339
9340 if (previousValue != m_Cleanness)
9341 SetVariableMask(VARIABLE_CLEANNESS);
9342 }
9343
9344 override int GetCleanness()
9345 {
9346 return m_Cleanness;
9347 }
9348
9350 {
9351 return true;
9352 }
9353
9354 //----------------------------------------------------------------
9355 // ATTACHMENT LOCKING
9356 // Getters relevant to generic ActionLockAttachment
9357 int GetLockType()
9358 {
9359 return m_LockType;
9360 }
9361
9362 string GetLockSoundSet()
9363 {
9364 return m_LockSoundSet;
9365 }
9366
9367 //----------------------------------------------------------------
9368 //------------------------- Color
9369 // sets items color variable given color components
9370 override void SetColor(int r, int g, int b, int a)
9371 {
9376 SetVariableMask(VARIABLE_COLOR);
9377 }
9379 override void GetColor(out int r,out int g,out int b,out int a)
9380 {
9385 }
9386
9387 bool IsColorSet()
9388 {
9389 return IsVariableSet(VARIABLE_COLOR);
9390 }
9391
9393 string GetColorString()
9394 {
9395 int r,g,b,a;
9396 GetColor(r,g,b,a);
9397 r = r/255;
9398 g = g/255;
9399 b = b/255;
9400 a = a/255;
9401 return MiscGameplayFunctions.GetColorString(r, g, b, a);
9402 }
9403 //----------------------------------------------------------------
9404 //------------------------- LiquidType
9405
9406 override void SetLiquidType(int value, bool allow_client = false)
9407 {
9408 if (!IsServerCheck(allow_client))
9409 return;
9410
9411 int old = m_VarLiquidType;
9412 m_VarLiquidType = value;
9413 OnLiquidTypeChanged(old,value);
9414 SetVariableMask(VARIABLE_LIQUIDTYPE);
9415 }
9416
9417 int GetLiquidTypeInit()
9418 {
9419 return ConfigGetInt("varLiquidTypeInit");
9420 }
9421
9422 override int GetLiquidType()
9423 {
9424 return m_VarLiquidType;
9425 }
9426
9427 protected void OnLiquidTypeChanged(int oldType, int newType)
9428 {
9429 if (newType == LIQUID_NONE && GetIsFrozen())
9430 SetFrozen(false);
9431 }
9432
9434 void UpdateQuickbarShortcutVisibility(PlayerBase player)
9435 {
9436 player.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
9437 }
9438
9439 // -------------------------------------------------------------------------
9441 void OnInventoryEnter(Man player)
9442 {
9443 PlayerBase nplayer;
9444 if (PlayerBase.CastTo(nplayer, player))
9445 {
9446 m_CanPlayImpactSound = true;
9447 nplayer.SetEnableQuickBarEntityShortcut(this,!GetHierarchyParent() || GetHierarchyParent().GetInventory().AreChildrenAccessible());
9448 }
9449 }
9450
9451 // -------------------------------------------------------------------------
9453 void OnInventoryExit(Man player)
9454 {
9455 PlayerBase nplayer;
9456 if (PlayerBase.CastTo(nplayer,player))
9457 {
9458 nplayer.SetEnableQuickBarEntityShortcut(this, false);
9459 }
9460
9461 player.GetHumanInventory().ClearUserReservedLocationForContainer(this);
9462
9463 if (HasEnergyManager())
9464 {
9465 GetCompEM().UpdatePlugState(); // Unplug the el. device if it's necesarry.
9466 }
9467 }
9468
9469 // ADVANCED PLACEMENT EVENTS
9470 override void OnPlacementStarted(Man player)
9471 {
9472 super.OnPlacementStarted(player);
9473
9474 SetTakeable(false);
9475 }
9476
9477 override void OnPlacementComplete(Man player, vector position = "0 0 0", vector orientation = "0 0 0")
9478 {
9479 if (m_AdminLog)
9480 {
9481 m_AdminLog.OnPlacementComplete(player, this);
9482 }
9483
9484 super.OnPlacementComplete(player, position, orientation);
9485 }
9486
9487 //-----------------------------
9488 // AGENT SYSTEM
9489 //-----------------------------
9490 //--------------------------------------------------------------------------
9491 bool ContainsAgent(int agent_id)
9492 {
9493 if (agent_id & m_AttachedAgents)
9494 {
9495 return true;
9496 }
9497 else
9498 {
9499 return false;
9500 }
9501 }
9502
9503 //--------------------------------------------------------------------------
9504 override void RemoveAgent(int agent_id)
9505 {
9506 if (ContainsAgent(agent_id))
9507 {
9508 m_AttachedAgents = ~agent_id & m_AttachedAgents;
9509 }
9510 }
9511
9512 //--------------------------------------------------------------------------
9513 override void RemoveAllAgents()
9514 {
9515 m_AttachedAgents = 0;
9516 }
9517 //--------------------------------------------------------------------------
9518 override void RemoveAllAgentsExcept(int agent_to_keep)
9519 {
9520 m_AttachedAgents = m_AttachedAgents & agent_to_keep;
9521 }
9522 // -------------------------------------------------------------------------
9523 override void InsertAgent(int agent, float count = 1)
9524 {
9525 if (count < 1)
9526 return;
9527 //Debug.Log("Inserting Agent on item: " + agent.ToString() +" count: " + count.ToString());
9529 }
9530
9532 void TransferAgents(int agents)
9533 {
9535 }
9536
9537 // -------------------------------------------------------------------------
9538 override int GetAgents()
9539 {
9540 return m_AttachedAgents;
9541 }
9542 //----------------------------------------------------------------------
9543
9544 /*int GetContaminationType()
9545 {
9546 int contamination_type;
9547
9548 const int CONTAMINATED_MASK = eAgents.CHOLERA | eAgents.INFLUENZA | eAgents.SALMONELLA | eAgents.BRAIN;
9549 const int POISONED_MASK = eAgents.FOOD_POISON | eAgents.CHEMICAL_POISON;
9550 const int NERVE_GAS_MASK = eAgents.CHEMICAL_POISON;
9551 const int DIRTY_MASK = eAgents.WOUND_AGENT;
9552
9553 Edible_Base edible = Edible_Base.Cast(this);
9554 int agents = GetAgents();
9555 if (edible)
9556 {
9557 NutritionalProfile profile = Edible_Base.GetNutritionalProfile(edible);
9558 if (profile)
9559 {
9560 agents = agents | profile.GetAgents();//merge item's agents with nutritional agents
9561 }
9562 }
9563 if (agents & CONTAMINATED_MASK)
9564 {
9565 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_CONTAMINATED;
9566 }
9567 if (agents & POISONED_MASK)
9568 {
9569 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_POISONED;
9570 }
9571 if (agents & NERVE_GAS_MASK)
9572 {
9573 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_NERVE_GAS;
9574 }
9575 if (agents & DIRTY_MASK)
9576 {
9577 contamination_type = contamination_type | EContaminationTypes.ITEM_BADGE_DIRTY;
9578 }
9579
9580 return agents;
9581 }*/
9582
9583 // -------------------------------------------------------------------------
9584 bool LoadAgents(ParamsReadContext ctx, int version)
9585 {
9586 if (!ctx.Read(m_AttachedAgents))
9587 return false;
9588 return true;
9589 }
9590 // -------------------------------------------------------------------------
9592 {
9593
9595 }
9596 // -------------------------------------------------------------------------
9597
9599 override void CheckForRoofLimited(float timeTresholdMS = 3000)
9600 {
9601 super.CheckForRoofLimited(timeTresholdMS);
9602
9603 float time = g_Game.GetTime();
9604 if ((time - m_PreviousRoofTestTime) >= timeTresholdMS)
9605 {
9606 m_PreviousRoofTestTime = time;
9607 SetRoofAbove(MiscGameplayFunctions.IsUnderRoof(this));
9608 }
9609 }
9610
9611 // returns item's protection level against enviromental hazard, for masks with filters, returns the filters protection for valid filter, otherwise 0
9612 float GetProtectionLevel(int type, bool consider_filter = false, int system = 0)
9613 {
9614 if (IsDamageDestroyed() || (HasQuantity() && GetQuantity() <= 0))
9615 {
9616 return 0;
9617 }
9618
9619 if (GetInventory().GetAttachmentSlotsCount() != 0)//is it an item with attachable filter ?
9620 {
9621 ItemBase filter = ItemBase.Cast(FindAttachmentBySlotName("GasMaskFilter"));
9622 if (filter)
9623 return filter.GetProtectionLevel(type, false, system);//it's a valid filter, return the protection
9624 else
9625 return 0;//otherwise return 0 when no filter attached
9626 }
9627
9628 string subclassPath, entryName;
9629
9630 switch (type)
9631 {
9632 case DEF_BIOLOGICAL:
9633 entryName = "biological";
9634 break;
9635 case DEF_CHEMICAL:
9636 entryName = "chemical";
9637 break;
9638 default:
9639 entryName = "biological";
9640 break;
9641 }
9642
9643 subclassPath = "CfgVehicles " + this.GetType() + " Protection ";
9644
9645 return g_Game.ConfigGetFloat(subclassPath + entryName);
9646 }
9647
9648
9649
9651 override void EEOnCECreate()
9652 {
9653 if (!IsMagazine())
9655
9657 }
9658
9659
9660 //-------------------------
9661 // OPEN/CLOSE USER ACTIONS
9662 //-------------------------
9664 void Open();
9665 void Close();
9666 bool IsOpen()
9667 {
9668 return true;
9669 }
9670
9671 override bool CanDisplayCargo()
9672 {
9673 return IsOpen();
9674 }
9675
9676
9677 // ------------------------------------------------------------
9678 // CONDITIONS
9679 // ------------------------------------------------------------
9680 override bool CanPutInCargo(EntityAI parent)
9681 {
9682 if (parent)
9683 {
9684 if (parent.IsInherited(DayZInfected))
9685 return true;
9686
9687 if (!parent.IsRuined())
9688 return true;
9689 }
9690
9691 return true;
9692 }
9693
9694 override bool CanPutAsAttachment(EntityAI parent)
9695 {
9696 if (!super.CanPutAsAttachment(parent))
9697 {
9698 return false;
9699 }
9700
9701 if (!IsRuined() && !parent.IsRuined())
9702 {
9703 return true;
9704 }
9705
9706 return false;
9707 }
9708
9709 override bool CanReceiveItemIntoCargo(EntityAI item)
9710 {
9711 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9712 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9713 // return false;
9714
9715 return super.CanReceiveItemIntoCargo(item);
9716 }
9717
9718 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
9719 {
9720 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9721 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9722 // return false;
9723
9724 GameInventory attachmentInv = attachment.GetInventory();
9725 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
9726 {
9727 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
9728 return false;
9729 }
9730
9731 InventoryLocation loc = new InventoryLocation();
9732 attachment.GetInventory().GetCurrentInventoryLocation(loc);
9733 if (loc && loc.IsValid() && !GetInventory().AreChildrenAccessible())
9734 return false;
9735
9736 return super.CanReceiveAttachment(attachment, slotId);
9737 }
9738
9739 override bool CanReleaseAttachment(EntityAI attachment)
9740 {
9741 if (!super.CanReleaseAttachment(attachment))
9742 return false;
9743
9744 return GetInventory().AreChildrenAccessible();
9745 }
9746
9747 /*override bool CanLoadAttachment(EntityAI attachment)
9748 {
9749 //removed 15.06. coz of loading from storage -> after load items in cargo was lost -> waiting for proper solution
9750 //if (GetHealthLevel() == GameConstants.STATE_RUINED)
9751 // return false;
9752
9753 GameInventory attachmentInv = attachment.GetInventory();
9754 if (attachmentInv && attachmentInv.GetCargo() && attachmentInv.GetCargo().GetItemCount() > 0)
9755 {
9756 bool boo = (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase));
9757 ErrorEx("CanLoadAttachment | this: " + this + " | attachment: " + attachment + " | boo: " + boo,ErrorExSeverity.INFO);
9758
9759 if (GetHierarchyParent() && !GetHierarchyParent().IsInherited(PlayerBase))
9760 return false;
9761 }
9762
9763 return super.CanLoadAttachment(attachment);
9764 }*/
9765
9766 // Plays muzzle flash particle effects
9767 static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9768 {
9769 int id = muzzle_owner.GetMuzzleID();
9770 array<ref WeaponParticlesOnFire> WPOF_array = m_OnFireEffect.Get(id);
9771
9772 if (WPOF_array)
9773 {
9774 for (int i = 0; i < WPOF_array.Count(); i++)
9775 {
9776 WeaponParticlesOnFire WPOF = WPOF_array.Get(i);
9777
9778 if (WPOF)
9779 {
9780 WPOF.OnActivate(weapon, muzzle_index, ammoType, muzzle_owner, suppressor, config_to_search);
9781 }
9782 }
9783 }
9784 }
9785
9786 // Plays bullet eject particle effects (usually just smoke, the bullet itself is a 3D model and is not part of this function)
9787 static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9788 {
9789 int id = muzzle_owner.GetMuzzleID();
9790 array<ref WeaponParticlesOnBulletCasingEject> WPOBE_array = m_OnBulletCasingEjectEffect.Get(id);
9791
9792 if (WPOBE_array)
9793 {
9794 for (int i = 0; i < WPOBE_array.Count(); i++)
9795 {
9796 WeaponParticlesOnBulletCasingEject WPOBE = WPOBE_array.Get(i);
9797
9798 if (WPOBE)
9799 {
9800 WPOBE.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
9801 }
9802 }
9803 }
9804 }
9805
9806 // Plays all weapon overheating particles
9807 static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9808 {
9809 int id = muzzle_owner.GetMuzzleID();
9810 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
9811
9812 if (WPOOH_array)
9813 {
9814 for (int i = 0; i < WPOOH_array.Count(); i++)
9815 {
9816 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
9817
9818 if (WPOOH)
9819 {
9820 WPOOH.OnActivate(weapon, 0, ammoType, muzzle_owner, suppressor, config_to_search);
9821 }
9822 }
9823 }
9824 }
9825
9826 // Updates all weapon overheating particles
9827 static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9828 {
9829 int id = muzzle_owner.GetMuzzleID();
9830 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
9831
9832 if (WPOOH_array)
9833 {
9834 for (int i = 0; i < WPOOH_array.Count(); i++)
9835 {
9836 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
9837
9838 if (WPOOH)
9839 {
9840 WPOOH.OnUpdate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9841 }
9842 }
9843 }
9844 }
9845
9846 // Stops overheating particles
9847 static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
9848 {
9849 int id = muzzle_owner.GetMuzzleID();
9850 array<ref WeaponParticlesOnOverheating> WPOOH_array = weapon.m_OnOverheatingEffect.Get(id);
9851
9852 if (WPOOH_array)
9853 {
9854 for (int i = 0; i < WPOOH_array.Count(); i++)
9855 {
9856 WeaponParticlesOnOverheating WPOOH = WPOOH_array.Get(i);
9857
9858 if (WPOOH)
9859 {
9860 WPOOH.OnDeactivate(weapon, ammoType, muzzle_owner, suppressor, config_to_search);
9861 }
9862 }
9863 }
9864 }
9865
9866 //----------------------------------------------------------------
9867 //Item Behaviour - unified approach
9868 override bool IsHeavyBehaviour()
9869 {
9870 if (m_ItemBehaviour == 0)
9871 {
9872 return true;
9873 }
9874
9875 return false;
9876 }
9877
9878 override bool IsOneHandedBehaviour()
9879 {
9880 if (m_ItemBehaviour == 1)
9881 {
9882 return true;
9883 }
9884
9885 return false;
9886 }
9887
9888 override bool IsTwoHandedBehaviour()
9889 {
9890 if (m_ItemBehaviour == 2)
9891 {
9892 return true;
9893 }
9894
9895 return false;
9896 }
9897
9898 bool IsDeployable()
9899 {
9900 return false;
9901 }
9902
9904 float GetDeployTime()
9905 {
9906 return UATimeSpent.DEFAULT_DEPLOY;
9907 }
9908
9909
9910 //----------------------------------------------------------------
9911 // Item Targeting (User Actions)
9912 override void SetTakeable(bool pState)
9913 {
9914 m_IsTakeable = pState;
9915 SetSynchDirty();
9916 }
9917
9918 override bool IsTakeable()
9919 {
9920 return m_IsTakeable;
9921 }
9922
9923 // For cases where we want to show object widget which cant be taken to hands
9925 {
9926 return false;
9927 }
9928
9930 protected void PreLoadSoundAttachmentType()
9931 {
9932 string att_type = "None";
9933
9934 if (ConfigIsExisting("soundAttType"))
9935 {
9936 att_type = ConfigGetString("soundAttType");
9937 }
9938
9939 m_SoundAttType = att_type;
9940 }
9941
9942 override string GetAttachmentSoundType()
9943 {
9944 return m_SoundAttType;
9945 }
9946
9947 //----------------------------------------------------------------
9948 //SOUNDS - ItemSoundHandler
9949 //----------------------------------------------------------------
9950
9951 string GetPlaceSoundset(); // played when deploy starts
9952 string GetLoopDeploySoundset(); // played when deploy starts and stopped when it finishes
9953 string GetDeploySoundset(); // played when deploy sucessfully finishes
9954 string GetLoopFoldSoundset(); // played when fold starts and stopped when it finishes
9955 string GetFoldSoundset(); // played when fold sucessfully finishes
9956
9958 {
9959 if (!m_ItemSoundHandler)
9961
9962 return m_ItemSoundHandler;
9963 }
9964
9965 // override to initialize sounds
9966 protected void InitItemSounds()
9967 {
9968 if (GetPlaceSoundset() == string.Empty && GetDeploySoundset() == string.Empty && GetLoopDeploySoundset() == string.Empty && !GetInventoryItemType().SetDetachSoundEvent() && !GetInventoryItemType().SetAttachSoundEvent())
9969 return;
9970
9972
9973 if (GetPlaceSoundset() != string.Empty)
9974 handler.AddSound(SoundConstants.ITEM_PLACE, GetPlaceSoundset());
9975
9976 if (GetDeploySoundset() != string.Empty)
9977 handler.AddSound(SoundConstants.ITEM_DEPLOY, GetDeploySoundset());
9978
9979 SoundParameters params = new SoundParameters();
9980 params.m_Loop = true;
9981 if (GetLoopDeploySoundset() != string.Empty)
9982 handler.AddSound(SoundConstants.ITEM_DEPLOY_LOOP, GetLoopDeploySoundset(), params);
9983 }
9984
9985 // Start sound using ItemSoundHandler
9986 void StartItemSoundServer(int id, int slotId)
9987 {
9988 if (g_Game.IsServer() || !g_Game.IsMultiplayer()) // single player or server side multiplayer
9989 {
9990 m_SoundSyncSlotID = slotId;
9991 m_SoundSyncPlay = id;
9992
9993 SetSynchDirty();
9994
9995 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStartItemSoundServer); // in case one is queued already
9996 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStartItemSoundServer, 100);
9997 }
9998 }
9999
10000 void StartItemSoundServer(int id)
10001 {
10002 StartItemSoundServer(id, InventorySlots.INVALID);
10003 }
10004
10005 // Stop sound using ItemSoundHandler
10006 void StopItemSoundServer(int id)
10007 {
10008 if (!g_Game.IsServer())
10009 return;
10010
10011 m_SoundSyncStop = id;
10012 SetSynchDirty();
10013
10014 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(ClearStopItemSoundServer); // in case one is queued already
10015 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(ClearStopItemSoundServer, 100);
10016 }
10017
10018 protected void ClearStartItemSoundServer()
10019 {
10020 m_SoundSyncPlay = 0;
10021 m_SoundSyncSlotID = InventorySlots.INVALID;
10022 }
10023
10024 protected void ClearStopItemSoundServer()
10025 {
10026 m_SoundSyncStop = 0;
10027 }
10028
10029 void OnApply(PlayerBase player);
10030
10032 {
10033 return 1.0;
10034 };
10035 //returns applicable selection
10036 array<string> GetHeadHidingSelection()
10037 {
10039 }
10040
10042 {
10044 }
10045
10046 WrittenNoteData GetWrittenNoteData() {};
10047
10049 {
10050 SetDynamicPhysicsLifeTime(0.01);
10051 m_ItemBeingDroppedPhys = false;
10052 }
10053
10055 {
10056 array<string> zone_names = new array<string>;
10057 GetDamageZones(zone_names);
10058 for (int i = 0; i < zone_names.Count(); i++)
10059 {
10060 SetHealthMax(zone_names.Get(i),"Health");
10061 }
10062 SetHealthMax("","Health");
10063 }
10064
10066 void SetZoneDamageCEInit()
10067 {
10068 float global_health = GetHealth01("","Health");
10069 array<string> zones = new array<string>;
10070 GetDamageZones(zones);
10071 //set damage of all zones to match global health level
10072 for (int i = 0; i < zones.Count(); i++)
10073 {
10074 SetHealth01(zones.Get(i),"Health",global_health);
10075 }
10076 }
10077
10079 bool IsCoverFaceForShave(string slot_name)
10080 {
10081 return IsExclusionFlagPresent(PlayerBase.GetFaceCoverageShaveValues());
10082 }
10083
10084 void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10085 {
10086 if (!hasRootAsPlayer)
10087 {
10088 if (refParentIB)
10089 {
10090 // parent is wet
10091 if ((refParentIB.GetWet() >= GameConstants.STATE_SOAKING_WET) && (m_VarWet < m_VarWetMax))
10092 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_INSIDE);
10093 // parent has liquid inside
10094 else if ((refParentIB.GetLiquidType() != 0) && (refParentIB.GetQuantity() > 0) && (m_VarWet < m_VarWetMax))
10095 AddWet(delta * GameConstants.WETNESS_RATE_WETTING_LIQUID);
10096 // drying
10097 else if (m_VarWet > m_VarWetMin)
10098 AddWet(-1 * delta * GetDryingIncrement("ground") * 2);
10099 }
10100 else
10101 {
10102 // drying on ground or inside non-itembase (car, ...)
10103 if (m_VarWet > m_VarWetMin)
10104 AddWet(-1 * delta * GetDryingIncrement("ground"));
10105 }
10106 }
10107 }
10108
10109 void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10110 {
10112 {
10113 float target = g_Game.GetMission().GetWorldData().GetBaseEnvTemperatureAtObject(this);
10114 if (GetTemperature() != target || !IsFreezeThawProgressFinished())
10115 {
10116 float heatPermCoef = 1.0;
10117 EntityAI ent = this;
10118 while (ent)
10119 {
10120 heatPermCoef *= ent.GetHeatPermeabilityCoef();
10121 ent = ent.GetHierarchyParent();
10122 }
10123
10124 SetTemperatureEx(new TemperatureDataInterpolated(target,ETemperatureAccessTypes.ACCESS_WORLD,delta,GameConstants.TEMP_COEF_WORLD,heatPermCoef));
10125 }
10126 }
10127 }
10128
10129 void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
10130 {
10131 // hierarchy check for an item to decide whether it has some parent and it is in some player inventory
10132 EntityAI parent = GetHierarchyParent();
10133 if (!parent)
10134 {
10135 hasParent = false;
10136 hasRootAsPlayer = false;
10137 }
10138 else
10139 {
10140 hasParent = true;
10141 hasRootAsPlayer = (GetHierarchyRootPlayer() != null);
10142 refParentIB = ItemBase.Cast(parent);
10143 }
10144 }
10145
10146 protected void ProcessDecay(float delta, bool hasRootAsPlayer)
10147 {
10148 // this is stub, implemented on Edible_Base
10149 }
10150
10151 bool CanDecay()
10152 {
10153 // return true used on selected food clases so they can decay
10154 return false;
10155 }
10156
10157 protected bool CanProcessDecay()
10158 {
10159 // this is stub, implemented on Edible_Base class
10160 // used to determine whether it is still necessary for the food to decay
10161 return false;
10162 }
10163
10164 protected bool CanHaveWetness()
10165 {
10166 // return true used on selected items that have a wetness effect
10167 return false;
10168 }
10169
10171 bool CanBeConsumed(ConsumeConditionData data = null)
10172 {
10173 return !GetIsFrozen() && IsOpen();
10174 }
10175
10176 override void ProcessVariables()
10177 {
10178 bool hasParent = false, hasRootAsPlayer = false;
10179 ItemBase refParentIB;
10180
10181 bool wwtu = g_Game.IsWorldWetTempUpdateEnabled();
10182 bool foodDecay = g_Game.IsFoodDecayEnabled();
10183
10184 if (wwtu || foodDecay)
10185 {
10186 bool processWetness = wwtu && CanHaveWetness();
10187 bool processTemperature = wwtu && CanHaveTemperature();
10188 bool processDecay = foodDecay && CanDecay() && CanProcessDecay();
10189
10190 if (processWetness || processTemperature || processDecay)
10191 {
10192 HierarchyCheck(hasParent, hasRootAsPlayer, refParentIB);
10193
10194 if (processWetness)
10195 ProcessItemWetness(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10196
10197 if (processTemperature)
10198 ProcessItemTemperature(m_ElapsedSinceLastUpdate, hasParent, hasRootAsPlayer, refParentIB);
10199
10200 if (processDecay)
10201 ProcessDecay(m_ElapsedSinceLastUpdate, hasRootAsPlayer);
10202 }
10203 }
10204 }
10205
10208 {
10209 return m_TemperaturePerQuantityWeight * GameConstants.ITEM_TEMPERATURE_QUANTITY_WEIGHT_MULTIPLIER;
10210 }
10211
10212 override float GetTemperatureFreezeThreshold()
10213 {
10215 return Liquid.GetFreezeThreshold(GetLiquidType());
10216
10217 return super.GetTemperatureFreezeThreshold();
10218 }
10219
10220 override float GetTemperatureThawThreshold()
10221 {
10223 return Liquid.GetThawThreshold(GetLiquidType());
10224
10225 return super.GetTemperatureThawThreshold();
10226 }
10227
10228 override float GetItemOverheatThreshold()
10229 {
10231 return Liquid.GetBoilThreshold(GetLiquidType());
10232
10233 return super.GetItemOverheatThreshold();
10234 }
10235
10236 override float GetTemperatureFreezeTime()
10237 {
10238 if (HasQuantity())
10239 return Math.Lerp(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureFreezeTime()),GetQuantityNormalized());
10240
10241 return super.GetTemperatureFreezeTime();
10242 }
10243
10244 override float GetTemperatureThawTime()
10245 {
10246 if (HasQuantity())
10247 return Math.Lerp(GameConstants.TEMPERATURE_TIME_THAW_MIN,Math.Max(GameConstants.TEMPERATURE_TIME_FREEZE_MIN,super.GetTemperatureThawTime()),GetQuantityNormalized());
10248
10249 return super.GetTemperatureThawTime();
10250 }
10251
10253 void AffectLiquidContainerOnFill(int liquid_type, float amount);
10255 void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature);
10256
10257 bool IsCargoException4x3(EntityAI item)
10258 {
10259 return (item.IsKindOf("Cauldron") || item.IsKindOf("Pot") || item.IsKindOf("FryingPan") || item.IsKindOf("SmallProtectorCase") || (item.IsKindOf("PortableGasStove") && item.FindAttachmentBySlotName("CookingEquipment")));
10260 }
10261
10263 {
10264 MiscGameplayFunctions.TransferItemProperties(oldItem, this);
10265 }
10266
10268 void AddLightSourceItem(ItemBase lightsource)
10269 {
10270 m_LightSourceItem = lightsource;
10271 }
10272
10274 {
10275 m_LightSourceItem = null;
10276 }
10277
10279 {
10280 return m_LightSourceItem;
10281 }
10282
10284 array<int> GetValidFinishers()
10285 {
10286 return null;
10287 }
10288
10290 bool GetActionWidgetOverride(out typename name)
10291 {
10292 return false;
10293 }
10294
10295 bool PairWithDevice(notnull ItemBase otherDevice)
10296 {
10297 if (g_Game.IsServer())
10298 {
10299 ItemBase explosive = otherDevice;
10301 if (!trg)
10302 {
10303 trg = RemoteDetonatorTrigger.Cast(otherDevice);
10304 explosive = this;
10305 }
10306
10307 explosive.PairRemote(trg);
10308 trg.SetControlledDevice(explosive);
10309
10310 int persistentID = RemotelyActivatedItemBehaviour.GeneratePersistentID();
10311 trg.SetPersistentPairID(persistentID);
10312 explosive.SetPersistentPairID(persistentID);
10313
10314 return true;
10315 }
10316 return false;
10317 }
10318
10320 float GetBaitEffectivity()
10321 {
10322 float ret = 1.0;
10323 if (HasQuantity())
10324 ret *= GetQuantityNormalized();
10325 ret *= GetHealth01();
10326
10327 return ret;
10328 }
10329
10330 #ifdef DEVELOPER
10331 override void SetDebugItem()
10332 {
10333 super.SetDebugItem();
10334 _itemBase = this;
10335 }
10336
10337 override string GetDebugText()
10338 {
10339 string text = super.GetDebugText();
10340
10341 text += string.Format("Heat isolation(raw): %1\n", GetHeatIsolation());
10342 text += string.Format("Heat isolation(modified): %1\n", MiscGameplayFunctions.GetCurrentItemHeatIsolation(this));
10343
10344 return text;
10345 }
10346 #endif
10347
10348 bool CanBeUsedForSuicide()
10349 {
10350 return true;
10351 }
10352
10354 //DEPRECATED BELOW
10356 // Backwards compatibility
10357 void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
10358 {
10359 ProcessItemWetness(delta, hasParent, hasRootAsPlayer, refParentIB);
10360 ProcessItemTemperature(delta, hasParent, hasRootAsPlayer, refParentIB);
10361 }
10362
10363 // replaced by ItemSoundHandler
10364 protected EffectSound m_SoundDeployFinish;
10365 protected EffectSound m_SoundPlace;
10366 protected EffectSound m_DeployLoopSoundEx;
10367 protected EffectSound m_SoundDeploy;
10368 bool m_IsPlaceSound;
10369 bool m_IsDeploySound;
10371
10372 string GetDeployFinishSoundset();
10373 void PlayDeploySound();
10374 void PlayDeployFinishSound();
10375 void PlayPlaceSound();
10376 void PlayDeployLoopSoundEx();
10377 void StopDeployLoopSoundEx();
10378 void SoundSynchRemoteReset();
10379 void SoundSynchRemote();
10380 bool UsesGlobalDeploy(){return false;}
10381 bool CanPlayDeployLoopSound(){return false;}
10383 bool IsPlaceSound(){return m_IsPlaceSound;}
10384 bool IsDeploySound(){return m_IsDeploySound;}
10385 void SetIsPlaceSound(bool is_place_sound);
10386 void SetIsDeploySound(bool is_deploy_sound);
10387
10388 [Obsolete("Use ItemSoundHandler instead")]
10390 void PlayAttachSound(string slot_type)
10391 {
10392 if (!g_Game.IsDedicatedServer())
10393 {
10394 if (ConfigIsExisting("attachSoundSet"))
10395 {
10396 string cfg_path = "";
10397 string soundset = "";
10398 string type_name = GetType();
10399
10400 TStringArray cfg_soundset_array = new TStringArray;
10401 TStringArray cfg_slot_array = new TStringArray;
10402 ConfigGetTextArray("attachSoundSet",cfg_soundset_array);
10403 ConfigGetTextArray("attachSoundSlot",cfg_slot_array);
10404
10405 if (cfg_soundset_array.Count() > 0 && cfg_soundset_array.Count() == cfg_slot_array.Count())
10406 {
10407 for (int i = 0; i < cfg_soundset_array.Count(); i++)
10408 {
10409 if (cfg_slot_array[i] == slot_type)
10410 {
10411 soundset = cfg_soundset_array[i];
10412 break;
10413 }
10414 }
10415 }
10416
10417 if (soundset != "")
10418 {
10419 EffectSound sound = SEffectManager.PlaySound(soundset, GetPosition());
10420 sound.SetAutodestroy(true);
10421 }
10422 }
10423 }
10424 }
10425
10426 void PlayDetachSound(string slot_type) {}
10427}
10428
10429EntityAI SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
10430{
10431 EntityAI entity = SpawnEntity(object_name, loc, ECE_IN_INVENTORY, RF_DEFAULT);
10432 if (entity)
10433 {
10434 bool is_item = entity.IsInherited(ItemBase);
10435 if (is_item && full_quantity)
10436 {
10437 ItemBase item = ItemBase.Cast(entity);
10438 item.SetQuantity(item.GetQuantityInit());
10439 }
10440 }
10441 else
10442 {
10443 ErrorEx("Cannot spawn entity: " + object_name,ErrorExSeverity.INFO);
10444 return NULL;
10445 }
10446 return entity;
10447}
10448
10449void SetupSpawnedItem(ItemBase item, float health, float quantity)
10450{
10451 if (item)
10452 {
10453 if (health > 0)
10454 item.SetHealth("", "", health);
10455
10456 if (item.CanHaveTemperature())
10457 {
10458 item.SetTemperatureDirect(GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE);
10459 if (item.CanFreeze())
10460 item.SetFrozen(false);
10461 }
10462
10463 if (item.HasEnergyManager())
10464 {
10465 if (quantity >= 0)
10466 {
10467 item.GetCompEM().SetEnergy0To1(quantity);
10468 }
10469 else
10470 {
10471 item.GetCompEM().SetEnergy(Math.AbsFloat(quantity));
10472 }
10473 }
10474 else if (item.IsMagazine())
10475 {
10476 Magazine mag = Magazine.Cast(item);
10477 if (quantity >= 0)
10478 {
10479 mag.ServerSetAmmoCount(mag.GetAmmoMax() * quantity);
10480 }
10481 else
10482 {
10483 mag.ServerSetAmmoCount(Math.AbsFloat(quantity));
10484 }
10485
10486 }
10487 else
10488 {
10489 if (quantity >= 0)
10490 {
10491 item.SetQuantityNormalized(quantity, false);
10492 }
10493 else
10494 {
10495 item.SetQuantity(Math.AbsFloat(quantity));
10496 }
10497
10498 }
10499 }
10500}
10501
10502#ifdef DEVELOPER
10503ItemBase _itemBase;//watched item goes here(LCTRL+RMB->Watch)
10504#endif
Param4< int, int, string, int > TSelectableActionInfoWithColor
Param3 TSelectableActionInfo
EWetnessLevel
Определения 3_Game/DayZ/Entities/EntityAI.c:2
bool SetAttachSoundEvent()
void InventoryItemType()
bool SetDetachSoundEvent()
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
const int INPUT_UDT_ITEM_MANIPULATION
class LogManager EntityAI
eBleedingSourceType GetType()
ItemSuppressor SuppressorBase
void ActionDropItem()
Определения ActionDropItem.c:34
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Определения ActionManagerClient.c:1
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void RemoveAction(typename actionName)
Определения AdvancedCommunication.c:252
TInputActionMap m_InputActionMap
Определения AdvancedCommunication.c:137
bool m_ActionsInitialize
Определения AdvancedCommunication.c:138
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Определения AdvancedCommunication.c:202
void InitializeActions()
Определения AdvancedCommunication.c:190
string Debug()
Определения CachedEquipmentStorageBase.c:29
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:36
const int RF_DEFAULT
Определения CentralEconomy.c:65
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
PlayerSpawnPreset slotName
Open
Implementations only.
override void EEOnCECreate()
Определения ContaminatedArea_Dynamic.c:42
map
Определения ControlsXboxNew.c:4
CookingMethodType
Определения Cooking.c:2
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
DayZGame g_Game
Определения DayZGame.c:3942
DayZGame GetDayZGame()
Определения DayZGame.c:3944
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
PluginAdminLog m_AdminLog
Определения EmoteManager.c:159
const int MIN
Определения EnConvert.c:28
const int MAX
Определения EnConvert.c:27
float GetTemperature()
Определения Environment.c:500
override bool IsExplosive()
Определения ExplosivesBase.c:59
override bool IsPrepareToDelete()
Определения FireplaceBase.c:643
override bool CanHaveTemperature()
Определения FireplaceBase.c:561
class GP5GasMask extends MaskBase ItemBase
proto GizmoApi GetGizmoApi()
Empty
Определения Hand_States.c:14
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:18
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
bool DamageItemInCargo(float damage)
Определения ItemBase.c:6453
static bool HasDebugActionsMask(int mask)
Определения ItemBase.c:5680
bool HidesSelectionBySlot()
Определения ItemBase.c:9413
float m_VarWetMin
Определения ItemBase.c:4937
void SplitItem(PlayerBase player)
Определения ItemBase.c:6908
void CopyScriptPropertiesFrom(EntityAI oldItem)
Определения ItemBase.c:9634
override void InsertAgent(int agent, float count=1)
Определения ItemBase.c:8895
override float GetQuantityNormalized()
Gets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8330
static void SetDebugActionsMask(int mask)
Определения ItemBase.c:5685
void SetIsDeploySound(bool is_deploy_sound)
bool IsOpen()
Определения ItemBase.c:9038
void SplitItemToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6875
override bool IsHeavyBehaviour()
Определения ItemBase.c:9240
override void SetWetMax()
Определения ItemBase.c:8616
bool IsCoverFaceForShave(string slot_name)
DEPRECATED in use, but returns correct values nontheless. Check performed elsewhere.
Определения ItemBase.c:9451
void ClearStartItemSoundServer()
Определения ItemBase.c:9390
float m_VarWet
Определения ItemBase.c:4934
void ProcessItemTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9481
map< typename, ref ActionOverrideData > TActionAnimOverrideMap
Определения ItemBase.c:3
override void RemoveAllAgentsExcept(int agent_to_keep)
Определения ItemBase.c:8890
static ref map< int, ref array< ref WeaponParticlesOnBulletCasingEject > > m_OnBulletCasingEjectEffect
Определения ItemBase.c:4997
bool CanBeMovedOverride()
Определения ItemBase.c:7600
override void SetWet(float value, bool allow_client=false)
Определения ItemBase.c:8592
ref TIntArray m_SingleUseActions
Определения ItemBase.c:4983
void StartItemSoundServer(int id, int slotId)
Определения ItemBase.c:9358
override void ProcessVariables()
Определения ItemBase.c:9548
ref TStringArray m_HeadHidingSelections
Определения ItemBase.c:5011
float GetWeightSpecialized(bool forceRecalc=false)
Определения ItemBase.c:8423
bool LoadAgents(ParamsReadContext ctx, int version)
Определения ItemBase.c:8956
void UpdateQuickbarShortcutVisibility(PlayerBase player)
To be called on moving item within character's inventory; 'player' should never be null.
Определения ItemBase.c:8806
void OverrideActionAnimation(typename action, int commandUID, int stanceMask=-1, int commandUIDProne=-1)
Определения ItemBase.c:5271
ref array< ref OverheatingParticle > m_OverheatingParticles
Определения ItemBase.c:5009
override float GetTemperatureFreezeThreshold()
Определения ItemBase.c:9584
bool m_IsSoundSynchRemote
Определения ItemBase.c:9742
float m_OverheatingShots
Определения ItemBase.c:5004
void StopItemSoundServer(int id)
Определения ItemBase.c:9378
static void ToggleDebugActionsMask(int mask)
Определения ItemBase.c:5700
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:5424
override float GetTemperatureFreezeTime()
Определения ItemBase.c:9608
ref array< int > m_CompatibleLocks
Определения ItemBase.c:5021
bool CanBeCooked()
Определения ItemBase.c:7556
override void CombineItemsClient(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:5767
float m_TemperaturePerQuantityWeight
Определения ItemBase.c:5035
bool m_RecipesInitialized
Определения ItemBase.c:4919
void SplitIntoStackMax(EntityAI destination_entity, int slot_id, PlayerBase player)
Определения ItemBase.c:6546
override float GetTemperatureThawThreshold()
Определения ItemBase.c:9592
override void OnEnergyConsumed()
Определения ItemBase.c:8536
void RefreshAudioVisualsOnClient(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
cooking-related effect methods
Определения Bottle_Base.c:158
int GetNumberOfItems()
Returns the number of items in cargo, otherwise returns 0(non-cargo objects). Recursive.
Определения ItemBase.c:8462
override EWetnessLevel GetWetLevel()
Определения ItemBase.c:8656
float GetSingleInventoryItemWeight()
Определения ItemBase.c:8418
ref TIntArray m_InteractActions
Определения ItemBase.c:4985
void MessageToOwnerStatus(string text)
Send message to owner player in grey color.
Определения ItemBase.c:7620
float m_VarQuantity
Определения ItemBase.c:4925
bool CanPlayDeployLoopSound()
Определения ItemBase.c:9753
override float GetWetMax()
Определения ItemBase.c:8626
bool CanBeUsedForSuicide()
Определения ItemBase.c:9720
override void CombineItemsEx(EntityAI entity2, bool use_stack_max=true)
Определения ItemBase.c:7193
void OnItemInHandsPlayerSwimStart(PlayerBase player)
void SetIsHologram(bool is_hologram)
Определения ItemBase.c:5905
void OnSyncVariables(ParamsReadContext ctx)
DEPRECATED (most likely)
Определения ItemBase.c:7774
void DoAmmoExplosion()
Определения ItemBase.c:6388
static ref map< int, ref array< ref WeaponParticlesOnFire > > m_OnFireEffect
Определения ItemBase.c:4996
void SplitIntoStackMaxCargoClient(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6732
int GetItemSize()
Определения ItemBase.c:7585
bool m_CanBeMovedOverride
Определения ItemBase.c:4962
override string ChangeIntoOnAttach(string slot)
Определения ItemBase.c:6312
void UpdateOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5492
bool CanDecay()
Определения ItemBase.c:9523
ScriptedLightBase GetLight()
string GetPlaceSoundset()
bool AddQuantity(float value, bool destroy_config=true, bool destroy_forced=false)
add item quantity[related to varQuantity... config entry], destroy_config = true > if the quantity re...
Определения ItemBase.c:8303
void SetQuantityMax()
Определения ItemBase.c:8308
override float GetQuantity()
Определения ItemBase.c:8398
int m_ColorComponentR
Определения ItemBase.c:4974
int m_ShotsToStartOverheating
Определения ItemBase.c:5006
override void OnWetChanged(float newVal, float oldVal)
Определения ItemBase.c:8641
void StopOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5499
static void PlayFireParticles(ItemBase weapon, int muzzle_index, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9139
void OnOverheatingDecay()
Определения ItemBase.c:5462
float GetDryingIncrement(string pIncrementName)
Определения ItemBase.c:8574
void SoundSynchRemoteReset()
int m_Cleanness
Определения ItemBase.c:4940
bool HasMuzzle()
Returns true if this item has a muzzle (weapons, suppressors)
Определения ItemBase.c:5600
bool UsesGlobalDeploy()
Определения ItemBase.c:9752
int m_ItemBehaviour
Определения ItemBase.c:4955
override bool CanReleaseAttachment(EntityAI attachment)
Определения ItemBase.c:9111
float m_HeatIsolation
Определения ItemBase.c:4950
float m_VarWetInit
Определения ItemBase.c:4936
override void OnMovedInsideCargo(EntityAI container)
Определения ItemBase.c:5945
void SetCEBasedQuantity()
Определения ItemBase.c:5713
bool m_CanPlayImpactSound
Определения ItemBase.c:4946
override string GetAttachmentSoundType()
Определения ItemBase.c:9314
float GetOverheatingCoef()
Определения ItemBase.c:5519
array< string > GetHeadHidingSelection()
Определения ItemBase.c:9408
void PlayAttachSound(string slot_type)
Plays sound on item attach. Be advised, the config structure may slightly change in 1....
Определения ItemBase.c:9762
override bool IsStoreLoad()
Определения ItemBase.c:8668
int ComputeQuantityUsed(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7169
bool IsLightSource()
Определения ItemBase.c:5841
bool m_HasQuantityBar
Определения ItemBase.c:4968
void SetResultOfSplit(bool value)
Определения ItemBase.c:7164
void SplitIntoStackMaxCargo(EntityAI destination_entity, int idx, int row, int col)
Определения ItemBase.c:6796
void OnAttachmentQuantityChanged(ItemBase item)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6965
void UpdateAllOverheatingParticles()
Определения ItemBase.c:5527
float GetSoakingIncrement(string pIncrementName)
Определения ItemBase.c:8583
static void StopOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9219
override float GetStoreLoadedQuantity()
Определения ItemBase.c:8678
int m_LockType
Определения ItemBase.c:5022
const int ITEM_SOUNDS_MAX
Определения ItemBase.c:5027
bool m_CanBeDigged
Определения ItemBase.c:4969
float m_ItemAttachOffset
Определения ItemBase.c:4952
float GetItemModelLength()
Определения ItemBase.c:8685
bool m_ThrowItemOnDrop
Определения ItemBase.c:4960
override bool ReadVarsFromCTX(ParamsReadContext ctx, int version=-1)
Определения ItemBase.c:7919
override void CheckForRoofLimited(float timeTresholdMS=3000)
Roof check for entity, limited by time (anti-spam solution)
Определения ItemBase.c:8971
void Close()
float GetHeatIsolation()
Определения ItemBase.c:8569
void CombineItems(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7198
void TransferModifiers(PlayerBase reciever)
appears to be deprecated, legacy code
float GetTemperaturePerQuantityWeight()
Used in heat comfort calculations only!
Определения ItemBase.c:9579
bool CanHaveWetness()
Определения ItemBase.c:9536
int m_CleannessMin
Определения ItemBase.c:4942
void TransferAgents(int agents)
transfer agents from another item
Определения ItemBase.c:8904
string IDToName(int id)
Определения ItemBase.c:7767
bool CanBeConsumed(ConsumeConditionData data=null)
Items cannot be consumed if frozen by default. Override for exceptions.
Определения ItemBase.c:9543
float GetHeatIsolationInit()
Определения ItemBase.c:8564
void PlayPlaceSound()
void SetCanBeMovedOverride(bool setting)
Определения ItemBase.c:7607
override bool HasQuantity()
Определения ItemBase.c:8393
float m_VarWetPrev
Определения ItemBase.c:4935
int m_SoundSyncStop
Определения ItemBase.c:5029
bool IsCargoException4x3(EntityAI item)
Определения ItemBase.c:9629
ref TIntArray m_ContinuousActions
Определения ItemBase.c:4984
int GetMuzzleID()
Returns global muzzle ID. If not found, then it gets automatically registered.
Определения ItemBase.c:5609
void LoadParticleConfigOnFire(int id)
Определения ItemBase.c:5294
int m_VarLiquidType
Определения ItemBase.c:4954
int m_QuickBarBonus
Определения ItemBase.c:4956
void PreLoadSoundAttachmentType()
Attachment Sound Type getting from config file.
Определения ItemBase.c:9302
override float GetWetInit()
Определения ItemBase.c:8636
int m_ImpactSoundSurfaceHash
Определения ItemBase.c:4948
int m_SoundSyncPlay
Определения ItemBase.c:5028
int m_MaxOverheatingValue
Определения ItemBase.c:5007
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4931
bool m_IsTakeable
Определения ItemBase.c:4959
bool ShouldSplitQuantity(float quantity)
Определения ItemBase.c:6503
static ref map< string, int > m_WeaponTypeToID
Определения ItemBase.c:4999
string GetLockSoundSet()
Определения ItemBase.c:8734
string GetColorString()
Returns item's PROCEDURAL color as formated string, i.e. "#(argb,8,8,3)color(0.15,...
Определения ItemBase.c:8765
array< int > GetValidFinishers()
returns an array of possible finishers
Определения ItemBase.c:9656
void OnAttachmentQuantityChangedEx(ItemBase item, float delta)
Called on server side when some attachment's quantity is changed. Call super.OnAttachmentQuantityChan...
Определения ItemBase.c:6971
class ItemBase extends InventoryItem SpawnItemOnLocation(string object_name, notnull InventoryLocation loc, bool full_quantity)
Определения ItemBase.c:4911
ItemSoundHandler GetItemSoundHandler()
Определения ItemBase.c:9329
override int GetQuantityMin()
Определения ItemBase.c:8382
void SplitIntoStackMaxToInventoryLocationClient(notnull InventoryLocation dst)
Определения ItemBase.c:6711
override int GetQuickBarBonus()
Определения ItemBase.c:5179
override void SetTakeable(bool pState)
Определения ItemBase.c:9284
float m_OverheatingDecayInterval
Определения ItemBase.c:5008
void SetIsPlaceSound(bool is_place_sound)
override void SplitIntoStackMaxClient(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6523
void HierarchyCheck(out bool hasParent, out bool hasRootAsPlayer, out ItemBase refParentIB)
Определения ItemBase.c:9501
bool CanProcessDecay()
Определения ItemBase.c:9529
void RemoveAudioVisualsOnClient()
Определения Bottle_Base.c:151
void SoundSynchRemote()
static void AddDebugActionsMask(int mask)
Определения ItemBase.c:5690
void PlayDeployLoopSoundEx()
void RemoveLightSourceItem()
Определения ItemBase.c:9645
bool CanRepair(ItemBase item_repair_kit)
Определения ItemBase.c:7571
bool can_this_be_combined
Определения ItemBase.c:4964
EffectSound m_SoundDeploy
Определения ItemBase.c:9739
int m_SoundSyncSlotID
Определения ItemBase.c:5030
int m_Count
Определения ItemBase.c:4930
float GetBaitEffectivity()
generic effectivity as a bait for animal catching
Определения ItemBase.c:9692
float GetDeployTime()
how long it takes to deploy this item in seconds
Определения ItemBase.c:9276
override bool IsSplitable()
Определения ItemBase.c:6490
bool DamageItemAttachments(float damage)
Определения ItemBase.c:6473
override void WriteVarsToCTX(ParamsWriteContext ctx)
Определения ItemBase.c:7883
void ConvertEnergyToQuantity()
Определения ItemBase.c:8551
override void RemoveAllAgents()
Определения ItemBase.c:8885
override void SetQuantityToMinimum()
Определения ItemBase.c:8314
bool m_WantPlayImpactSound
Определения ItemBase.c:4945
override float GetTemperatureThawTime()
Определения ItemBase.c:9616
ref map< int, ref array< ref WeaponParticlesOnOverheating > > m_OnOverheatingEffect
Определения ItemBase.c:4998
int m_ColorComponentG
Определения ItemBase.c:4975
float m_StoreLoadedQuantity
Определения ItemBase.c:4932
void MessageToOwnerAction(string text)
Send message to owner player in yellow color.
Определения ItemBase.c:7638
int m_ColorComponentA
Определения ItemBase.c:4977
int m_VarQuantityInit
Определения ItemBase.c:4927
float GetFilterDamageRatio()
Определения ItemBase.c:5594
override void SetLiquidType(int value, bool allow_client=false)
Определения ItemBase.c:8778
void OnQuantityChanged(float delta)
Called on server side when this item's quantity is changed. Call super.OnQuantityChanged(); first whe...
Определения ItemBase.c:6942
void OnApply(PlayerBase player)
override void SetQuantityNormalized(float value, bool destroy_config=true, bool destroy_forced=false)
Sets quantity in normalized 0..1 form between the item's Min a Max values as defined by item's config...
Определения ItemBase.c:8321
bool m_HideSelectionsBySlot
Определения ItemBase.c:5012
bool IsOverheatingEffectActive()
Определения ItemBase.c:5457
void SetIsBeingPlaced(bool is_being_placed)
Определения ItemBase.c:5874
int GetLiquidContainerMask()
Определения ItemBase.c:5811
void SetInventoryLocationToVicinityOrCurrent(EntityAI root, inout InventoryLocation dst)
Определения ItemBase.c:7078
ref Timer m_CheckOverheating
Определения ItemBase.c:5005
void RegisterOverheatingParticle(Particle p, float min_heat_coef, float max_heat_coef, int particle_id, Object parent, vector local_pos, vector local_ori)
Определения ItemBase.c:5505
float GetEnergy()
Определения ItemBase.c:8525
bool CanBeDigged()
Определения ItemBase.c:5890
bool GetActionWidgetOverride(out typename name)
If we need a different (handheld)item action widget displayed, the logic goes in here.
Определения ItemBase.c:9662
bool IsNVG()
Определения ItemBase.c:5822
float GetUnitWeight(bool include_wetness=true)
Obsolete, use GetWeightEx instead.
Определения ItemBase.c:8485
void SetZoneDamageCEInit()
Sets zone damages to match randomized global health set by CE (CE spawn only)
Определения ItemBase.c:9438
bool m_IsDeploySound
Определения ItemBase.c:9741
bool CanEat()
Определения ItemBase.c:7531
static void PlayOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9179
override bool IsOneHandedBehaviour()
Определения ItemBase.c:9250
void AddLightSourceItem(ItemBase lightsource)
Adds a light source child.
Определения ItemBase.c:9640
bool IsLiquidContainer()
Определения ItemBase.c:5806
FoodStage GetFoodStage()
overridden on Edible_Base; so we don't have to parse configs all the time
Определения ItemBase.c:7551
override float GetSingleInventoryItemWeightEx()
Определения ItemBase.c:8409
void SaveAgents(ParamsWriteContext ctx)
Определения ItemBase.c:8963
override int GetTargetQuantityMax(int attSlotID=-1)
Определения ItemBase.c:8363
int m_CleannessInit
Определения ItemBase.c:4941
float GetDisinfectQuantity(int system=0, Param param1=null)
Определения ItemBase.c:5589
override int GetAgents()
Определения ItemBase.c:8910
int m_VarQuantityMax
Определения ItemBase.c:4929
override bool IsHologram()
Определения ItemBase.c:5885
float GetItemAttachOffset()
Определения ItemBase.c:8694
bool IsPlaceSound()
Определения ItemBase.c:9755
static int GetDebugActionsMask()
Определения ItemBase.c:5675
override int GetLiquidType()
Определения ItemBase.c:8794
void ProcessDecay(float delta, bool hasRootAsPlayer)
Определения ItemBase.c:9518
override bool IsItemBase()
Определения ItemBase.c:7684
void PlayDeploySound()
override bool IsTwoHandedBehaviour()
Определения ItemBase.c:9260
void ExplodeAmmo()
Определения ItemBase.c:6375
bool IsCombineAll(ItemBase other_item, bool use_stack_max=false)
Определения ItemBase.c:7154
float GetProtectionLevel(int type, bool consider_filter=false, int system=0)
Определения ItemBase.c:8984
static void PlayBulletCasingEjectParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9159
override void OnEnergyAdded()
Определения ItemBase.c:8543
void AffectLiquidContainerOnFill(int liquid_type, float amount)
from enviro source
void AffectLiquidContainerOnTransfer(int liquidType, float amount, float sourceLiquidTemperature)
from other liquid container source
string GetExplosiveTriggerSlotName()
Определения ItemBase.c:5834
EffectSound m_DeployLoopSoundEx
Определения ItemBase.c:9738
override void DeSerializeNumericalVars(array< float > floats)
Определения ItemBase.c:7824
void StopItemDynamicPhysics()
Определения ItemBase.c:9420
bool HasFoodStage()
Определения ItemBase.c:7544
override void SetStoreLoad(bool value)
Определения ItemBase.c:8663
float GetOverheatingValue()
Определения ItemBase.c:5419
bool ContainsAgent(int agent_id)
Определения ItemBase.c:8863
override void AddWet(float value)
Определения ItemBase.c:8611
bool IsLiquidPresent()
Определения ItemBase.c:5801
bool IsFullQuantity()
Определения ItemBase.c:8403
override void EOnContact(IEntity other, Contact extra)
Определения ItemBase.c:6084
void SplitIntoStackMaxHands(PlayerBase player)
Определения ItemBase.c:6847
void SplitIntoStackMaxHandsClient(PlayerBase player)
Определения ItemBase.c:6823
int m_CleannessMax
Определения ItemBase.c:4943
float m_VarStackMax
Определения ItemBase.c:4931
ref Timer m_PhysDropTimer
Определения ItemBase.c:5018
void MessageToOwnerFriendly(string text)
Send message to owner player in green color.
Определения ItemBase.c:7656
override void SetStoreLoadedQuantity(float value)
Определения ItemBase.c:8673
bool m_IsResultOfSplit string m_SoundAttType
distinguish if item has been created as new or it came from splitting (server only flag)
Определения ItemBase.c:4972
void CheckOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5440
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Определения ItemBase.c:5755
bool Repair(PlayerBase player, ItemBase item_repair_kit, float specialty_weight)
Определения ItemBase.c:7578
void OnLiquidTypeChanged(int oldType, int newType)
Определения ItemBase.c:8799
void StartOverheating(ItemBase weapon=null, string ammoType="", ItemBase muzzle_owner=null, ItemBase suppressor=null, string config_to_search="")
Определения ItemBase.c:5486
void PlayDeployFinishSound()
bool AllowFoodConsumption()
Определения ItemBase.c:8721
bool m_IsOverheatingEffectActive
Определения ItemBase.c:5003
int m_LiquidContainerMask
Определения ItemBase.c:4953
void ProcessItemWetness(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9456
override int GetCleanness()
Определения ItemBase.c:8716
bool PairWithDevice(notnull ItemBase otherDevice)
Определения ItemBase.c:9667
bool IsDeploySound()
Определения ItemBase.c:9756
static void RemoveDebugActionsMask(int mask)
Определения ItemBase.c:5695
static void UpdateOverheatingParticles(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
Определения ItemBase.c:9199
int m_VarQuantityMin
Определения ItemBase.c:4928
void PerformDamageSystemReinit()
Определения ItemBase.c:9426
override void ClearInventory()
Определения ItemBase.c:8504
static int m_LastRegisteredWeaponID
Определения ItemBase.c:5000
ItemBase GetLightSourceItem()
Определения ItemBase.c:9650
void MessageToOwnerImportant(string text)
Send message to owner player in red color.
Определения ItemBase.c:7674
override float GetItemOverheatThreshold()
Определения ItemBase.c:9600
void StopDeployLoopSoundEx()
bool m_CanThisBeSplit
Определения ItemBase.c:4965
override void SerializeNumericalVars(array< float > floats_out)
Определения ItemBase.c:7788
ItemBase SplitIntoStackMaxToInventoryLocationEx(notnull InventoryLocation dst)
Определения ItemBase.c:6762
float m_ItemModelLength
Определения ItemBase.c:4951
bool m_IsHologram
Определения ItemBase.c:4958
static int m_DebugActionsMask
Определения ItemBase.c:4918
void KillAllOverheatingParticles()
Определения ItemBase.c:5555
bool CanBeCookedOnStick()
Определения ItemBase.c:7561
override int GetQuantityMax()
Определения ItemBase.c:8349
void GetRecipesActions(Man player, out TSelectableActionInfoArray outputList)
Определения ItemBase.c:7232
void OnActivatedByTripWire()
bool IsColorSet()
Определения ItemBase.c:8759
override void RemoveAgent(int agent_id)
Определения ItemBase.c:8876
bool m_ItemBeingDroppedPhys
Определения ItemBase.c:4961
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:9066
void PlayDetachSound(string slot_type)
Определения ItemBase.c:9798
static ref map< typename, ref TInputActionMap > m_ItemTypeActionsMap
Определения ItemBase.c:4912
void ProcessItemWetnessAndTemperature(float delta, bool hasParent, bool hasRootAsPlayer, ItemBase refParentIB)
Определения ItemBase.c:9729
override bool IsBeingPlaced()
Определения ItemBase.c:5869
int GetQuantityInit()
Определения ItemBase.c:8387
float ComputeQuantityUsedEx(ItemBase other_item, bool use_stack_max=true)
Определения ItemBase.c:7174
bool IsResultOfSplit()
Определения ItemBase.c:7159
bool m_FixDamageSystemInit
Определения ItemBase.c:4963
float m_ImpactSpeed
Определения ItemBase.c:4947
bool m_IsStoreLoad
Определения ItemBase.c:4966
int GetLiquidTypeInit()
Определения ItemBase.c:8789
string GetDeployFinishSoundset()
ItemBase m_LightSourceItem
Определения ItemBase.c:4981
void LockToParent()
Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible i...
Определения ItemBase.c:5742
override void SplitIntoStackMaxEx(EntityAI destination_entity, int slot_id)
Определения ItemBase.c:6633
int m_AttachedAgents
Определения ItemBase.c:4989
string m_LockSoundSet
Определения ItemBase.c:5024
void LoadParticleConfigOnOverheating(int id)
Определения ItemBase.c:5363
float m_VarQuantityPrev
Определения ItemBase.c:4926
bool IsSoundSynchRemote()
Определения ItemBase.c:9754
bool m_CanShowQuantity
Определения ItemBase.c:4967
override void OnRightClick()
Определения ItemBase.c:7014
int m_ColorComponentB
Определения ItemBase.c:4976
static ref map< typename, ref TActionAnimOverrideMap > m_ItemActionOverrides
Определения ItemBase.c:4914
bool IsActionTargetVisible()
Определения ItemBase.c:9296
override void OnItemAttachmentSlotChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения ItemBase.c:6119
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6412
bool m_IsBeingPlaced
Определения ItemBase.c:4957
int NameToID(string name)
Определения ItemBase.c:7761
void ~ItemBase()
Определения ItemBase.c:5640
override void OnWetLevelChanged(EWetnessLevel newLevel, EWetnessLevel oldLevel)
Определения ItemBase.c:8651
void ClearStopItemSoundServer()
Определения ItemBase.c:9396
override string ChangeIntoOnDetach()
Определения ItemBase.c:6336
float m_VarWetMax
Определения ItemBase.c:4938
void SplitIntoStackMaxToInventoryLocation(notnull InventoryLocation dst)
Определения ItemBase.c:6757
int GetLockType()
Определения ItemBase.c:8729
EffectSound m_SoundDeployFinish
Определения ItemBase.c:9736
override float GetWet()
Определения ItemBase.c:8621
EffectSound m_SoundPlace
Определения ItemBase.c:9737
float GetQuantityNormalizedScripted()
Определения ItemBase.c:8335
override void SetCleanness(int value, bool allow_client=false)
Определения ItemBase.c:8703
bool m_IsPlaceSound
Определения ItemBase.c:9740
override float GetWetMin()
Определения ItemBase.c:8631
ref ItemSoundHandler m_ItemSoundHandler
Определения ItemBase.c:5032
override bool KindOf(string tag)
Определения ItemBase.c:7690
void ItemSoundHandler(ItemBase parent)
Определения ItemSoundHandler.c:31
string Type
Определения JsonDataContaminatedArea.c:11
EffectSound m_LockingSound
Определения Land_Underground_Entrance.c:336
string GetDebugText()
Определения ModifierBase.c:71
@ LOWEST
Определения PPEConstants.c:54
void PluginItemDiagnostic()
Определения PluginItemDiagnostic.c:74
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:325
override RemotelyActivatedItemBehaviour GetRemotelyActivatedItemBehaviour()
Определения RemoteDetonator.c:272
void RemoteDetonatorTrigger()
Определения RemoteDetonator.c:233
override void OnActivatedByItem(notnull ItemBase item)
Called when this item is activated by other.
Определения RemoteDetonator.c:305
int particle_id
Определения SmokeSimulation.c:28
ETemperatureAccessTypes
Определения TemperatureAccessConstants.c:2
override void Explode(int damageType, string ammoType="")
Определения Trap_LandMine.c:220
bool m_Initialized
Определения UiHintPanel.c:317
int GetID()
Определения ActionBase.c:1335
void OnItemLocationChanged(ItemBase item)
Определения ActionBase.c:974
GetInputType()
Определения ActionBase.c:221
int m_StanceMask
Определения ActionBase.c:25
int m_CommandUIDProne
Определения ActionBase.c:24
int m_CommandUID
Определения ActionBase.c:23
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
float GetEnergyAtSpawn()
Определения ComponentEnergyManager.c:1325
void SetEnergy0To1(float energy01)
Energy manager: Sets stored energy for this device between 0 and MAX based on relative input value be...
Определения ComponentEnergyManager.c:550
float GetEnergyMaxPristine()
Energy manager: Returns the maximum amount of energy this device can store. It's damage is NOT taken ...
Определения ComponentEnergyManager.c:1320
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:603
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
Определения EffectSound.c:274
override bool IsMan()
Определения 3_Game/DayZ/Entities/Man.c:48
proto native EntityAI GetAttachmentFromIndex(int index)
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
proto native int AttachmentCount()
Returns count of attachments attached to this item.
proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
proto void SelectObject(Object object)
proto void SelectPhysics(Physics physics)
Определения ItemBase.c:21
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetCol()
returns column of cargo if current type is Cargo / ProxyCargo
proto native int GetRow()
returns row of cargo if current type is Cargo / ProxyCargo
bool WriteToContext(ParamsWriteContext ctx)
Определения InventoryLocation.c:507
proto native int GetType()
returns type of InventoryLocation
proto native int GetIdx()
returns index of cargo if current type is Cargo / ProxyCargo
proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
sets current inventory location type to Cargo with coordinates (idx, row, col)
proto native bool GetFlip()
returns flip status of cargo
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:30
override bool CanDisplayCargo()
Определения TentBase.c:91
override void OnInventoryEnter(Man player)
Определения BarbedWire.c:203
override string GetFoldSoundset()
Определения BaseBuildingBase.c:108
override bool CanPutAsAttachment(EntityAI parent)
Определения ItemBase.c:7
override bool CanReceiveItemIntoCargo(EntityAI item)
Определения TentBase.c:934
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Определения GardenBase.c:199
override void OnWasDetached(EntityAI parent, int slot_id)
override void EEOnAfterLoad()
Определения GardenBase.c:242
override void EEDelete(EntityAI parent)
Определения BaseBuildingBase.c:68
override bool CanBeRepairedByCrafting()
Определения TentBase.c:86
override void OnPlacementStarted(Man player)
Определения BatteryCharger.c:376
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
Определения BarbedWire.c:357
override bool IsElectricAppliance()
Определения BatteryCharger.c:43
override bool IsItemTent()
Определения TentBase.c:81
override string GetLoopFoldSoundset()
Определения BaseBuildingBase.c:113
override bool CanMakeGardenplot()
Определения FieldShovel.c:3
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения PowerGenerator.c:397
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
Определения HandcuffsLocked.c:12
override WrittenNoteData GetWrittenNoteData()
Определения Paper.c:30
override int GetDamageSystemVersionChange()
Определения BaseBuildingBase.c:1238
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
override void InitItemVariables()
Определения Matchbox.c:3
override void SetActionAnimOverrides()
Определения PickAxe.c:28
override void OnCreatePhysics()
Определения BaseBuildingBase.c:489
override string GetDeploySoundset()
Определения BarbedWire.c:392
override float GetBandagingEffectivity()
Определения BandageDressing.c:49
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения PowerGenerator.c:409
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения BaseBuildingBase.c:496
override void OnStoreSave(ParamsWriteContext ctx)
Определения GardenBase.c:266
override void AfterStoreLoad()
Определения BarbedWire.c:155
override int GetOnDigWormsAmount()
Определения FieldShovel.c:27
override bool IsSelfAdjustingTemperature()
Определения PortableGasStove.c:287
override bool IsPlayerInside(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1037
override void OnVariablesSynchronized()
Определения GardenBase.c:97
override void RefreshPhysics()
Определения BatteryCharger.c:359
override bool CanObstruct()
Определения BaseBuildingBase.c:84
override void OnWasAttached(EntityAI parent, int slot_id)
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения BaseBuildingBase.c:982
override bool CanPutInCargo(EntityAI parent)
Определения GardenBase.c:331
override string GetLoopDeploySoundset()
Определения BarbedWire.c:397
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
Определения BarbedWire.c:372
override void OnInventoryExit(Man player)
Определения BatteryCharger.c:341
override bool IsTakeable()
Определения BaseBuildingBase.c:1008
override bool IsIgnoredByConstruction()
Определения BaseBuildingBase.c:1170
override void InitItemSounds()
Определения BaseBuildingBase.c:94
override void EEKilled(Object killer)
Определения HandcuffsLocked.c:70
override void OnCombine(ItemBase other_item)
Определения BandageDressing.c:71
override bool CanExplodeInFire()
Определения LargeGasCannister.c:3
override bool IsFacingPlayer(PlayerBase player, string selection)
Определения BaseBuildingBase.c:1032
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Определения Rag.c:61
override bool IsBloodContainer()
Определения BloodContainerBase.c:10
override bool CanBeSplit()
Определения Rag.c:34
override bool IsDeployable()
Определения BaseBuildingBase.c:365
override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения ToolBase.c:24
override bool CanBeDisinfected()
Определения BandageDressing.c:54
override float GetInfectionChance(int system=0, Param param=null)
Определения BandageDressing.c:59
override void OnEndPlacement()
Определения KitBase.c:65
Определения ItemBase.c:14
Определения EnMath.c:7
float GetOverheatingLimitMax()
Определения WeaponParticles.c:417
void SetOverheatingLimitMax(float max)
Определения WeaponParticles.c:407
void SetParticleParams(int particle_id, Object parent, vector local_pos, vector local_ori)
Определения WeaponParticles.c:422
float GetOverheatingLimitMin()
Определения WeaponParticles.c:412
Particle GetParticle()
Определения WeaponParticles.c:397
void SetOverheatingLimitMin(float min)
Определения WeaponParticles.c:402
void RegisterParticle(Particle p)
Определения WeaponParticles.c:392
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Определения Particle.c:266
void SetControlledDevice(EntityAI pDevice)
Определения RemoteDetonator.c:140
bool OnStoreLoad(ParamsReadContext ctx, int version)
void OnStoreSave(ParamsWriteContext ctx)
proto native void Send()
proto bool Write(void value_out)
proto bool Read(void value_in)
bool m_Loop
Определения ItemSoundHandler.c:5
override void Stop()
Определения DayZPlayerImplement.c:40
proto native float GetDamage(string zoneName, string healthType)
override void Refresh()
Определения ChatInputMenu.c:70
void SetCalcDetails(string details)
Определения 3_Game/DayZ/tools/Debug.c:916
void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Определения WrittenNoteData.c:13
const float LOWEST
Определения EnConvert.c:113
Serializer ParamsReadContext
Определения gameplay.c:15
class LOD Object
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Определения gameplay.c:6
Serializer ParamsWriteContext
Определения gameplay.c:16
const int DEF_BIOLOGICAL
Определения 3_Game/DayZ/constants.c:515
const int DEF_CHEMICAL
Определения 3_Game/DayZ/constants.c:516
const int COMP_TYPE_ENERGY_MANAGER
Определения Component.c:9
ErrorExSeverity
Определения EnDebug.c:62
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
enum ShapeType ErrorEx
proto native void SetColor(int color)
array< string > TStringArray
Определения EnScript.c:712
array< int > TIntArray
Определения EnScript.c:714
void Obsolete(string msg="")
Определения EnScript.c:371
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
Определения 3_Game/DayZ/constants.c:811
const int VARIABLE_LIQUIDTYPE
Определения 3_Game/DayZ/constants.c:635
const int VARIABLE_CLEANNESS
Определения 3_Game/DayZ/constants.c:638
const int VARIABLE_COLOR
Определения 3_Game/DayZ/constants.c:637
const int VARIABLE_TEMPERATURE
Определения 3_Game/DayZ/constants.c:633
const int VARIABLE_QUANTITY
Определения 3_Game/DayZ/constants.c:631
const int VARIABLE_WET
Определения 3_Game/DayZ/constants.c:634
const int LIQUID_NONE
Определения 3_Game/DayZ/constants.c:532
static proto float AbsFloat(float f)
Returns absolute value.
const int MENU_INVENTORY
Определения 3_Game/DayZ/constants.c:180
proto native bool dBodyIsDynamic(notnull IEntity ent)
const int SAT_CRAFTING
Определения 3_Game/DayZ/constants.c:456
const int SAT_DEBUG_ACTION
Определения 3_Game/DayZ/constants.c:457
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
const int CALL_CATEGORY_GAMEPLAY
Определения 3_Game/DayZ/tools/tools.c:10
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/DayZ/tools/tools.c:8
proto native int GetColor()

Используется в InventoryItem::UpdateAllOverheatingParticles().