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

◆ UnlockFromParent()

void SpawnItemOnLocation::UnlockFromParent ( )
private

Unlocks this item from its attachment slot of its parent.

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

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

Используется в DestroyPlant(), CarWheel_Ruined::EEHealthLevelChanged(), InventoryItemSuper::EEHealthLevelChanged() и RemovePlantEx().