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

◆ SetCEBasedQuantity()

void SpawnItemOnLocation::SetCEBasedQuantity ( )
private

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

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

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