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

◆ UpdateAllOverheatingParticles()

void SpawnItemOnLocation::UpdateAllOverheatingParticles ( )
private

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

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

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