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

◆ LockToParent()

void SpawnItemOnLocation::LockToParent ( )
private

Locks this item in it's current attachment slot of its parent. This makes the "locked" icon visible in inventory over this item.

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

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