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

◆ GetFilterDamageRatio()

override float GetFilterDamageRatio ( )
private

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

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