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

◆ GetInfectionChance()

float SpawnItemOnLocation::GetInfectionChance ( int system = 0,
Param param = null )
private

Infection chance while/after using this item, originally used for wound infection after bandaging, params 'system' and 'param' can allow usage by other systems as well.

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

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