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

◆ SetCEBasedQuantity()

void SpawnItemOnLocation::SetCEBasedQuantity ( )
private

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

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

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